From 94721385ceb17e20428b94a946d39828bdd5b74e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 8 Oct 2024 13:00:27 +0200 Subject: [PATCH] LibWeb: Ignore boxes wholly in the negative scrollable overflow region This fixes an issue where https://hey.com/ was horizontally scrollable even though it shouldn't be. --- .../actually-ignore-the-negative-overflow-region.txt | 9 +++++++++ .../actually-ignore-the-negative-overflow-region.html | 8 ++++++++ Userland/Libraries/LibWeb/Layout/LayoutState.cpp | 10 ++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 Tests/LibWeb/Layout/expected/actually-ignore-the-negative-overflow-region.txt create mode 100644 Tests/LibWeb/Layout/input/actually-ignore-the-negative-overflow-region.html diff --git a/Tests/LibWeb/Layout/expected/actually-ignore-the-negative-overflow-region.txt b/Tests/LibWeb/Layout/expected/actually-ignore-the-negative-overflow-region.txt new file mode 100644 index 00000000000..d9e2e3e8af5 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/actually-ignore-the-negative-overflow-region.txt @@ -0,0 +1,9 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x16 [BFC] children: not-inline + Box at (8,8) content-size 784x0 flex-container(row) [FFC] children: not-inline + BlockContainer
at (-5000,8) content-size 0x0 positioned [BFC] children: not-inline + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x16] + PaintableBox (Box) [8,8 784x0] + PaintableWithLines (BlockContainer
) [-5000,8 0x0] diff --git a/Tests/LibWeb/Layout/input/actually-ignore-the-negative-overflow-region.html b/Tests/LibWeb/Layout/input/actually-ignore-the-negative-overflow-region.html new file mode 100644 index 00000000000..26b823f0c72 --- /dev/null +++ b/Tests/LibWeb/Layout/input/actually-ignore-the-negative-overflow-region.html @@ -0,0 +1,8 @@ +
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/LayoutState.cpp b/Userland/Libraries/LibWeb/Layout/LayoutState.cpp index 1e513a9015b..02bc67fc773 100644 --- a/Userland/Libraries/LibWeb/Layout/LayoutState.cpp +++ b/Userland/Libraries/LibWeb/Layout/LayoutState.cpp @@ -105,11 +105,13 @@ static CSSPixelRect measure_scrollable_overflow(Box const& box) return IterationDecision::Continue; auto child_border_box = child.paintable_box()->absolute_border_box_rect(); + // 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) { - scrollable_overflow_rect = scrollable_overflow_rect.united(child_border_box); - content_overflow_rect = content_overflow_rect.united(child_border_box); - } + if (child_border_box.bottom() < 0 || child_border_box.right() < 0) + return IterationDecision::Continue; + + scrollable_overflow_rect = scrollable_overflow_rect.united(child_border_box); + content_overflow_rect = content_overflow_rect.united(child_border_box); // - The scrollable overflow areas of all of the above boxes // (including zero-area boxes and accounting for transforms as described above),