inline YGUnwrapFloatOptional
Summary: @public Replaces C-style function call with C++ method invokation. Reviewed By: SidharthGuglani Differential Revision: D13209154 fbshipit-source-id: 14e650af4655efb3a659f3cd949a11df773aabcf
This commit is contained in:
committed by
Facebook Github Bot
parent
b6498987fa
commit
10b316f315
@@ -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.unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
YGFloatOptional YGFloatOptionalMax(
|
YGFloatOptional YGFloatOptionalMax(
|
||||||
const YGFloatOptional op1,
|
const YGFloatOptional op1,
|
||||||
const YGFloatOptional op2) {
|
const YGFloatOptional op2) {
|
||||||
|
@@ -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);
|
||||||
|
@@ -232,20 +232,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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
390
yoga/Yoga.cpp
390
yoga/Yoga.cpp
@@ -1093,9 +1093,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(
|
||||||
@@ -1177,9 +1177,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(
|
||||||
@@ -1246,8 +1246,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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1354,22 +1353,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;
|
||||||
}
|
}
|
||||||
@@ -1495,13 +1496,14 @@ static void YGNodeAbsoluteLayoutChild(
|
|||||||
YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined;
|
YGMeasureMode childHeightMeasureMode = YGMeasureModeUndefined;
|
||||||
|
|
||||||
auto marginRow =
|
auto marginRow =
|
||||||
YGUnwrapFloatOptional(child->getMarginForAxis(YGFlexDirectionRow, width));
|
(child->getMarginForAxis(YGFlexDirectionRow, width)).unwrap();
|
||||||
auto marginColumn = YGUnwrapFloatOptional(
|
auto marginColumn =
|
||||||
child->getMarginForAxis(YGFlexDirectionColumn, width));
|
(child->getMarginForAxis(YGFlexDirectionColumn, width)).unwrap();
|
||||||
|
|
||||||
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
|
||||||
@@ -1512,17 +1514,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
|
||||||
@@ -1530,13 +1533,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);
|
||||||
}
|
}
|
||||||
@@ -1589,11 +1591,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(
|
||||||
@@ -1615,9 +1615,10 @@ 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) &&
|
||||||
@@ -1642,9 +1643,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->getTrailingPosition(
|
||||||
crossAxis, isMainAxisRow ? height : width)),
|
crossAxis, isMainAxisRow ? height : width))
|
||||||
|
.unwrap(),
|
||||||
leading[crossAxis]);
|
leading[crossAxis]);
|
||||||
|
|
||||||
} else if (
|
} else if (
|
||||||
@@ -1683,10 +1685,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)
|
||||||
@@ -1761,10 +1763,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(
|
||||||
@@ -1805,10 +1807,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(
|
||||||
@@ -1864,8 +1866,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);
|
||||||
|
|
||||||
@@ -1969,9 +1970,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;
|
||||||
@@ -2006,14 +2008,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
|
||||||
@@ -2039,7 +2042,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);
|
||||||
@@ -2086,12 +2089,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) &&
|
||||||
@@ -2141,10 +2145,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;
|
||||||
@@ -2180,9 +2186,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 ==
|
||||||
@@ -2262,12 +2269,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 =
|
||||||
@@ -2418,10 +2426,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 &&
|
||||||
@@ -2437,8 +2445,9 @@ 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;
|
||||||
@@ -2528,11 +2537,11 @@ 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))
|
||||||
child->getLeadingMargin(mainAxis, availableInnerWidth)),
|
.unwrap(),
|
||||||
pos[mainAxis]);
|
pos[mainAxis]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -2566,9 +2575,9 @@ 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))
|
||||||
mainAxis, availableInnerWidth)) +
|
.unwrap() +
|
||||||
YGUnwrapFloatOptional(childLayout.computedFlexBasis);
|
(childLayout.computedFlexBasis).unwrap();
|
||||||
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
|
||||||
@@ -2580,12 +2589,14 @@ 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->getLeadingMargin(
|
||||||
YGFlexDirectionColumn, availableInnerWidth));
|
YGFlexDirectionColumn, availableInnerWidth))
|
||||||
|
.unwrap();
|
||||||
const float descent =
|
const float descent =
|
||||||
child->getLayout().measuredDimensions[YGDimensionHeight] +
|
child->getLayout().measuredDimensions[YGDimensionHeight] +
|
||||||
YGUnwrapFloatOptional(child->getMarginForAxis(
|
(child->getMarginForAxis(
|
||||||
YGFlexDirectionColumn, availableInnerWidth)) -
|
YGFlexDirectionColumn, availableInnerWidth))
|
||||||
|
.unwrap() -
|
||||||
ascent;
|
ascent;
|
||||||
|
|
||||||
maxAscentForCurrentLine =
|
maxAscentForCurrentLine =
|
||||||
@@ -2738,20 +2749,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);
|
||||||
@@ -2761,20 +2768,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) {
|
||||||
@@ -2832,8 +2835,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 =
|
||||||
@@ -2849,26 +2852,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;
|
||||||
@@ -3079,11 +3086,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,
|
||||||
@@ -3092,8 +3099,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 {
|
||||||
@@ -3119,16 +3126,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.unwrap()
|
child->getStyle().aspectRatio.unwrap()
|
||||||
: childMainSize *
|
: childMainSize *
|
||||||
child->getStyle().aspectRatio.unwrap())))
|
child->getStyle().aspectRatio.unwrap())))
|
||||||
: 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;
|
||||||
@@ -3270,17 +3278,19 @@ 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->getLeadingMargin(
|
||||||
YGFlexDirectionColumn, availableInnerWidth));
|
YGFlexDirectionColumn, availableInnerWidth))
|
||||||
|
.unwrap();
|
||||||
const float descent =
|
const float descent =
|
||||||
child->getLayout().measuredDimensions[YGDimensionHeight] +
|
child->getLayout().measuredDimensions[YGDimensionHeight] +
|
||||||
YGUnwrapFloatOptional(child->getMarginForAxis(
|
(child->getMarginForAxis(
|
||||||
YGFlexDirectionColumn, availableInnerWidth)) -
|
YGFlexDirectionColumn, availableInnerWidth))
|
||||||
|
.unwrap() -
|
||||||
ascent;
|
ascent;
|
||||||
maxAscentForCurrentLine =
|
maxAscentForCurrentLine =
|
||||||
YGFloatMax(maxAscentForCurrentLine, ascent);
|
YGFloatMax(maxAscentForCurrentLine, ascent);
|
||||||
@@ -3305,16 +3315,18 @@ 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;
|
||||||
@@ -3331,8 +3343,9 @@ 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
|
||||||
@@ -3342,15 +3355,17 @@ 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(
|
||||||
@@ -3380,8 +3395,9 @@ static void YGNodelayoutImpl(
|
|||||||
case YGAlignBaseline: {
|
case YGAlignBaseline: {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
currentLead + maxAscentForCurrentLine - YGBaseline(child) +
|
currentLead + maxAscentForCurrentLine - YGBaseline(child) +
|
||||||
YGUnwrapFloatOptional(child->getLeadingPosition(
|
(child->getLeadingPosition(
|
||||||
YGFlexDirectionColumn, availableInnerCrossDim)),
|
YGFlexDirectionColumn, availableInnerCrossDim))
|
||||||
|
.unwrap(),
|
||||||
YGEdgeTop);
|
YGEdgeTop);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -3437,8 +3453,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]);
|
||||||
}
|
}
|
||||||
@@ -3464,11 +3481,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]);
|
||||||
}
|
}
|
||||||
@@ -3768,10 +3786,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(
|
||||||
@@ -4071,16 +4089,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;
|
||||||
@@ -4091,18 +4111,20 @@ 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 =
|
||||||
node->getStyle().maxDimensions[YGDimensionHeight], ownerHeight));
|
(YGResolveValue(
|
||||||
|
node->getStyle().maxDimensions[YGDimensionHeight], ownerHeight))
|
||||||
|
.unwrap();
|
||||||
heightMeasureMode = YGMeasureModeAtMost;
|
heightMeasureMode = YGMeasureModeAtMost;
|
||||||
} else {
|
} else {
|
||||||
height = ownerHeight;
|
height = ownerHeight;
|
||||||
|
Reference in New Issue
Block a user