From f3c2ab306c360d79c8d8784cacc78b650858aaf3 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Wed, 4 Apr 2018 07:55:42 -0700 Subject: [PATCH] Changed the type of return value of getLeadingPosition to YGFloatOptional Reviewed By: emilsjolander Differential Revision: D7344367 fbshipit-source-id: 0f5a667ca357b2ce056c86763aa3e9e4c54b82f0 --- ReactCommon/yoga/yoga/YGNode.cpp | 17 +++++++++-------- ReactCommon/yoga/yoga/YGNode.h | 3 ++- ReactCommon/yoga/yoga/Yoga.cpp | 16 ++++++++++------ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/ReactCommon/yoga/yoga/YGNode.cpp b/ReactCommon/yoga/yoga/YGNode.cpp index eb840ef1d..3d1729cda 100644 --- a/ReactCommon/yoga/yoga/YGNode.cpp +++ b/ReactCommon/yoga/yoga/YGNode.cpp @@ -85,14 +85,14 @@ std::array YGNode::getResolvedDimensions() const { return resolvedDimensions_; } -float YGNode::getLeadingPosition( - const YGFlexDirection axis, - const float axisSize) const { +YGFloatOptional YGNode::getLeadingPosition( + const YGFlexDirection& axis, + const float& axisSize) const { if (YGFlexDirectionIsRow(axis)) { const YGValue* leadingPosition = YGComputedEdgeValue(style_.position, YGEdgeStart, &YGValueUndefined); if (leadingPosition->unit != YGUnitUndefined) { - return YGUnwrapFloatOptional(YGResolveValue(*leadingPosition, axisSize)); + return YGResolveValue(*leadingPosition, axisSize); } } @@ -100,8 +100,8 @@ float YGNode::getLeadingPosition( YGComputedEdgeValue(style_.position, leading[axis], &YGValueUndefined); return leadingPosition->unit == YGUnitUndefined - ? 0.0f - : YGUnwrapFloatOptional(YGResolveValue(*leadingPosition, axisSize)); + ? YGFloatOptional(0) + : YGResolveValue(*leadingPosition, axisSize); } float YGNode::getTrailingPosition( @@ -343,8 +343,9 @@ void YGNode::setLayoutDimension(float dimension, int index) { float YGNode::relativePosition( const YGFlexDirection axis, const float axisSize) { - return isLeadingPositionDefined(axis) ? getLeadingPosition(axis, axisSize) - : -getTrailingPosition(axis, axisSize); + return isLeadingPositionDefined(axis) + ? YGUnwrapFloatOptional(getLeadingPosition(axis, axisSize)) + : -getTrailingPosition(axis, axisSize); } void YGNode::setPosition( diff --git a/ReactCommon/yoga/yoga/YGNode.h b/ReactCommon/yoga/yoga/YGNode.h index fe24fa037..8fb55d6de 100644 --- a/ReactCommon/yoga/yoga/YGNode.h +++ b/ReactCommon/yoga/yoga/YGNode.h @@ -85,7 +85,8 @@ struct YGNode { YGValue getResolvedDimension(int index); // Methods related to positions, margin, padding and border - float getLeadingPosition(const YGFlexDirection axis, const float axisSize) const; + YGFloatOptional getLeadingPosition(const YGFlexDirection& axis, + const float& axisSize) const; bool isLeadingPositionDefined(const YGFlexDirection axis) const; bool isTrailingPosDefined(const YGFlexDirection axis) const; float getTrailingPosition(const YGFlexDirection axis, const float axisSize) const; diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 3b117243e..fbb37ee4d 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -1408,7 +1408,8 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, childWidth = node->getLayout().measuredDimensions[YGDimensionWidth] - (node->getLeadingBorder(YGFlexDirectionRow) + node->getTrailingBorder(YGFlexDirectionRow)) - - (child->getLeadingPosition(YGFlexDirectionRow, width) + + (YGUnwrapFloatOptional( + child->getLeadingPosition(YGFlexDirectionRow, width)) + child->getTrailingPosition(YGFlexDirectionRow, width)); childWidth = YGNodeBoundAxis(child, YGFlexDirectionRow, childWidth, width, width); } @@ -1427,7 +1428,8 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node, childHeight = node->getLayout().measuredDimensions[YGDimensionHeight] - (node->getLeadingBorder(YGFlexDirectionColumn) + node->getTrailingBorder(YGFlexDirectionColumn)) - - (child->getLeadingPosition(YGFlexDirectionColumn, height) + + (YGUnwrapFloatOptional( + child->getLeadingPosition(YGFlexDirectionColumn, height)) + child->getTrailingPosition(YGFlexDirectionColumn, height)); childHeight = YGNodeBoundAxis(child, YGFlexDirectionColumn, childHeight, height, width); } @@ -2390,7 +2392,8 @@ static void YGJustifyMainAxis( // defined, we override the position to whatever the user said // (and margin/border). child->setLayoutPosition( - child->getLeadingPosition(mainAxis, availableInnerMainDim) + + YGUnwrapFloatOptional( + child->getLeadingPosition(mainAxis, availableInnerMainDim)) + node->getLeadingBorder(mainAxis) + child->getLeadingMargin(mainAxis, availableInnerWidth), pos[mainAxis]); @@ -2893,7 +2896,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, child->isLeadingPositionDefined(crossAxis); if (isChildLeadingPosDefined) { child->setLayoutPosition( - child->getLeadingPosition(crossAxis, availableInnerCrossDim) + + YGUnwrapFloatOptional(child->getLeadingPosition( + crossAxis, availableInnerCrossDim)) + node->getLeadingBorder(crossAxis) + child->getLeadingMargin(crossAxis, availableInnerWidth), pos[crossAxis]); @@ -3178,8 +3182,8 @@ static void YGNodelayoutImpl(const YGNodeRef node, case YGAlignBaseline: { child->setLayoutPosition( currentLead + maxAscentForCurrentLine - YGBaseline(child) + - child->getLeadingPosition( - YGFlexDirectionColumn, availableInnerCrossDim), + YGUnwrapFloatOptional(child->getLeadingPosition( + YGFlexDirectionColumn, availableInnerCrossDim)), YGEdgeTop); break;