diff --git a/yoga/algorithm/BoundAxis.h b/yoga/algorithm/BoundAxis.h index 7d7f969b91..92cc5d9c79 100644 --- a/yoga/algorithm/BoundAxis.h +++ b/yoga/algorithm/BoundAxis.h @@ -21,8 +21,8 @@ inline float paddingAndBorderForAxis( const yoga::Node* const node, const FlexDirection axis, const float widthSize) { - return node->getLeadingPaddingAndBorder(axis, widthSize) + - node->getTrailingPaddingAndBorder(axis, widthSize); + return node->getFlexStartPaddingAndBorder(axis, widthSize) + + node->getFlexEndPaddingAndBorder(axis, widthSize); } inline FloatOptional boundAxisWithinMinAndMax( diff --git a/yoga/algorithm/CalculateLayout.cpp b/yoga/algorithm/CalculateLayout.cpp index dc9f785eac..3f8a25ad05 100644 --- a/yoga/algorithm/CalculateLayout.cpp +++ b/yoga/algorithm/CalculateLayout.cpp @@ -88,8 +88,8 @@ static void setChildTrailingPosition( const float size = child->getLayout().measuredDimension(dimension(axis)); child->setLayoutPosition( node->getLayout().measuredDimension(dimension(axis)) - size - - child->getLayout().position[leadingEdge(axis)], - trailingEdge(axis)); + child->getLayout().position[flexStartEdge(axis)], + flexEndEdge(axis)); } static void constrainMaxSizeForMode( @@ -343,13 +343,13 @@ static void layoutAbsoluteChild( } else { // If the child doesn't have a specified width, compute the width based on // the left/right offsets if they're defined. - if (child->isLeadingPositionDefined(FlexDirection::Row) && - child->isTrailingPosDefined(FlexDirection::Row)) { + if (child->isFlexStartPositionDefined(FlexDirection::Row) && + child->isFlexEndPositionDefined(FlexDirection::Row)) { childWidth = node->getLayout().measuredDimension(Dimension::Width) - - (node->getLeadingBorder(FlexDirection::Row) + - node->getTrailingBorder(FlexDirection::Row)) - - (child->getLeadingPosition(FlexDirection::Row, width) + - child->getTrailingPosition(FlexDirection::Row, width)); + (node->getFlexStartBorder(FlexDirection::Row) + + node->getFlexEndBorder(FlexDirection::Row)) - + (child->getFlexStartPosition(FlexDirection::Row, width) + + child->getFlexEndPosition(FlexDirection::Row, width)); childWidth = boundAxis(child, FlexDirection::Row, childWidth, width, width); } @@ -363,13 +363,13 @@ static void layoutAbsoluteChild( } else { // If the child doesn't have a specified height, compute the height based on // the top/bottom offsets if they're defined. - if (child->isLeadingPositionDefined(FlexDirection::Column) && - child->isTrailingPosDefined(FlexDirection::Column)) { + if (child->isFlexStartPositionDefined(FlexDirection::Column) && + child->isFlexEndPositionDefined(FlexDirection::Column)) { childHeight = node->getLayout().measuredDimension(Dimension::Height) - - (node->getLeadingBorder(FlexDirection::Column) + - node->getTrailingBorder(FlexDirection::Column)) - - (child->getLeadingPosition(FlexDirection::Column, height) + - child->getTrailingPosition(FlexDirection::Column, height)); + (node->getFlexStartBorder(FlexDirection::Column) + + node->getFlexEndBorder(FlexDirection::Column)) - + (child->getFlexStartPosition(FlexDirection::Column, height) + + child->getFlexEndPosition(FlexDirection::Column, height)); childHeight = boundAxis(child, FlexDirection::Column, childHeight, height, width); } @@ -446,90 +446,89 @@ static void layoutAbsoluteChild( depth, generationCount); - if (child->isTrailingPosDefined(mainAxis) && - !child->isLeadingPositionDefined(mainAxis)) { + if (child->isFlexEndPositionDefined(mainAxis) && + !child->isFlexStartPositionDefined(mainAxis)) { child->setLayoutPosition( node->getLayout().measuredDimension(dimension(mainAxis)) - child->getLayout().measuredDimension(dimension(mainAxis)) - - node->getTrailingBorder(mainAxis) - - child->getTrailingMargin( + node->getFlexEndBorder(mainAxis) - + child->getInlineEndMargin( mainAxis, direction, isMainAxisRow ? width : height) - - child->getTrailingPosition( - mainAxis, isMainAxisRow ? width : height), - leadingEdge(mainAxis)); + child->getFlexEndPosition(mainAxis, isMainAxisRow ? width : height), + flexStartEdge(mainAxis)); } else if ( - !child->isLeadingPositionDefined(mainAxis) && + !child->isFlexStartPositionDefined(mainAxis) && node->getStyle().justifyContent() == Justify::Center) { child->setLayoutPosition( (node->getLayout().measuredDimension(dimension(mainAxis)) - child->getLayout().measuredDimension(dimension(mainAxis))) / 2.0f, - leadingEdge(mainAxis)); + flexStartEdge(mainAxis)); } else if ( - !child->isLeadingPositionDefined(mainAxis) && + !child->isFlexStartPositionDefined(mainAxis) && node->getStyle().justifyContent() == Justify::FlexEnd) { child->setLayoutPosition( (node->getLayout().measuredDimension(dimension(mainAxis)) - child->getLayout().measuredDimension(dimension(mainAxis))), - leadingEdge(mainAxis)); + flexStartEdge(mainAxis)); } else if ( node->getConfig()->isExperimentalFeatureEnabled( ExperimentalFeature::AbsolutePercentageAgainstPaddingEdge) && - child->isLeadingPositionDefined(mainAxis)) { + child->isFlexStartPositionDefined(mainAxis)) { child->setLayoutPosition( - child->getLeadingPosition( + child->getFlexStartPosition( mainAxis, node->getLayout().measuredDimension(dimension(mainAxis))) + - node->getLeadingBorder(mainAxis) + - child->getLeadingMargin( + node->getFlexStartBorder(mainAxis) + + child->getInlineStartMargin( mainAxis, direction, node->getLayout().measuredDimension(dimension(mainAxis))), - leadingEdge(mainAxis)); + flexStartEdge(mainAxis)); } - if (child->isTrailingPosDefined(crossAxis) && - !child->isLeadingPositionDefined(crossAxis)) { + if (child->isFlexEndPositionDefined(crossAxis) && + !child->isFlexStartPositionDefined(crossAxis)) { child->setLayoutPosition( node->getLayout().measuredDimension(dimension(crossAxis)) - child->getLayout().measuredDimension(dimension(crossAxis)) - - node->getTrailingBorder(crossAxis) - - child->getTrailingMargin( + node->getFlexEndBorder(crossAxis) - + child->getInlineEndMargin( crossAxis, direction, isMainAxisRow ? height : width) - - child->getTrailingPosition( + child->getFlexEndPosition( crossAxis, isMainAxisRow ? height : width), - leadingEdge(crossAxis)); + flexStartEdge(crossAxis)); } else if ( - !child->isLeadingPositionDefined(crossAxis) && + !child->isFlexStartPositionDefined(crossAxis) && resolveChildAlignment(node, child) == Align::Center) { child->setLayoutPosition( (node->getLayout().measuredDimension(dimension(crossAxis)) - child->getLayout().measuredDimension(dimension(crossAxis))) / 2.0f, - leadingEdge(crossAxis)); + flexStartEdge(crossAxis)); } else if ( - !child->isLeadingPositionDefined(crossAxis) && + !child->isFlexStartPositionDefined(crossAxis) && ((resolveChildAlignment(node, child) == Align::FlexEnd) ^ (node->getStyle().flexWrap() == Wrap::WrapReverse))) { child->setLayoutPosition( (node->getLayout().measuredDimension(dimension(crossAxis)) - child->getLayout().measuredDimension(dimension(crossAxis))), - leadingEdge(crossAxis)); + flexStartEdge(crossAxis)); } else if ( node->getConfig()->isExperimentalFeatureEnabled( ExperimentalFeature::AbsolutePercentageAgainstPaddingEdge) && - child->isLeadingPositionDefined(crossAxis)) { + child->isFlexStartPositionDefined(crossAxis)) { child->setLayoutPosition( - child->getLeadingPosition( + child->getFlexStartPosition( crossAxis, node->getLayout().measuredDimension(dimension(crossAxis))) + - node->getLeadingBorder(crossAxis) + - child->getLeadingMargin( + node->getFlexStartBorder(crossAxis) + + child->getInlineStartMargin( crossAxis, direction, node->getLayout().measuredDimension(dimension(crossAxis))), - leadingEdge(crossAxis)); + flexStartEdge(crossAxis)); } } @@ -946,7 +945,8 @@ static float distributeFreeSpaceSecondPass( measureModeCrossDim == MeasureMode::Exactly && !(isNodeFlexWrap && mainAxisOverflows) && resolveChildAlignment(node, currentLineChild) == Align::Stretch && - currentLineChild->marginLeadingValue(crossAxis).unit != YGUnitAuto && + currentLineChild->getFlexStartMarginValue(crossAxis).unit != + YGUnitAuto && currentLineChild->marginTrailingValue(crossAxis).unit != YGUnitAuto) { childCrossSize = availableInnerCrossDim; childCrossMeasureMode = MeasureMode::Exactly; @@ -992,7 +992,8 @@ static float distributeFreeSpaceSecondPass( !styleDefinesDimension( currentLineChild, crossAxis, availableInnerCrossDim) && resolveChildAlignment(node, currentLineChild) == Align::Stretch && - currentLineChild->marginLeadingValue(crossAxis).unit != YGUnitAuto && + currentLineChild->getFlexStartMarginValue(crossAxis).unit != + YGUnitAuto && currentLineChild->marginTrailingValue(crossAxis).unit != YGUnitAuto; const float childWidth = isMainAxisRow ? childMainSize : childCrossSize; @@ -1199,9 +1200,9 @@ static void justifyMainAxis( const bool performLayout) { const auto& style = node->getStyle(); const float leadingPaddingAndBorderMain = - node->getLeadingPaddingAndBorder(mainAxis, ownerWidth); + node->getFlexStartPaddingAndBorder(mainAxis, ownerWidth); const float trailingPaddingAndBorderMain = - node->getTrailingPaddingAndBorder(mainAxis, ownerWidth); + node->getFlexEndPaddingAndBorder(mainAxis, ownerWidth); const float gap = node->getGapForAxis(mainAxis); // If we are using "at most" rules in the main axis, make sure that // remainingFreeSpace is 0 when min main dimension is not given @@ -1236,7 +1237,7 @@ static void justifyMainAxis( for (size_t i = startOfLineIndex; i < flexLine.endOfLineIndex; i++) { auto child = node->getChild(i); if (child->getStyle().positionType() != PositionType::Absolute) { - if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) { + if (child->getFlexStartMarginValue(mainAxis).unit == YGUnitAuto) { numberOfAutoMarginsOnCurrentLine++; } if (child->marginTrailingValue(mainAxis).unit == YGUnitAuto) { @@ -1298,33 +1299,33 @@ static void justifyMainAxis( continue; } if (childStyle.positionType() == PositionType::Absolute && - child->isLeadingPositionDefined(mainAxis)) { + child->isFlexStartPositionDefined(mainAxis)) { if (performLayout) { // In case the child is position absolute and has left/top being // defined, we override the position to whatever the user said (and // margin/border). child->setLayoutPosition( - child->getLeadingPosition(mainAxis, availableInnerMainDim) + - node->getLeadingBorder(mainAxis) + - child->getLeadingMargin( + child->getFlexStartPosition(mainAxis, availableInnerMainDim) + + node->getFlexStartBorder(mainAxis) + + child->getInlineStartMargin( mainAxis, direction, availableInnerWidth), - leadingEdge(mainAxis)); + flexStartEdge(mainAxis)); } } else { // Now that we placed the element, we need to update the variables. // We need to do that only for relative elements. Absolute elements do not // take part in that phase. if (childStyle.positionType() != PositionType::Absolute) { - if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) { + if (child->getFlexStartMarginValue(mainAxis).unit == YGUnitAuto) { flexLine.layout.mainDim += flexLine.layout.remainingFreeSpace / static_cast(numberOfAutoMarginsOnCurrentLine); } if (performLayout) { child->setLayoutPosition( - childLayout.position[leadingEdge(mainAxis)] + + childLayout.position[flexStartEdge(mainAxis)] + flexLine.layout.mainDim, - leadingEdge(mainAxis)); + flexStartEdge(mainAxis)); } if (child != flexLine.itemsInFlow.back()) { @@ -1355,7 +1356,7 @@ static void justifyMainAxis( // If the child is baseline aligned then the cross dimension is // calculated by adding maxAscent and maxDescent from the baseline. const float ascent = calculateBaseline(child) + - child->getLeadingMargin( + child->getInlineStartMargin( FlexDirection::Column, direction, availableInnerWidth); const float descent = child->getLayout().measuredDimension(Dimension::Height) + @@ -1378,9 +1379,9 @@ static void justifyMainAxis( } } else if (performLayout) { child->setLayoutPosition( - childLayout.position[leadingEdge(mainAxis)] + - node->getLeadingBorder(mainAxis) + leadingMainDim, - leadingEdge(mainAxis)); + childLayout.position[flexStartEdge(mainAxis)] + + node->getFlexStartBorder(mainAxis) + leadingMainDim, + flexStartEdge(mainAxis)); } } } @@ -1502,35 +1503,36 @@ static void calculateLayoutImpl( const YGEdge endEdge = direction == Direction::LTR ? YGEdgeRight : YGEdgeLeft; const float marginRowLeading = - node->getLeadingMargin(flexRowDirection, direction, ownerWidth); + node->getInlineStartMargin(flexRowDirection, direction, ownerWidth); node->setLayoutMargin(marginRowLeading, startEdge); const float marginRowTrailing = - node->getTrailingMargin(flexRowDirection, direction, ownerWidth); + node->getInlineEndMargin(flexRowDirection, direction, ownerWidth); node->setLayoutMargin(marginRowTrailing, endEdge); const float marginColumnLeading = - node->getLeadingMargin(flexColumnDirection, direction, ownerWidth); + node->getInlineStartMargin(flexColumnDirection, direction, ownerWidth); node->setLayoutMargin(marginColumnLeading, YGEdgeTop); const float marginColumnTrailing = - node->getTrailingMargin(flexColumnDirection, direction, ownerWidth); + node->getInlineEndMargin(flexColumnDirection, direction, ownerWidth); node->setLayoutMargin(marginColumnTrailing, YGEdgeBottom); const float marginAxisRow = marginRowLeading + marginRowTrailing; const float marginAxisColumn = marginColumnLeading + marginColumnTrailing; - node->setLayoutBorder(node->getLeadingBorder(flexRowDirection), startEdge); - node->setLayoutBorder(node->getTrailingBorder(flexRowDirection), endEdge); - node->setLayoutBorder(node->getLeadingBorder(flexColumnDirection), YGEdgeTop); + node->setLayoutBorder(node->getFlexStartBorder(flexRowDirection), startEdge); + node->setLayoutBorder(node->getFlexEndBorder(flexRowDirection), endEdge); node->setLayoutBorder( - node->getTrailingBorder(flexColumnDirection), YGEdgeBottom); + node->getFlexStartBorder(flexColumnDirection), YGEdgeTop); + node->setLayoutBorder( + node->getFlexEndBorder(flexColumnDirection), YGEdgeBottom); node->setLayoutPadding( - node->getLeadingPadding(flexRowDirection, ownerWidth), startEdge); + node->getFlexStartPadding(flexRowDirection, ownerWidth), startEdge); node->setLayoutPadding( - node->getTrailingPadding(flexRowDirection, ownerWidth), endEdge); + node->getFlexEndPadding(flexRowDirection, ownerWidth), endEdge); node->setLayoutPadding( - node->getLeadingPadding(flexColumnDirection, ownerWidth), YGEdgeTop); + node->getFlexStartPadding(flexColumnDirection, ownerWidth), YGEdgeTop); node->setLayoutPadding( - node->getTrailingPadding(flexColumnDirection, ownerWidth), YGEdgeBottom); + node->getFlexEndPadding(flexColumnDirection, ownerWidth), YGEdgeBottom); if (node->hasMeasureFunc()) { measureNodeWithMeasureFunc( @@ -1592,9 +1594,9 @@ static void calculateLayoutImpl( const float paddingAndBorderAxisMain = paddingAndBorderForAxis(node, mainAxis, ownerWidth); const float leadingPaddingAndBorderCross = - node->getLeadingPaddingAndBorder(crossAxis, ownerWidth); + node->getFlexStartPaddingAndBorder(crossAxis, ownerWidth); const float trailingPaddingAndBorderCross = - node->getTrailingPaddingAndBorder(crossAxis, ownerWidth); + node->getFlexEndPaddingAndBorder(crossAxis, ownerWidth); const float paddingAndBorderAxisCross = leadingPaddingAndBorderCross + trailingPaddingAndBorderCross; @@ -1849,25 +1851,25 @@ static void calculateLayoutImpl( // top/left/bottom/right set, override all the previously computed // positions to set it correctly. const bool isChildLeadingPosDefined = - child->isLeadingPositionDefined(crossAxis); + child->isFlexStartPositionDefined(crossAxis); if (isChildLeadingPosDefined) { child->setLayoutPosition( - child->getLeadingPosition(crossAxis, availableInnerCrossDim) + - node->getLeadingBorder(crossAxis) + - child->getLeadingMargin( + child->getFlexStartPosition(crossAxis, availableInnerCrossDim) + + node->getFlexStartBorder(crossAxis) + + child->getInlineStartMargin( crossAxis, direction, availableInnerWidth), - leadingEdge(crossAxis)); + flexStartEdge(crossAxis)); } // If leading position is not defined or calculations result in Nan, // default to border + margin if (!isChildLeadingPosDefined || yoga::isUndefined( - child->getLayout().position[leadingEdge(crossAxis)])) { + child->getLayout().position[flexStartEdge(crossAxis)])) { child->setLayoutPosition( - node->getLeadingBorder(crossAxis) + - child->getLeadingMargin( + node->getFlexStartBorder(crossAxis) + + child->getInlineStartMargin( crossAxis, direction, availableInnerWidth), - leadingEdge(crossAxis)); + flexStartEdge(crossAxis)); } } else { float leadingCrossDim = leadingPaddingAndBorderCross; @@ -1881,7 +1883,7 @@ static void calculateLayoutImpl( // time, this time forcing the cross-axis size to be the computed // cross size for the current line. if (alignItem == Align::Stretch && - child->marginLeadingValue(crossAxis).unit != YGUnitAuto && + child->getFlexStartMarginValue(crossAxis).unit != YGUnitAuto && child->marginTrailingValue(crossAxis).unit != YGUnitAuto) { // If the child defines a definite size for its cross axis, there's // no need to stretch. @@ -1955,7 +1957,7 @@ static void calculateLayoutImpl( const float remainingCrossDim = containerCrossAxis - dimensionWithMargin(child, crossAxis, availableInnerWidth); - if (child->marginLeadingValue(crossAxis).unit == YGUnitAuto && + if (child->getFlexStartMarginValue(crossAxis).unit == YGUnitAuto && child->marginTrailingValue(crossAxis).unit == YGUnitAuto) { leadingCrossDim += yoga::maxOrDefined(0.0f, remainingCrossDim / 2); @@ -1963,7 +1965,7 @@ static void calculateLayoutImpl( child->marginTrailingValue(crossAxis).unit == YGUnitAuto) { // No-Op } else if ( - child->marginLeadingValue(crossAxis).unit == YGUnitAuto) { + child->getFlexStartMarginValue(crossAxis).unit == YGUnitAuto) { leadingCrossDim += yoga::maxOrDefined(0.0f, remainingCrossDim); } else if (alignItem == Align::FlexStart) { // No-Op @@ -1975,9 +1977,9 @@ static void calculateLayoutImpl( } // And we apply the position child->setLayoutPosition( - child->getLayout().position[leadingEdge(crossAxis)] + + child->getLayout().position[flexStartEdge(crossAxis)] + totalLineCrossDim + leadingCrossDim, - leadingEdge(crossAxis)); + flexStartEdge(crossAxis)); } } } @@ -2059,7 +2061,7 @@ static void calculateLayoutImpl( } if (resolveChildAlignment(node, child) == Align::Baseline) { const float ascent = calculateBaseline(child) + - child->getLeadingMargin( + child->getInlineStartMargin( FlexDirection::Column, direction, availableInnerWidth); const float descent = child->getLayout().measuredDimension(Dimension::Height) + @@ -2090,19 +2092,19 @@ static void calculateLayoutImpl( case Align::FlexStart: { child->setLayoutPosition( currentLead + - child->getLeadingMargin( + child->getInlineStartMargin( crossAxis, direction, availableInnerWidth), - leadingEdge(crossAxis)); + flexStartEdge(crossAxis)); break; } case Align::FlexEnd: { child->setLayoutPosition( currentLead + lineHeight - - child->getTrailingMargin( + child->getInlineEndMargin( crossAxis, direction, availableInnerWidth) - child->getLayout().measuredDimension( dimension(crossAxis)), - leadingEdge(crossAxis)); + flexStartEdge(crossAxis)); break; } case Align::Center: { @@ -2111,15 +2113,15 @@ static void calculateLayoutImpl( child->setLayoutPosition( currentLead + (lineHeight - childHeight) / 2, - leadingEdge(crossAxis)); + flexStartEdge(crossAxis)); break; } case Align::Stretch: { child->setLayoutPosition( currentLead + - child->getLeadingMargin( + child->getInlineStartMargin( crossAxis, direction, availableInnerWidth), - leadingEdge(crossAxis)); + flexStartEdge(crossAxis)); // Remeasure child with the line height as it as been only // measured with the owners height yet. @@ -2168,7 +2170,7 @@ static void calculateLayoutImpl( child->setLayoutPosition( currentLead + maxAscentForCurrentLine - calculateBaseline(child) + - child->getLeadingPosition( + child->getFlexStartPosition( FlexDirection::Column, availableInnerCrossDim), YGEdgeTop); @@ -2275,9 +2277,9 @@ static void calculateLayoutImpl( if (child->getStyle().positionType() != PositionType::Absolute) { child->setLayoutPosition( node->getLayout().measuredDimension(dimension(crossAxis)) - - child->getLayout().position[leadingEdge(crossAxis)] - + child->getLayout().position[flexStartEdge(crossAxis)] - child->getLayout().measuredDimension(dimension(crossAxis)), - leadingEdge(crossAxis)); + flexStartEdge(crossAxis)); } } } diff --git a/yoga/algorithm/FlexDirection.h b/yoga/algorithm/FlexDirection.h index 7dd2b4cce7..c6cd95f20e 100644 --- a/yoga/algorithm/FlexDirection.h +++ b/yoga/algorithm/FlexDirection.h @@ -47,7 +47,7 @@ inline FlexDirection resolveCrossDirection( : FlexDirection::Column; } -inline YGEdge leadingEdge(const FlexDirection flexDirection) { +inline YGEdge flexStartEdge(const FlexDirection flexDirection) { switch (flexDirection) { case FlexDirection::Column: return YGEdgeTop; @@ -62,7 +62,7 @@ inline YGEdge leadingEdge(const FlexDirection flexDirection) { fatalWithMessage("Invalid FlexDirection"); } -inline YGEdge trailingEdge(const FlexDirection flexDirection) { +inline YGEdge flexEndEdge(const FlexDirection flexDirection) { switch (flexDirection) { case FlexDirection::Column: return YGEdgeBottom; @@ -77,7 +77,7 @@ inline YGEdge trailingEdge(const FlexDirection flexDirection) { fatalWithMessage("Invalid FlexDirection"); } -inline YGEdge leadingLayoutEdge( +inline YGEdge inlineStartEdge( const FlexDirection flexDirection, const Direction direction) { if (isRow(flexDirection)) { @@ -87,7 +87,7 @@ inline YGEdge leadingLayoutEdge( return YGEdgeTop; } -inline YGEdge trailingLayoutEdge( +inline YGEdge inlineEndEdge( const FlexDirection flexDirection, const Direction direction) { if (isRow(flexDirection)) { diff --git a/yoga/node/Node.cpp b/yoga/node/Node.cpp index c7cee82930..ab91306bc0 100644 --- a/yoga/node/Node.cpp +++ b/yoga/node/Node.cpp @@ -83,61 +83,61 @@ CompactValue Node::computeEdgeValueForColumn( } } -YGEdge Node::getLeadingLayoutEdgeUsingErrata( +YGEdge Node::getInlineStartEdgeUsingErrata( FlexDirection flexDirection, Direction direction) const { return hasErrata(Errata::StartingEndingEdgeFromFlexDirection) - ? leadingEdge(flexDirection) - : leadingLayoutEdge(flexDirection, direction); + ? flexStartEdge(flexDirection) + : inlineStartEdge(flexDirection, direction); } -YGEdge Node::getTrailingLayoutEdgeUsingErrata( +YGEdge Node::getInlineEndEdgeUsingErrata( FlexDirection flexDirection, Direction direction) const { return hasErrata(Errata::StartingEndingEdgeFromFlexDirection) - ? trailingEdge(flexDirection) - : trailingLayoutEdge(flexDirection, direction); + ? flexEndEdge(flexDirection) + : inlineEndEdge(flexDirection, direction); } -bool Node::isLeadingPositionDefined(FlexDirection axis) const { +bool Node::isFlexStartPositionDefined(FlexDirection axis) const { auto leadingPosition = isRow(axis) ? computeEdgeValueForRow( - style_.position(), YGEdgeStart, leadingEdge(axis)) - : computeEdgeValueForColumn(style_.position(), leadingEdge(axis)); + style_.position(), YGEdgeStart, flexStartEdge(axis)) + : computeEdgeValueForColumn(style_.position(), flexStartEdge(axis)); return !leadingPosition.isUndefined(); } -bool Node::isTrailingPosDefined(FlexDirection axis) const { +bool Node::isFlexEndPositionDefined(FlexDirection axis) const { auto trailingPosition = isRow(axis) - ? computeEdgeValueForRow(style_.position(), YGEdgeEnd, trailingEdge(axis)) - : computeEdgeValueForColumn(style_.position(), trailingEdge(axis)); + ? computeEdgeValueForRow(style_.position(), YGEdgeEnd, flexEndEdge(axis)) + : computeEdgeValueForColumn(style_.position(), flexEndEdge(axis)); return !trailingPosition.isUndefined(); } -float Node::getLeadingPosition(FlexDirection axis, float axisSize) const { +float Node::getFlexStartPosition(FlexDirection axis, float axisSize) const { auto leadingPosition = isRow(axis) ? computeEdgeValueForRow( - style_.position(), YGEdgeStart, leadingEdge(axis)) - : computeEdgeValueForColumn(style_.position(), leadingEdge(axis)); + style_.position(), YGEdgeStart, flexStartEdge(axis)) + : computeEdgeValueForColumn(style_.position(), flexStartEdge(axis)); return resolveValue(leadingPosition, axisSize).unwrapOrDefault(0.0f); } -float Node::getTrailingPosition(FlexDirection axis, float axisSize) const { +float Node::getFlexEndPosition(FlexDirection axis, float axisSize) const { auto trailingPosition = isRow(axis) - ? computeEdgeValueForRow(style_.position(), YGEdgeEnd, trailingEdge(axis)) - : computeEdgeValueForColumn(style_.position(), trailingEdge(axis)); + ? computeEdgeValueForRow(style_.position(), YGEdgeEnd, flexEndEdge(axis)) + : computeEdgeValueForColumn(style_.position(), flexEndEdge(axis)); return resolveValue(trailingPosition, axisSize).unwrapOrDefault(0.0f); } -float Node::getLeadingMargin( +float Node::getInlineStartMargin( FlexDirection axis, Direction direction, float widthSize) const { - const YGEdge startEdge = getLeadingLayoutEdgeUsingErrata(axis, direction); + const YGEdge startEdge = getInlineStartEdgeUsingErrata(axis, direction); auto leadingMargin = isRow(axis) ? computeEdgeValueForRow(style_.margin(), YGEdgeStart, startEdge) : computeEdgeValueForColumn(style_.margin(), startEdge); @@ -145,11 +145,11 @@ float Node::getLeadingMargin( return resolveValue(leadingMargin, widthSize).unwrapOrDefault(0.0f); } -float Node::getTrailingMargin( +float Node::getInlineEndMargin( FlexDirection axis, Direction direction, float widthSize) const { - const YGEdge endEdge = getTrailingLayoutEdgeUsingErrata(axis, direction); + const YGEdge endEdge = getInlineEndEdgeUsingErrata(axis, direction); auto trailingMargin = isRow(axis) ? computeEdgeValueForRow(style_.margin(), YGEdgeEnd, endEdge) : computeEdgeValueForColumn(style_.margin(), endEdge); @@ -157,53 +157,55 @@ float Node::getTrailingMargin( return resolveValue(trailingMargin, widthSize).unwrapOrDefault(0.0f); } -float Node::getLeadingBorder(FlexDirection axis) const { +float Node::getFlexStartBorder(FlexDirection axis) const { YGValue leadingBorder = isRow(axis) - ? computeEdgeValueForRow(style_.border(), YGEdgeStart, leadingEdge(axis)) - : computeEdgeValueForColumn(style_.border(), leadingEdge(axis)); + ? computeEdgeValueForRow( + style_.border(), YGEdgeStart, flexStartEdge(axis)) + : computeEdgeValueForColumn(style_.border(), flexStartEdge(axis)); return maxOrDefined(leadingBorder.value, 0.0f); } -float Node::getTrailingBorder(FlexDirection axis) const { +float Node::getFlexEndBorder(FlexDirection axis) const { YGValue trailingBorder = isRow(axis) - ? computeEdgeValueForRow(style_.border(), YGEdgeEnd, trailingEdge(axis)) - : computeEdgeValueForColumn(style_.border(), trailingEdge(axis)); + ? computeEdgeValueForRow(style_.border(), YGEdgeEnd, flexEndEdge(axis)) + : computeEdgeValueForColumn(style_.border(), flexEndEdge(axis)); return maxOrDefined(trailingBorder.value, 0.0f); } -float Node::getLeadingPadding(FlexDirection axis, float widthSize) const { +float Node::getFlexStartPadding(FlexDirection axis, float widthSize) const { auto leadingPadding = isRow(axis) - ? computeEdgeValueForRow(style_.padding(), YGEdgeStart, leadingEdge(axis)) - : computeEdgeValueForColumn(style_.padding(), leadingEdge(axis)); + ? computeEdgeValueForRow( + style_.padding(), YGEdgeStart, flexStartEdge(axis)) + : computeEdgeValueForColumn(style_.padding(), flexStartEdge(axis)); return maxOrDefined(resolveValue(leadingPadding, widthSize).unwrap(), 0.0f); } -float Node::getTrailingPadding(FlexDirection axis, float widthSize) const { +float Node::getFlexEndPadding(FlexDirection axis, float widthSize) const { auto trailingPadding = isRow(axis) - ? computeEdgeValueForRow(style_.padding(), YGEdgeEnd, trailingEdge(axis)) - : computeEdgeValueForColumn(style_.padding(), trailingEdge(axis)); + ? computeEdgeValueForRow(style_.padding(), YGEdgeEnd, flexEndEdge(axis)) + : computeEdgeValueForColumn(style_.padding(), flexEndEdge(axis)); return maxOrDefined(resolveValue(trailingPadding, widthSize).unwrap(), 0.0f); } -float Node::getLeadingPaddingAndBorder(FlexDirection axis, float widthSize) +float Node::getFlexStartPaddingAndBorder(FlexDirection axis, float widthSize) const { - return getLeadingPadding(axis, widthSize) + getLeadingBorder(axis); + return getFlexStartPadding(axis, widthSize) + getFlexStartBorder(axis); } -float Node::getTrailingPaddingAndBorder(FlexDirection axis, float widthSize) +float Node::getFlexEndPaddingAndBorder(FlexDirection axis, float widthSize) const { - return getTrailingPadding(axis, widthSize) + getTrailingBorder(axis); + return getFlexEndPadding(axis, widthSize) + getFlexEndBorder(axis); } float Node::getMarginForAxis(FlexDirection axis, float widthSize) const { // The total margin for a given axis does not depend on the direction // so hardcoding LTR here to avoid piping direction to this function - return getLeadingMargin(axis, Direction::LTR, widthSize) + - getTrailingMargin(axis, Direction::LTR, widthSize); + return getInlineStartMargin(axis, Direction::LTR, widthSize) + + getInlineEndMargin(axis, Direction::LTR, widthSize); } float Node::getGapForAxis(FlexDirection axis) const { @@ -360,11 +362,11 @@ void Node::setLayoutDimension(float dimensionValue, Dimension dimension) { // If both left and right are defined, then use left. Otherwise return +left or // -right depending on which is defined. float Node::relativePosition(FlexDirection axis, float axisSize) const { - if (isLeadingPositionDefined(axis)) { - return getLeadingPosition(axis, axisSize); + if (isFlexStartPositionDefined(axis)) { + return getFlexStartPosition(axis, axisSize); } - return -1 * getTrailingPosition(axis, axisSize); + return -1 * getFlexEndPosition(axis, axisSize); } void Node::setPosition( @@ -388,37 +390,37 @@ void Node::setPosition( const float relativePositionCross = relativePosition(crossAxis, crossSize); const YGEdge mainAxisLeadingEdge = - getLeadingLayoutEdgeUsingErrata(mainAxis, direction); + getInlineStartEdgeUsingErrata(mainAxis, direction); const YGEdge mainAxisTrailingEdge = - getTrailingLayoutEdgeUsingErrata(mainAxis, direction); + getInlineEndEdgeUsingErrata(mainAxis, direction); const YGEdge crossAxisLeadingEdge = - getLeadingLayoutEdgeUsingErrata(crossAxis, direction); + getInlineStartEdgeUsingErrata(crossAxis, direction); const YGEdge crossAxisTrailingEdge = - getTrailingLayoutEdgeUsingErrata(crossAxis, direction); + getInlineEndEdgeUsingErrata(crossAxis, direction); setLayoutPosition( - (getLeadingMargin(mainAxis, direction, ownerWidth) + + (getInlineStartMargin(mainAxis, direction, ownerWidth) + relativePositionMain), mainAxisLeadingEdge); setLayoutPosition( - (getTrailingMargin(mainAxis, direction, ownerWidth) + + (getInlineEndMargin(mainAxis, direction, ownerWidth) + relativePositionMain), mainAxisTrailingEdge); setLayoutPosition( - (getLeadingMargin(crossAxis, direction, ownerWidth) + + (getInlineStartMargin(crossAxis, direction, ownerWidth) + relativePositionCross), crossAxisLeadingEdge); setLayoutPosition( - (getTrailingMargin(crossAxis, direction, ownerWidth) + + (getInlineEndMargin(crossAxis, direction, ownerWidth) + relativePositionCross), crossAxisTrailingEdge); } -YGValue Node::marginLeadingValue(FlexDirection axis) const { +YGValue Node::getFlexStartMarginValue(FlexDirection axis) const { if (isRow(axis) && !style_.margin()[YGEdgeStart].isUndefined()) { return style_.margin()[YGEdgeStart]; } else { - return style_.margin()[leadingEdge(axis)]; + return style_.margin()[flexStartEdge(axis)]; } } @@ -426,7 +428,7 @@ YGValue Node::marginTrailingValue(FlexDirection axis) const { if (isRow(axis) && !style_.margin()[YGEdgeEnd].isUndefined()) { return style_.margin()[YGEdgeEnd]; } else { - return style_.margin()[trailingEdge(axis)]; + return style_.margin()[flexEndEdge(axis)]; } } diff --git a/yoga/node/Node.h b/yoga/node/Node.h index 4aaf0f7b3c..710f919fc6 100644 --- a/yoga/node/Node.h +++ b/yoga/node/Node.h @@ -50,10 +50,10 @@ class YG_EXPORT Node : public ::YGNode { float relativePosition(FlexDirection axis, const float axisSize) const; - YGEdge getLeadingLayoutEdgeUsingErrata( + YGEdge getInlineStartEdgeUsingErrata( FlexDirection flexDirection, Direction direction) const; - YGEdge getTrailingLayoutEdgeUsingErrata( + YGEdge getInlineEndEdgeUsingErrata( FlexDirection flexDirection, Direction direction) const; @@ -196,24 +196,24 @@ class YG_EXPORT Node : public ::YGNode { YGEdge edge); // Methods related to positions, margin, padding and border - bool isLeadingPositionDefined(FlexDirection axis) const; - bool isTrailingPosDefined(FlexDirection axis) const; - float getLeadingPosition(FlexDirection axis, float axisSize) const; - float getTrailingPosition(FlexDirection axis, float axisSize) const; - float getLeadingMargin( + bool isFlexStartPositionDefined(FlexDirection axis) const; + bool isFlexEndPositionDefined(FlexDirection axis) const; + float getFlexStartPosition(FlexDirection axis, float axisSize) const; + float getFlexEndPosition(FlexDirection axis, float axisSize) const; + float getInlineStartMargin( FlexDirection axis, Direction direction, float widthSize) const; - float getTrailingMargin( + float getInlineEndMargin( FlexDirection axis, Direction direction, float widthSize) const; - float getLeadingBorder(FlexDirection flexDirection) const; - float getTrailingBorder(FlexDirection flexDirection) const; - float getLeadingPadding(FlexDirection axis, float widthSize) const; - float getTrailingPadding(FlexDirection axis, float widthSize) const; - float getLeadingPaddingAndBorder(FlexDirection axis, float widthSize) const; - float getTrailingPaddingAndBorder(FlexDirection axis, float widthSize) const; + float getFlexStartBorder(FlexDirection flexDirection) const; + float getFlexEndBorder(FlexDirection flexDirection) const; + float getFlexStartPadding(FlexDirection axis, float widthSize) const; + float getFlexEndPadding(FlexDirection axis, float widthSize) const; + float getFlexStartPaddingAndBorder(FlexDirection axis, float widthSize) const; + float getFlexEndPaddingAndBorder(FlexDirection axis, float widthSize) const; float getMarginForAxis(FlexDirection axis, float widthSize) const; float getGapForAxis(FlexDirection axis) const; // Setters @@ -293,7 +293,7 @@ class YG_EXPORT Node : public ::YGNode { void markDirtyAndPropagateDownwards(); // Other methods - YGValue marginLeadingValue(FlexDirection axis) const; + YGValue getFlexStartMarginValue(FlexDirection axis) const; YGValue marginTrailingValue(FlexDirection axis) const; YGValue resolveFlexBasisPtr() const; void resolveDimension();