Skip to content

Commit

Permalink
Fixed failing snapshot test
Browse files Browse the repository at this point in the history
Reviewed By: emilsjolander

Differential Revision: D6901242

fbshipit-source-id: 7391d6a34fa28e9f92f4ff834755a89dd876fdad
  • Loading branch information
priteshrnandgaonkar authored and facebook-github-bot committed Feb 6, 2018
1 parent 114c258 commit 9658d9f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ReactCommon/yoga/yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -1774,7 +1774,7 @@ static void YGDistributeFreeSpaceSecondPass(
}
}

deltaFreeSpace -= updatedMainSize - childFlexBasis;
deltaFreeSpace += updatedMainSize - childFlexBasis;

const float marginMain = YGNodeMarginForAxis(
currentRelativeChild, mainAxis, availableInnerWidth);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -2025,6 +2025,9 @@ static void YGResolveFlexibleLength(
measureModeCrossDim,
performLayout,
config);

collectedFlexItemsValues.remainingFreeSpace =
originalFreeSpace - distributedFreeSpace;
}

//
Expand Down

0 comments on commit 9658d9f

Please sign in to comment.