From 0318ac5ce450bb286a2b0fdd7a2d8aa90f6cf342 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Thu, 4 May 2023 23:39:13 +0300 Subject: [PATCH] LibWeb: Remove setting length to 0px if it is not definite If available width (or height) is max-content and width (or height) value is 100% it should be resolved in infinite px, not 0 px. Fixes #18639 --- .../block-and-inline/max-width-percentage-100.txt | 8 ++++++++ .../input/block-and-inline/max-width-percentage-100.html | 5 +++++ Userland/Libraries/LibWeb/Layout/FormattingContext.cpp | 6 ------ 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 Tests/LibWeb/Layout/expected/block-and-inline/max-width-percentage-100.txt create mode 100644 Tests/LibWeb/Layout/input/block-and-inline/max-width-percentage-100.html diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/max-width-percentage-100.txt b/Tests/LibWeb/Layout/expected/block-and-inline/max-width-percentage-100.txt new file mode 100644 index 0000000000..7d55399a04 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/block-and-inline/max-width-percentage-100.txt @@ -0,0 +1,8 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (1,1) content-size 798x0 [BFC] children: not-inline + BlockContainer at (10,10) content-size 138.609375x19.46875 positioned [BFC] children: not-inline + BlockContainer
at (11,11) content-size 136.609375x17.46875 children: inline + line 0 width: 136.609375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 18, rect: [11,11 136.609375x17.46875] + "well hello friends" + TextNode <#text> diff --git a/Tests/LibWeb/Layout/input/block-and-inline/max-width-percentage-100.html b/Tests/LibWeb/Layout/input/block-and-inline/max-width-percentage-100.html new file mode 100644 index 0000000000..3343cfdaa2 --- /dev/null +++ b/Tests/LibWeb/Layout/input/block-and-inline/max-width-percentage-100.html @@ -0,0 +1,5 @@ +
well hello friends \ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index 55e3d337c5..e699d0aba2 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -1289,9 +1289,6 @@ CSS::Length FormattingContext::calculate_inner_width(Layout::Box const& box, Ava return width.resolved(box, width_of_containing_block_as_length_for_resolve).resolved(box); } - if (!available_width.is_definite()) - width_of_containing_block_as_length_for_resolve = CSS::Length::make_px(0); - auto& computed_values = box.computed_values(); if (computed_values.box_sizing() == CSS::BoxSizing::BorderBox) { auto const padding_left = computed_values.padding().left().resolved(box, width_of_containing_block_as_length_for_resolve).resolved(box); @@ -1316,9 +1313,6 @@ CSS::Length FormattingContext::calculate_inner_height(Layout::Box const& box, Av return height.resolved(box, height_of_containing_block_as_length_for_resolve).resolved(box); } - if (!available_height.is_definite()) - height_of_containing_block_as_length_for_resolve = CSS::Length::make_px(0); - auto& computed_values = box.computed_values(); if (computed_values.box_sizing() == CSS::BoxSizing::BorderBox) { auto width_of_containing_block = CSS::Length::make_px(containing_block_width_for(box));