layout: Support stretch cross size for flex base size (#35663)

The computation of the flex base size may involve transferring a
definite cross size into the main axis through the aspect ratio.
We were only considering numeric sizes as definite, but `stretch` can
also be definite.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-02-26 19:03:38 +01:00 committed by GitHub
parent 8d8f0f49cf
commit 03e953e22c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 93 additions and 5 deletions

View file

@ -2687,15 +2687,17 @@ impl FlexItemBox {
// > If a single-line flex container has a definite cross size, the automatic preferred
// > outer cross size of any stretched flex items is the flex containers inner cross size
// > (clamped to the flex items min and max cross size) and is considered definite.
let cross_stretch_size = container_definite_inner_size
.cross
.map(|v| v - pbm_auto_is_zero.cross);
let cross_size = if content_box_size.cross.is_initial() &&
item_with_auto_cross_size_stretches_to_container_size
{
container_definite_inner_size
.cross
.map(|v| v - pbm_auto_is_zero.cross)
cross_stretch_size
} else {
// TODO(#32853): handle size keywords.
content_box_size.cross.to_numeric()
content_box_size
.cross
.maybe_resolve_extrinsic(cross_stretch_size)
};
if let (Some(ratio), Some(cross_size)) = (preferred_aspect_ratio, cross_size) {
let cross_size = cross_size.clamp_between_extremums(