From 1475fc4856d366f8ec2027374971ed5aefcdeafa Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Tue, 6 Feb 2018 08:39:52 -0800 Subject: [PATCH] Moved trailing padding and border function as a method on YGNode Reviewed By: emilsjolander Differential Revision: D6899571 fbshipit-source-id: 7f686e8771d5a94aae502191516557b20c557d7c --- ReactCommon/yoga/yoga/YGNode.cpp | 6 ++++++ ReactCommon/yoga/yoga/YGNode.h | 3 +++ ReactCommon/yoga/yoga/Yoga.cpp | 11 ++--------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ReactCommon/yoga/yoga/YGNode.cpp b/ReactCommon/yoga/yoga/YGNode.cpp index e56350dca..8add290f1 100644 --- a/ReactCommon/yoga/yoga/YGNode.cpp +++ b/ReactCommon/yoga/yoga/YGNode.cpp @@ -678,6 +678,12 @@ float YGNode::getLeadingPaddingAndBorder( return getLeadingPadding(axis, widthSize) + getLeadingBorder(axis); } +float YGNode::getTrailingPaddingAndBorder( + const YGFlexDirection axis, + const float widthSize) { + return getTrailingPadding(axis, widthSize) + getTrailingBorder(axis); +} + bool YGNode::didUseLegacyFlag() { bool didUseLegacyFlag = layout_.didUseLegacyFlag; if (didUseLegacyFlag) { diff --git a/ReactCommon/yoga/yoga/YGNode.h b/ReactCommon/yoga/yoga/YGNode.h index 9d0c1029d..1d5260dc0 100644 --- a/ReactCommon/yoga/yoga/YGNode.h +++ b/ReactCommon/yoga/yoga/YGNode.h @@ -94,6 +94,9 @@ struct YGNode { float getLeadingPaddingAndBorder( const YGFlexDirection axis, const float widthSize); + float getTrailingPaddingAndBorder( + const YGFlexDirection axis, + const float widthSize); // Setters void setContext(void* context); diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 6987a5cab..42272e4fa 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -797,13 +797,6 @@ static const std::array pos = {{ static const std::array dim = { {YGDimensionHeight, YGDimensionHeight, YGDimensionWidth, YGDimensionWidth}}; -static inline float YGNodeTrailingPaddingAndBorder(const YGNodeRef node, - const YGFlexDirection axis, - const float widthSize) { - return node->getTrailingPadding(axis, widthSize) + - node->getTrailingBorder(axis); -} - static inline float YGNodeMarginForAxis(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { @@ -815,7 +808,7 @@ static inline float YGNodePaddingAndBorderForAxis(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { return node->getLeadingPaddingAndBorder(axis, widthSize) + - YGNodeTrailingPaddingAndBorder(node, axis, widthSize); + node->getTrailingPaddingAndBorder(axis, widthSize); } static inline YGAlign YGNodeAlignItem(const YGNodeRef node, const YGNodeRef child) { @@ -2202,7 +2195,7 @@ static void YGJustifyMainAxis( } } collectedFlexItemsValues.mainDim += - YGNodeTrailingPaddingAndBorder(node, mainAxis, parentWidth); + node->getTrailingPaddingAndBorder(mainAxis, parentWidth); } //