Truly independent web browser
LibWeb: Leave a clamp of layout's scroll offset to the compositor
Andreas Kling8a21ff8bac46
diff --git a/Libraries/LibWeb/HTML/LocalNavigable.cpp b/Libraries/LibWeb/HTML/LocalNavigable.cppindex 6cf05ea5392..09e9b385425 100644--- a/Libraries/LibWeb/HTML/LocalNavigable.cpp+++ b/Libraries/LibWeb/HTML/LocalNavigable.cpp@@ -7372,6 +7372,14 @@ bool LocalNavigable::set_scroll_offset_for_user_input(Layout::Node& scrolling_boreturn did_scroll;}+void LocalNavigable::set_scroll_offset_settled_by_layout(Layout::Node& scrolling_box, CSSPixelPoint scroll_offset)+{+ // NB: The compositor keeps the box in the same scroll range as it takes in the frame of this layout, from wherever+ // the user has scrolled it since. A jump to the offset this thread knows would take that scroll back.+ TemporaryChange compositor_keeps_the_box_in_range { m_scroll_offset_changes_need_no_request, true };+ (void)Painting::set_scroll_offset(scrolling_box, scroll_offset);+}+u64 LocalNavigable::compositor_user_input_scroll_count() const{u64 count = 0;diff --git a/Libraries/LibWeb/HTML/LocalNavigable.h b/Libraries/LibWeb/HTML/LocalNavigable.hindex 0d1d06c64e8..310104ca147 100644--- a/Libraries/LibWeb/HTML/LocalNavigable.h+++ b/Libraries/LibWeb/HTML/LocalNavigable.h@@ -255,6 +255,7 @@ public:// Every change of a scroll offset here, other than one the compositor made, goes to the compositor as a request.void did_change_scroll_offset(Web::AsyncScrollNodeStableID);u64 compositor_user_input_scroll_count() const;+ void set_scroll_offset_settled_by_layout(Layout::Node& scrolling_box, CSSPixelPoint scroll_offset);// Changes a scrolling box's offset for user input on this thread, which the compositor is asked for as the user's.bool set_scroll_offset_for_user_input(Layout::Node& scrolling_box, Web::AsyncScrollNodeStableID, CSSPixelPoint);void adopt_pending_async_scroll_offsets(Compositing::AsyncScrollUpdateFreshness = Compositing::AsyncScrollUpdateFreshness::Pushed);diff --git a/Libraries/LibWeb/Painting/PaintingRustBridge.cpp b/Libraries/LibWeb/Painting/PaintingRustBridge.cppindex efe31f7b5b5..a63de3a8797 100644--- a/Libraries/LibWeb/Painting/PaintingRustBridge.cpp+++ b/Libraries/LibWeb/Painting/PaintingRustBridge.cpp@@ -252,7 +252,9 @@ void register_geometry_host(Layout::NodeArena& arena).set_scroll_offset = [](void* context, Layout::BegunRead const* read, Compositing::RustFFI::NodeSlotId slot, CSSPixelPoint offset) {auto* layout_node = static_cast<Layout::NodeArena*>(context)->node_if_live(*read, slot);VERIFY(layout_node);- set_scroll_offset(*layout_node, offset); },+ auto navigable = layout_node->document().navigable();+ VERIFY(navigable);+ navigable->set_scroll_offset_settled_by_layout(*layout_node, offset); },};Layout::RustFFI::document_host_set_geometry_host(arena.host(), callbacks);}diff --git a/Tests/LibWeb/Text/expected/async-scrolling/page-getting-shorter-keeps-a-compositor-scroll.txt b/Tests/LibWeb/Text/expected/async-scrolling/page-getting-shorter-keeps-a-compositor-scroll.txtindex e4820bc6577..f52df54d503 100644--- a/Tests/LibWeb/Text/expected/async-scrolling/page-getting-shorter-keeps-a-compositor-scroll.txt+++ b/Tests/LibWeb/Text/expected/async-scrolling/page-getting-shorter-keeps-a-compositor-scroll.txt@@ -1,3 +1,3 @@main thread moved up with the bottom: truewheel scrolled up by: 200-after the frame, up from the old bottom by: 100+after the frame, up from the old bottom by: 200