LibWeb: Treat unresolvable percentage flex-basis values as 'content'

Per CSS-FLEXBOX-1, we should treat percentage values of flex-basis as
'content' if they resolve against an indefinite size of the flex
container.
This commit is contained in:
Andreas Kling 2023-04-18 09:10:28 +02:00
commit 0d5e0d27aa
Notes: sideshowbarker 2024-07-17 09:49:33 +09:00
3 changed files with 36 additions and 0 deletions

View file

@ -572,6 +572,15 @@ CSS::FlexBasisData FlexFormattingContext::used_flex_basis_for_item(FlexItem cons
}
}
// For example, percentage values of flex-basis are resolved against the flex items containing block
// (i.e. its flex container); and if that containing blocks size is indefinite,
// the used value for flex-basis is content.
if (flex_basis.type == CSS::FlexBasis::LengthPercentage
&& flex_basis.length_percentage->is_percentage()
&& !has_definite_main_size(flex_container())) {
flex_basis.type = CSS::FlexBasis::Content;
}
return flex_basis;
}