@@ -1978,16 +1978,21 @@ impl FlexItemBox {
1978
1978
if self
1979
1979
. independent_formatting_context
1980
1980
. style ( )
1981
- . get_box ( )
1982
- . overflow_x
1983
- . is_scrollable ( )
1981
+ . establishes_scroll_container ( )
1984
1982
{
1985
1983
return Au :: zero ( ) ;
1986
1984
}
1987
1985
1988
1986
if cross_axis_is_item_block_axis {
1989
- let specified_size_suggestion = content_box_size. inline ;
1990
-
1987
+ // > **specified size suggestion**
1988
+ // > If the item’s preferred main size is definite and not automatic, then the specified
1989
+ // > size suggestion is that size. It is otherwise undefined.
1990
+ let specified_size_suggestion = content_box_size. inline . non_auto ( ) ;
1991
+
1992
+ // > **transferred size suggestion**
1993
+ // > If the item has a preferred aspect ratio and its preferred cross size is definite, then the
1994
+ // > transferred size suggestion is that size (clamped by its minimum and maximum cross sizes if they
1995
+ // > are definite), converted through the aspect ratio. It is otherwise undefined.
1991
1996
let transferred_size_suggestion = match self . independent_formatting_context {
1992
1997
IndependentFormattingContext :: NonReplaced ( _) => None ,
1993
1998
IndependentFormattingContext :: Replaced ( ref bfc) => {
@@ -2009,40 +2014,46 @@ impl FlexItemBox {
2009
2014
} ,
2010
2015
} ;
2011
2016
2017
+ // > **content size suggestion**
2018
+ // > The content size suggestion is the min-content size in the main axis, clamped, if it has a
2019
+ // > preferred aspect ratio, by any definite minimum and maximum cross sizes converted through the
2020
+ // > aspect ratio.
2012
2021
let inline_content_size = self
2013
2022
. independent_formatting_context
2014
2023
. inline_content_sizes ( layout_context)
2015
2024
. min_content ;
2016
- let content_size_suggestion = match self . independent_formatting_context {
2017
- IndependentFormattingContext :: NonReplaced ( _) => inline_content_size,
2018
- IndependentFormattingContext :: Replaced ( ref replaced) => {
2019
- if let Some ( ratio) = replaced
2025
+ let ( is_replaced, aspect_ratio) = match self . independent_formatting_context {
2026
+ IndependentFormattingContext :: NonReplaced ( _) => ( false , None ) ,
2027
+ IndependentFormattingContext :: Replaced ( ref replaced) => (
2028
+ true ,
2029
+ replaced
2020
2030
. contents
2021
2031
. inline_size_over_block_size_intrinsic_ratio (
2022
2032
self . independent_formatting_context . style ( ) ,
2023
- )
2024
- {
2025
- inline_content_size. clamp_between_extremums (
2026
- min_size. block . auto_is ( Au :: zero) . scale_by ( ratio) ,
2027
- max_size. block . map ( |l| l. scale_by ( ratio) ) ,
2028
- )
2029
- } else {
2030
- inline_content_size
2031
- }
2032
- } ,
2033
- } ;
2034
-
2035
- let result = match specified_size_suggestion {
2036
- AuOrAuto :: LengthPercentage ( l) => l. min ( content_size_suggestion) ,
2037
- AuOrAuto :: Auto => {
2038
- if let Some ( l) = transferred_size_suggestion {
2039
- l. min ( content_size_suggestion)
2040
- } else {
2041
- content_size_suggestion
2042
- }
2043
- } ,
2033
+ ) ,
2034
+ ) ,
2044
2035
} ;
2045
- result. clamp_below_max ( max_size. inline )
2036
+ let content_size_suggestion = aspect_ratio
2037
+ . map ( |aspect_ratio| {
2038
+ inline_content_size. clamp_between_extremums (
2039
+ min_size. block . auto_is ( Au :: zero) . scale_by ( aspect_ratio) ,
2040
+ max_size. block . map ( |l| l. scale_by ( aspect_ratio) ) ,
2041
+ )
2042
+ } )
2043
+ . unwrap_or ( inline_content_size) ;
2044
+
2045
+ // > The content-based minimum size of a flex item is the smaller of its specified size
2046
+ // > suggestion and its content size suggestion if its specified size suggestion exists;
2047
+ // > otherwise, the smaller of its transferred size suggestion and its content size
2048
+ // > suggestion if the element is replaced and its transferred size suggestion exists;
2049
+ // > otherwise its content size suggestion. In all cases, the size is clamped by the maximum
2050
+ // > main size if it’s definite.
2051
+ match ( specified_size_suggestion, transferred_size_suggestion) {
2052
+ ( Some ( specified) , _) => specified. min ( content_size_suggestion) ,
2053
+ ( _, Some ( transferred) ) if is_replaced => transferred. min ( content_size_suggestion) ,
2054
+ _ => content_size_suggestion,
2055
+ }
2056
+ . clamp_below_max ( max_size. inline )
2046
2057
} else {
2047
2058
// FIXME(stshine): Implement this when main axis is item's block axis.
2048
2059
Au :: zero ( )
0 commit comments