From a5f8f8238fd768e38eed297acd5bba7f90715e27 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 8 Jun 2023 11:09:35 +0200 Subject: [PATCH] LibWeb: Fix a case of incorrect flex container max-content main size We were incorrectly returning a "specified size suggestion" for flex items with a definite main size where that main size was also automatic. This led to us incorrectly choosing 0 as the automatic minimum size for that flex item, instead of its min-content size. --- ...d-flex-container-with-max-content-main-size.txt | 8 ++++++++ ...-flex-container-with-max-content-main-size.html | 14 ++++++++++++++ .../LibWeb/Layout/FlexFormattingContext.cpp | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Layout/expected/flex/automatic-minimum-size-with-explicit-flex-basis-and-flex-container-with-max-content-main-size.txt create mode 100644 Tests/LibWeb/Layout/input/flex/automatic-minimum-size-with-explicit-flex-basis-and-flex-container-with-max-content-main-size.html diff --git a/Tests/LibWeb/Layout/expected/flex/automatic-minimum-size-with-explicit-flex-basis-and-flex-container-with-max-content-main-size.txt b/Tests/LibWeb/Layout/expected/flex/automatic-minimum-size-with-explicit-flex-basis-and-flex-container-with-max-content-main-size.txt new file mode 100644 index 0000000000..b678c548b4 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/flex/automatic-minimum-size-with-explicit-flex-basis-and-flex-container-with-max-content-main-size.txt @@ -0,0 +1,8 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (1,1) content-size 798x68 [BFC] children: not-inline + Box at (10,10) content-size 38.84375x50 flex-container(row) [FFC] children: not-inline + BlockContainer at (11,11) content-size 36.84375x48 flex-item [BFC] children: inline + line 0 width: 36.84375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 5, rect: [11,11 36.84375x17.46875] + "hello" + TextNode <#text> diff --git a/Tests/LibWeb/Layout/input/flex/automatic-minimum-size-with-explicit-flex-basis-and-flex-container-with-max-content-main-size.html b/Tests/LibWeb/Layout/input/flex/automatic-minimum-size-with-explicit-flex-basis-and-flex-container-with-max-content-main-size.html new file mode 100644 index 0000000000..524470bb2b --- /dev/null +++ b/Tests/LibWeb/Layout/input/flex/automatic-minimum-size-with-explicit-flex-basis-and-flex-container-with-max-content-main-size.html @@ -0,0 +1,14 @@ +
hello \ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index 3577fb2ee7..0d00a6550d 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -750,7 +750,7 @@ Optional FlexFormattingContext::specified_size_suggestion(FlexItem co { // If the item’s preferred main size is definite and not automatic, // then the specified size suggestion is that size. It is otherwise undefined. - if (has_definite_main_size(item.box)) { + if (has_definite_main_size(item.box) && !should_treat_main_size_as_auto(item.box)) { // NOTE: We use get_pixel_{width,height} to ensure that CSS box-sizing is respected. return is_row_layout() ? get_pixel_width(item.box, computed_main_size(item.box)) : get_pixel_height(item.box, computed_main_size(item.box)); }