From f7e57881adc07f23dfa7436e3634555fe157fee8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 13 Apr 2024 11:21:54 +0200 Subject: [PATCH] LibWeb: Don't limit available space during early height for inline-flex There was no need to set an available height constraint when doing early height calculation for inline-flex boxes. It created a situation where the flex containers could wrongly get zero height early, and then resolve percentages against zero instead of the real intrinsic size. Fixes #23942 --- ...-flex-early-resolution-of-percentage-height.txt | 14 ++++++++++++++ ...flex-early-resolution-of-percentage-height.html | 14 ++++++++++++++ .../LibWeb/Layout/InlineFormattingContext.cpp | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Layout/expected/flex/inline-flex-early-resolution-of-percentage-height.txt create mode 100644 Tests/LibWeb/Layout/input/flex/inline-flex-early-resolution-of-percentage-height.html diff --git a/Tests/LibWeb/Layout/expected/flex/inline-flex-early-resolution-of-percentage-height.txt b/Tests/LibWeb/Layout/expected/flex/inline-flex-early-resolution-of-percentage-height.txt new file mode 100644 index 00000000000..351fd6640e4 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/flex/inline-flex-early-resolution-of-percentage-height.txt @@ -0,0 +1,14 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x216 [BFC] children: inline + frag 0 from Box start: 0, length: 0, rect: [8,8 200x200] baseline: 13.296875 + Box at (8,8) content-size 200x200 flex-container(row) [FFC] children: not-inline + BlockContainer
at (8,8) content-size 200x200 flex-item [BFC] children: inline + frag 0 from TextNode start: 0, length: 5, rect: [8,8 36.84375x17] baseline: 13.296875 + "hello" + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x216] + PaintableBox (Box) [8,8 200x200] + PaintableWithLines (BlockContainer
) [8,8 200x200] + TextPaintable (TextNode<#text>) diff --git a/Tests/LibWeb/Layout/input/flex/inline-flex-early-resolution-of-percentage-height.html b/Tests/LibWeb/Layout/input/flex/inline-flex-early-resolution-of-percentage-height.html new file mode 100644 index 00000000000..c91ef8f5fbe --- /dev/null +++ b/Tests/LibWeb/Layout/input/flex/inline-flex-early-resolution-of-percentage-height.html @@ -0,0 +1,14 @@ +
hello diff --git a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp index a45e3229a95..d35073c888e 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp @@ -178,7 +178,7 @@ void InlineFormattingContext::dimension_box_on_line(Box const& box, LayoutMode l // NOTE: Flex containers with `auto` height are treated as `max-content`, so we can compute their height early. if (box_state.has_definite_height() || box.display().is_flex_inside()) - parent().compute_height(box, AvailableSpace(AvailableSize::make_definite(width), AvailableSize::make_definite(m_containing_block_used_values.content_height()))); + parent().compute_height(box, AvailableSpace(AvailableSize::make_definite(width), AvailableSize::make_indefinite())); auto independent_formatting_context = layout_inside(box, layout_mode, box_state.available_inner_space_or_constraints_from(*m_available_space));