Skip to content

Commit 8208858

Browse files
Move trailing border function as a method on YGNode
Reviewed By: emilsjolander Differential Revision: D6711666 fbshipit-source-id: fe4fdfc2db59d03beb763317e1a6f9de52f851d4
1 parent 210ae5b commit 8208858

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

ReactCommon/yoga/yoga/YGNode.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,3 +608,16 @@ float YGNode::getLeadingBorder(const YGFlexDirection axis) {
608608
YGComputedEdgeValue(style_.border, leading[axis], &YGValueZero)->value,
609609
0.0f);
610610
}
611+
612+
float YGNode::getTrailingBorder(const YGFlexDirection flexDirection) {
613+
if (YGFlexDirectionIsRow(flexDirection) &&
614+
style_.border[YGEdgeEnd].unit != YGUnitUndefined &&
615+
style_.border[YGEdgeEnd].value >= 0.0f) {
616+
return style_.border[YGEdgeEnd].value;
617+
}
618+
619+
return fmaxf(
620+
YGComputedEdgeValue(style_.border, trailing[flexDirection], &YGValueZero)
621+
->value,
622+
0.0f);
623+
}

ReactCommon/yoga/yoga/YGNode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct YGNode {
8686
float getLeadingMargin(const YGFlexDirection axis, const float widthSize);
8787
float getTrailingMargin(const YGFlexDirection axis, const float widthSize);
8888
float getLeadingBorder(const YGFlexDirection flexDirection);
89+
float getTrailingBorder(const YGFlexDirection flexDirection);
8990
// Setters
9091

9192
void setContext(void* context);

ReactCommon/yoga/yoga/Yoga.cpp

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -797,21 +797,6 @@ static float YGNodeTrailingPadding(const YGNodeRef node,
797797
0.0f);
798798
}
799799

800-
static float YGNodeTrailingBorder(
801-
const YGNodeRef node,
802-
const YGFlexDirection axis) {
803-
if (YGFlexDirectionIsRow(axis) &&
804-
node->getStyle().border[YGEdgeEnd].unit != YGUnitUndefined &&
805-
node->getStyle().border[YGEdgeEnd].value >= 0.0f) {
806-
return node->getStyle().border[YGEdgeEnd].value;
807-
}
808-
809-
return fmaxf(
810-
YGComputedEdgeValue(node->getStyle().border, trailing[axis], &YGValueZero)
811-
->value,
812-
0.0f);
813-
}
814-
815800
static inline float YGNodeLeadingPaddingAndBorder(
816801
const YGNodeRef node,
817802
const YGFlexDirection axis,
@@ -823,7 +808,8 @@ static inline float YGNodeLeadingPaddingAndBorder(
823808
static inline float YGNodeTrailingPaddingAndBorder(const YGNodeRef node,
824809
const YGFlexDirection axis,
825810
const float widthSize) {
826-
return YGNodeTrailingPadding(node, axis, widthSize) + YGNodeTrailingBorder(node, axis);
811+
return YGNodeTrailingPadding(node, axis, widthSize) +
812+
node->getTrailingBorder(axis);
827813
}
828814

829815
static inline float YGNodeMarginForAxis(const YGNodeRef node,
@@ -1221,7 +1207,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
12211207
child->isTrailingPosDefined(YGFlexDirectionRow)) {
12221208
childWidth = node->getLayout().measuredDimensions[YGDimensionWidth] -
12231209
(node->getLeadingBorder(YGFlexDirectionRow) +
1224-
YGNodeTrailingBorder(node, YGFlexDirectionRow)) -
1210+
node->getTrailingBorder(YGFlexDirectionRow)) -
12251211
(child->getLeadingPosition(YGFlexDirectionRow, width) +
12261212
child->getTrailingPosition(YGFlexDirectionRow, width));
12271213
childWidth = YGNodeBoundAxis(child, YGFlexDirectionRow, childWidth, width, width);
@@ -1240,7 +1226,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
12401226
child->isTrailingPosDefined(YGFlexDirectionColumn)) {
12411227
childHeight = node->getLayout().measuredDimensions[YGDimensionHeight] -
12421228
(node->getLeadingBorder(YGFlexDirectionColumn) +
1243-
YGNodeTrailingBorder(node, YGFlexDirectionColumn)) -
1229+
node->getTrailingBorder(YGFlexDirectionColumn)) -
12441230
(child->getLeadingPosition(YGFlexDirectionColumn, height) +
12451231
child->getTrailingPosition(YGFlexDirectionColumn, height));
12461232
childHeight = YGNodeBoundAxis(child, YGFlexDirectionColumn, childHeight, height, width);
@@ -1311,7 +1297,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
13111297
child->setLayoutPosition(
13121298
node->getLayout().measuredDimensions[dim[mainAxis]] -
13131299
child->getLayout().measuredDimensions[dim[mainAxis]] -
1314-
YGNodeTrailingBorder(node, mainAxis) -
1300+
node->getTrailingBorder(mainAxis) -
13151301
child->getTrailingMargin(mainAxis, width) -
13161302
child->getTrailingPosition(
13171303
mainAxis, isMainAxisRow ? width : height),
@@ -1338,7 +1324,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
13381324
child->setLayoutPosition(
13391325
node->getLayout().measuredDimensions[dim[crossAxis]] -
13401326
child->getLayout().measuredDimensions[dim[crossAxis]] -
1341-
YGNodeTrailingBorder(node, crossAxis) -
1327+
node->getTrailingBorder(crossAxis) -
13421328
child->getTrailingMargin(crossAxis, width) -
13431329
child->getTrailingPosition(
13441330
crossAxis, isMainAxisRow ? height : width),
@@ -1775,11 +1761,10 @@ static void YGNodelayoutImpl(const YGNodeRef node,
17751761
node->getTrailingMargin(flexColumnDirection, parentWidth), YGEdgeBottom);
17761762

17771763
node->setLayoutBorder(node->getLeadingBorder(flexRowDirection), YGEdgeStart);
1778-
node->setLayoutBorder(
1779-
YGNodeTrailingBorder(node, flexRowDirection), YGEdgeEnd);
1764+
node->setLayoutBorder(node->getTrailingBorder(flexRowDirection), YGEdgeEnd);
17801765
node->setLayoutBorder(node->getLeadingBorder(flexColumnDirection), YGEdgeTop);
17811766
node->setLayoutBorder(
1782-
YGNodeTrailingBorder(node, flexColumnDirection), YGEdgeBottom);
1767+
node->getTrailingBorder(flexColumnDirection), YGEdgeBottom);
17831768

17841769
node->setLayoutPadding(
17851770
YGNodeLeadingPadding(node, flexRowDirection, parentWidth), YGEdgeStart);

0 commit comments

Comments
 (0)