1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:27:35 +00:00

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
parent 8f988b7bae
commit 0d5e0d27aa
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;
}