diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/intrinsic-sizing-with-min-width-specified.txt b/Tests/LibWeb/Layout/expected/block-and-inline/intrinsic-sizing-with-min-width-specified.txt new file mode 100644 index 00000000000..36aeea9e0f2 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/block-and-inline/intrinsic-sizing-with-min-width-specified.txt @@ -0,0 +1,5 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (1,1) content-size 798x52 children: not-inline + BlockContainer at (10,10) content-size 104x34 floating children: not-inline + BlockContainer at (11,11) content-size 102x32 children: not-inline + BlockContainer at (12,12) content-size 100x30 children: not-inline diff --git a/Tests/LibWeb/Layout/input/block-and-inline/intrinsic-sizing-with-min-width-specified.html b/Tests/LibWeb/Layout/input/block-and-inline/intrinsic-sizing-with-min-width-specified.html new file mode 100644 index 00000000000..c0b5a635ca3 --- /dev/null +++ b/Tests/LibWeb/Layout/input/block-and-inline/intrinsic-sizing-with-min-width-specified.html @@ -0,0 +1,17 @@ +
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index 05647e77fb7..01ef8ed9190 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -229,7 +229,8 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const& // but this time using the computed value of 'max-width' as the computed value for 'width'. if (!computed_values.max_width().is_none()) { auto max_width = calculate_inner_width(box, available_space.width, computed_values.max_width()); - if (used_width.to_px(box) > max_width.to_px(box)) { + auto used_width_px = used_width.is_auto() ? available_space.width.to_px() : used_width.to_px(box); + if (used_width_px > max_width.to_px(box)) { used_width = try_compute_width(max_width); } } @@ -238,7 +239,8 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const& // but this time using the value of 'min-width' as the computed value for 'width'. if (!computed_values.min_width().is_auto()) { auto min_width = calculate_inner_width(box, available_space.width, computed_values.min_width()); - if (used_width.to_px(box) < min_width.to_px(box)) { + auto used_width_px = used_width.is_auto() ? available_space.width.to_px() : used_width.to_px(box); + if (used_width_px < min_width.to_px(box)) { used_width = try_compute_width(min_width); } }