@@ -1705,7 +1705,7 @@ static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues(
1705
1705
// of the flex items abide the min and max constraints. At the end of this
1706
1706
// function the child nodes would have proper size. Prior using this function
1707
1707
// please ensure that YGDistributeFreeSpaceFirstPass is called.
1708
- static void YGDistributeFreeSpaceSecondPass (
1708
+ static float YGDistributeFreeSpaceSecondPass (
1709
1709
YGCollectFlexItemsRowValues& collectedFlexItemsValues,
1710
1710
const YGNodeRef node,
1711
1711
const YGFlexDirection mainAxis,
@@ -1774,7 +1774,7 @@ static void YGDistributeFreeSpaceSecondPass(
1774
1774
}
1775
1775
}
1776
1776
1777
- deltaFreeSpace - = updatedMainSize - childFlexBasis;
1777
+ deltaFreeSpace + = updatedMainSize - childFlexBasis;
1778
1778
1779
1779
const float marginMain = YGNodeMarginForAxis (
1780
1780
currentRelativeChild, mainAxis, availableInnerWidth);
@@ -1878,8 +1878,7 @@ static void YGDistributeFreeSpaceSecondPass(
1878
1878
node->getLayout ().hadOverflow |
1879
1879
currentRelativeChild->getLayout ().hadOverflow );
1880
1880
}
1881
-
1882
- collectedFlexItemsValues.remainingFreeSpace += deltaFreeSpace;
1881
+ return deltaFreeSpace;
1883
1882
}
1884
1883
1885
1884
// It distributes the free space to the flexible items.For those flexible items
@@ -2002,6 +2001,7 @@ static void YGResolveFlexibleLength(
2002
2001
const YGMeasureMode measureModeCrossDim,
2003
2002
const bool performLayout,
2004
2003
const YGConfigRef config) {
2004
+ const float originalFreeSpace = collectedFlexItemsValues.remainingFreeSpace ;
2005
2005
// First pass: detect the flex items whose min/max constraints trigger
2006
2006
YGDistributeFreeSpaceFirstPass (
2007
2007
collectedFlexItemsValues,
@@ -2011,7 +2011,7 @@ static void YGResolveFlexibleLength(
2011
2011
availableInnerWidth);
2012
2012
2013
2013
// Second pass: resolve the sizes of the flexible items
2014
- YGDistributeFreeSpaceSecondPass (
2014
+ const float distributedFreeSpace = YGDistributeFreeSpaceSecondPass (
2015
2015
collectedFlexItemsValues,
2016
2016
node,
2017
2017
mainAxis,
@@ -2025,6 +2025,9 @@ static void YGResolveFlexibleLength(
2025
2025
measureModeCrossDim,
2026
2026
performLayout,
2027
2027
config);
2028
+
2029
+ collectedFlexItemsValues.remainingFreeSpace =
2030
+ originalFreeSpace - distributedFreeSpace;
2028
2031
}
2029
2032
2030
2033
//
0 commit comments