@@ -97,6 +97,7 @@ typedef struct YGStyle {
9797typedef struct YGConfig {
9898 bool experimentalFeatures [YGExperimentalFeatureCount + 1 ];
9999 bool useWebDefaults ;
100+ bool useLegacyStretchBehaviour ;
100101 float pointScaleFactor ;
101102} YGConfig ;
102103
@@ -202,7 +203,6 @@ static YGNode gYGNodeDefaults = {
202203static YGConfig gYGConfigDefaults = {
203204 .experimentalFeatures =
204205 {
205- [YGExperimentalFeatureMinFlexFix ] = false,
206206 [YGExperimentalFeatureWebFlexBasis ] = false,
207207 },
208208 .useWebDefaults = false,
@@ -2199,23 +2199,25 @@ static void YGNodelayoutImpl(const YGNodeRef node,
21992199 // If the main dimension size isn't known, it is computed based on
22002200 // the line length, so there's no more space left to distribute.
22012201
2202+ bool sizeBasedOnContent = false;
22022203 // If we don't measure with exact main dimension we want to ensure we don't violate min and max
22032204 if (measureModeMainDim != YGMeasureModeExactly ) {
22042205 if (!YGFloatIsUndefined (minInnerMainDim ) && sizeConsumedOnCurrentLine < minInnerMainDim ) {
22052206 availableInnerMainDim = minInnerMainDim ;
22062207 } else if (!YGFloatIsUndefined (maxInnerMainDim ) && sizeConsumedOnCurrentLine > maxInnerMainDim ) {
22072208 availableInnerMainDim = maxInnerMainDim ;
2208- } else if (YGConfigIsExperimentalFeatureEnabled (node -> config , YGExperimentalFeatureMinFlexFix ) &&
2209- (totalFlexGrowFactors == 0 || YGResolveFlexGrow (node ) == 0 )) {
2210- // TODO: this needs to be moved out of experimental feature, as this is legitimate fix
2211- // If we don't have any children to flex or we can't flex the node itself,
2212- // space we've used is all space we need
2213- availableInnerMainDim = sizeConsumedOnCurrentLine ;
2209+ } else {
2210+ if (!node -> config -> useLegacyStretchBehaviour && (totalFlexGrowFactors == 0 || YGResolveFlexGrow (node ) == 0 )) {
2211+ // If we don't have any children to flex or we can't flex the node itself,
2212+ // space we've used is all space we need
2213+ availableInnerMainDim = sizeConsumedOnCurrentLine ;
2214+ }
2215+ sizeBasedOnContent = true;
22142216 }
22152217 }
22162218
22172219 float remainingFreeSpace = 0 ;
2218- if (!YGFloatIsUndefined (availableInnerMainDim )) {
2220+ if ((! sizeBasedOnContent || node -> config -> useLegacyStretchBehaviour ) && !YGFloatIsUndefined (availableInnerMainDim )) {
22192221 remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine ;
22202222 } else if (sizeConsumedOnCurrentLine < 0 ) {
22212223 // availableInnerMainDim is indefinite which means the node is being sized
@@ -3427,6 +3429,10 @@ void YGConfigSetUseWebDefaults(const YGConfigRef config, const bool enabled) {
34273429 config -> useWebDefaults = enabled ;
34283430}
34293431
3432+ void YGConfigSetUseLegacyStretchBehaviour (const YGConfigRef config , const bool useLegacyStretchBehaviour ) {
3433+ config -> useLegacyStretchBehaviour = useLegacyStretchBehaviour ;
3434+ }
3435+
34303436bool YGConfigGetUseWebDefaults (const YGConfigRef config ) {
34313437 return config -> useWebDefaults ;
34323438}
0 commit comments