From 1dc074fc18970915c08b0b9b5e07945c67bda7e4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 18 Mar 2023 00:24:51 +0100 Subject: [PATCH] LibWeb: Treat flex item's cyclic percentage cross size as auto This fixes an issue where e.g `height: 100%` on a flex item whose container has indefinite height was being resolved to 0. It now correctly behaves the same as auto. --- .../flex-item-with-cyclic-percentage-height.txt | 10 ++++++++++ .../flex-item-with-cyclic-percentage-height.html | 14 ++++++++++++++ .../LibWeb/Layout/FlexFormattingContext.cpp | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Layout/expected/flex-item-with-cyclic-percentage-height.txt create mode 100644 Tests/LibWeb/Layout/input/flex-item-with-cyclic-percentage-height.html diff --git a/Tests/LibWeb/Layout/expected/flex-item-with-cyclic-percentage-height.txt b/Tests/LibWeb/Layout/expected/flex-item-with-cyclic-percentage-height.txt new file mode 100644 index 0000000000..56e5352b60 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/flex-item-with-cyclic-percentage-height.txt @@ -0,0 +1,10 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (1,1) content-size 798x39.46875 children: not-inline + BlockContainer at (10,10) content-size 780x21.46875 children: not-inline + Box at (11,11) content-size 778x19.46875 flex-container(row) children: not-inline + Box at (12,12) content-size 44.03125x17.46875 flex-container(column) flex-item children: not-inline + BlockContainer <(anonymous)> at (12,12) content-size 44.03125x17.46875 flex-item children: inline + line 0 width: 44.03125, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 6, rect: [12,12 44.03125x17.46875] + "pillow" + TextNode <#text> diff --git a/Tests/LibWeb/Layout/input/flex-item-with-cyclic-percentage-height.html b/Tests/LibWeb/Layout/input/flex-item-with-cyclic-percentage-height.html new file mode 100644 index 0000000000..44a0ecccf7 --- /dev/null +++ b/Tests/LibWeb/Layout/input/flex-item-with-cyclic-percentage-height.html @@ -0,0 +1,14 @@ +
pillow \ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index 28b7714f9b..e04527a688 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -1103,7 +1103,7 @@ void FlexFormattingContext::determine_hypothetical_cross_size_of_item(FlexItem& return; } - if (computed_cross_size(item.box).is_auto()) { + if (should_treat_cross_size_as_auto(item.box)) { // Item has automatic cross size, layout with "fit-content" CSSPixels fit_content_cross_size = 0;