diff --git a/components/layout_2020/flexbox/layout.rs b/components/layout_2020/flexbox/layout.rs index 56a48109494..d1314c8dfbc 100644 --- a/components/layout_2020/flexbox/layout.rs +++ b/components/layout_2020/flexbox/layout.rs @@ -2031,15 +2031,21 @@ impl FlexItem<'_> { }) }, IndependentFormattingContextContents::NonReplaced(non_replaced) => { - let calculate_hypothetical_cross_size = |content_block_size| { - // TODO(#32853): handle size keywords. + let calculate_hypothetical_cross_size = |content_block_size: Au| { + if !cross_axis_is_item_block_axis { + return inline_size; + } + // This means that an auto size with stretch alignment will behave different than + // a stretch size. That's not what the spec says, but matches other browsers. + // To be discussed in https://github.com/w3c/csswg-drafts/issues/11784. + let stretch_size = containing_block + .size + .block + .to_definite() + .map(|size| Au::zero().max(size - self.pbm_auto_is_zero.cross)); + let content_size = LazyCell::new(|| content_block_size.into()); self.content_cross_size - .to_numeric() - .unwrap_or(if cross_axis_is_item_block_axis { - content_block_size - } else { - inline_size - }) + .resolve_for_preferred(Size::FitContent, stretch_size, &content_size) .clamp_between_extremums( self.content_min_size.cross, self.content_max_size.cross, diff --git a/tests/wpt/meta/css/css-sizing/keyword-sizes-on-flex-item-001.html.ini b/tests/wpt/meta/css/css-sizing/keyword-sizes-on-flex-item-001.html.ini index 9cd556f2ece..0e701728602 100644 --- a/tests/wpt/meta/css/css-sizing/keyword-sizes-on-flex-item-001.html.ini +++ b/tests/wpt/meta/css/css-sizing/keyword-sizes-on-flex-item-001.html.ini @@ -89,15 +89,6 @@ [.test 45] expected: FAIL - [.test 46] - expected: FAIL - - [.test 47] - expected: FAIL - - [.test 48] - expected: FAIL - [.test 49] expected: FAIL diff --git a/tests/wpt/meta/css/css-sizing/stretch/stretch-block-size-001.html.ini b/tests/wpt/meta/css/css-sizing/stretch/stretch-block-size-001.html.ini index f5d4623da35..71383bace51 100644 --- a/tests/wpt/meta/css/css-sizing/stretch/stretch-block-size-001.html.ini +++ b/tests/wpt/meta/css/css-sizing/stretch/stretch-block-size-001.html.ini @@ -2,23 +2,11 @@ [[data-expected-height\] 8] expected: FAIL - [[data-expected-height\] 19] - expected: FAIL - - [[data-expected-height\] 21] - expected: FAIL - [[data-expected-height\] 22] expected: FAIL [[data-expected-height\] 31] expected: FAIL - [[data-expected-height\] 42] - expected: FAIL - - [[data-expected-height\] 44] - expected: FAIL - [[data-expected-height\] 45] expected: FAIL