Truly independent web browser
Compositor: Page toward the pointer on a press beside the thumb
Andreas Klinge59a63ae57a9
diff --git a/Services/Compositor/CompositorState.cpp b/Services/Compositor/CompositorState.cppindex 35b950b66f6..d2abc74b365 100644--- a/Services/Compositor/CompositorState.cpp+++ b/Services/Compositor/CompositorState.cpp@@ -195,11 +195,11 @@ void CompositorState::create_context(Web::CompositorContextId context_id, Optionauto schedule_caret_repaint = [this, context_id](Gfx::IntRect damage_rect) {this->schedule_caret_repaint(context_id, damage_rect);};- auto request_scrollbar_fade_frames = [this, context_id] {+ auto request_animation_frames = [this, context_id] {if (auto* context = context_if_present(context_id))schedule_animation_frames_if_needed(*context);};- return make<ContextState>(context_id, page_id, web_content_client, Compositing::OwnedCanvasSurfaces { m_canvas_surface_registry, web_content_client.canvas_surface_owner_id() }, move(schedule_caret_repaint), move(request_scrollbar_fade_frames));+ return make<ContextState>(context_id, page_id, web_content_client, Compositing::OwnedCanvasSurfaces { m_canvas_surface_registry, web_content_client.canvas_surface_owner_id() }, move(schedule_caret_repaint), move(request_animation_frames));});resize_backing_stores_if_needed(context_id, context);}diff --git a/Services/Compositor/ContextState.cpp b/Services/Compositor/ContextState.cppindex db7f52e6c49..dd1709fcca3 100644--- a/Services/Compositor/ContextState.cpp+++ b/Services/Compositor/ContextState.cpp@@ -24,6 +24,17 @@namespace Compositor {+// INTEROP: Holding a press beside the thumb pages again after these delays, as in Chromium and Firefox.+static constexpr auto scrollbar_paging_initial_delay = AK::Duration::from_milliseconds(250);+static constexpr auto scrollbar_paging_repeat_interval = AK::Duration::from_milliseconds(50);++// INTEROP: The modifier that makes a press beside the thumb jump there instead of paging, as in Chromium and Firefox.+#if defined(AK_OS_MACOS)+static constexpr auto scrollbar_jump_modifier = Web::UIEvents::Mod_Alt;+#else+static constexpr auto scrollbar_jump_modifier = Web::UIEvents::Mod_Shift;+#endif+static Web::AsyncScrollNodeStableID viewport_stable_id_from(Compositing::AsyncScrollNodeID node_id){return {@@ -47,18 +58,22 @@ static void clamp_visual_viewport_transform_to_viewport(Compositing::TransformWitransform.matrix[1, 3] = clamp(transform.matrix[1, 3], min_y, 0.0f);}-ContextState::ContextState(Web::CompositorContextId context_id, Optional<u64> page_id, CompositorStateWebContentClient& web_content_client, Compositing::OwnedCanvasSurfaces canvas_surfaces, Function<void(Gfx::IntRect)> schedule_caret_repaint, Function<void()> request_scrollbar_fade_frames)+ContextState::ContextState(Web::CompositorContextId context_id, Optional<u64> page_id, CompositorStateWebContentClient& web_content_client, Compositing::OwnedCanvasSurfaces canvas_surfaces, Function<void(Gfx::IntRect)> schedule_caret_repaint, Function<void()> request_animation_frames): m_web_content_client(web_content_client), m_context_id(context_id), m_page_id(page_id), m_presenter(m_scene, canvas_surfaces, page_id.has_value()), m_caret_blink_timer([this] { return damage_rect_of_blinking_carets(); }, move(schedule_caret_repaint))- , m_request_scrollbar_fade_frames(move(request_scrollbar_fade_frames))+ , m_request_animation_frames(move(request_animation_frames)){}ContextState::~ContextState(){+ if (m_scrollbar_paging_timer) {+ m_scrollbar_paging_timer->on_timeout = {};+ m_scrollbar_paging_timer->stop();+ }if (m_scrollbar_fade_out_timer) {m_scrollbar_fade_out_timer->on_timeout = {};m_scrollbar_fade_out_timer->stop();@@ -142,6 +157,8 @@ void ContextState::install_display_list_update(auto was_dragging_scrollbar = m_scrollbar_controller.has_captured_scrollbar();m_scrollbar_controller.set_scrollbars(async_scrolling_state.scrollbars);+ if (!m_scrollbar_controller.has_captured_scrollbar())+ stop_scrollbar_paging();note_user_scroll_gesture_end_if_drag_ended(was_dragging_scrollbar);m_async_scroll_tree.set_state(move(async_scrolling_state));m_elastic_overscroll_controller.did_install_scrolling_state(m_async_scroll_tree);@@ -398,6 +415,7 @@ ContextState::ContextUpdateResult ContextState::handle_mouse_event(Web::MouseEveif (!drag.has_value())return ContextUpdateResult::declined(Web::InputRoutingDecision::NotOverAScrollbar);m_scrollbar_press_scroll_operation.clear();+ stop_scrollbar_paging();ContextUpdateResult result;result.accepted = true;@@ -406,6 +424,40 @@ ContextState::ContextUpdateResult ContextState::handle_mouse_event(Web::MouseEveresult.scrollbar_dragged_by_compositor = m_scrollbar_controller.captured_scrollbar_painted_by_display_list();if (!result.scrollbar_dragged_by_compositor.has_value())result.frame_to_present = frame_repainting_scrollbars_painted_by_compositor();++ // A press beside the thumb pages toward the pointer, unless the modifier that jumps there instead is held.+ if (drag->is_press_beside_thumb && !(event.modifiers & scrollbar_jump_modifier)) {+ auto const& scrollbar = m_scrollbar_controller.scrollbars()[drag->scrollbar_index];+ auto scroll_offset = m_async_scroll_tree.scroll_offset_for_node(scrollbar.scroll_node_id, m_scroll_state_snapshot);+ VERIFY(scroll_offset.has_value());+ m_scrollbar_paging = ScrollbarPaging {+ .direction = m_scrollbar_controller.paging_direction(drag->scrollbar_index, drag->primary_position, *scroll_offset),+ .primary_position = drag->primary_position,+ };+ if (auto frame_to_present = page_captured_scrollbar(); frame_to_present.has_value()) {+ result.frame_to_present = *frame_to_present;+ result.should_request_rendering_update = true;+ }+ if (!m_scrollbar_paging_timer) {+ m_scrollbar_paging_timer = Core::Timer::create_single_shot(scrollbar_paging_initial_delay, [this] {+ // Paging ends with the press, and with the scrollbar the press holds.+ if (!m_scrollbar_paging.has_value() || !m_scrollbar_controller.has_captured_scrollbar()) {+ stop_scrollbar_paging();+ return;+ }+ // Once the thumb reaches the pointer, paging waits for the pointer to move.+ if (!page_captured_scrollbar().has_value())+ return;+ request_rendering_update();+ if (m_request_animation_frames)+ m_request_animation_frames();+ m_scrollbar_paging_timer->restart(scrollbar_paging_repeat_interval);+ });+ }+ m_scrollbar_paging_timer->restart(scrollbar_paging_initial_delay);+ return result;+ }+if (auto frame_to_present = apply_scrollbar_drag(*drag); frame_to_present.has_value()) {result.frame_to_present = *frame_to_present;result.should_request_rendering_update = true;@@ -417,7 +469,15 @@ ContextState::ContextUpdateResult ContextState::handle_mouse_event(Web::MouseEveauto scrollbar_dragged_by_compositor = m_scrollbar_controller.captured_scrollbar_painted_by_display_list();auto drag = m_scrollbar_controller.captured_drag(m_scene.visual_context_tree_for_compositing(), m_scroll_state_snapshot, position);VERIFY(drag.has_value());- auto frame_to_present = apply_scrollbar_drag(*drag);+ // While paging, the pointer only says where the thumb pages to.+ Optional<PendingFrame> frame_to_present;+ if (m_scrollbar_paging.has_value()) {+ m_scrollbar_paging->primary_position = drag->primary_position;+ if (!m_scrollbar_paging_timer->is_active())+ m_scrollbar_paging_timer->restart(scrollbar_paging_repeat_interval);+ } else {+ frame_to_present = apply_scrollbar_drag(*drag);+ }return {.accepted = true,.frame_to_present = frame_to_present,@@ -450,6 +510,8 @@ ContextState::ContextUpdateResult ContextState::handle_mouse_event(Web::MouseEveauto was_dragging_scrollbar = m_scrollbar_controller.has_captured_scrollbar();auto scrollbar_dragged_by_compositor = m_scrollbar_controller.captured_scrollbar_painted_by_display_list();auto drag = m_scrollbar_controller.release_captured_drag(m_scene.visual_context_tree_for_compositing(), m_scroll_state_snapshot, position);+ auto was_paging = m_scrollbar_paging.has_value();+ stop_scrollbar_paging();if (!drag.has_value())return ContextUpdateResult::declined(Web::InputRoutingDecision::NoScrollbarDrag);@@ -465,8 +527,10 @@ ContextState::ContextUpdateResult ContextState::handle_mouse_event(Web::MouseEveresult.should_request_rendering_update = true;if (!scrollbar_dragged_by_compositor.has_value())result.frame_to_present = frame_repainting_scrollbars_painted_by_compositor();- if (auto frame_to_present = apply_scrollbar_drag(*drag); frame_to_present.has_value())- result.frame_to_present = *frame_to_present;+ if (!was_paging) {+ if (auto frame_to_present = apply_scrollbar_drag(*drag); frame_to_present.has_value())+ result.frame_to_present = *frame_to_present;+ }auto hovered_scrollbar_index = m_scrollbar_controller.hit_test_scrollbar_painted_by_compositor(m_async_scroll_tree, m_scroll_state_snapshot, position);if (m_scrollbar_controller.set_hovered_scrollbar(hovered_scrollbar_index)) {@@ -495,6 +559,7 @@ ContextState::ContextUpdateResult ContextState::handle_mouse_event(Web::MouseEveauto was_dragging_scrollbar = m_scrollbar_controller.has_captured_scrollbar();auto scrollbar_dragged_by_compositor = m_scrollbar_controller.captured_scrollbar_painted_by_display_list();(void)m_scrollbar_controller.release_captured_drag(m_scene.visual_context_tree_for_compositing(), m_scroll_state_snapshot, position);+ stop_scrollbar_paging();note_user_scroll_gesture_end_if_drag_ended(was_dragging_scrollbar);auto hovered_scrollbar_changed = m_scrollbar_controller.set_hovered_scrollbar({});@@ -1546,19 +1611,19 @@ Gfx::IntRect ContextState::update_scrollbar_visibility()auto damage_rect = m_scrollbar_controller.update_visibility(visual_context_tree, presented_scroll_state_snapshot, now);// A hovered scrollbar starts to grow here, which needs display ticks before anything else asks for a frame.- if (m_request_scrollbar_fade_frames && m_scrollbar_controller.fades_need_frame(now))- m_request_scrollbar_fade_frames();+ if (m_request_animation_frames && m_scrollbar_controller.fades_need_frame(now))+ m_request_animation_frames();// The fade out runs on display ticks, which the wait before it does not need.auto fade_out_time = m_scrollbar_controller.next_fade_out_time();- if (!fade_out_time.has_value() || !m_request_scrollbar_fade_frames) {+ if (!fade_out_time.has_value() || !m_request_animation_frames) {if (m_scrollbar_fade_out_timer)m_scrollbar_fade_out_timer->stop();return damage_rect;}if (!m_scrollbar_fade_out_timer) {m_scrollbar_fade_out_timer = Core::Timer::create_single_shot(AK::Duration::zero(), [this] {- m_request_scrollbar_fade_frames();+ m_request_animation_frames();});}auto delay = max(AK::Duration::zero(), *fade_out_time - now);@@ -1817,6 +1882,84 @@ void ContextState::end_scroll_step_gestures_whose_input_ran_out(MonotonicTime noschedule_end_of_scroll_step_gestures(now);}+Optional<PendingFrame> ContextState::start_scrollbar_press_scroll(Compositing::AsyncScrollNode const& node, Gfx::FloatPoint old_scroll_offset, Gfx::FloatPoint destination, bool is_absolute_scroll)+{+ auto operation_id = m_async_scroll_update_outbox.allocate_operation_id();+ m_smooth_scroll_animations.append({+ .stable_node_id = node.stable_node_id,+ .operation_id = operation_id,+ .animation = Compositing::SmoothScrollAnimation { old_scroll_offset, destination, m_async_scroll_tree.device_pixels_per_css_pixel() },+ .started_at = MonotonicTime::now(),+ .is_user_scroll = true,+ });+ report_started_user_scroll(operation_id, node.stable_node_id, old_scroll_offset, destination, Compositing::ScrollAnimationKind::SmoothScroll, is_absolute_scroll);+ m_scrollbar_press_scroll_operation = operation_id;+ return PendingFrame::repainting_changes(m_async_scrolling_viewport_rect);+}++// https://source.chromium.org/chromium/chromium/src/+/main:cc/input/scroll_utils.cc+// INTEROP: A page is most of the scrollport, keeping as much of the last page in view as Chromium does.+static float scrollbar_page_step(float scrollport_length, float device_pixels_per_css_pixel)+{+ static constexpr float min_fraction_to_step_when_paging = 0.875f;+ static constexpr float max_overlap_between_pages = 40;+ return max(1.0f, max(scrollport_length * min_fraction_to_step_when_paging, scrollport_length - max_overlap_between_pages * device_pixels_per_css_pixel));+}++// Pages the scroller of the captured scrollbar once toward the pointer, from where a page scroll in flight goes, unless+// the thumb has reached the pointer there.+Optional<PendingFrame> ContextState::page_captured_scrollbar()+{+ auto scrollbar_index = m_scrollbar_controller.captured_scrollbar_index();+ if (!scrollbar_index.has_value() || !m_scrollbar_paging.has_value() || m_scrollbar_paging->direction == 0)+ return {};+ auto const& scrollbar = m_scrollbar_controller.scrollbars()[*scrollbar_index];+ auto const* node = m_async_scroll_tree.scroll_node_for_id(scrollbar.scroll_node_id);+ auto old_scroll_offset = m_async_scroll_tree.scroll_offset_for_node(scrollbar.scroll_node_id, m_scroll_state_snapshot);+ if (!node || !old_scroll_offset.has_value())+ return {};++ auto* running_animation = running_scrollbar_press_scroll();+ auto step_start = running_animation ? running_animation->animation.destination_offset() : *old_scroll_offset;+ if (m_scrollbar_controller.paging_direction(*scrollbar_index, m_scrollbar_paging->primary_position, step_start) != m_scrollbar_paging->direction)+ return {};++ auto orientation = scrollbar.vertical ? Gfx::Orientation::Vertical : Gfx::Orientation::Horizontal;+ auto step = scrollbar_page_step(static_cast<float>(node->scrollport_rect.primary_size_for_orientation(orientation)), m_async_scroll_tree.device_pixels_per_css_pixel());+ auto destination = step_start;+ destination.set_primary_offset_for_orientation(orientation, step_start.primary_offset_for_orientation(orientation) + static_cast<float>(m_scrollbar_paging->direction) * step);+ destination = m_async_scroll_tree.clamped_scroll_offset_for_node(scrollbar.scroll_node_id, destination);+ if (destination == step_start)+ return {};++ if (running_animation) {+ retarget_user_scroll(*running_animation, destination, MonotonicTime::now());+ report_started_user_scroll(running_animation->operation_id, node->stable_node_id, step_start, destination, Compositing::ScrollAnimationKind::SmoothScroll, false);+ return PendingFrame::repainting_changes(m_async_scrolling_viewport_rect);+ }+ cancel_smooth_scroll_taken_over_by_user_input(scrollbar.scroll_node_id);+ return start_scrollbar_press_scroll(*node, *old_scroll_offset, destination, false);+}++ContextState::ActiveSmoothScrollAnimation* ContextState::running_scrollbar_press_scroll()+{+ if (!m_scrollbar_press_scroll_operation.has_value())+ return nullptr;+ auto animation = m_smooth_scroll_animations.first_matching([&](auto const& animation) { return animation.operation_id == *m_scrollbar_press_scroll_operation; });+ if (!animation.has_value()) {+ m_scrollbar_press_scroll_operation.clear();+ return nullptr;+ }+ return &animation.value();+}++void ContextState::stop_scrollbar_paging()+{+ m_scrollbar_paging.clear();+ if (m_scrollbar_paging_timer)+ m_scrollbar_paging_timer->stop();+}+Optional<PendingFrame> ContextState::apply_scrollbar_drag(ScrollbarController::Drag const& drag){auto dragged_to = m_scrollbar_controller.scroll_offset_for_drag(m_async_scroll_tree, m_scroll_state_snapshot, drag);@@ -1833,16 +1976,12 @@ Optional<PendingFrame> ContextState::apply_scrollbar_drag(ScrollbarController::D// A press beside the thumb scrolls there smoothly, as a page step does. Dragging on before that scroll has ended// moves where it goes.- if (m_scrollbar_press_scroll_operation.has_value()) {- auto running_animation = m_smooth_scroll_animations.find_if([&](auto const& animation) { return animation.operation_id == *m_scrollbar_press_scroll_operation; });- if (running_animation != m_smooth_scroll_animations.end()) {- if (running_animation->animation.destination_offset() == destination)- return {};- retarget_user_scroll(*running_animation, destination, MonotonicTime::now());- report_started_user_scroll(running_animation->operation_id, node->stable_node_id, *old_scroll_offset, destination, Compositing::ScrollAnimationKind::SmoothScroll, true);- return PendingFrame::repainting_changes(m_async_scrolling_viewport_rect);- }- m_scrollbar_press_scroll_operation.clear();+ if (auto* running_animation = running_scrollbar_press_scroll()) {+ if (running_animation->animation.destination_offset() == destination)+ return {};+ retarget_user_scroll(*running_animation, destination, MonotonicTime::now());+ report_started_user_scroll(running_animation->operation_id, node->stable_node_id, *old_scroll_offset, destination, Compositing::ScrollAnimationKind::SmoothScroll, true);+ return PendingFrame::repainting_changes(m_async_scrolling_viewport_rect);}if (destination == *old_scroll_offset)@@ -1850,19 +1989,8 @@ Optional<PendingFrame> ContextState::apply_scrollbar_drag(ScrollbarController::Dcancel_smooth_scroll_taken_over_by_user_input(node_id);- if (drag.is_press_beside_thumb) {- auto operation_id = m_async_scroll_update_outbox.allocate_operation_id();- m_smooth_scroll_animations.append({- .stable_node_id = node->stable_node_id,- .operation_id = operation_id,- .animation = Compositing::SmoothScrollAnimation { *old_scroll_offset, destination, m_async_scroll_tree.device_pixels_per_css_pixel() },- .started_at = MonotonicTime::now(),- .is_user_scroll = true,- });- report_started_user_scroll(operation_id, node->stable_node_id, *old_scroll_offset, destination, Compositing::ScrollAnimationKind::SmoothScroll, true);- m_scrollbar_press_scroll_operation = operation_id;- return PendingFrame::repainting_changes(m_async_scrolling_viewport_rect);- }+ if (drag.is_press_beside_thumb)+ return start_scrollbar_press_scroll(*node, *old_scroll_offset, destination, true);auto new_scroll_offset = m_async_scroll_tree.set_scroll_offset(node_id, dragged_to->scroll_offset, m_scene.current_visual_context_tree(), m_scroll_state_snapshot);VERIFY(new_scroll_offset.has_value());diff --git a/Services/Compositor/ContextState.h b/Services/Compositor/ContextState.hindex 4f3a678dbfe..977c5d943b2 100644--- a/Services/Compositor/ContextState.h+++ b/Services/Compositor/ContextState.h@@ -124,7 +124,7 @@ public:Optional<Compositing::NestedContextWheelHit> nested_context_hit {};};- ContextState(Web::CompositorContextId, Optional<u64> page_id, CompositorStateWebContentClient&, Compositing::OwnedCanvasSurfaces, Function<void(Gfx::IntRect)> schedule_caret_repaint = {}, Function<void()> request_scrollbar_fade_frames = {});+ ContextState(Web::CompositorContextId, Optional<u64> page_id, CompositorStateWebContentClient&, Compositing::OwnedCanvasSurfaces, Function<void(Gfx::IntRect)> schedule_caret_repaint = {}, Function<void()> request_animation_frames = {});~ContextState();bool is_owned_by(CompositorStateWebContentClient const&) const;@@ -330,6 +330,11 @@ private:// that it settles the gesture then rather than on a clock of its own.void end_scroll_step_gestures_whose_input_ran_out(MonotonicTime now);Optional<PendingFrame> apply_scrollbar_drag(ScrollbarController::Drag const&);+ Optional<PendingFrame> start_scrollbar_press_scroll(Compositing::AsyncScrollNode const&, Gfx::FloatPoint old_scroll_offset, Gfx::FloatPoint destination, bool is_absolute_scroll);+ Optional<PendingFrame> page_captured_scrollbar();+ void stop_scrollbar_paging();+ // The smooth scroll that a press beside the thumb started, while it lasts.+ ActiveSmoothScrollAnimation* running_scrollbar_press_scroll();void rebuild_wheel_hit_test_targets();ContextPresenter::FrameContent frame_content(Compositing::ScrollStateSnapshot const& presented_scroll_state_snapshot, CompositedContextResolver const*) const;Gfx::IntRect damage_rect_of_blinking_carets();@@ -356,13 +361,20 @@ private:Vector<ActiveSmoothScrollAnimation> m_smooth_scroll_animations;// The smooth scroll that a press beside the thumb of the captured scrollbar started.Optional<Compositing::AsyncScrollOperationID> m_scrollbar_press_scroll_operation;+ // A press beside the thumb that pages toward the pointer for as long as it is held.+ struct ScrollbarPaging {+ int direction { 0 };+ float primary_position { 0 };+ };+ Optional<ScrollbarPaging> m_scrollbar_paging;+ RefPtr<Core::Timer> m_scrollbar_paging_timer;ScrollFlingController m_scroll_fling_controller;ElasticOverscrollController m_elastic_overscroll_controller;Gfx::IntRect m_async_scrolling_viewport_rect;bool m_has_async_scrolling_state { false };CaretBlinkTimer m_caret_blink_timer;- Function<void()> m_request_scrollbar_fade_frames;+ Function<void()> m_request_animation_frames;RefPtr<Core::Timer> m_scrollbar_fade_out_timer;Web::InputTraceRecorder m_input_trace;Optional<u64> m_display_id;diff --git a/Services/Compositor/ScrollbarController.cpp b/Services/Compositor/ScrollbarController.cppindex f58759543cd..72c39b4b129 100644--- a/Services/Compositor/ScrollbarController.cpp+++ b/Services/Compositor/ScrollbarController.cpp@@ -310,6 +310,18 @@ Optional<ScrollbarController::ScrollOffset> ScrollbarController::scroll_offset_freturn ScrollOffset { scrollbar.scroll_node_id, scroll_offset };}+int ScrollbarController::paging_direction(size_t scrollbar_index, float primary_position, Gfx::FloatPoint scroll_offset) const+{+ auto const& scrollbar = m_scrollbars[scrollbar_index];+ auto orientation = orientation_for_scrollbar(scrollbar);+ auto thumb_rect = translated_thumb_rect(scrollbar, scroll_offset, is_expanded(scrollbar_index));+ if (primary_position < static_cast<float>(thumb_rect.primary_offset_for_orientation(orientation)))+ return -1;+ if (primary_position >= static_cast<float>(thumb_rect.primary_offset_for_orientation(orientation) + thumb_rect.primary_size_for_orientation(orientation)))+ return 1;+ return 0;+}+Gfx::IntRect ScrollbarController::update_visibility(Compositing::AccumulatedVisualContextTree const* visual_context_tree, Compositing::ScrollStateSnapshot const& scroll_state_snapshot, MonotonicTime now){Gfx::IntRect damage_rect;diff --git a/Services/Compositor/ScrollbarController.h b/Services/Compositor/ScrollbarController.hindex 2b566500d4d..5b4cc7614eb 100644--- a/Services/Compositor/ScrollbarController.h+++ b/Services/Compositor/ScrollbarController.h@@ -86,6 +86,10 @@ public:bool is_empty() const { return m_scrollbars.is_empty(); }Vector<Compositing::AsyncScrollbar> const& scrollbars() const { return m_scrollbars; }bool has_captured_scrollbar() const { return m_captured_scrollbar_index.has_value(); }+ Optional<size_t> captured_scrollbar_index() const { return m_captured_scrollbar_index; }+ // Which way a press beside the thumb pages: -1 or 1 toward the pointer from where the thumb is at the given scroll+ // offset, or 0 when the thumb is under the pointer.+ int paging_direction(size_t scrollbar_index, float primary_position, Gfx::FloatPoint scroll_offset) const;// The main thread still takes the mouse events of a drag that holds a scrollbar the display list paints.Optional<Web::ScrollbarDraggedByCompositor> captured_scrollbar_painted_by_display_list() const;diff --git a/Tests/Compositor/TestScrollbarController.cpp b/Tests/Compositor/TestScrollbarController.cppindex 0d9360f99bf..d5261a6cd76 100644--- a/Tests/Compositor/TestScrollbarController.cpp+++ b/Tests/Compositor/TestScrollbarController.cpp@@ -352,3 +352,16 @@ TEST_CASE(scrolling_expanded_scrollbar_the_display_list_paints_thin_damages_it)auto damage_rect = controller.update_visibility(&visual_context_tree, scroll_state_snapshot, start);EXPECT(damage_rect.contains(Gfx::IntRect { 92, 0, 8, 100 }));}++TEST_CASE(press_beside_thumb_pages_toward_pointer_until_thumb_reaches_it)+{+ Compositor::ScrollbarController controller;+ controller.set_scrollbars({ scrollbar_painted_by_display_list() });++ // The thumb spans 20 to 40 at no scroll offset, and moves 0.8 for each unit scrolled.+ EXPECT_EQ(controller.paging_direction(0, 10, { 0, 0 }), -1);+ EXPECT_EQ(controller.paging_direction(0, 30, { 0, 0 }), 0);+ EXPECT_EQ(controller.paging_direction(0, 60, { 0, 0 }), 1);+ EXPECT_EQ(controller.paging_direction(0, 60, { 0, 30 }), 0);+ EXPECT_EQ(controller.paging_direction(0, 60, { 0, 60 }), -1);+}