@@ -1334,7 +1334,14 @@ static float YGNodeRelativePosition(const YGNodeRef node,
13341334 : - YGNodeTrailingPosition (node , axis , axisSize );
13351335}
13361336
1337- static void YGConstrainMaxSizeForMode (const float maxSize , YGMeasureMode * mode , float * size ) {
1337+ static void YGConstrainMaxSizeForMode (const YGNodeRef node ,
1338+ const enum YGFlexDirection axis ,
1339+ const float parentAxisSize ,
1340+ const float parentWidth ,
1341+ YGMeasureMode * mode ,
1342+ float * size ) {
1343+ const float maxSize = YGValueResolve (& node -> style .maxDimensions [dim [axis ]], parentAxisSize ) +
1344+ YGNodeMarginForAxis (node , axis , parentWidth );
13381345 switch (* mode ) {
13391346 case YGMeasureModeExactly :
13401347 case YGMeasureModeAtMost :
@@ -1480,14 +1487,10 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node,
14801487 }
14811488 }
14821489
1483- YGConstrainMaxSizeForMode (YGValueResolve (& child -> style .maxDimensions [YGDimensionWidth ],
1484- parentWidth ),
1485- & childWidthMeasureMode ,
1486- & childWidth );
1487- YGConstrainMaxSizeForMode (YGValueResolve (& child -> style .maxDimensions [YGDimensionHeight ],
1488- parentHeight ),
1489- & childHeightMeasureMode ,
1490- & childHeight );
1490+ YGConstrainMaxSizeForMode (
1491+ child , YGFlexDirectionRow , parentWidth , parentWidth , & childWidthMeasureMode , & childWidth );
1492+ YGConstrainMaxSizeForMode (
1493+ child , YGFlexDirectionColumn , parentHeight , parentWidth , & childHeightMeasureMode , & childHeight );
14911494
14921495 // Measure the child
14931496 YGLayoutNodeInternal (child ,
@@ -2443,16 +2446,18 @@ static void YGNodelayoutImpl(const YGNodeRef node,
24432446 childCrossSize += marginCross ;
24442447 }
24452448
2446- YGConstrainMaxSizeForMode (
2447- YGValueResolve (& currentRelativeChild -> style .maxDimensions [dim [mainAxis ]],
2448- availableInnerWidth ),
2449- & childMainMeasureMode ,
2450- & childMainSize );
2451- YGConstrainMaxSizeForMode (
2452- YGValueResolve (& currentRelativeChild -> style .maxDimensions [dim [crossAxis ]],
2453- availableInnerHeight ),
2454- & childCrossMeasureMode ,
2455- & childCrossSize );
2449+ YGConstrainMaxSizeForMode (currentRelativeChild ,
2450+ mainAxis ,
2451+ availableInnerMainDim ,
2452+ availableInnerWidth ,
2453+ & childMainMeasureMode ,
2454+ & childMainSize );
2455+ YGConstrainMaxSizeForMode (currentRelativeChild ,
2456+ crossAxis ,
2457+ availableInnerCrossDim ,
2458+ availableInnerWidth ,
2459+ & childCrossMeasureMode ,
2460+ & childCrossSize );
24562461
24572462 const bool requiresStretchLayout =
24582463 !YGNodeIsStyleDimDefined (currentRelativeChild , crossAxis , availableInnerCrossDim ) &&
@@ -2690,12 +2695,16 @@ static void YGNodelayoutImpl(const YGNodeRef node,
26902695
26912696 YGMeasureMode childMainMeasureMode = YGMeasureModeExactly ;
26922697 YGMeasureMode childCrossMeasureMode = YGMeasureModeExactly ;
2693- YGConstrainMaxSizeForMode (YGValueResolve (& child -> style .maxDimensions [dim [mainAxis ]],
2694- availableInnerMainDim ),
2698+ YGConstrainMaxSizeForMode (child ,
2699+ mainAxis ,
2700+ availableInnerMainDim ,
2701+ availableInnerWidth ,
26952702 & childMainMeasureMode ,
26962703 & childMainSize );
2697- YGConstrainMaxSizeForMode (YGValueResolve (& child -> style .maxDimensions [dim [crossAxis ]],
2698- availableInnerCrossDim ),
2704+ YGConstrainMaxSizeForMode (child ,
2705+ crossAxis ,
2706+ availableInnerCrossDim ,
2707+ availableInnerWidth ,
26992708 & childCrossMeasureMode ,
27002709 & childCrossSize );
27012710
0 commit comments