From 9658d9f82ba536c2f39937d61b3954e3dcc6a54e Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Tue, 6 Feb 2018 07:05:18 -0800 Subject: [PATCH] Fixed failing snapshot test Reviewed By: emilsjolander Differential Revision: D6901242 fbshipit-source-id: 7391d6a34fa28e9f92f4ff834755a89dd876fdad --- ReactCommon/yoga/yoga/Yoga.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 01a6ba916780a3..576904f621351d 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -1705,7 +1705,7 @@ static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues( // of the flex items abide the min and max constraints. At the end of this // function the child nodes would have proper size. Prior using this function // please ensure that YGDistributeFreeSpaceFirstPass is called. -static void YGDistributeFreeSpaceSecondPass( +static float YGDistributeFreeSpaceSecondPass( YGCollectFlexItemsRowValues& collectedFlexItemsValues, const YGNodeRef node, const YGFlexDirection mainAxis, @@ -1774,7 +1774,7 @@ static void YGDistributeFreeSpaceSecondPass( } } - deltaFreeSpace -= updatedMainSize - childFlexBasis; + deltaFreeSpace += updatedMainSize - childFlexBasis; const float marginMain = YGNodeMarginForAxis( currentRelativeChild, mainAxis, availableInnerWidth); @@ -1878,8 +1878,7 @@ static void YGDistributeFreeSpaceSecondPass( node->getLayout().hadOverflow | currentRelativeChild->getLayout().hadOverflow); } - - collectedFlexItemsValues.remainingFreeSpace += deltaFreeSpace; + return deltaFreeSpace; } // It distributes the free space to the flexible items.For those flexible items @@ -2002,6 +2001,7 @@ static void YGResolveFlexibleLength( const YGMeasureMode measureModeCrossDim, const bool performLayout, const YGConfigRef config) { + const float originalFreeSpace = collectedFlexItemsValues.remainingFreeSpace; // First pass: detect the flex items whose min/max constraints trigger YGDistributeFreeSpaceFirstPass( collectedFlexItemsValues, @@ -2011,7 +2011,7 @@ static void YGResolveFlexibleLength( availableInnerWidth); // Second pass: resolve the sizes of the flexible items - YGDistributeFreeSpaceSecondPass( + const float distributedFreeSpace = YGDistributeFreeSpaceSecondPass( collectedFlexItemsValues, node, mainAxis, @@ -2025,6 +2025,9 @@ static void YGResolveFlexibleLength( measureModeCrossDim, performLayout, config); + + collectedFlexItemsValues.remainingFreeSpace = + originalFreeSpace - distributedFreeSpace; } //