Fix percentage calculation when parent size is undefined
Reviewed By: gkassabli Differential Revision: D4494265 fbshipit-source-id: 9efef9e39a1b66af2d0f144575a96c919d60dbf7
This commit is contained in:
parent
eb54290a3a
commit
61848ea2f3
|
@ -256,12 +256,16 @@ static inline const YGValue *YGComputedEdgeValue(const YGValue edges[YGEdgeCount
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float YGValueResolve(const YGValue *const unit, const float parentSize) {
|
static inline float YGValueResolve(const YGValue *const value, const float parentSize) {
|
||||||
if (unit->unit == YGUnitPixel) {
|
switch (value->unit) {
|
||||||
return unit->value;
|
case YGUnitUndefined:
|
||||||
} else {
|
return YGUndefined;
|
||||||
return unit->value * parentSize / 100.0f;
|
case YGUnitPixel:
|
||||||
|
return value->value;
|
||||||
|
case YGUnitPercent:
|
||||||
|
return value->value * parentSize / 100.0f;
|
||||||
}
|
}
|
||||||
|
return YGUndefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t gNodeInstanceCount = 0;
|
int32_t gNodeInstanceCount = 0;
|
||||||
|
@ -2253,7 +2257,8 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||||
childHeight = YGValueResolve(¤tRelativeChild->style.dimensions[YGDimensionHeight],
|
childHeight = YGValueResolve(¤tRelativeChild->style.dimensions[YGDimensionHeight],
|
||||||
availableInnerHeight) +
|
availableInnerHeight) +
|
||||||
marginColumn;
|
marginColumn;
|
||||||
childHeightMeasureMode = YGMeasureModeExactly;
|
childHeightMeasureMode =
|
||||||
|
YGFloatIsUndefined(childHeight) ? YGMeasureModeUndefined : YGMeasureModeExactly;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
childHeight = updatedMainSize + marginColumn;
|
childHeight = updatedMainSize + marginColumn;
|
||||||
|
@ -2277,7 +2282,8 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||||
childWidth = YGValueResolve(¤tRelativeChild->style.dimensions[YGDimensionWidth],
|
childWidth = YGValueResolve(¤tRelativeChild->style.dimensions[YGDimensionWidth],
|
||||||
availableInnerWidth) +
|
availableInnerWidth) +
|
||||||
marginRow;
|
marginRow;
|
||||||
childWidthMeasureMode = YGMeasureModeExactly;
|
childWidthMeasureMode =
|
||||||
|
YGFloatIsUndefined(childWidth) ? YGMeasureModeUndefined : YGMeasureModeExactly;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue