Truly independent web browser
LibWeb+Compositor: Report the presented scroll offset to tests
Andreas Klingecb20631eafe
diff --git a/Libraries/LibWeb/Internals/Internals.idl b/Libraries/LibWeb/Internals/Internals.idlindex 86bc1653dce..c88064204ba 100644--- a/Libraries/LibWeb/Internals/Internals.idl+++ b/Libraries/LibWeb/Internals/Internals.idl@@ -102,8 +102,8 @@ interface Internals {undefined clickAndHold(double x, double y, optional unsigned short clickCount = 1, optional unsigned short button = 0, optional unsigned short modifiers = 0);[CreatesPromise] Promise<undefined> wheel(double x, double y, double deltaX, double deltaY, optional boolean precise = false, optional ScrollGesturePhase scrollGesturePhase = "none", optional WheelTicks ticks = {});// The scrolling state the compositor has installed from the frames rendered so far, its wheel routing admission,- // and how far, in CSS pixels, it presents the scroller past the edges of its scroll range. The scroller is the- // viewport if none is given.+ // and where, in CSS pixels, it presents the scroller and how far past the edges of its scroll range. The scroller+ // is the viewport if none is given.object compositorScrollState(optional Element? scroller = null);undefined pinch(double x, double y, double scaleDelta, optional unsigned short modifiers = 0);// Sends a pinch through the UI process as it sends the user's, so that the compositor zooms for it if it can.diff --git a/Services/Compositor/ContextState.cpp b/Services/Compositor/ContextState.cppindex 107d7ddf25b..0929bc84349 100644--- a/Services/Compositor/ContextState.cpp+++ b/Services/Compositor/ContextState.cpp@@ -1917,7 +1917,7 @@ Compositing::FirstWheelStepRouteForTesting ContextState::route_first_wheel_step_return { m_async_scroll_tree.route_first_wheel_step(m_wheel_gesture_routing.admission(), m_scene.visual_context_tree_for_compositing(), position, delta, nested_context_regions), document_id };}-String ContextState::scroll_state_for_testing(Web::AsyncScrollNodeStableID stretched_scroller) const+String ContextState::scroll_state_for_testing(Web::AsyncScrollNodeStableID scroller) const{auto const& display_list = m_scene.display_list();auto scroll_state = Compositing::async_scrolling_state_to_json(display_list ? Compositing::async_scrolling_state_from_display_list(*display_list) : Compositing::AsyncScrollingState {});@@ -1928,7 +1928,16 @@ String ContextState::scroll_state_for_testing(Web::AsyncScrollNodeStableID stret: Web::input_routing_decision_name(Compositing::input_routing_decision_for_wheel_step_not_admitted_by(admission));scroll_state.set("wheelRoutingAdmission"sv, admission_name);- auto stretch = m_elastic_overscroll_controller.stretch_of(stretched_scroller).scaled(1.0f / static_cast<float>(m_async_scroll_tree.device_pixels_per_css_pixel()));+ if (auto scroll_node_index = m_async_scroll_tree.scroll_node_index_for_stable_id(scroller); scroll_node_index.has_value()) {+ if (auto offset = m_async_scroll_tree.css_scroll_offset_for_node(*scroll_node_index, m_scroll_state_snapshot); offset.has_value()) {+ JsonObject offset_object;+ offset_object.set("x"sv, offset->x().to_double());+ offset_object.set("y"sv, offset->y().to_double());+ scroll_state.set("scrollOffset"sv, move(offset_object));+ }+ }++ auto stretch = m_elastic_overscroll_controller.stretch_of(scroller).scaled(1.0f / static_cast<float>(m_async_scroll_tree.device_pixels_per_css_pixel()));JsonObject stretch_object;stretch_object.set("x"sv, stretch.x());stretch_object.set("y"sv, stretch.y());diff --git a/Services/Compositor/ContextState.h b/Services/Compositor/ContextState.hindex c497d0dcb7e..10f0821cbaa 100644--- a/Services/Compositor/ContextState.h+++ b/Services/Compositor/ContextState.h@@ -305,7 +305,7 @@ public:Optional<Gfx::IntRect> advance_elastic_overscroll_rebounds(MonotonicTime frame_time);Optional<PendingFrame> advance_scrollbar_fades(MonotonicTime frame_time);// The installed scrolling state, its routing admission, and how far the given scroller is stretched, as JSON.- String scroll_state_for_testing(Web::AsyncScrollNodeStableID stretched_scroller) const;+ String scroll_state_for_testing(Web::AsyncScrollNodeStableID scroller) const;Web::InputTraceRecorder& input_trace() { return m_input_trace; }// Where the first step of a wheel gesture at the position, by the delta in CSS pixels, would go.Compositing::FirstWheelStepRouteForTesting route_first_wheel_step_for_testing(Gfx::FloatPoint position, Gfx::FloatPoint delta_in_css_pixels, Compositing::NestedContextRegions);