Fix min/max not overriding width/height
Differential Revision: D4537576 fbshipit-source-id: c003f723f424afbca63170d41e54fd5ff837926d
This commit is contained in:
parent
906e579dd7
commit
aac7b19a7c
|
@ -15,21 +15,26 @@ YG_EXTERN_C_BEGIN
|
||||||
|
|
||||||
#define YGAlignCount 6
|
#define YGAlignCount 6
|
||||||
typedef YG_ENUM_BEGIN(YGAlign) {
|
typedef YG_ENUM_BEGIN(YGAlign) {
|
||||||
YGAlignAuto, YGAlignFlexStart, YGAlignCenter, YGAlignFlexEnd, YGAlignStretch, YGAlignBaseline,
|
YGAlignAuto,
|
||||||
}
|
YGAlignFlexStart,
|
||||||
YG_ENUM_END(YGAlign);
|
YGAlignCenter,
|
||||||
|
YGAlignFlexEnd,
|
||||||
|
YGAlignStretch,
|
||||||
|
YGAlignBaseline,
|
||||||
|
} YG_ENUM_END(YGAlign);
|
||||||
|
|
||||||
#define YGDimensionCount 2
|
#define YGDimensionCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGDimension) {
|
typedef YG_ENUM_BEGIN(YGDimension) {
|
||||||
YGDimensionWidth, YGDimensionHeight,
|
YGDimensionWidth,
|
||||||
}
|
YGDimensionHeight,
|
||||||
YG_ENUM_END(YGDimension);
|
} YG_ENUM_END(YGDimension);
|
||||||
|
|
||||||
#define YGDirectionCount 3
|
#define YGDirectionCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGDirection) {
|
typedef YG_ENUM_BEGIN(YGDirection) {
|
||||||
YGDirectionInherit, YGDirectionLTR, YGDirectionRTL,
|
YGDirectionInherit,
|
||||||
}
|
YGDirectionLTR,
|
||||||
YG_ENUM_END(YGDirection);
|
YGDirectionRTL,
|
||||||
|
} YG_ENUM_END(YGDirection);
|
||||||
|
|
||||||
#define YGDisplayCount 2
|
#define YGDisplayCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGDisplay) {
|
typedef YG_ENUM_BEGIN(YGDisplay) {
|
||||||
|
@ -39,71 +44,87 @@ typedef YG_ENUM_BEGIN(YGDisplay) {
|
||||||
|
|
||||||
#define YGEdgeCount 9
|
#define YGEdgeCount 9
|
||||||
typedef YG_ENUM_BEGIN(YGEdge) {
|
typedef YG_ENUM_BEGIN(YGEdge) {
|
||||||
YGEdgeLeft, YGEdgeTop, YGEdgeRight, YGEdgeBottom, YGEdgeStart, YGEdgeEnd, YGEdgeHorizontal,
|
YGEdgeLeft,
|
||||||
YGEdgeVertical, YGEdgeAll,
|
YGEdgeTop,
|
||||||
}
|
YGEdgeRight,
|
||||||
YG_ENUM_END(YGEdge);
|
YGEdgeBottom,
|
||||||
|
YGEdgeStart,
|
||||||
|
YGEdgeEnd,
|
||||||
|
YGEdgeHorizontal,
|
||||||
|
YGEdgeVertical,
|
||||||
|
YGEdgeAll,
|
||||||
|
} YG_ENUM_END(YGEdge);
|
||||||
|
|
||||||
#define YGExperimentalFeatureCount 2
|
#define YGExperimentalFeatureCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGExperimentalFeature) {
|
typedef YG_ENUM_BEGIN(YGExperimentalFeature) {
|
||||||
YGExperimentalFeatureRounding, YGExperimentalFeatureWebFlexBasis,
|
YGExperimentalFeatureRounding,
|
||||||
}
|
YGExperimentalFeatureWebFlexBasis,
|
||||||
YG_ENUM_END(YGExperimentalFeature);
|
} YG_ENUM_END(YGExperimentalFeature);
|
||||||
|
|
||||||
#define YGFlexDirectionCount 4
|
#define YGFlexDirectionCount 4
|
||||||
typedef YG_ENUM_BEGIN(YGFlexDirection) {
|
typedef YG_ENUM_BEGIN(YGFlexDirection) {
|
||||||
YGFlexDirectionColumn, YGFlexDirectionColumnReverse, YGFlexDirectionRow,
|
YGFlexDirectionColumn,
|
||||||
|
YGFlexDirectionColumnReverse,
|
||||||
|
YGFlexDirectionRow,
|
||||||
YGFlexDirectionRowReverse,
|
YGFlexDirectionRowReverse,
|
||||||
}
|
} YG_ENUM_END(YGFlexDirection);
|
||||||
YG_ENUM_END(YGFlexDirection);
|
|
||||||
|
|
||||||
#define YGJustifyCount 5
|
#define YGJustifyCount 5
|
||||||
typedef YG_ENUM_BEGIN(YGJustify) {
|
typedef YG_ENUM_BEGIN(YGJustify) {
|
||||||
YGJustifyFlexStart, YGJustifyCenter, YGJustifyFlexEnd, YGJustifySpaceBetween,
|
YGJustifyFlexStart,
|
||||||
|
YGJustifyCenter,
|
||||||
|
YGJustifyFlexEnd,
|
||||||
|
YGJustifySpaceBetween,
|
||||||
YGJustifySpaceAround,
|
YGJustifySpaceAround,
|
||||||
}
|
} YG_ENUM_END(YGJustify);
|
||||||
YG_ENUM_END(YGJustify);
|
|
||||||
|
|
||||||
#define YGLogLevelCount 5
|
#define YGLogLevelCount 5
|
||||||
typedef YG_ENUM_BEGIN(YGLogLevel) {
|
typedef YG_ENUM_BEGIN(YGLogLevel) {
|
||||||
YGLogLevelError, YGLogLevelWarn, YGLogLevelInfo, YGLogLevelDebug, YGLogLevelVerbose,
|
YGLogLevelError,
|
||||||
}
|
YGLogLevelWarn,
|
||||||
YG_ENUM_END(YGLogLevel);
|
YGLogLevelInfo,
|
||||||
|
YGLogLevelDebug,
|
||||||
|
YGLogLevelVerbose,
|
||||||
|
} YG_ENUM_END(YGLogLevel);
|
||||||
|
|
||||||
#define YGMeasureModeCount 3
|
#define YGMeasureModeCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGMeasureMode) {
|
typedef YG_ENUM_BEGIN(YGMeasureMode) {
|
||||||
YGMeasureModeUndefined, YGMeasureModeExactly, YGMeasureModeAtMost,
|
YGMeasureModeUndefined,
|
||||||
}
|
YGMeasureModeExactly,
|
||||||
YG_ENUM_END(YGMeasureMode);
|
YGMeasureModeAtMost,
|
||||||
|
} YG_ENUM_END(YGMeasureMode);
|
||||||
|
|
||||||
#define YGOverflowCount 3
|
#define YGOverflowCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGOverflow) {
|
typedef YG_ENUM_BEGIN(YGOverflow) {
|
||||||
YGOverflowVisible, YGOverflowHidden, YGOverflowScroll,
|
YGOverflowVisible,
|
||||||
}
|
YGOverflowHidden,
|
||||||
YG_ENUM_END(YGOverflow);
|
YGOverflowScroll,
|
||||||
|
} YG_ENUM_END(YGOverflow);
|
||||||
|
|
||||||
#define YGPositionTypeCount 2
|
#define YGPositionTypeCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGPositionType) {
|
typedef YG_ENUM_BEGIN(YGPositionType) {
|
||||||
YGPositionTypeRelative, YGPositionTypeAbsolute,
|
YGPositionTypeRelative,
|
||||||
}
|
YGPositionTypeAbsolute,
|
||||||
YG_ENUM_END(YGPositionType);
|
} YG_ENUM_END(YGPositionType);
|
||||||
|
|
||||||
#define YGPrintOptionsCount 3
|
#define YGPrintOptionsCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGPrintOptions) {
|
typedef YG_ENUM_BEGIN(YGPrintOptions) {
|
||||||
YGPrintOptionsLayout = 1, YGPrintOptionsStyle = 2, YGPrintOptionsChildren = 4,
|
YGPrintOptionsLayout = 1,
|
||||||
}
|
YGPrintOptionsStyle = 2,
|
||||||
YG_ENUM_END(YGPrintOptions);
|
YGPrintOptionsChildren = 4,
|
||||||
|
} YG_ENUM_END(YGPrintOptions);
|
||||||
|
|
||||||
#define YGUnitCount 3
|
#define YGUnitCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGUnit) {
|
typedef YG_ENUM_BEGIN(YGUnit) {
|
||||||
YGUnitUndefined, YGUnitPixel, YGUnitPercent,
|
YGUnitUndefined,
|
||||||
}
|
YGUnitPixel,
|
||||||
YG_ENUM_END(YGUnit);
|
YGUnitPercent,
|
||||||
|
} YG_ENUM_END(YGUnit);
|
||||||
|
|
||||||
#define YGWrapCount 2
|
#define YGWrapCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGWrap) {
|
typedef YG_ENUM_BEGIN(YGWrap) {
|
||||||
YGWrapNoWrap, YGWrapWrap,
|
YGWrapNoWrap,
|
||||||
}
|
YGWrapWrap,
|
||||||
YG_ENUM_END(YGWrap);
|
} YG_ENUM_END(YGWrap);
|
||||||
|
|
||||||
YG_EXTERN_C_END
|
YG_EXTERN_C_END
|
||||||
|
|
|
@ -641,13 +641,11 @@ static inline bool YGValueEqual(const YGValue a, const YGValue b) {
|
||||||
|
|
||||||
static inline void YGResolveDimensions(YGNodeRef node) {
|
static inline void YGResolveDimensions(YGNodeRef node) {
|
||||||
for (YGDimension dim = YGDimensionWidth; dim <= YGDimensionHeight; dim++) {
|
for (YGDimension dim = YGDimensionWidth; dim <= YGDimensionHeight; dim++) {
|
||||||
if (node->style.dimensions[dim].unit != YGUnitUndefined) {
|
|
||||||
node->resolvedDimensions[dim] = node->style.dimensions[dim];
|
|
||||||
} else {
|
|
||||||
if (node->style.maxDimensions[dim].unit != YGUnitUndefined &&
|
if (node->style.maxDimensions[dim].unit != YGUnitUndefined &&
|
||||||
YGValueEqual(node->style.maxDimensions[dim], node->style.minDimensions[dim])) {
|
YGValueEqual(node->style.maxDimensions[dim], node->style.minDimensions[dim])) {
|
||||||
node->resolvedDimensions[dim] = node->style.maxDimensions[dim];
|
node->resolvedDimensions[dim] = node->style.maxDimensions[dim];
|
||||||
}
|
} else {
|
||||||
|
node->resolvedDimensions[dim] = node->style.dimensions[dim];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1167,7 +1165,7 @@ static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node,
|
||||||
const float axisSize) {
|
const float axisSize) {
|
||||||
float min = YGUndefined;
|
float min = YGUndefined;
|
||||||
float max = YGUndefined;
|
float max = YGUndefined;
|
||||||
if (!YGNodeIsStyleDimDefined(node, axis, axisSize)) {
|
|
||||||
if (YGFlexDirectionIsColumn(axis)) {
|
if (YGFlexDirectionIsColumn(axis)) {
|
||||||
min = YGValueResolve(&node->style.minDimensions[YGDimensionHeight], axisSize);
|
min = YGValueResolve(&node->style.minDimensions[YGDimensionHeight], axisSize);
|
||||||
max = YGValueResolve(&node->style.maxDimensions[YGDimensionHeight], axisSize);
|
max = YGValueResolve(&node->style.maxDimensions[YGDimensionHeight], axisSize);
|
||||||
|
@ -1175,7 +1173,6 @@ static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node,
|
||||||
min = YGValueResolve(&node->style.minDimensions[YGDimensionWidth], axisSize);
|
min = YGValueResolve(&node->style.minDimensions[YGDimensionWidth], axisSize);
|
||||||
max = YGValueResolve(&node->style.maxDimensions[YGDimensionWidth], axisSize);
|
max = YGValueResolve(&node->style.maxDimensions[YGDimensionWidth], axisSize);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
float boundValue = value;
|
float boundValue = value;
|
||||||
|
|
||||||
|
@ -1545,7 +1542,9 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node,
|
||||||
const float availableWidth,
|
const float availableWidth,
|
||||||
const float availableHeight,
|
const float availableHeight,
|
||||||
const YGMeasureMode widthMeasureMode,
|
const YGMeasureMode widthMeasureMode,
|
||||||
const YGMeasureMode heightMeasureMode) {
|
const YGMeasureMode heightMeasureMode,
|
||||||
|
const float parentWidth,
|
||||||
|
const float parentHeight) {
|
||||||
YG_ASSERT(node->measure, "Expected node to have custom measure function");
|
YG_ASSERT(node->measure, "Expected node to have custom measure function");
|
||||||
|
|
||||||
const float paddingAndBorderAxisRow =
|
const float paddingAndBorderAxisRow =
|
||||||
|
@ -1561,13 +1560,9 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node,
|
||||||
if (widthMeasureMode == YGMeasureModeExactly && heightMeasureMode == YGMeasureModeExactly) {
|
if (widthMeasureMode == YGMeasureModeExactly && heightMeasureMode == YGMeasureModeExactly) {
|
||||||
// Don't bother sizing the text if both dimensions are already defined.
|
// Don't bother sizing the text if both dimensions are already defined.
|
||||||
node->layout.measuredDimensions[YGDimensionWidth] = YGNodeBoundAxis(
|
node->layout.measuredDimensions[YGDimensionWidth] = YGNodeBoundAxis(
|
||||||
node, YGFlexDirectionRow, availableWidth - marginAxisRow, availableWidth, availableWidth);
|
node, YGFlexDirectionRow, availableWidth - marginAxisRow, parentWidth, parentWidth);
|
||||||
node->layout.measuredDimensions[YGDimensionHeight] =
|
node->layout.measuredDimensions[YGDimensionHeight] = YGNodeBoundAxis(
|
||||||
YGNodeBoundAxis(node,
|
node, YGFlexDirectionColumn, availableHeight - marginAxisColumn, parentHeight, parentWidth);
|
||||||
YGFlexDirectionColumn,
|
|
||||||
availableHeight - marginAxisColumn,
|
|
||||||
availableHeight,
|
|
||||||
availableWidth);
|
|
||||||
} else if (innerWidth <= 0.0f || innerHeight <= 0.0f) {
|
} else if (innerWidth <= 0.0f || innerHeight <= 0.0f) {
|
||||||
// Don't bother sizing the text if there's no horizontal or vertical
|
// Don't bother sizing the text if there's no horizontal or vertical
|
||||||
// space.
|
// space.
|
||||||
|
@ -1841,8 +1836,13 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||||
YGNodeTrailingPadding(node, flexColumnDirection, parentWidth);
|
YGNodeTrailingPadding(node, flexColumnDirection, parentWidth);
|
||||||
|
|
||||||
if (node->measure) {
|
if (node->measure) {
|
||||||
YGNodeWithMeasureFuncSetMeasuredDimensions(
|
YGNodeWithMeasureFuncSetMeasuredDimensions(node,
|
||||||
node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode);
|
availableWidth,
|
||||||
|
availableHeight,
|
||||||
|
widthMeasureMode,
|
||||||
|
heightMeasureMode,
|
||||||
|
parentWidth,
|
||||||
|
parentHeight);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue