@@ -87,8 +87,9 @@ public static IList<IList<FlexItemInfo>> CalculateChildrenRectangles(Rectangle f
8787 mainSize = layoutBox . GetWidth ( ) ;
8888 }
8989 // We need to have crossSize only if its value is definite.
90- // The calculation differs from width calculation because if width isn't definite, parent's width shall be taken
91- float ? crossSize = flexContainerRenderer . RetrieveMinHeight ( ) ;
90+ float ? crossSize = flexContainerRenderer . RetrieveHeight ( ) ;
91+ float ? minCrossSize = flexContainerRenderer . RetrieveMinHeight ( ) ;
92+ float ? maxCrossSize = flexContainerRenderer . RetrieveMaxHeight ( ) ;
9293 DetermineFlexBasisAndHypotheticalMainSizeForFlexItems ( flexItemCalculationInfos , ( float ) mainSize ) ;
9394 // 9.3. Main Size Determination
9495 // 5. Collect flex items into flex lines:
@@ -105,7 +106,8 @@ public static IList<IList<FlexItemInfo>> CalculateChildrenRectangles(Rectangle f
105106 // performing layout with the used main size and the available space, treating auto as fit-content.
106107 DetermineHypotheticalCrossSizeForFlexItems ( lines ) ;
107108 // 8. Calculate the cross size of each flex line.
108- IList < float > lineCrossSizes = CalculateCrossSizeOfEachFlexLine ( lines , isSingleLine , crossSize ) ;
109+ IList < float > lineCrossSizes = CalculateCrossSizeOfEachFlexLine ( lines , isSingleLine , minCrossSize , crossSize
110+ , maxCrossSize ) ;
109111 // TODO DEVSIX-5003 min/max height calculations are not supported
110112 // If the flex container is single-line, then clamp the line’s cross-size to be within
111113 // the container’s computed min and max cross sizes. Note that if CSS 2.1’s definition of min/max-width/height
@@ -353,7 +355,7 @@ internal static void DetermineHypotheticalCrossSizeForFlexItems(IList<IList<Flex
353355 }
354356
355357 internal static IList < float > CalculateCrossSizeOfEachFlexLine ( IList < IList < FlexUtil . FlexItemCalculationInfo
356- > > lines , bool isSingleLine , float ? crossSize ) {
358+ > > lines , bool isSingleLine , float ? minCrossSize , float ? crossSize , float ? maxCrossSize ) {
357359 IList < float > lineCrossSizes = new List < float > ( ) ;
358360 if ( isSingleLine && crossSize != null && ! lines . IsEmpty ( ) ) {
359361 lineCrossSizes . Add ( ( float ) crossSize ) ;
@@ -378,6 +380,16 @@ internal static IList<float> CalculateCrossSizeOfEachFlexLine(IList<IList<FlexUt
378380 }
379381 flexLinesCrossSize = Math . Max ( 0 , largestHypotheticalCrossSize ) ;
380382 }
383+ // 3. If the flex container is single-line, then clamp the line’s cross-size to be
384+ // within the container’s computed min and max cross sizes
385+ if ( isSingleLine && ! lines . IsEmpty ( ) ) {
386+ if ( null != minCrossSize ) {
387+ flexLinesCrossSize = Math . Max ( ( float ) minCrossSize , flexLinesCrossSize ) ;
388+ }
389+ if ( null != maxCrossSize ) {
390+ flexLinesCrossSize = Math . Min ( ( float ) maxCrossSize , flexLinesCrossSize ) ;
391+ }
392+ }
381393 lineCrossSizes . Add ( flexLinesCrossSize ) ;
382394 }
383395 }
0 commit comments