From 1d44df74f7a16bde694f2af9d6f328001162774f Mon Sep 17 00:00:00 2001 From: Psychpsyo Date: Sat, 23 Nov 2024 12:41:29 +0100 Subject: [PATCH] LibWeb: Stop zero-area children from causing scrollable overflow --- Libraries/LibWeb/Layout/LayoutState.cpp | 4 ++++ .../bfc-float-left-break-vertically-2.txt | 2 +- .../block-and-inline/margin-collapse-1.txt | 2 +- .../relpos-inline-element-js-offsets.txt | 2 +- .../Layout/expected/css-counters/basic.txt | 2 +- .../expected/css-namespace-rule-matches.txt | 2 +- .../expected/css-namespace-rule-no-match.txt | 2 +- .../expected/css-text-transform-math-auto.txt | 2 +- .../css-values/comparison-functions.txt | 6 +++--- .../css-values/exponential-functions.txt | 12 ++++++------ .../expected/css-values/numeric-constants.txt | 6 +++--- .../rect-non-token-contents-crash.txt | 2 +- .../css-values/sign-related-functions.txt | 6 +++--- .../css-values/stepped-value-functions.txt | 8 ++++---- Tests/LibWeb/Layout/expected/div_align.txt | 2 +- .../document-write-incomplete-tag.txt | 2 +- .../abspos-flex-child-with-auto-height.txt | 4 ++-- .../grid/grid-area-non-token-parts-crash.txt | 2 +- .../grid-column-non-token-parts-crash.txt | 2 +- .../grid-row-start-non-token-parts-crash.txt | 2 +- .../expected/grid/inline-abspos-item.txt | 2 +- .../expected/grid/justify-content-cols.txt | 2 +- .../grid/minmax-non-token-contents-crash.txt | 2 +- .../grid/repeat-non-token-contents-crash.txt | 2 +- Tests/LibWeb/Layout/expected/inline-size.txt | 6 +++--- Tests/LibWeb/Layout/expected/input-image.txt | 2 +- .../expected/multi-code-point-graphemes.txt | 2 +- Tests/LibWeb/Layout/expected/ordered-list.txt | 2 +- .../position-empty-pseudo-elements.txt | 4 ++-- .../LibWeb/Layout/expected/textarea-reset.txt | 2 +- ...-be-xhtml-file-should-decode-correctly.txt | 4 ++-- ...-height-replaced-box-with-aspect-ratio.txt | 4 ++-- ...ro-size-replaced-box-with-aspect-ratio.txt | 4 ++-- ...ea-child-creating-scrollable-overflow.html | 1 + ...ea-child-creating-scrollable-overflow.html | 9 +++++++++ .../images/css-color-functions-ref.png | Bin 115666 -> 81553 bytes .../Screenshot/images/css-gradients-ref.png | Bin 440459 -> 312621 bytes 37 files changed, 67 insertions(+), 53 deletions(-) create mode 100644 Tests/LibWeb/Ref/expected/zero-area-child-creating-scrollable-overflow.html create mode 100644 Tests/LibWeb/Ref/input/zero-area-child-creating-scrollable-overflow.html diff --git a/Libraries/LibWeb/Layout/LayoutState.cpp b/Libraries/LibWeb/Layout/LayoutState.cpp index 3b28755d91d..bc5cc21e530 100644 --- a/Libraries/LibWeb/Layout/LayoutState.cpp +++ b/Libraries/LibWeb/Layout/LayoutState.cpp @@ -109,6 +109,10 @@ static CSSPixelRect measure_scrollable_overflow(Box const& box) auto child_border_box = child.paintable_box()->absolute_border_box_rect(); + // Border boxes with zero area do not affect the scrollable overflow area. + if (child_border_box.is_empty()) + return TraversalDecision::Continue; + // NOTE: Here we check that the child is not wholly in the negative scrollable overflow region. if (child_border_box.bottom() < 0 || child_border_box.right() < 0) return TraversalDecision::Continue; diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/bfc-float-left-break-vertically-2.txt b/Tests/LibWeb/Layout/expected/block-and-inline/bfc-float-left-break-vertically-2.txt index 43b2f8d7243..6d8570c29af 100644 --- a/Tests/LibWeb/Layout/expected/block-and-inline/bfc-float-left-break-vertically-2.txt +++ b/Tests/LibWeb/Layout/expected/block-and-inline/bfc-float-left-break-vertically-2.txt @@ -11,7 +11,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline ViewportPaintable (Viewport<#document>) [0,0 800x600] PaintableWithLines (BlockContainer) [0,0 800x150] - PaintableWithLines (BlockContainer) [0,0 200x0] overflow: [0,0 200x150] + PaintableWithLines (BlockContainer) [0,0 200x0] overflow: [0,100 150x50] PaintableWithLines (BlockContainer