From 59f2b4fefcd6f39964b04087f859d30cfc092f53 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sun, 1 Sep 2024 01:23:49 +0200 Subject: [PATCH] LibWeb: Account for fixed position in nearest scrollable ancestor lookup Scroll offset of body does not affect position of fixed elements, so nearest scrollable lookup should early return from ancestor scrollable lookup loop once "position: fixed" box is encountered. Fixes regression introduced in 866608532a743df9e3d10c0dae9aacd7d0b89ce6 --- ...content-inside-fixed-position-box-ref.html | 67 +++++++++++++++++ ...ble-content-inside-fixed-position-box.html | 72 +++++++++++++++++++ .../LibWeb/Painting/PaintableBox.cpp | 6 ++ 3 files changed, 145 insertions(+) create mode 100644 Tests/LibWeb/Ref/reference/scrollable-content-inside-fixed-position-box-ref.html create mode 100644 Tests/LibWeb/Ref/scrollable-content-inside-fixed-position-box.html diff --git a/Tests/LibWeb/Ref/reference/scrollable-content-inside-fixed-position-box-ref.html b/Tests/LibWeb/Ref/reference/scrollable-content-inside-fixed-position-box-ref.html new file mode 100644 index 00000000000..53cd4c54aa7 --- /dev/null +++ b/Tests/LibWeb/Ref/reference/scrollable-content-inside-fixed-position-box-ref.html @@ -0,0 +1,67 @@ + + + +
+

Fixed Element

+
Box 1
+
Box 2
+
Box 3
+
Box 4
+
Box 5
+
diff --git a/Tests/LibWeb/Ref/scrollable-content-inside-fixed-position-box.html b/Tests/LibWeb/Ref/scrollable-content-inside-fixed-position-box.html new file mode 100644 index 00000000000..f7e1cb77302 --- /dev/null +++ b/Tests/LibWeb/Ref/scrollable-content-inside-fixed-position-box.html @@ -0,0 +1,72 @@ + + + +
+

Fixed Element

+
Box 1
+
Box 2
+
Box 3
+
Box 4
+
Box 5
+
+ diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index b5ca0d22cc5..9d943f9aa35 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -1107,10 +1107,14 @@ void PaintableWithLines::resolve_paint_properties() RefPtr PaintableBox::nearest_scroll_frame() const { + if (is_fixed_position()) + return nullptr; auto const* paintable = this->containing_block(); while (paintable) { if (paintable->own_scroll_frame()) return paintable->own_scroll_frame(); + if (paintable->is_fixed_position()) + return nullptr; paintable = paintable->containing_block(); } return nullptr; @@ -1132,6 +1136,8 @@ PaintableBox const* PaintableBox::nearest_scrollable_ancestor() const while (paintable) { if (paintable->is_scrollable()) return paintable; + if (paintable->is_fixed_position()) + return nullptr; paintable = paintable->containing_block(); } return nullptr;