From 83bc92ae983e3c5dea983c8669425fb4f451bb14 Mon Sep 17 00:00:00 2001 From: Joe Vilches Date: Tue, 17 Oct 2023 13:16:04 -0700 Subject: [PATCH] Rename ambiguous getLeading/Trailing... functions in Node.cpp Differential Revision: https://www.internalfb.com/diff/D50344874?entry_point=27 fbshipit-source-id: 111f43ef7548251c4af316f2153b56cc6f8c8a6e --- yoga/algorithm/BoundAxis.h | 4 +- yoga/algorithm/CalculateLayout.cpp | 152 +++++++++++++++-------------- yoga/node/Node.cpp | 64 ++++++------ yoga/node/Node.h | 30 +++--- 4 files changed, 126 insertions(+), 124 deletions(-) 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 feed51708c..3f8a25ad05 100644 --- a/yoga/algorithm/CalculateLayout.cpp +++ b/yoga/algorithm/CalculateLayout.cpp @@ -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,19 +446,18 @@ 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), + 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)) - @@ -466,7 +465,7 @@ static void layoutAbsoluteChild( 2.0f, flexStartEdge(mainAxis)); } else if ( - !child->isLeadingPositionDefined(mainAxis) && + !child->isFlexStartPositionDefined(mainAxis) && node->getStyle().justifyContent() == Justify::FlexEnd) { child->setLayoutPosition( (node->getLayout().measuredDimension(dimension(mainAxis)) - @@ -475,33 +474,33 @@ static void layoutAbsoluteChild( } 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))), 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), flexStartEdge(crossAxis)); } else if ( - !child->isLeadingPositionDefined(crossAxis) && + !child->isFlexStartPositionDefined(crossAxis) && resolveChildAlignment(node, child) == Align::Center) { child->setLayoutPosition( (node->getLayout().measuredDimension(dimension(crossAxis)) - @@ -509,7 +508,7 @@ static void layoutAbsoluteChild( 2.0f, flexStartEdge(crossAxis)); } else if ( - !child->isLeadingPositionDefined(crossAxis) && + !child->isFlexStartPositionDefined(crossAxis) && ((resolveChildAlignment(node, child) == Align::FlexEnd) ^ (node->getStyle().flexWrap() == Wrap::WrapReverse))) { child->setLayoutPosition( @@ -519,13 +518,13 @@ static void layoutAbsoluteChild( } 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))), @@ -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,15 +1299,15 @@ 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), flexStartEdge(mainAxis)); } @@ -1315,7 +1316,7 @@ static void justifyMainAxis( // 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); } @@ -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) + @@ -1379,7 +1380,7 @@ static void justifyMainAxis( } else if (performLayout) { child->setLayoutPosition( childLayout.position[flexStartEdge(mainAxis)] + - node->getLeadingBorder(mainAxis) + leadingMainDim, + 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,12 +1851,12 @@ 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), flexStartEdge(crossAxis)); } @@ -1864,8 +1866,8 @@ static void calculateLayoutImpl( yoga::isUndefined( child->getLayout().position[flexStartEdge(crossAxis)])) { child->setLayoutPosition( - node->getLeadingBorder(crossAxis) + - child->getLeadingMargin( + node->getFlexStartBorder(crossAxis) + + child->getInlineStartMargin( crossAxis, direction, availableInnerWidth), flexStartEdge(crossAxis)); } @@ -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 @@ -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,7 +2092,7 @@ static void calculateLayoutImpl( case Align::FlexStart: { child->setLayoutPosition( currentLead + - child->getLeadingMargin( + child->getInlineStartMargin( crossAxis, direction, availableInnerWidth), flexStartEdge(crossAxis)); break; @@ -2098,7 +2100,7 @@ static void calculateLayoutImpl( case Align::FlexEnd: { child->setLayoutPosition( currentLead + lineHeight - - child->getTrailingMargin( + child->getInlineEndMargin( crossAxis, direction, availableInnerWidth) - child->getLayout().measuredDimension( dimension(crossAxis)), @@ -2117,7 +2119,7 @@ static void calculateLayoutImpl( case Align::Stretch: { child->setLayoutPosition( currentLead + - child->getLeadingMargin( + child->getInlineStartMargin( crossAxis, direction, availableInnerWidth), flexStartEdge(crossAxis)); @@ -2168,7 +2170,7 @@ static void calculateLayoutImpl( child->setLayoutPosition( currentLead + maxAscentForCurrentLine - calculateBaseline(child) + - child->getLeadingPosition( + child->getFlexStartPosition( FlexDirection::Column, availableInnerCrossDim), YGEdgeTop); diff --git a/yoga/node/Node.cpp b/yoga/node/Node.cpp index 3ea8f9bd3d..ab91306bc0 100644 --- a/yoga/node/Node.cpp +++ b/yoga/node/Node.cpp @@ -83,7 +83,7 @@ CompactValue Node::computeEdgeValueForColumn( } } -YGEdge Node::getLeadingLayoutEdgeUsingErrata( +YGEdge Node::getInlineStartEdgeUsingErrata( FlexDirection flexDirection, Direction direction) const { return hasErrata(Errata::StartingEndingEdgeFromFlexDirection) @@ -91,7 +91,7 @@ YGEdge Node::getLeadingLayoutEdgeUsingErrata( : inlineStartEdge(flexDirection, direction); } -YGEdge Node::getTrailingLayoutEdgeUsingErrata( +YGEdge Node::getInlineEndEdgeUsingErrata( FlexDirection flexDirection, Direction direction) const { return hasErrata(Errata::StartingEndingEdgeFromFlexDirection) @@ -99,7 +99,7 @@ YGEdge Node::getTrailingLayoutEdgeUsingErrata( : inlineEndEdge(flexDirection, direction); } -bool Node::isLeadingPositionDefined(FlexDirection axis) const { +bool Node::isFlexStartPositionDefined(FlexDirection axis) const { auto leadingPosition = isRow(axis) ? computeEdgeValueForRow( style_.position(), YGEdgeStart, flexStartEdge(axis)) @@ -108,7 +108,7 @@ bool Node::isLeadingPositionDefined(FlexDirection axis) const { return !leadingPosition.isUndefined(); } -bool Node::isTrailingPosDefined(FlexDirection axis) const { +bool Node::isFlexEndPositionDefined(FlexDirection axis) const { auto trailingPosition = isRow(axis) ? computeEdgeValueForRow(style_.position(), YGEdgeEnd, flexEndEdge(axis)) : computeEdgeValueForColumn(style_.position(), flexEndEdge(axis)); @@ -116,7 +116,7 @@ bool Node::isTrailingPosDefined(FlexDirection axis) const { 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, flexStartEdge(axis)) @@ -125,7 +125,7 @@ float Node::getLeadingPosition(FlexDirection axis, float axisSize) const { 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, flexEndEdge(axis)) : computeEdgeValueForColumn(style_.position(), flexEndEdge(axis)); @@ -133,11 +133,11 @@ float Node::getTrailingPosition(FlexDirection axis, float axisSize) const { 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,7 +157,7 @@ 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, flexStartEdge(axis)) @@ -166,7 +166,7 @@ float Node::getLeadingBorder(FlexDirection axis) const { 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, flexEndEdge(axis)) : computeEdgeValueForColumn(style_.border(), flexEndEdge(axis)); @@ -174,7 +174,7 @@ float Node::getTrailingBorder(FlexDirection axis) const { 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, flexStartEdge(axis)) @@ -183,7 +183,7 @@ float Node::getLeadingPadding(FlexDirection axis, float widthSize) const { 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, flexEndEdge(axis)) : computeEdgeValueForColumn(style_.padding(), flexEndEdge(axis)); @@ -191,21 +191,21 @@ float Node::getTrailingPadding(FlexDirection axis, float widthSize) const { 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 { @@ -362,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( @@ -390,33 +390,33 @@ 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 { 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();