Skip to content

Commit 831a1bb

Browse files
Moved leadingpaddingnandborder function as a method on YGNode
Reviewed By: emilsjolander Differential Revision: D6711991 fbshipit-source-id: 41ad7191bf8df6fe3131106436dc0c87e9dee297
1 parent 2fe65b0 commit 831a1bb

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

ReactCommon/yoga/yoga/YGNode.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,3 +660,9 @@ float YGNode::getTrailingPadding(
660660
widthSize),
661661
0.0f);
662662
}
663+
664+
float YGNode::getLeadingPaddingAndBorder(
665+
const YGFlexDirection axis,
666+
const float widthSize) {
667+
return getLeadingPadding(axis, widthSize) + getLeadingBorder(axis);
668+
}

ReactCommon/yoga/yoga/YGNode.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ struct YGNode {
9090
float getTrailingBorder(const YGFlexDirection flexDirection);
9191
float getLeadingPadding(const YGFlexDirection axis, const float widthSize);
9292
float getTrailingPadding(const YGFlexDirection axis, const float widthSize);
93+
float getLeadingPaddingAndBorder(
94+
const YGFlexDirection axis,
95+
const float widthSize);
9396
// Setters
9497

9598
void setContext(void* context);

ReactCommon/yoga/yoga/Yoga.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -762,14 +762,6 @@ static const std::array<YGEdge, 4> pos = {{
762762
static const std::array<YGDimension, 4> dim = {
763763
{YGDimensionHeight, YGDimensionHeight, YGDimensionWidth, YGDimensionWidth}};
764764

765-
static inline float YGNodeLeadingPaddingAndBorder(
766-
const YGNodeRef node,
767-
const YGFlexDirection axis,
768-
const float widthSize) {
769-
return node->getLeadingPadding(axis, widthSize) +
770-
node->getLeadingBorder(axis);
771-
}
772-
773765
static inline float YGNodeTrailingPaddingAndBorder(const YGNodeRef node,
774766
const YGFlexDirection axis,
775767
const float widthSize) {
@@ -787,8 +779,8 @@ static inline float YGNodeMarginForAxis(const YGNodeRef node,
787779
static inline float YGNodePaddingAndBorderForAxis(const YGNodeRef node,
788780
const YGFlexDirection axis,
789781
const float widthSize) {
790-
return YGNodeLeadingPaddingAndBorder(node, axis, widthSize) +
791-
YGNodeTrailingPaddingAndBorder(node, axis, widthSize);
782+
return node->getLeadingPaddingAndBorder(axis, widthSize) +
783+
YGNodeTrailingPaddingAndBorder(node, axis, widthSize);
792784
}
793785

794786
static inline YGAlign YGNodeAlignItem(const YGNodeRef node, const YGNodeRef child) {
@@ -1785,11 +1777,11 @@ static void YGNodelayoutImpl(const YGNodeRef node,
17851777
YGNodeRef currentAbsoluteChild = nullptr;
17861778

17871779
const float leadingPaddingAndBorderMain =
1788-
YGNodeLeadingPaddingAndBorder(node, mainAxis, parentWidth);
1780+
node->getLeadingPaddingAndBorder(mainAxis, parentWidth);
17891781
const float trailingPaddingAndBorderMain =
17901782
YGNodeTrailingPaddingAndBorder(node, mainAxis, parentWidth);
17911783
const float leadingPaddingAndBorderCross =
1792-
YGNodeLeadingPaddingAndBorder(node, crossAxis, parentWidth);
1784+
node->getLeadingPaddingAndBorder(crossAxis, parentWidth);
17931785
const float paddingAndBorderAxisMain = YGNodePaddingAndBorderForAxis(node, mainAxis, parentWidth);
17941786
const float paddingAndBorderAxisCross =
17951787
YGNodePaddingAndBorderForAxis(node, crossAxis, parentWidth);

0 commit comments

Comments
 (0)