From 92bfcbafc05aed9105599bef4c9d375349d57745 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Mon, 15 Jan 2018 10:09:55 -0800 Subject: [PATCH] Moved leadingpaddingnandborder function as a method on YGNode Summary: Moved leadingpaddingnandborder function as a method on YGNode Reviewed By: emilsjolander Differential Revision: D6711991 fbshipit-source-id: 41ad7191bf8df6fe3131106436dc0c87e9dee297 --- yoga/YGNode.cpp | 6 ++++++ yoga/YGNode.h | 3 +++ yoga/Yoga.cpp | 16 ++++------------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/yoga/YGNode.cpp b/yoga/YGNode.cpp index 7b4d98e1..223dd919 100644 --- a/yoga/YGNode.cpp +++ b/yoga/YGNode.cpp @@ -660,3 +660,9 @@ float YGNode::getTrailingPadding( widthSize), 0.0f); } + +float YGNode::getLeadingPaddingAndBorder( + const YGFlexDirection axis, + const float widthSize) { + return getLeadingPadding(axis, widthSize) + getLeadingBorder(axis); +} diff --git a/yoga/YGNode.h b/yoga/YGNode.h index 8ae19dec..a639bf90 100644 --- a/yoga/YGNode.h +++ b/yoga/YGNode.h @@ -90,6 +90,9 @@ struct YGNode { float getTrailingBorder(const YGFlexDirection flexDirection); float getLeadingPadding(const YGFlexDirection axis, const float widthSize); float getTrailingPadding(const YGFlexDirection axis, const float widthSize); + float getLeadingPaddingAndBorder( + const YGFlexDirection axis, + const float widthSize); // Setters void setContext(void* context); diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index a6b89f88..b4f30dd0 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -762,14 +762,6 @@ static const std::array pos = {{ static const std::array dim = { {YGDimensionHeight, YGDimensionHeight, YGDimensionWidth, YGDimensionWidth}}; -static inline float YGNodeLeadingPaddingAndBorder( - const YGNodeRef node, - const YGFlexDirection axis, - const float widthSize) { - return node->getLeadingPadding(axis, widthSize) + - node->getLeadingBorder(axis); -} - static inline float YGNodeTrailingPaddingAndBorder(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { @@ -787,8 +779,8 @@ static inline float YGNodeMarginForAxis(const YGNodeRef node, static inline float YGNodePaddingAndBorderForAxis(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - return YGNodeLeadingPaddingAndBorder(node, axis, widthSize) + - YGNodeTrailingPaddingAndBorder(node, axis, widthSize); + return node->getLeadingPaddingAndBorder(axis, widthSize) + + YGNodeTrailingPaddingAndBorder(node, axis, widthSize); } static inline YGAlign YGNodeAlignItem(const YGNodeRef node, const YGNodeRef child) { @@ -1785,11 +1777,11 @@ static void YGNodelayoutImpl(const YGNodeRef node, YGNodeRef currentAbsoluteChild = nullptr; const float leadingPaddingAndBorderMain = - YGNodeLeadingPaddingAndBorder(node, mainAxis, parentWidth); + node->getLeadingPaddingAndBorder(mainAxis, parentWidth); const float trailingPaddingAndBorderMain = YGNodeTrailingPaddingAndBorder(node, mainAxis, parentWidth); const float leadingPaddingAndBorderCross = - YGNodeLeadingPaddingAndBorder(node, crossAxis, parentWidth); + node->getLeadingPaddingAndBorder(crossAxis, parentWidth); const float paddingAndBorderAxisMain = YGNodePaddingAndBorderForAxis(node, mainAxis, parentWidth); const float paddingAndBorderAxisCross = YGNodePaddingAndBorderForAxis(node, crossAxis, parentWidth);