From 77b720f9a56d4ebd6097cf006655344c0dd14c00 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Wed, 4 Apr 2018 07:55:37 -0700 Subject: [PATCH] Fixed types of getLeadingPaddingAndBorder and getTrailingPaddingAndBorder to YGFloatOptional Summary: Fixed types of getLeadingPaddingAndBorder and getTrailingPaddingAndBorder to YGFloatOptional Reviewed By: emilsjolander Differential Revision: D7339998 fbshipit-source-id: aa24335c2db1cd895b9711214b72195add718c32 --- yoga/YGNode.cpp | 24 ++++++++++++------------ yoga/YGNode.h | 16 ++++++++-------- yoga/Yoga.cpp | 17 +++++++++-------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/yoga/YGNode.cpp b/yoga/YGNode.cpp index 9f6c6a2a..06a58395 100644 --- a/yoga/YGNode.cpp +++ b/yoga/YGNode.cpp @@ -627,7 +627,7 @@ bool YGNode::isNodeFlexible() { (resolveFlexGrow() != 0 || resolveFlexShrink() != 0)); } -float YGNode::getLeadingBorder(const YGFlexDirection axis) const { +float YGNode::getLeadingBorder(const YGFlexDirection& axis) const { if (YGFlexDirectionIsRow(axis) && style_.border[YGEdgeStart].unit != YGUnitUndefined && !YGFloatIsUndefined(style_.border[YGEdgeStart].value) && @@ -640,7 +640,7 @@ float YGNode::getLeadingBorder(const YGFlexDirection axis) const { return YGFloatMax(computedEdgeValue, 0.0f); } -float YGNode::getTrailingBorder(const YGFlexDirection flexDirection) const { +float YGNode::getTrailingBorder(const YGFlexDirection& flexDirection) const { if (YGFlexDirectionIsRow(flexDirection) && style_.border[YGEdgeEnd].unit != YGUnitUndefined && !YGFloatIsUndefined(style_.border[YGEdgeEnd].value) && @@ -688,18 +688,18 @@ YGFloatOptional YGNode::getTrailingPadding( return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f)); } -float YGNode::getLeadingPaddingAndBorder( - const YGFlexDirection axis, - const float widthSize) const { - return YGUnwrapFloatOptional(getLeadingPadding(axis, widthSize)) + - getLeadingBorder(axis); +YGFloatOptional YGNode::getLeadingPaddingAndBorder( + const YGFlexDirection& axis, + const float& widthSize) const { + return getLeadingPadding(axis, widthSize) + + YGFloatOptional(getLeadingBorder(axis)); } -float YGNode::getTrailingPaddingAndBorder( - const YGFlexDirection axis, - const float widthSize) const { - return YGUnwrapFloatOptional(getTrailingPadding(axis, widthSize)) + - getTrailingBorder(axis); +YGFloatOptional YGNode::getTrailingPaddingAndBorder( + const YGFlexDirection& axis, + const float& widthSize) const { + return getTrailingPadding(axis, widthSize) + + YGFloatOptional(getTrailingBorder(axis)); } bool YGNode::didUseLegacyFlag() { diff --git a/yoga/YGNode.h b/yoga/YGNode.h index 010b0dc7..d65b0b71 100644 --- a/yoga/YGNode.h +++ b/yoga/YGNode.h @@ -91,20 +91,20 @@ struct YGNode { float getTrailingPosition(const YGFlexDirection axis, const float axisSize) const; float getLeadingMargin(const YGFlexDirection axis, const float widthSize) const; float getTrailingMargin(const YGFlexDirection axis, const float widthSize) const; - float getLeadingBorder(const YGFlexDirection flexDirection) const; - float getTrailingBorder(const YGFlexDirection flexDirection) const; + float getLeadingBorder(const YGFlexDirection& flexDirection) const; + float getTrailingBorder(const YGFlexDirection& flexDirection) const; YGFloatOptional getLeadingPadding( const YGFlexDirection& axis, const float& widthSize) const; YGFloatOptional getTrailingPadding( const YGFlexDirection& axis, const float& widthSize) const; - float getLeadingPaddingAndBorder( - const YGFlexDirection axis, - const float widthSize) const; - float getTrailingPaddingAndBorder( - const YGFlexDirection axis, - const float widthSize) const; + YGFloatOptional getLeadingPaddingAndBorder( + const YGFlexDirection& axis, + const float& widthSize) const; + YGFloatOptional getTrailingPaddingAndBorder( + const YGFlexDirection& axis, + const float& widthSize) const; float getMarginForAxis(const YGFlexDirection axis, const float widthSize) const; // Setters diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index 8740c666..19cb30df 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -1014,8 +1014,9 @@ static const std::array dim = { static inline float YGNodePaddingAndBorderForAxis(const YGNodeRef node, const YGFlexDirection axis, const float widthSize) { - return node->getLeadingPaddingAndBorder(axis, widthSize) + - node->getTrailingPaddingAndBorder(axis, widthSize); + return YGUnwrapFloatOptional( + node->getLeadingPaddingAndBorder(axis, widthSize) + + node->getTrailingPaddingAndBorder(axis, widthSize)); } static inline YGAlign YGNodeAlignItem(const YGNodeRef node, const YGNodeRef child) { @@ -2357,8 +2358,8 @@ static void YGJustifyMainAxis( } } - const float leadingPaddingAndBorderMain = - node->getLeadingPaddingAndBorder(mainAxis, ownerWidth); + const float leadingPaddingAndBorderMain = YGUnwrapFloatOptional( + node->getLeadingPaddingAndBorder(mainAxis, ownerWidth)); collectedFlexItemsValues.mainDim = leadingPaddingAndBorderMain + leadingMainDim; collectedFlexItemsValues.crossDim = 0; @@ -2438,8 +2439,8 @@ static void YGJustifyMainAxis( } } } - collectedFlexItemsValues.mainDim += - node->getTrailingPaddingAndBorder(mainAxis, ownerWidth); + collectedFlexItemsValues.mainDim += YGUnwrapFloatOptional( + node->getTrailingPaddingAndBorder(mainAxis, ownerWidth)); } // @@ -2639,8 +2640,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, const float mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight; const float crossAxisownerSize = isMainAxisRow ? ownerHeight : ownerWidth; - const float leadingPaddingAndBorderCross = - node->getLeadingPaddingAndBorder(crossAxis, ownerWidth); + const float leadingPaddingAndBorderCross = YGUnwrapFloatOptional( + node->getLeadingPaddingAndBorder(crossAxis, ownerWidth)); const float paddingAndBorderAxisMain = YGNodePaddingAndBorderForAxis(node, mainAxis, ownerWidth); const float paddingAndBorderAxisCross = YGNodePaddingAndBorderForAxis(node, crossAxis, ownerWidth);