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

LibWeb: Ignore preferred width when calculating intrinsic width of block

When calculating the intrinsic width of a block-level box, we now ignore
the preferred width entirely, and not just when the preferred width
should be treated as auto.

The condition for this was both confused and wrong, as it looked at the
available width around the box, but didn't check for a width constraint
on the box itself.

Just because the available width has an intrinsic sizing constraint
doesn't mean that the box is undergoing intrinsic sizing. It could also
be the box's containing block!
This commit is contained in:
Andreas Kling 2023-04-06 14:37:54 +02:00
parent 68459d43e0
commit b97229c9b5
3 changed files with 31 additions and 1 deletions

View file

@ -136,7 +136,10 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const&
box_state.padding_left = padding_left.to_px(box);
box_state.padding_right = padding_right.to_px(box);
if (should_treat_width_as_auto(box, available_space) && available_space.width.is_intrinsic_sizing_constraint())
// NOTE: If we are calculating the min-content or max-content width of this box,
// and the width should be treated as auto, then we can simply return here,
// as the preferred width and min/max constraints are irrelevant for intrinsic sizing.
if (box_state.width_constraint != SizeConstraint::None)
return;
auto try_compute_width = [&](auto const& a_width) {