LibWeb: Size box as normal if it has aspect ratio but auto sizes

Otherwise we apply `calculate_stretch_fit_width()` instead of
calculating width based on the content inside the box, like other
browsers do.
This commit is contained in:
Aliaksandr Kalenik 2025-03-27 17:12:07 +00:00 committed by Andreas Kling
commit fc45121b70
Notes: github-actions[bot] 2025-03-27 23:38:46 +00:00
3 changed files with 40 additions and 5 deletions

View file

@ -1895,11 +1895,9 @@ bool box_is_sized_as_replaced_element(Box const& box)
// However, it is suggested that, if the containing blocks width does not itself depend on the replaced elements width,
// then the used value of width is calculated from the constraint equation used for block-level, non-replaced elements in normal flow.
// AD-HOC: For inline-level boxes, we don't want to end up in a situation where we apply stretch-fit sizing,
// since that would not match other browsers. Because of that, we specifically reject this case here
// instead of allowing it to proceed.
if (box.display().is_inline_outside()
&& box.computed_values().height().is_auto()
// AD-HOC: If box has preferred aspect ratio but width and height are not specified, then we should
// size it as a normal box to match other browsers.
if (box.computed_values().height().is_auto()
&& box.computed_values().width().is_auto()
&& !box.has_natural_width()
&& !box.has_natural_height()) {