From 2887976ce9ce342d3a885e57be6a8d10e59338ee Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 15 Jul 2023 10:43:39 +0200 Subject: [PATCH] LibWeb: Fully resolve max-width values on inline-block elements This fixes an issue where `max-width: fit-content` (and other layout-dependent values) were treated as 0 on inline-blocks. --- .../inline-block-with-max-width-fit-content.txt | 10 ++++++++++ .../inline-block-with-max-width-fit-content.html | 7 +++++++ .../LibWeb/Layout/InlineFormattingContext.cpp | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Layout/expected/block-and-inline/inline-block-with-max-width-fit-content.txt create mode 100644 Tests/LibWeb/Layout/input/block-and-inline/inline-block-with-max-width-fit-content.html diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/inline-block-with-max-width-fit-content.txt b/Tests/LibWeb/Layout/expected/block-and-inline/inline-block-with-max-width-fit-content.txt new file mode 100644 index 0000000000..5d03f95032 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/block-and-inline/inline-block-with-max-width-fit-content.txt @@ -0,0 +1,10 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x35.46875 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x19.46875 children: inline + line 0 width: 102.203125, height: 19.46875, bottom: 19.46875, baseline: 14.53125 + frag 0 from BlockContainer start: 0, length: 0, rect: [9,9 100.203125x17.46875] + BlockContainer at (9,9) content-size 100.203125x17.46875 inline-block [BFC] children: inline + line 0 width: 100.203125, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 13, rect: [9,9 100.203125x17.46875] + "hello friends" + TextNode <#text> diff --git a/Tests/LibWeb/Layout/input/block-and-inline/inline-block-with-max-width-fit-content.html b/Tests/LibWeb/Layout/input/block-and-inline/inline-block-with-max-width-fit-content.html new file mode 100644 index 0000000000..151134240f --- /dev/null +++ b/Tests/LibWeb/Layout/input/block-and-inline/inline-block-with-max-width-fit-content.html @@ -0,0 +1,7 @@ +hello friends diff --git a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp index 4ae23ea0f4..623464db01 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp @@ -150,7 +150,7 @@ void InlineFormattingContext::dimension_box_on_line(Box const& box, LayoutMode l CSSPixels width = unconstrained_width; if (!should_treat_max_width_as_none(box, m_available_space->width)) { - auto max_width = box.computed_values().max_width().to_px(box, width_of_containing_block); + auto max_width = calculate_inner_width(box, m_available_space->width, box.computed_values().max_width()).to_px(box); width = min(width, max_width); }