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

LibWeb: Resolve cyclic % against 0 when available size is min-content

This fixes an issue where replaced elements with cyclic percentage width
would make an oversized min-content contribution to its container.
This commit is contained in:
Andreas Kling 2023-06-08 12:56:34 +02:00
parent a5f8f8238f
commit 3365a1e034
3 changed files with 60 additions and 4 deletions

View file

@ -1463,14 +1463,28 @@ CSSPixels FormattingContext::calculate_stretch_fit_height(Box const& box, Availa
bool FormattingContext::should_treat_width_as_auto(Box const& box, AvailableSpace const& available_space)
{
return box.computed_values().width().is_auto()
|| (box.computed_values().width().contains_percentage() && !available_space.width.is_definite());
if (box.computed_values().width().is_auto())
return true;
if (box.computed_values().width().contains_percentage()) {
if (available_space.width.is_max_content())
return true;
if (available_space.width.is_indefinite())
return true;
}
return false;
}
bool FormattingContext::should_treat_height_as_auto(Box const& box, AvailableSpace const& available_space)
{
return box.computed_values().height().is_auto()
|| (box.computed_values().height().contains_percentage() && !available_space.height.is_definite());
if (box.computed_values().height().is_auto())
return true;
if (box.computed_values().height().contains_percentage()) {
if (available_space.height.is_max_content())
return true;
if (available_space.height.is_indefinite())
return true;
}
return false;
}
bool FormattingContext::can_skip_is_anonymous_text_run(Box& box)