Remove YGUnwrapFloatOptional

Summary:
Replaces `YGUnwrapFloatOptional` with `YGFloatOptional::unwrap`.

This leads to more idiomatic C++, and to less function call nesting, thus increasing readability.

Reviewed By: SidharthGuglani

Differential Revision: D13439604

fbshipit-source-id: 33b43c08d725c253c359959e7cbbd83fd6bd9ba4
This commit is contained in:
David Aurelio
2018-12-13 07:09:30 -08:00
committed by Facebook Github Bot
parent 6bdd39d0ed
commit aaa018bbea
6 changed files with 211 additions and 201 deletions

View File

@@ -200,8 +200,8 @@ TEST(YGFloatOptionalTest, YGFloatOptionalMax) {
YGFloatOptional{1.125f}); YGFloatOptional{1.125f});
} }
TEST(YGFloatOptionalTest, YGUnwrapFloatOptional) { TEST(YGFloatOptionalTest, unwrap) {
ASSERT_TRUE(YGFloatIsUndefined(YGUnwrapFloatOptional(empty))); ASSERT_TRUE(YGFloatIsUndefined(empty.unwrap()));
ASSERT_EQ(YGUnwrapFloatOptional(zero), 0.0f); ASSERT_EQ(zero.unwrap(), 0.0f);
ASSERT_EQ(YGUnwrapFloatOptional(YGFloatOptional{123456.78f}), 123456.78f); ASSERT_EQ(YGFloatOptional{123456.78f}.unwrap(), 123456.78f);
} }

View File

