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

LibWeb: Resolve replaced element size constraints using aspect ratios

Some replaced elements can have intrinsic aspect ratios but no
intrinsic size. In these cases, the tentative sizes are undefined, and
can therefore sometimes be zero. However, when resolving the size
constraints, we are already guaranteed to have an intrinsic aspect
ratio, so let's use that instead to calculate the resolved sizes.
This commit is contained in:
Zaggy1024 2023-09-03 19:20:50 -05:00 committed by Andreas Kling
parent 051f357110
commit e3f693ca7c
3 changed files with 37 additions and 1 deletions

View file

@ -274,7 +274,7 @@ CSSPixelSize FormattingContext::solve_replaced_size_constraint(CSSPixels input_w
auto specified_max_height = should_treat_max_height_as_none(box, available_space.height) ? input_height : box.computed_values().max_height().to_px(box, height_of_containing_block);
auto max_height = max(min_height, specified_max_height);
auto aspect_ratio = input_width / input_height;
CSSPixelFraction aspect_ratio = *box.preferred_aspect_ratio();
// These are from the "Constraint Violation" table in spec, but reordered so that each condition is
// interpreted as mutually exclusive to any other.