summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-04-06 14:37:54 +0200
committerAndreas Kling <kling@serenityos.org>2023-04-06 16:47:40 +0200
commitb97229c9b5927fa7b43777aefae769fc4d2a0834 (patch)
tree557f9a4453b79b73ade5a39b6ff4b8394e387c68 /Userland
parent68459d43e01546ba9b14b36cd784deaff7d4454e (diff)
downloadserenity-b97229c9b5927fa7b43777aefae769fc4d2a0834.zip
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!
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
index 5bb8dba717..4013194d45 100644
--- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
@@ -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) {