@@ -55,10 +55,6 @@ float YGFloatSanitize(const float val) {
return yoga::isUndefined(val) ? 0 : val; return yoga::isUndefined(val) ? 0 : val;
} }
float YGUnwrapFloatOptional(const YGFloatOptional& op) {
return op.isUndefined() ? YGUndefined : op.getValue();
}
YGFloatOptional YGFloatOptionalMax( YGFloatOptional YGFloatOptionalMax(
const YGFloatOptional& op1, const YGFloatOptional& op1,
const YGFloatOptional& op2) { const YGFloatOptional& op2) {

View File

@@ -82,11 +82,6 @@ bool YGFloatArrayEqual(
// This function returns 0 if YGFloatIsUndefined(val) is true and val otherwise // This function returns 0 if YGFloatIsUndefined(val) is true and val otherwise
float YGFloatSanitize(const float val); float YGFloatSanitize(const float val);
// This function unwraps optional and returns YGUndefined if not defined or
// op.value otherwise
// TODO: Get rid off this function
float YGUnwrapFloatOptional(const YGFloatOptional& op);
YGFlexDirection YGFlexDirectionCross( YGFlexDirection YGFlexDirectionCross(
const YGFlexDirection flexDirection, const YGFlexDirection flexDirection,
const YGDirection direction); const YGDirection direction);

View File

@@ -22,6 +22,11 @@ struct YGFloatOptional {
// To check if float optional is defined, use `isUndefined()`. // To check if float optional is defined, use `isUndefined()`.
float getValue() const; float getValue() const;
// returns the wrapped value, or a value x with YGIsUndefined(x) == true
float unwrap() const {
return value_;
}
bool isUndefined() const { bool isUndefined() const {
return std::isnan(value_); return std::isnan(value_);
} }

View File

@@ -236,20 +236,18 @@ void YGNode::setPosition(
relativePosition(crossAxis, crossSize); relativePosition(crossAxis, crossSize);
setLayoutPosition( setLayoutPosition(
YGUnwrapFloatOptional( (getLeadingMargin(mainAxis, ownerWidth) + relativePositionMain).unwrap(),
getLeadingMargin(mainAxis, ownerWidth) + relativePositionMain),
leading[mainAxis]); leading[mainAxis]);
setLayoutPosition( setLayoutPosition(
YGUnwrapFloatOptional( (getTrailingMargin(mainAxis, ownerWidth) + relativePositionMain).unwrap(),
getTrailingMargin(mainAxis, ownerWidth) + relativePositionMain),
trailing[mainAxis]); trailing[mainAxis]);
setLayoutPosition( setLayoutPosition(
YGUnwrapFloatOptional( (getLeadingMargin(crossAxis, ownerWidth) + relativePositionCross)
getLeadingMargin(crossAxis, ownerWidth) + relativePositionCross), .unwrap(),
leading[crossAxis]); leading[crossAxis]);
setLayoutPosition( setLayoutPosition(
YGUnwrapFloatOptional( (getTrailingMargin(crossAxis, ownerWidth) + relativePositionCross)
getTrailingMargin(crossAxis, ownerWidth) + relativePositionCross), .unwrap(),
trailing[crossAxis]); trailing[crossAxis]);
} }

View File

@@ -1096,9 +1096,9 @@ static inline float YGNodePaddingAndBorderForAxis(
const YGNodeRef node, const YGNodeRef node,
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) { const float widthSize) {
return YGUnwrapFloatOptional( return (node->getLeadingPaddingAndBorder(axis, widthSize) +
node->getLeadingPaddingAndBorder(axis, widthSize) + node->getTrailingPaddingAndBorder(axis, widthSize))
node->getTrailingPaddingAndBorder(axis, widthSize)); .unwrap();
} }
static inline YGAlign YGNodeAlignItem( static inline YGAlign YGNodeAlignItem(
@@ -1180,9 +1180,9 @@ static inline float YGNodeDimWithMargin(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) { const float widthSize) {
return node->getLayout().measuredDimensions[dim[axis]] + return node->getLayout().measuredDimensions[dim[axis]] +
YGUnwrapFloatOptional( (node->getLeadingMargin(axis, widthSize) +
node->getLeadingMargin(axis, widthSize) + node->getTrailingMargin(axis, widthSize))
node->getTrailingMargin(axis, widthSize)); .unwrap();
} }
static inline bool YGNodeIsStyleDimDefined( static inline bool YGNodeIsStyleDimDefined(
@@ -1249,8 +1249,7 @@ static inline float YGNodeBoundAxis(
const float axisSize, const float axisSize,
const float widthSize) { const float widthSize) {
return YGFloatMax( return YGFloatMax(
YGUnwrapFloatOptional( YGNodeBoundAxisWithinMinAndMax(node, axis, value, axisSize).unwrap(),
YGNodeBoundAxisWithinMinAndMax(node, axis, value, axisSize)),
YGNodePaddingAndBorderForAxis(node, axis, widthSize)); YGNodePaddingAndBorderForAxis(node, axis, widthSize));
} }
@@ -1357,22 +1356,24 @@ static void YGNodeComputeFlexBasisForChild(
childWidthMeasureMode = YGMeasureModeUndefined; childWidthMeasureMode = YGMeasureModeUndefined;
childHeightMeasureMode = YGMeasureModeUndefined; childHeightMeasureMode = YGMeasureModeUndefined;
auto marginRow = YGUnwrapFloatOptional( auto marginRow =
child->getMarginForAxis(YGFlexDirectionRow, ownerWidth)); child->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
auto marginColumn = YGUnwrapFloatOptional( auto marginColumn =
child->getMarginForAxis(YGFlexDirectionColumn, ownerWidth)); child->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
if (isRowStyleDimDefined) { if (isRowStyleDimDefined) {
childWidth = childWidth =
YGUnwrapFloatOptional(YGResolveValue( YGResolveValue(
child->getResolvedDimension(YGDimensionWidth), ownerWidth)) + child->getResolvedDimension(YGDimensionWidth), ownerWidth)
.unwrap() +
marginRow; marginRow;
childWidthMeasureMode = YGMeasureModeExactly; childWidthMeasureMode = YGMeasureModeExactly;
} }
if (isColumnStyleDimDefined) { if (isColumnStyleDimDefined) {
childHeight = childHeight =
YGUnwrapFloatOptional(YGResolveValue( YGResolveValue(
child->getResolvedDimension(YGDimensionHeight), ownerHeight)) + child->getResolvedDimension(YGDimensionHeight), ownerHeight)
.unwrap() +
marginColumn; marginColumn;
childHeightMeasureMode = YGMeasureModeExactly; childHeightMeasureMode = YGMeasureModeExactly;
} }
@@ -1500,14 +1501,14 @@ static void YGNodeAbsoluteLayoutChild(
YGMeasureMode childWidthMeasureMode = YGMeasureModeUndefined; YGMeasureMode childWidthMeasureMode = YGMeasureModeUndefined;
YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined; YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined;
auto marginRow = auto marginRow = child->getMarginForAxis(YGFlexDirectionRow, width).unwrap();
YGUnwrapFloatOptional(child->getMarginForAxis(YGFlexDirectionRow, width)); auto marginColumn =
auto marginColumn = YGUnwrapFloatOptional( child->getMarginForAxis(YGFlexDirectionColumn, width).unwrap();
child->getMarginForAxis(YGFlexDirectionColumn, width));
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionRow, width)) { if (YGNodeIsStyleDimDefined(child, YGFlexDirectionRow, width)) {
childWidth = YGUnwrapFloatOptional(YGResolveValue( childWidth =
child->getResolvedDimension(YGDimensionWidth), width)) + YGResolveValue(child->getResolvedDimension(YGDimensionWidth), width)
.unwrap() +
marginRow; marginRow;
} else { } else {
// If the child doesn't have a specified width, compute the width based // If the child doesn't have a specified width, compute the width based
@@ -1518,17 +1519,18 @@ static void YGNodeAbsoluteLayoutChild(
childWidth = node->getLayout().measuredDimensions[YGDimensionWidth] - childWidth = node->getLayout().measuredDimensions[YGDimensionWidth] -
(node->getLeadingBorder(YGFlexDirectionRow) + (node->getLeadingBorder(YGFlexDirectionRow) +
node->getTrailingBorder(YGFlexDirectionRow)) - node->getTrailingBorder(YGFlexDirectionRow)) -
YGUnwrapFloatOptional( (child->getLeadingPosition(YGFlexDirectionRow, width) +
child->getLeadingPosition(YGFlexDirectionRow, width) + child->getTrailingPosition(YGFlexDirectionRow, width))
child->getTrailingPosition(YGFlexDirectionRow, width)); .unwrap();
childWidth = childWidth =
YGNodeBoundAxis(child, YGFlexDirectionRow, childWidth, width, width); YGNodeBoundAxis(child, YGFlexDirectionRow, childWidth, width, width);
} }
} }
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn, height)) { if (YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn, height)) {
childHeight = YGUnwrapFloatOptional(YGResolveValue( childHeight =
child->getResolvedDimension(YGDimensionHeight), height)) + YGResolveValue(child->getResolvedDimension(YGDimensionHeight), height)
.unwrap() +
marginColumn; marginColumn;
} else { } else {
// If the child doesn't have a specified height, compute the height // If the child doesn't have a specified height, compute the height
@@ -1536,13 +1538,12 @@ static void YGNodeAbsoluteLayoutChild(
// offsets if they're defined. // offsets if they're defined.
if (child->isLeadingPositionDefined(YGFlexDirectionColumn) && if (child->isLeadingPositionDefined(YGFlexDirectionColumn) &&
child->isTrailingPosDefined(YGFlexDirectionColumn)) { child->isTrailingPosDefined(YGFlexDirectionColumn)) {
childHeight = childHeight = node->getLayout().measuredDimensions[YGDimensionHeight] -
node->getLayout().measuredDimensions[YGDimensionHeight] -
(node->getLeadingBorder(YGFlexDirectionColumn) + (node->getLeadingBorder(YGFlexDirectionColumn) +
node->getTrailingBorder(YGFlexDirectionColumn)) - node->getTrailingBorder(YGFlexDirectionColumn)) -
YGUnwrapFloatOptional( (child->getLeadingPosition(YGFlexDirectionColumn, height) +
child->getLeadingPosition(YGFlexDirectionColumn, height) + child->getTrailingPosition(YGFlexDirectionColumn, height))
child->getTrailingPosition(YGFlexDirectionColumn, height)); .unwrap();
childHeight = YGNodeBoundAxis( childHeight = YGNodeBoundAxis(
child, YGFlexDirectionColumn, childHeight, height, width); child, YGFlexDirectionColumn, childHeight, height, width);
} }
@@ -1597,11 +1598,9 @@ static void YGNodeAbsoluteLayoutChild(
"abs-measure", "abs-measure",
config); config);
childWidth = child->getLayout().measuredDimensions[YGDimensionWidth] + childWidth = child->getLayout().measuredDimensions[YGDimensionWidth] +
YGUnwrapFloatOptional( child->getMarginForAxis(YGFlexDirectionRow, width).unwrap();
child->getMarginForAxis(YGFlexDirectionRow, width));
childHeight = child->getLayout().measuredDimensions[YGDimensionHeight] + childHeight = child->getLayout().measuredDimensions[YGDimensionHeight] +
YGUnwrapFloatOptional( child->getMarginForAxis(YGFlexDirectionColumn, width).unwrap();
child->getMarginForAxis(YGFlexDirectionColumn, width));
} }
YGLayoutNodeInternal( YGLayoutNodeInternal(
@@ -1623,9 +1622,9 @@ static void YGNodeAbsoluteLayoutChild(
node->getLayout().measuredDimensions[dim[mainAxis]] - node->getLayout().measuredDimensions[dim[mainAxis]] -
child->getLayout().measuredDimensions[dim[mainAxis]] - child->getLayout().measuredDimensions[dim[mainAxis]] -
node->getTrailingBorder(mainAxis) - node->getTrailingBorder(mainAxis) -
YGUnwrapFloatOptional(child->getTrailingMargin(mainAxis, width)) - child->getTrailingMargin(mainAxis, width).unwrap() -
YGUnwrapFloatOptional(child->getTrailingPosition( child->getTrailingPosition(mainAxis, isMainAxisRow ? width : height)
mainAxis, isMainAxisRow ? width : height)), .unwrap(),
leading[mainAxis]); leading[mainAxis]);
} else if ( } else if (
!child->isLeadingPositionDefined(mainAxis) && !child->isLeadingPositionDefined(mainAxis) &&
@@ -1650,9 +1649,10 @@ static void YGNodeAbsoluteLayoutChild(
node->getLayout().measuredDimensions[dim[crossAxis]] - node->getLayout().measuredDimensions[dim[crossAxis]] -
child->getLayout().measuredDimensions[dim[crossAxis]] - child->getLayout().measuredDimensions[dim[crossAxis]] -
node->getTrailingBorder(crossAxis) - node->getTrailingBorder(crossAxis) -
YGUnwrapFloatOptional(child->getTrailingMargin(crossAxis, width)) - child->getTrailingMargin(crossAxis, width).unwrap() -
YGUnwrapFloatOptional(child->getTrailingPosition( child
crossAxis, isMainAxisRow ? height : width)), ->getTrailingPosition(crossAxis, isMainAxisRow ? height : width)
.unwrap(),
leading[crossAxis]); leading[crossAxis]);
} else if ( } else if (
@@ -1691,10 +1691,10 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, availableWidth); YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, availableWidth);
const float paddingAndBorderAxisColumn = YGNodePaddingAndBorderForAxis( const float paddingAndBorderAxisColumn = YGNodePaddingAndBorderForAxis(
node, YGFlexDirectionColumn, availableWidth); node, YGFlexDirectionColumn, availableWidth);
const float marginAxisRow = YGUnwrapFloatOptional( const float marginAxisRow =
node->getMarginForAxis(YGFlexDirectionRow, availableWidth)); node->getMarginForAxis(YGFlexDirectionRow, availableWidth).unwrap();
const float marginAxisColumn = YGUnwrapFloatOptional( const float marginAxisColumn =
node->getMarginForAxis(YGFlexDirectionColumn, availableWidth)); node->getMarginForAxis(YGFlexDirectionColumn, availableWidth).unwrap();
// We want to make sure we don't call measure with negative size // We want to make sure we don't call measure with negative size
const float innerWidth = YGFloatIsUndefined(availableWidth) const float innerWidth = YGFloatIsUndefined(availableWidth)
@@ -1769,10 +1769,10 @@ static void YGNodeEmptyContainerSetMeasuredDimensions(
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, ownerWidth); YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, ownerWidth);
const float paddingAndBorderAxisColumn = const float paddingAndBorderAxisColumn =
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, ownerWidth); YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, ownerWidth);
const float marginAxisRow = YGUnwrapFloatOptional( const float marginAxisRow =
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth)); node->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
const float marginAxisColumn = YGUnwrapFloatOptional( const float marginAxisColumn =
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth)); node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
node->setLayoutMeasuredDimension( node->setLayoutMeasuredDimension(
YGNodeBoundAxis( YGNodeBoundAxis(
@@ -1813,10 +1813,10 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(
heightMeasureMode == YGMeasureModeAtMost && availableHeight <= 0.0f) || heightMeasureMode == YGMeasureModeAtMost && availableHeight <= 0.0f) ||
(widthMeasureMode == YGMeasureModeExactly && (widthMeasureMode == YGMeasureModeExactly &&
heightMeasureMode == YGMeasureModeExactly)) { heightMeasureMode == YGMeasureModeExactly)) {
auto marginAxisColumn = YGUnwrapFloatOptional( auto marginAxisColumn =
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth)); node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
auto marginAxisRow = YGUnwrapFloatOptional( auto marginAxisRow =
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth)); node->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
node->setLayoutMeasuredDimension( node->setLayoutMeasuredDimension(
YGNodeBoundAxis( YGNodeBoundAxis(
@@ -1872,8 +1872,7 @@ static float YGNodeCalculateAvailableInnerDim(
YGDimension dimension = YGDimension dimension =
YGFlexDirectionIsRow(axis) ? YGDimensionWidth : YGDimensionHeight; YGFlexDirectionIsRow(axis) ? YGDimensionWidth : YGDimensionHeight;
const float margin = const float margin = node->getMarginForAxis(direction, ownerDim).unwrap();
YGUnwrapFloatOptional(node->getMarginForAxis(direction, ownerDim));
const float paddingAndBorder = const float paddingAndBorder =
YGNodePaddingAndBorderForAxis(node, direction, ownerDim); YGNodePaddingAndBorderForAxis(node, direction, ownerDim);
@@ -1978,9 +1977,10 @@ static float YGNodeComputeFlexBasisForChildren(
config); config);
} }
totalOuterFlexBasis += YGUnwrapFloatOptional( totalOuterFlexBasis +=
child->getLayout().computedFlexBasis + (child->getLayout().computedFlexBasis +
child->getMarginForAxis(mainAxis, availableInnerWidth)); child->getMarginForAxis(mainAxis, availableInnerWidth))
.unwrap();
} }
return totalOuterFlexBasis; return totalOuterFlexBasis;
@@ -2015,14 +2015,15 @@ static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues(
continue; continue;
} }
child->setLineIndex(lineCount); child->setLineIndex(lineCount);
const float childMarginMainAxis = YGUnwrapFloatOptional( const float childMarginMainAxis =
child->getMarginForAxis(mainAxis, availableInnerWidth)); child->getMarginForAxis(mainAxis, availableInnerWidth).unwrap();
const float flexBasisWithMinAndMaxConstraints = const float flexBasisWithMinAndMaxConstraints =
YGUnwrapFloatOptional(YGNodeBoundAxisWithinMinAndMax( YGNodeBoundAxisWithinMinAndMax(
child, child,
mainAxis, mainAxis,
YGUnwrapFloatOptional(child->getLayout().computedFlexBasis), child->getLayout().computedFlexBasis.unwrap(),
mainAxisownerSize)); mainAxisownerSize)
.unwrap();
// If this is a multi-line flow and this item pushes us over the // If this is a multi-line flow and this item pushes us over the
// available size, we've // available size, we've
@@ -2048,7 +2049,7 @@ static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues(
// child dimension. // child dimension.
flexAlgoRowMeasurement.totalFlexShrinkScaledFactors += flexAlgoRowMeasurement.totalFlexShrinkScaledFactors +=
-child->resolveFlexShrink() * -child->resolveFlexShrink() *
YGUnwrapFloatOptional(child->getLayout().computedFlexBasis); child->getLayout().computedFlexBasis.unwrap();
} }
flexAlgoRowMeasurement.relativeChildren.push_back(child); flexAlgoRowMeasurement.relativeChildren.push_back(child);
@@ -2095,12 +2096,13 @@ static float YGDistributeFreeSpaceSecondPass(
const bool isNodeFlexWrap = node->getStyle().flexWrap != YGWrapNoWrap; const bool isNodeFlexWrap = node->getStyle().flexWrap != YGWrapNoWrap;
for (auto currentRelativeChild : collectedFlexItemsValues.relativeChildren) { for (auto currentRelativeChild : collectedFlexItemsValues.relativeChildren) {
childFlexBasis = YGUnwrapFloatOptional(YGNodeBoundAxisWithinMinAndMax( childFlexBasis =
currentRelativeChild, YGNodeBoundAxisWithinMinAndMax(
mainAxis, currentRelativeChild,
YGUnwrapFloatOptional( mainAxis,
currentRelativeChild->getLayout().computedFlexBasis), currentRelativeChild->getLayout().computedFlexBasis.unwrap(),
mainAxisownerSize)); mainAxisownerSize)
.unwrap();
float updatedMainSize = childFlexBasis; float updatedMainSize = childFlexBasis;
if (!YGFloatIsUndefined(collectedFlexItemsValues.remainingFreeSpace) && if (!YGFloatIsUndefined(collectedFlexItemsValues.remainingFreeSpace) &&
@@ -2150,10 +2152,12 @@ static float YGDistributeFreeSpaceSecondPass(
deltaFreeSpace += updatedMainSize - childFlexBasis; deltaFreeSpace += updatedMainSize - childFlexBasis;
const float marginMain = YGUnwrapFloatOptional( const float marginMain =
currentRelativeChild->getMarginForAxis(mainAxis, availableInnerWidth)); currentRelativeChild->getMarginForAxis(mainAxis, availableInnerWidth)
const float marginCross = YGUnwrapFloatOptional( .unwrap();
currentRelativeChild->getMarginForAxis(crossAxis, availableInnerWidth)); const float marginCross =
currentRelativeChild->getMarginForAxis(crossAxis, availableInnerWidth)
.unwrap();
float childCrossSize; float childCrossSize;
float childMainSize = updatedMainSize + marginMain; float childMainSize = updatedMainSize + marginMain;
@@ -2189,9 +2193,10 @@ static float YGDistributeFreeSpaceSecondPass(
: YGMeasureModeAtMost; : YGMeasureModeAtMost;
} else { } else {
childCrossSize = childCrossSize =
YGUnwrapFloatOptional(YGResolveValue( YGResolveValue(
currentRelativeChild->getResolvedDimension(dim[crossAxis]), currentRelativeChild->getResolvedDimension(dim[crossAxis]),
availableInnerCrossDim)) + availableInnerCrossDim)
.unwrap() +
marginCross; marginCross;
const bool isLoosePercentageMeasurement = const bool isLoosePercentageMeasurement =
currentRelativeChild->getResolvedDimension(dim[crossAxis]).unit == currentRelativeChild->getResolvedDimension(dim[crossAxis]).unit ==
@@ -2271,12 +2276,13 @@ static void YGDistributeFreeSpaceFirstPass(
float deltaFreeSpace = 0; float deltaFreeSpace = 0;
for (auto currentRelativeChild : collectedFlexItemsValues.relativeChildren) { for (auto currentRelativeChild : collectedFlexItemsValues.relativeChildren) {
float childFlexBasis = YGUnwrapFloatOptional(YGNodeBoundAxisWithinMinAndMax( float childFlexBasis =
currentRelativeChild, YGNodeBoundAxisWithinMinAndMax(
mainAxis, currentRelativeChild,
YGUnwrapFloatOptional( mainAxis,
currentRelativeChild->getLayout().computedFlexBasis), currentRelativeChild->getLayout().computedFlexBasis.unwrap(),
mainAxisownerSize)); mainAxisownerSize)
.unwrap();
if (collectedFlexItemsValues.remainingFreeSpace < 0) { if (collectedFlexItemsValues.remainingFreeSpace < 0) {
flexShrinkScaledFactor = flexShrinkScaledFactor =
@@ -2427,10 +2433,10 @@ static void YGJustifyMainAxis(
const float availableInnerWidth, const float availableInnerWidth,
const bool performLayout) { const bool performLayout) {
const YGStyle& style = node->getStyle(); const YGStyle& style = node->getStyle();
const float leadingPaddingAndBorderMain = YGUnwrapFloatOptional( const float leadingPaddingAndBorderMain =
node->getLeadingPaddingAndBorder(mainAxis, ownerWidth)); node->getLeadingPaddingAndBorder(mainAxis, ownerWidth).unwrap();
const float trailingPaddingAndBorderMain = YGUnwrapFloatOptional( const float trailingPaddingAndBorderMain =
node->getTrailingPaddingAndBorder(mainAxis, ownerWidth)); node->getTrailingPaddingAndBorder(mainAxis, ownerWidth).unwrap();
// If we are using "at most" rules in the main axis, make sure that // If we are using "at most" rules in the main axis, make sure that
// remainingFreeSpace is 0 when min main dimension is not given // remainingFreeSpace is 0 when min main dimension is not given
if (measureModeMainDim == YGMeasureModeAtMost && if (measureModeMainDim == YGMeasureModeAtMost &&
@@ -2446,8 +2452,8 @@ static void YGJustifyMainAxis(
// `minAvailableMainDim` denotes minimum available space in which child // `minAvailableMainDim` denotes minimum available space in which child
// can be laid out, it will exclude space consumed by padding and border. // can be laid out, it will exclude space consumed by padding and border.
const float minAvailableMainDim = const float minAvailableMainDim =
YGUnwrapFloatOptional(YGResolveValue( YGResolveValue(style.minDimensions[dim[mainAxis]], mainAxisownerSize)
style.minDimensions[dim[mainAxis]], mainAxisownerSize)) - .unwrap() -
leadingPaddingAndBorderMain - trailingPaddingAndBorderMain; leadingPaddingAndBorderMain - trailingPaddingAndBorderMain;
const float occupiedSpaceByChildNodes = const float occupiedSpaceByChildNodes =
availableInnerMainDim - collectedFlexItemsValues.remainingFreeSpace; availableInnerMainDim - collectedFlexItemsValues.remainingFreeSpace;
@@ -2537,11 +2543,10 @@ static void YGJustifyMainAxis(
// defined, we override the position to whatever the user said // defined, we override the position to whatever the user said
// (and margin/border). // (and margin/border).
child->setLayoutPosition( child->setLayoutPosition(
YGUnwrapFloatOptional( child->getLeadingPosition(mainAxis, availableInnerMainDim)
child->getLeadingPosition(mainAxis, availableInnerMainDim)) + .unwrap() +
node->getLeadingBorder(mainAxis) + node->getLeadingBorder(mainAxis) +
YGUnwrapFloatOptional( child->getLeadingMargin(mainAxis, availableInnerWidth).unwrap(),
child->getLeadingMargin(mainAxis, availableInnerWidth)),
pos[mainAxis]); pos[mainAxis]);
} }
} else { } else {
@@ -2575,9 +2580,8 @@ static void YGJustifyMainAxis(
// they weren't computed. This means we can't call // they weren't computed. This means we can't call
// YGNodeDimWithMargin. // YGNodeDimWithMargin.
collectedFlexItemsValues.mainDim += betweenMainDim + collectedFlexItemsValues.mainDim += betweenMainDim +
YGUnwrapFloatOptional(child->getMarginForAxis( child->getMarginForAxis(mainAxis, availableInnerWidth).unwrap() +
mainAxis, availableInnerWidth)) + childLayout.computedFlexBasis.unwrap();
YGUnwrapFloatOptional(childLayout.computedFlexBasis);
collectedFlexItemsValues.crossDim = availableInnerCrossDim; collectedFlexItemsValues.crossDim = availableInnerCrossDim;
} else { } else {
// The main dimension is the sum of all the elements dimension plus // The main dimension is the sum of all the elements dimension plus
@@ -2589,12 +2593,16 @@ static void YGJustifyMainAxis(
// If the child is baseline aligned then the cross dimension is // If the child is baseline aligned then the cross dimension is
// calculated by adding maxAscent and maxDescent from the baseline. // calculated by adding maxAscent and maxDescent from the baseline.
const float ascent = YGBaseline(child) + const float ascent = YGBaseline(child) +
YGUnwrapFloatOptional(child->getLeadingMargin( child
YGFlexDirectionColumn, availableInnerWidth)); ->getLeadingMargin(
YGFlexDirectionColumn, availableInnerWidth)
.unwrap();
const float descent = const float descent =
child->getLayout().measuredDimensions[YGDimensionHeight] + child->getLayout().measuredDimensions[YGDimensionHeight] +
YGUnwrapFloatOptional(child->getMarginForAxis( child
YGFlexDirectionColumn, availableInnerWidth)) - ->getMarginForAxis(
YGFlexDirectionColumn, availableInnerWidth)
.unwrap() -
ascent; ascent;
maxAscentForCurrentLine = maxAscentForCurrentLine =
@@ -2747,20 +2755,16 @@ static void YGNodelayoutImpl(
YGResolveFlexDirection(YGFlexDirectionColumn, direction); YGResolveFlexDirection(YGFlexDirectionColumn, direction);
node->setLayoutMargin( node->setLayoutMargin(
YGUnwrapFloatOptional( node->getLeadingMargin(flexRowDirection, ownerWidth).unwrap(),
node->getLeadingMargin(flexRowDirection, ownerWidth)),
YGEdgeStart); YGEdgeStart);
node->setLayoutMargin( node->setLayoutMargin(
YGUnwrapFloatOptional( node->getTrailingMargin(flexRowDirection, ownerWidth).unwrap(),
node->getTrailingMargin(flexRowDirection, ownerWidth)),
YGEdgeEnd); YGEdgeEnd);
node->setLayoutMargin( node->setLayoutMargin(
YGUnwrapFloatOptional( node->getLeadingMargin(flexColumnDirection, ownerWidth).unwrap(),
node->getLeadingMargin(flexColumnDirection, ownerWidth)),
YGEdgeTop); YGEdgeTop);
node->setLayoutMargin( node->setLayoutMargin(
YGUnwrapFloatOptional( node->getTrailingMargin(flexColumnDirection, ownerWidth).unwrap(),
node->getTrailingMargin(flexColumnDirection, ownerWidth)),
YGEdgeBottom); YGEdgeBottom);
node->setLayoutBorder(node->getLeadingBorder(flexRowDirection), YGEdgeStart); node->setLayoutBorder(node->getLeadingBorder(flexRowDirection), YGEdgeStart);
@@ -2770,20 +2774,16 @@ static void YGNodelayoutImpl(
node->getTrailingBorder(flexColumnDirection), YGEdgeBottom); node->getTrailingBorder(flexColumnDirection), YGEdgeBottom);
node->setLayoutPadding( node->setLayoutPadding(
YGUnwrapFloatOptional( node->getLeadingPadding(flexRowDirection, ownerWidth).unwrap(),
node->getLeadingPadding(flexRowDirection, ownerWidth)),
YGEdgeStart); YGEdgeStart);
node->setLayoutPadding( node->setLayoutPadding(
YGUnwrapFloatOptional( node->getTrailingPadding(flexRowDirection, ownerWidth).unwrap(),
node->getTrailingPadding(flexRowDirection, ownerWidth)),
YGEdgeEnd); YGEdgeEnd);
node->setLayoutPadding( node->setLayoutPadding(
YGUnwrapFloatOptional( node->getLeadingPadding(flexColumnDirection, ownerWidth).unwrap(),
node->getLeadingPadding(flexColumnDirection, ownerWidth)),
YGEdgeTop); YGEdgeTop);
node->setLayoutPadding( node->setLayoutPadding(
YGUnwrapFloatOptional( node->getTrailingPadding(flexColumnDirection, ownerWidth).unwrap(),
node->getTrailingPadding(flexColumnDirection, ownerWidth)),
YGEdgeBottom); YGEdgeBottom);
if (node->getMeasure() != nullptr) { if (node->getMeasure() != nullptr) {
@@ -2841,8 +2841,8 @@ static void YGNodelayoutImpl(
const float mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight; const float mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight;
const float crossAxisownerSize = isMainAxisRow ? ownerHeight : ownerWidth; const float crossAxisownerSize = isMainAxisRow ? ownerHeight : ownerWidth;
const float leadingPaddingAndBorderCross = YGUnwrapFloatOptional( const float leadingPaddingAndBorderCross =
node->getLeadingPaddingAndBorder(crossAxis, ownerWidth)); node->getLeadingPaddingAndBorder(crossAxis, ownerWidth).unwrap();
const float paddingAndBorderAxisMain = const float paddingAndBorderAxisMain =
YGNodePaddingAndBorderForAxis(node, mainAxis, ownerWidth); YGNodePaddingAndBorderForAxis(node, mainAxis, ownerWidth);
const float paddingAndBorderAxisCross = const float paddingAndBorderAxisCross =
@@ -2858,26 +2858,30 @@ static void YGNodelayoutImpl(
const float paddingAndBorderAxisColumn = const float paddingAndBorderAxisColumn =
isMainAxisRow ? paddingAndBorderAxisCross : paddingAndBorderAxisMain; isMainAxisRow ? paddingAndBorderAxisCross : paddingAndBorderAxisMain;
const float marginAxisRow = YGUnwrapFloatOptional( const float marginAxisRow =
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth)); node->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
const float marginAxisColumn = YGUnwrapFloatOptional( const float marginAxisColumn =
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth)); node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
const float minInnerWidth = const float minInnerWidth =
YGUnwrapFloatOptional(YGResolveValue( YGResolveValue(
node->getStyle().minDimensions[YGDimensionWidth], ownerWidth)) - node->getStyle().minDimensions[YGDimensionWidth], ownerWidth)
.unwrap() -
paddingAndBorderAxisRow; paddingAndBorderAxisRow;
const float maxInnerWidth = const float maxInnerWidth =
YGUnwrapFloatOptional(YGResolveValue( YGResolveValue(
node->getStyle().maxDimensions[YGDimensionWidth], ownerWidth)) - node->getStyle().maxDimensions[YGDimensionWidth], ownerWidth)
.unwrap() -
paddingAndBorderAxisRow; paddingAndBorderAxisRow;
const float minInnerHeight = const float minInnerHeight =
YGUnwrapFloatOptional(YGResolveValue( YGResolveValue(
node->getStyle().minDimensions[YGDimensionHeight], ownerHeight)) - node->getStyle().minDimensions[YGDimensionHeight], ownerHeight)
.unwrap() -
paddingAndBorderAxisColumn; paddingAndBorderAxisColumn;
const float maxInnerHeight = const float maxInnerHeight =
YGUnwrapFloatOptional(YGResolveValue( YGResolveValue(
node->getStyle().maxDimensions[YGDimensionHeight], ownerHeight)) - node->getStyle().maxDimensions[YGDimensionHeight], ownerHeight)
.unwrap() -
paddingAndBorderAxisColumn; paddingAndBorderAxisColumn;
const float minInnerMainDim = isMainAxisRow ? minInnerWidth : minInnerHeight; const float minInnerMainDim = isMainAxisRow ? minInnerWidth : minInnerHeight;
@@ -3088,11 +3092,11 @@ static void YGNodelayoutImpl(
child->isLeadingPositionDefined(crossAxis); child->isLeadingPositionDefined(crossAxis);
if (isChildLeadingPosDefined) { if (isChildLeadingPosDefined) {
child->setLayoutPosition( child->setLayoutPosition(
YGUnwrapFloatOptional(child->getLeadingPosition( child->getLeadingPosition(crossAxis, availableInnerCrossDim)
crossAxis, availableInnerCrossDim)) + .unwrap() +
node->getLeadingBorder(crossAxis) + node->getLeadingBorder(crossAxis) +
YGUnwrapFloatOptional(child->getLeadingMargin( child->getLeadingMargin(crossAxis, availableInnerWidth)
crossAxis, availableInnerWidth)), .unwrap(),
pos[crossAxis]); pos[crossAxis]);
} }
// If leading position is not defined or calculations result in Nan, // If leading position is not defined or calculations result in Nan,
@@ -3101,8 +3105,8 @@ static void YGNodelayoutImpl(
YGFloatIsUndefined(child->getLayout().position[pos[crossAxis]])) { YGFloatIsUndefined(child->getLayout().position[pos[crossAxis]])) {
child->setLayoutPosition( child->setLayoutPosition(
node->getLeadingBorder(crossAxis) + node->getLeadingBorder(crossAxis) +
YGUnwrapFloatOptional(child->getLeadingMargin( child->getLeadingMargin(crossAxis, availableInnerWidth)
crossAxis, availableInnerWidth)), .unwrap(),
pos[crossAxis]); pos[crossAxis]);
} }
} else { } else {
@@ -3128,16 +3132,17 @@ static void YGNodelayoutImpl(
child->getLayout().measuredDimensions[dim[mainAxis]]; child->getLayout().measuredDimensions[dim[mainAxis]];
float childCrossSize = float childCrossSize =
!child->getStyle().aspectRatio.isUndefined() !child->getStyle().aspectRatio.isUndefined()
? ((YGUnwrapFloatOptional(child->getMarginForAxis( ? child->getMarginForAxis(crossAxis, availableInnerWidth)
crossAxis, availableInnerWidth)) + .unwrap() +
(isMainAxisRow ? childMainSize / (isMainAxisRow ? childMainSize /
child->getStyle().aspectRatio.getValue() child->getStyle().aspectRatio.getValue()
: childMainSize * : childMainSize *
child->getStyle().aspectRatio.getValue()))) child->getStyle().aspectRatio.getValue())
: collectedFlexItemsValues.crossDim; : collectedFlexItemsValues.crossDim;
childMainSize += YGUnwrapFloatOptional( childMainSize +=
child->getMarginForAxis(mainAxis, availableInnerWidth)); child->getMarginForAxis(mainAxis, availableInnerWidth)
.unwrap();
YGMeasureMode childMainMeasureMode = YGMeasureModeExactly; YGMeasureMode childMainMeasureMode = YGMeasureModeExactly;
YGMeasureMode childCrossMeasureMode = YGMeasureModeExactly; YGMeasureMode childCrossMeasureMode = YGMeasureModeExactly;
@@ -3279,17 +3284,21 @@ static void YGNodelayoutImpl(
lineHeight = YGFloatMax( lineHeight = YGFloatMax(
lineHeight, lineHeight,
child->getLayout().measuredDimensions[dim[crossAxis]] + child->getLayout().measuredDimensions[dim[crossAxis]] +
YGUnwrapFloatOptional(child->getMarginForAxis( child->getMarginForAxis(crossAxis, availableInnerWidth)
crossAxis, availableInnerWidth))); .unwrap());
} }
if (YGNodeAlignItem(node, child) == YGAlignBaseline) { if (YGNodeAlignItem(node, child) == YGAlignBaseline) {
const float ascent = YGBaseline(child) + const float ascent = YGBaseline(child) +
YGUnwrapFloatOptional(child->getLeadingMargin( child
YGFlexDirectionColumn, availableInnerWidth)); ->getLeadingMargin(
YGFlexDirectionColumn, availableInnerWidth)
.unwrap();
const float descent = const float descent =
child->getLayout().measuredDimensions[YGDimensionHeight] + child->getLayout().measuredDimensions[YGDimensionHeight] +
YGUnwrapFloatOptional(child->getMarginForAxis( child
YGFlexDirectionColumn, availableInnerWidth)) - ->getMarginForAxis(
YGFlexDirectionColumn, availableInnerWidth)
.unwrap() -
ascent; ascent;
maxAscentForCurrentLine = maxAscentForCurrentLine =
YGFloatMax(maxAscentForCurrentLine, ascent); YGFloatMax(maxAscentForCurrentLine, ascent);
@@ -3314,16 +3323,16 @@ static void YGNodelayoutImpl(
case YGAlignFlexStart: { case YGAlignFlexStart: {
child->setLayoutPosition( child->setLayoutPosition(
currentLead + currentLead +
YGUnwrapFloatOptional(child->getLeadingMargin( child->getLeadingMargin(crossAxis, availableInnerWidth)
crossAxis, availableInnerWidth)), .unwrap(),
pos[crossAxis]); pos[crossAxis]);
break; break;
} }
case YGAlignFlexEnd: { case YGAlignFlexEnd: {
child->setLayoutPosition( child->setLayoutPosition(
currentLead + lineHeight - currentLead + lineHeight -
YGUnwrapFloatOptional(child->getTrailingMargin( child->getTrailingMargin(crossAxis, availableInnerWidth)
crossAxis, availableInnerWidth)) - .unwrap() -
child->getLayout().measuredDimensions[dim[crossAxis]], child->getLayout().measuredDimensions[dim[crossAxis]],
pos[crossAxis]); pos[crossAxis]);
break; break;
@@ -3340,8 +3349,8 @@ static void YGNodelayoutImpl(
case YGAlignStretch: { case YGAlignStretch: {
child->setLayoutPosition( child->setLayoutPosition(
currentLead + currentLead +
YGUnwrapFloatOptional(child->getLeadingMargin( child->getLeadingMargin(crossAxis, availableInnerWidth)
crossAxis, availableInnerWidth)), .unwrap(),
pos[crossAxis]); pos[crossAxis]);
// Remeasure child with the line height as it as been only // Remeasure child with the line height as it as been only
@@ -3351,15 +3360,15 @@ static void YGNodelayoutImpl(
const float childWidth = isMainAxisRow const float childWidth = isMainAxisRow
? (child->getLayout() ? (child->getLayout()
.measuredDimensions[YGDimensionWidth] + .measuredDimensions[YGDimensionWidth] +
YGUnwrapFloatOptional(child->getMarginForAxis( child->getMarginForAxis(mainAxis, availableInnerWidth)
mainAxis, availableInnerWidth))) .unwrap())
: lineHeight; : lineHeight;
const float childHeight = !isMainAxisRow const float childHeight = !isMainAxisRow
? (child->getLayout() ? (child->getLayout()
.measuredDimensions[YGDimensionHeight] + .measuredDimensions[YGDimensionHeight] +
YGUnwrapFloatOptional(child->getMarginForAxis( child->getMarginForAxis(crossAxis, availableInnerWidth)
crossAxis, availableInnerWidth))) .unwrap())
: lineHeight; : lineHeight;
if (!(YGFloatsEqual( if (!(YGFloatsEqual(
@@ -3389,8 +3398,10 @@ static void YGNodelayoutImpl(
case YGAlignBaseline: { case YGAlignBaseline: {
child->setLayoutPosition( child->setLayoutPosition(
currentLead + maxAscentForCurrentLine - YGBaseline(child) + currentLead + maxAscentForCurrentLine - YGBaseline(child) +
YGUnwrapFloatOptional(child->getLeadingPosition( child
YGFlexDirectionColumn, availableInnerCrossDim)), ->getLeadingPosition(
YGFlexDirectionColumn, availableInnerCrossDim)
.unwrap(),
YGEdgeTop); YGEdgeTop);
break; break;
@@ -3446,8 +3457,9 @@ static void YGNodelayoutImpl(
YGFloatMax( YGFloatMax(
YGFloatMin( YGFloatMin(
availableInnerMainDim + paddingAndBorderAxisMain, availableInnerMainDim + paddingAndBorderAxisMain,
YGUnwrapFloatOptional(YGNodeBoundAxisWithinMinAndMax( YGNodeBoundAxisWithinMinAndMax(
node, mainAxis, maxLineMainDim, mainAxisownerSize))), node, mainAxis, maxLineMainDim, mainAxisownerSize)
.unwrap()),
paddingAndBorderAxisMain), paddingAndBorderAxisMain),
dim[mainAxis]); dim[mainAxis]);
} }
@@ -3473,11 +3485,12 @@ static void YGNodelayoutImpl(
YGFloatMax( YGFloatMax(
YGFloatMin( YGFloatMin(
availableInnerCrossDim + paddingAndBorderAxisCross, availableInnerCrossDim + paddingAndBorderAxisCross,
YGUnwrapFloatOptional(YGNodeBoundAxisWithinMinAndMax( YGNodeBoundAxisWithinMinAndMax(
node, node,
crossAxis, crossAxis,
totalLineCrossDim + paddingAndBorderAxisCross, totalLineCrossDim + paddingAndBorderAxisCross,
crossAxisownerSize))), crossAxisownerSize)
.unwrap()),
paddingAndBorderAxisCross), paddingAndBorderAxisCross),
dim[crossAxis]); dim[crossAxis]);
} }
@@ -3777,10 +3790,10 @@ bool YGLayoutNodeInternal(
// expensive to measure, so it's worth avoiding redundant measurements if at // expensive to measure, so it's worth avoiding redundant measurements if at
// all possible. // all possible.
if (node->getMeasure() != nullptr) { if (node->getMeasure() != nullptr) {
const float marginAxisRow = YGUnwrapFloatOptional( const float marginAxisRow =
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth)); node->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
const float marginAxisColumn = YGUnwrapFloatOptional( const float marginAxisColumn =
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth)); node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
// First, try to use the layout cache. // First, try to use the layout cache.
if (YGNodeCanUseCachedMeasurement( if (YGNodeCanUseCachedMeasurement(
@@ -4080,16 +4093,18 @@ void YGNodeCalculateLayout(
float width = YGUndefined; float width = YGUndefined;
YGMeasureMode widthMeasureMode = YGMeasureModeUndefined; YGMeasureMode widthMeasureMode = YGMeasureModeUndefined;
if (YGNodeIsStyleDimDefined(node, YGFlexDirectionRow, ownerWidth)) { if (YGNodeIsStyleDimDefined(node, YGFlexDirectionRow, ownerWidth)) {
width = YGUnwrapFloatOptional( width =
YGResolveValue( (YGResolveValue(
node->getResolvedDimension(dim[YGFlexDirectionRow]), ownerWidth) + node->getResolvedDimension(dim[YGFlexDirectionRow]), ownerWidth) +
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth)); node->getMarginForAxis(YGFlexDirectionRow, ownerWidth))
.unwrap();
widthMeasureMode = YGMeasureModeExactly; widthMeasureMode = YGMeasureModeExactly;
} else if (!YGResolveValue( } else if (!YGResolveValue(
node->getStyle().maxDimensions[YGDimensionWidth], ownerWidth) node->getStyle().maxDimensions[YGDimensionWidth], ownerWidth)
.isUndefined()) { .isUndefined()) {
width = YGUnwrapFloatOptional(YGResolveValue( width = YGResolveValue(
node->getStyle().maxDimensions[YGDimensionWidth], ownerWidth)); node->getStyle().maxDimensions[YGDimensionWidth], ownerWidth)
.unwrap();
widthMeasureMode = YGMeasureModeAtMost; widthMeasureMode = YGMeasureModeAtMost;
} else { } else {
width = ownerWidth; width = ownerWidth;
@@ -4100,18 +4115,19 @@ void YGNodeCalculateLayout(
float height = YGUndefined; float height = YGUndefined;
YGMeasureMode heightMeasureMode = YGMeasureModeUndefined; YGMeasureMode heightMeasureMode = YGMeasureModeUndefined;
if (YGNodeIsStyleDimDefined(node, YGFlexDirectionColumn, ownerHeight)) { if (YGNodeIsStyleDimDefined(node, YGFlexDirectionColumn, ownerHeight)) {
height = YGUnwrapFloatOptional( height = (YGResolveValue(
YGResolveValue( node->getResolvedDimension(dim[YGFlexDirectionColumn]),
node->getResolvedDimension(dim[YGFlexDirectionColumn]), ownerHeight) +
ownerHeight) + node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth))
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth)); .unwrap();
heightMeasureMode = YGMeasureModeExactly; heightMeasureMode = YGMeasureModeExactly;
} else if (!YGResolveValue( } else if (!YGResolveValue(
node->getStyle().maxDimensions[YGDimensionHeight], node->getStyle().maxDimensions[YGDimensionHeight],
ownerHeight) ownerHeight)
.isUndefined()) { .isUndefined()) {
height = YGUnwrapFloatOptional(YGResolveValue( height = YGResolveValue(
node->getStyle().maxDimensions[YGDimensionHeight], ownerHeight)); node->getStyle().maxDimensions[YGDimensionHeight], ownerHeight)
.unwrap();
heightMeasureMode = YGMeasureModeAtMost; heightMeasureMode = YGMeasureModeAtMost;
} else { } else {
height = ownerHeight; height = ownerHeight;