layout: Handle keyword sizes when computing the hypothetical cross size (#35826)

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-03-10 13:06:33 +01:00 committed by GitHub
parent b1e1e01ee9
commit 71c207ff25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 29 deletions

View file

@ -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,

View file

@ -89,15 +89,6 @@
[.test 45]
expected: FAIL
[.test 46]
expected: FAIL
[.test 47]
expected: FAIL
[.test 48]
expected: FAIL
[.test 49]
expected: FAIL

View file

@ -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