Skip to content

Truly independent web browser

LibWeb+Compositor: Read the compositor's installed scroll state in tests

Aliaksandr Kalenik3a4507eaf93b
diff --git a/Libraries/LibCompositing/Scrolling/AsyncScrollingState.cpp b/Libraries/LibCompositing/Scrolling/AsyncScrollingState.cpp
index 6ce2a019051..3fa8d92a0f1 100644
--- a/Libraries/LibCompositing/Scrolling/AsyncScrollingState.cpp
+++ b/Libraries/LibCompositing/Scrolling/AsyncScrollingState.cpp
@@ -4,6 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <AK/JsonArray.h>
+#include <AK/JsonObject.h>
#include <AK/Utf16View.h>
#include <LibCompositing/DisplayList/DisplayList.h>
#include <LibCompositing/Scrolling/AsyncScrollTree.h>
@@ -203,6 +205,106 @@ AsyncScrollingState async_scrolling_state_from_display_list(Compositing::Display
return async_scrolling_state;
}
+static StringView snap_strictness_name(SnapStrictness strictness)
+{
+ switch (strictness) {
+ case SnapStrictness::None:
+ return "none"sv;
+ case SnapStrictness::Proximity:
+ return "proximity"sv;
+ case SnapStrictness::Mandatory:
+ return "mandatory"sv;
+ }
+ VERIFY_NOT_REACHED();
+}
+
+static StringView snap_align_name(SnapAlign align)
+{
+ switch (align) {
+ case SnapAlign::None:
+ return "none"sv;
+ case SnapAlign::Start:
+ return "start"sv;
+ case SnapAlign::End:
+ return "end"sv;
+ case SnapAlign::Center:
+ return "center"sv;
+ }
+ VERIFY_NOT_REACHED();
+}
+
+static JsonObject rect_to_json(Web::CSSPixelRect const& rect)
+{
+ JsonObject object;
+ object.set("x"sv, rect.x().to_double());
+ object.set("y"sv, rect.y().to_double());
+ object.set("width"sv, rect.width().to_double());
+ object.set("height"sv, rect.height().to_double());
+ return object;
+}
+
+static JsonObject point_to_json(Web::CSSPixelPoint const& point)
+{
+ JsonObject object;
+ object.set("x"sv, point.x().to_double());
+ object.set("y"sv, point.y().to_double());
+ return object;
+}
+
+JsonObject async_scrolling_state_to_json(AsyncScrollingState const& state)
+{
+ JsonArray scroll_nodes;
+ for (auto const& scroll_node : state.scroll_nodes) {
+ JsonObject node;
+ node.set("documentID"sv, scroll_node.node_id.document_id.value());
+ node.set("scrollNodeIndex"sv, scroll_node.node_id.scroll_node_index.value());
+ node.set("parentDocumentID"sv, scroll_node.parent_node_id.has_value() ? scroll_node.parent_node_id->document_id.value() : 0);
+ node.set("parentScrollNodeIndex"sv, scroll_node.parent_node_id.has_value() ? scroll_node.parent_node_id->scroll_node_index.value() : 0);
+ node.set("isViewport"sv, scroll_node.is_viewport);
+ scroll_nodes.must_append(move(node));
+ }
+
+ JsonArray snap_containers;
+ for (auto const& snap_container : state.snap_containers) {
+ JsonObject container;
+ container.set("documentID"sv, snap_container.node_id.document_id.value());
+ container.set("scrollNodeIndex"sv, snap_container.node_id.scroll_node_index.value());
+ container.set("snapport"sv, rect_to_json(snap_container.geometry.snapport));
+ container.set("minScrollOffset"sv, point_to_json(snap_container.geometry.min_scroll_offset));
+ container.set("maxScrollOffset"sv, point_to_json(snap_container.geometry.max_scroll_offset));
+ container.set("strictness"sv, snap_strictness_name(snap_container.geometry.strictness));
+ container.set("snapsX"sv, snap_container.geometry.axes.x);
+ container.set("snapsY"sv, snap_container.geometry.axes.y);
+ container.set("horizontalWritingMode"sv, snap_container.geometry.horizontal_writing_mode);
+ JsonArray areas;
+ for (auto const& snap_area : snap_container.areas) {
+ JsonObject area;
+ area.set("nodeID"sv, snap_area.identity.node_id.value());
+ area.set("pseudoElementType"sv, snap_area.identity.pseudo_element_type);
+ area.set("rect"sv, rect_to_json(snap_area.rect));
+ area.set("alignX"sv, snap_align_name(snap_area.align_x));
+ area.set("alignY"sv, snap_align_name(snap_area.align_y));
+ area.set("alwaysStop"sv, snap_area.always_stop);
+ areas.must_append(move(area));
+ }
+ container.set("areas"sv, move(areas));
+ snap_containers.must_append(move(container));
+ }
+
+ JsonObject object;
+ object.set("documentID"sv, state.document_id.has_value() ? JsonValue { state.document_id->value() } : JsonValue {});
+ object.set("scrollNodeCount"sv, state.scroll_nodes.size());
+ object.set("scrollNodes"sv, move(scroll_nodes));
+ object.set("snapContainers"sv, move(snap_containers));
+ object.set("devicePixelsPerCssPixel"sv, state.device_pixels_per_css_pixel);
+ object.set("hasBlockingWheelEventListeners"sv, state.has_blocking_wheel_event_listeners);
+ object.set("blockingWheelEventRegionCount"sv, state.blocking_wheel_event_regions.size());
+ object.set("mainThreadWheelEventRegionCount"sv, state.main_thread_wheel_event_regions.size());
+ object.set("wheelEventListenerStateGeneration"sv, state.wheel_event_listener_state_generation);
+ object.set("hasBlockingWheelEventRegionCoveringViewport"sv, state.has_blocking_wheel_event_region_covering_viewport);
+ return object;
+}
+
WheelRoutingAdmission wheel_routing_admission_for(AsyncScrollingState const& state)
{
if (state.has_blocking_wheel_event_region_covering_viewport)
diff --git a/Libraries/LibCompositing/Scrolling/AsyncScrollingState.h b/Libraries/LibCompositing/Scrolling/AsyncScrollingState.h
index 632e143bd95..2414e4e92ef 100644
--- a/Libraries/LibCompositing/Scrolling/AsyncScrollingState.h
+++ b/Libraries/LibCompositing/Scrolling/AsyncScrollingState.h
@@ -181,6 +181,8 @@ enum class WheelScrollAdmission {
};
COMPOSITING_API AsyncScrollingState async_scrolling_state_from_display_list(Compositing::DisplayList const&);
+// The scrolling state as tests read it, from WebContent and from the compositor alike.
+COMPOSITING_API JsonObject async_scrolling_state_to_json(AsyncScrollingState const&);
COMPOSITING_API WheelRoutingAdmission wheel_routing_admission_for(AsyncScrollingState const&);
// The admission of a scrolling state recorded before the newest change to the page's blocking wheel event listeners is
// stale, as the state may not have the regions that change made.
diff --git a/Libraries/LibWeb/Compositor/CompositorConnection.cpp b/Libraries/LibWeb/Compositor/CompositorConnection.cpp
index 19916bd778a..4958ef79c32 100644
--- a/Libraries/LibWeb/Compositor/CompositorConnection.cpp
+++ b/Libraries/LibWeb/Compositor/CompositorConnection.cpp
@@ -438,17 +438,17 @@ Compositing::AsyncScrollEnqueueResult CompositorConnection::smooth_scroll_to(Web
return response->take_result();
}
-Gfx::FloatPoint CompositorConnection::elastic_overscroll_stretch_for_testing(Web::CompositorContextId context_id, Web::AsyncScrollNodeStableID stable_node_id)
+String CompositorConnection::scroll_state_for_testing(Web::CompositorContextId context_id, Web::AsyncScrollNodeStableID stretched_scroller)
{
if (!can_send_message_to_compositor())
return {};
- auto response = send_sync_but_allow_failure<Messages::CompositorWebContentServer::ElasticOverscrollStretchForTesting>(context_id, stable_node_id);
+ auto response = send_sync_but_allow_failure<Messages::CompositorWebContentServer::ScrollStateForTesting>(context_id, stretched_scroller);
if (!response) {
did_lose_compositor();
return {};
}
- return response->stretch();
+ return response->take_scroll_state();
}
void CompositorConnection::synchronize_for_testing()
diff --git a/Libraries/LibWeb/Compositor/CompositorConnection.h b/Libraries/LibWeb/Compositor/CompositorConnection.h
index 2a4906618f2..8d3b228774f 100644
--- a/Libraries/LibWeb/Compositor/CompositorConnection.h
+++ b/Libraries/LibWeb/Compositor/CompositorConnection.h
@@ -71,7 +71,7 @@ public:
Compositing::AsyncScrollEnqueueResult async_scroll_by(Web::CompositorContextId, Web::UniqueNodeID document_id, Gfx::FloatPoint position, Gfx::FloatPoint delta, Gfx::IntRect viewport_rect, Web::WheelDeltaPrecision, Web::ScrollGesturePhase, u32 modifiers, Compositing::AsyncScrollOperationTracking, Compositing::WheelStepDispatch, u64 input_event_id);
Compositing::AsyncScrollEnqueueResult smooth_scroll_to(Web::CompositorContextId, Web::AsyncScrollNodeStableID, Gfx::FloatPoint offset, Gfx::FloatPoint main_thread_offset, Gfx::IntRect viewport_rect, Compositing::ScrollAnimationKind, Compositing::SmoothScrollInitiator, Optional<Compositing::AsyncScrollOperationID> operation_to_continue);
void cancel_smooth_scroll(Web::CompositorContextId, Web::AsyncScrollNodeStableID);
- Gfx::FloatPoint elastic_overscroll_stretch_for_testing(Web::CompositorContextId, Web::AsyncScrollNodeStableID);
+ String scroll_state_for_testing(Web::CompositorContextId, Web::AsyncScrollNodeStableID stretched_scroller);
void synchronize_for_testing();
Optional<Compositing::FirstWheelStepRouteForTesting> route_first_wheel_step_for_testing(Web::CompositorContextId, Gfx::FloatPoint position, Gfx::FloatPoint delta_in_css_pixels);
void begin_input_trace_for_testing(Web::CompositorContextId);
diff --git a/Libraries/LibWeb/Compositor/CompositorHost.cpp b/Libraries/LibWeb/Compositor/CompositorHost.cpp
index e63782b488c..36aeb4e3560 100644
--- a/Libraries/LibWeb/Compositor/CompositorHost.cpp
+++ b/Libraries/LibWeb/Compositor/CompositorHost.cpp
@@ -78,9 +78,9 @@ void CompositorContextHandle::cancel_smooth_scroll(Web::AsyncScrollNodeStableID
m_host.cancel_smooth_scroll(m_context_id, stable_node_id);
}
-Gfx::FloatPoint CompositorContextHandle::elastic_overscroll_stretch_for_testing(Web::AsyncScrollNodeStableID stable_node_id)
+String CompositorContextHandle::scroll_state_for_testing(Web::AsyncScrollNodeStableID stretched_scroller)
{
- return m_host.elastic_overscroll_stretch_for_testing(m_context_id, stable_node_id);
+ return m_host.scroll_state_for_testing(m_context_id, stretched_scroller);
}
void CompositorContextHandle::synchronize_for_testing()
@@ -449,10 +449,10 @@ void CompositorHost::cancel_smooth_scroll(Web::CompositorContextId context_id, W
connection->cancel_smooth_scroll(context_id, stable_node_id);
}
-Gfx::FloatPoint CompositorHost::elastic_overscroll_stretch_for_testing(Web::CompositorContextId context_id, Web::AsyncScrollNodeStableID stable_node_id)
+String CompositorHost::scroll_state_for_testing(Web::CompositorContextId context_id, Web::AsyncScrollNodeStableID stretched_scroller)
{
if (auto* connection = compositor_connection())
- return connection->elastic_overscroll_stretch_for_testing(context_id, stable_node_id);
+ return connection->scroll_state_for_testing(context_id, stretched_scroller);
return {};
}
diff --git a/Libraries/LibWeb/Compositor/CompositorHost.h b/Libraries/LibWeb/Compositor/CompositorHost.h
index c29f0bbce16..2dada11c8ab 100644
--- a/Libraries/LibWeb/Compositor/CompositorHost.h
+++ b/Libraries/LibWeb/Compositor/CompositorHost.h
@@ -62,7 +62,7 @@ public:
Gfx::IntRect viewport_rect, Web::WheelDeltaPrecision, Web::ScrollGesturePhase, u32 modifiers, Compositing::AsyncScrollOperationTracking, Compositing::WheelStepDispatch, u64 input_event_id);
Compositing::AsyncScrollEnqueueResult smooth_scroll_to(Web::AsyncScrollNodeStableID, Gfx::FloatPoint offset_in_device_pixels, Gfx::FloatPoint main_thread_offset_in_device_pixels, Gfx::IntRect viewport_rect, Compositing::ScrollAnimationKind, Compositing::SmoothScrollInitiator, Optional<Compositing::AsyncScrollOperationID> operation_to_continue);
void cancel_smooth_scroll(Web::AsyncScrollNodeStableID);
- Gfx::FloatPoint elastic_overscroll_stretch_for_testing(Web::AsyncScrollNodeStableID);
+ String scroll_state_for_testing(Web::AsyncScrollNodeStableID stretched_scroller);
void synchronize_for_testing();
Optional<Compositing::FirstWheelStepRouteForTesting> route_first_wheel_step_for_testing(Gfx::FloatPoint position, Gfx::FloatPoint delta_in_css_pixels);
void begin_input_trace_for_testing();
@@ -124,7 +124,7 @@ public:
Gfx::FloatPoint delta_in_device_pixels, Gfx::IntRect viewport_rect, Web::WheelDeltaPrecision, Web::ScrollGesturePhase, u32 modifiers, Compositing::AsyncScrollOperationTracking, Compositing::WheelStepDispatch, u64 input_event_id);
Compositing::AsyncScrollEnqueueResult smooth_scroll_to(Web::CompositorContextId, Web::AsyncScrollNodeStableID, Gfx::FloatPoint offset_in_device_pixels, Gfx::FloatPoint main_thread_offset_in_device_pixels, Gfx::IntRect viewport_rect, Compositing::ScrollAnimationKind, Compositing::SmoothScrollInitiator, Optional<Compositing::AsyncScrollOperationID> operation_to_continue);
void cancel_smooth_scroll(Web::CompositorContextId, Web::AsyncScrollNodeStableID);
- Gfx::FloatPoint elastic_overscroll_stretch_for_testing(Web::CompositorContextId, Web::AsyncScrollNodeStableID);
+ String scroll_state_for_testing(Web::CompositorContextId, Web::AsyncScrollNodeStableID stretched_scroller);
void synchronize_for_testing();
Optional<Compositing::FirstWheelStepRouteForTesting> route_first_wheel_step_for_testing(Web::CompositorContextId, Gfx::FloatPoint position, Gfx::FloatPoint delta_in_css_pixels);
void begin_input_trace_for_testing(Web::CompositorContextId);
diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cpp
index 99da255c261..ec605b9cffa 100644
--- a/Libraries/LibWeb/Internals/Internals.cpp
+++ b/Libraries/LibWeb/Internals/Internals.cpp
@@ -865,38 +865,73 @@ void Internals::wheel(double x, double y, double delta_x, double delta_y, bool p
wheel(promise, x, y, delta_x, delta_y, precise, phase);
}
-static Gfx::FloatPoint elastic_overscroll_stretch_in_css_pixels(HTML::Window& window, GC::Ptr<DOM::Element> scroller)
+static JS::Value wrapped_node_with_unique_id(HTML::Window& window, Optional<UniqueNodeID> node_id)
{
- auto& document = window.associated_document();
- auto navigable = document.navigable();
- if (!navigable || !navigable->has_compositor_context())
- return {};
+ auto* node = node_id.has_value() ? DOM::Node::from_unique_id(*node_id) : nullptr;
+ if (!node)
+ return JS::js_null();
+ auto& realm = HTML::relevant_realm(window);
+ return Bindings::wrap(Bindings::host_defined_wrapper_world(realm), realm, GC::Ref<DOM::Node> { *node });
+}
- Web::AsyncScrollNodeStableID stable_node_id { .node_id = document.unique_id(), .kind = Web::AsyncScrollNodeKind::Viewport };
- if (scroller) {
- Layout::ForcedReadScope read { document };
- document.update_layout(DOM::UpdateLayoutReason::InternalsHitTest);
- auto const* scrolling_box = scroller->layout_node(read);
- if (!scrolling_box)
- return {};
- auto scroller_stable_node_id = Painting::async_scroll_node_stable_id(*scrolling_box);
- if (!scroller_stable_node_id.has_value())
- return {};
- stable_node_id = *scroller_stable_node_id;
+// A JSON report of a testing message as a script reads it, made of objects without a prototype like the other objects
+// these hooks return.
+static JS::Value json_value_to_js_value(HTML::Window& window, JsonValue const& value)
+{
+ auto& realm = HTML::relevant_realm(window);
+ if (value.is_null())
+ return JS::js_null();
+ if (value.is_bool())
+ return JS::Value(value.as_bool());
+ if (value.is_number())
+ return JS::Value(value.get_double_with_precision_loss().value());
+ if (value.is_string())
+ return JS::PrimitiveString::create(window.vm(), Utf16String::from_utf8(value.as_string()));
+ if (value.is_array()) {
+ auto const& values = value.as_array().values();
+ auto array = MUST(JS::Array::create(realm, values.size()));
+ for (size_t i = 0; i < values.size(); ++i)
+ MUST(array->create_data_property_or_throw(i, json_value_to_js_value(window, values[i])));
+ return array;
}
-
- auto stretch_in_device_pixels = navigable->compositor_context().elastic_overscroll_stretch_for_testing(stable_node_id);
- return stretch_in_device_pixels.scaled(static_cast<float>(1 / navigable->page().client().device_pixels_per_css_pixel()));
+ auto object = JS::Object::create(realm, nullptr);
+ value.as_object().for_each_member([&](String const& name, JsonValue const& member) {
+ object->define_direct_property(Utf16FlyString::from_utf8(name), json_value_to_js_value(window, member), JS::default_attributes);
+ });
+ return object;
}
-double Internals::elastic_overscroll_stretch_x(GC::Ptr<DOM::Element> scroller)
+// A scrolling state as a script reads it, with the document it is the state of.
+static GC::Ref<JS::Object> scrolling_state_report_to_object(HTML::Window& window, JsonObject const& report)
{
- return elastic_overscroll_stretch_in_css_pixels(window(), scroller).x();
+ auto object = GC::Ref { json_value_to_js_value(window, report).as_object() };
+ auto document_id = report.get_i64("documentID"sv).map([](i64 id) { return UniqueNodeID { id }; });
+ object->define_direct_property("document"_utf16_fly_string, wrapped_node_with_unique_id(window, document_id), JS::default_attributes);
+ return object;
}
-double Internals::elastic_overscroll_stretch_y(GC::Ptr<DOM::Element> scroller)
+GC::Ref<JS::Object> Internals::compositor_scroll_state(GC::Ptr<DOM::Element> scroller)
{
- return elastic_overscroll_stretch_in_css_pixels(window(), scroller).y();
+ let_compositor_take_in_every_rendered_frame(window());
+
+ auto& document = window().associated_document();
+ Web::AsyncScrollNodeStableID stretched_scroller { .node_id = document.unique_id(), .kind = Web::AsyncScrollNodeKind::Viewport };
+ if (scroller) {
+ Layout::ForcedReadScope read { document };
+ document.update_layout(DOM::UpdateLayoutReason::InternalsHitTest);
+ if (auto const* scrolling_box = scroller->layout_node(read)) {
+ if (auto scroller_stable_node_id = Painting::async_scroll_node_stable_id(*scrolling_box); scroller_stable_node_id.has_value())
+ stretched_scroller = *scroller_stable_node_id;
+ }
+ }
+
+ String scroll_state;
+ if (auto navigable = document.navigable(); navigable && navigable->has_compositor_context())
+ scroll_state = navigable->compositor_context().scroll_state_for_testing(stretched_scroller);
+ auto report = JsonValue::from_string(scroll_state);
+ if (report.is_error() || !report.value().is_object())
+ return scrolling_state_report_to_object(window(), Compositing::async_scrolling_state_to_json({}));
+ return scrolling_state_report_to_object(window(), report.value().as_object());
}
void Internals::pinch(double x, double y, double scale_delta, WebIDL::UnsignedShort modifiers)
@@ -1307,15 +1342,6 @@ static Gfx::FloatPoint device_position_as_float_point(DevicePixelPoint position)
return { static_cast<float>(position.x().value()), static_cast<float>(position.y().value()) };
}
-static JS::Value wrapped_node_with_unique_id(HTML::Window& window, Optional<UniqueNodeID> node_id)
-{
- auto* node = node_id.has_value() ? DOM::Node::from_unique_id(*node_id) : nullptr;
- if (!node)
- return JS::js_null();
- auto& realm = HTML::relevant_realm(window);
- return Bindings::wrap(Bindings::host_defined_wrapper_world(realm), realm, GC::Ref<DOM::Node> { *node });
-}
-
// A scroller as the input hooks describe it: the document for its viewport, or the element whose box scrolls, with the
// pseudo-element that generated the box, if any.
static void define_scroller_properties(HTML::Window& window, JS::Object& object, Optional<AsyncScrollNodeStableID> scroller)
@@ -2996,100 +3022,16 @@ GC::Ref<JS::Object> Internals::style_invalidation_counters_object() const
return object;
}
-static GC::Ref<JS::Object> async_scrolling_state_to_object(HTML::Window& window, Compositing::AsyncScrollingState const& state)
-{
- auto& realm = HTML::relevant_realm(window);
- auto object = JS::Object::create(realm, nullptr);
-
- auto scroll_nodes = MUST(JS::Array::create(realm, state.scroll_nodes.size()));
- for (size_t i = 0; i < state.scroll_nodes.size(); ++i) {
- auto const& scroll_node = state.scroll_nodes[i];
- auto node = JS::Object::create(realm, nullptr);
- node->define_direct_property("documentID"_utf16_fly_string, JS::Value(static_cast<double>(scroll_node.node_id.document_id.value())), JS::default_attributes);
- node->define_direct_property("scrollNodeIndex"_utf16_fly_string, JS::Value(scroll_node.node_id.scroll_node_index.value()), JS::default_attributes);
- node->define_direct_property("parentDocumentID"_utf16_fly_string, JS::Value(scroll_node.parent_node_id.has_value() ? static_cast<double>(scroll_node.parent_node_id->document_id.value()) : 0), JS::default_attributes);
- node->define_direct_property("parentScrollNodeIndex"_utf16_fly_string, JS::Value(scroll_node.parent_node_id.has_value() ? scroll_node.parent_node_id->scroll_node_index.value() : 0), JS::default_attributes);
- node->define_direct_property("isViewport"_utf16_fly_string, JS::Value(scroll_node.is_viewport), JS::default_attributes);
- MUST(scroll_nodes->create_data_property_or_throw(i, node));
- }
-
- auto rect_to_object = [&](CSSPixelRect const& rect) {
- auto rect_object = JS::Object::create(realm, nullptr);
- rect_object->define_direct_property("x"_utf16_fly_string, JS::Value(rect.x().to_double()), JS::default_attributes);
- rect_object->define_direct_property("y"_utf16_fly_string, JS::Value(rect.y().to_double()), JS::default_attributes);
- rect_object->define_direct_property("width"_utf16_fly_string, JS::Value(rect.width().to_double()), JS::default_attributes);
- rect_object->define_direct_property("height"_utf16_fly_string, JS::Value(rect.height().to_double()), JS::default_attributes);
- return rect_object;
- };
- auto point_to_object = [&](CSSPixelPoint const& point) {
- auto point_object = JS::Object::create(realm, nullptr);
- point_object->define_direct_property("x"_utf16_fly_string, JS::Value(point.x().to_double()), JS::default_attributes);
- point_object->define_direct_property("y"_utf16_fly_string, JS::Value(point.y().to_double()), JS::default_attributes);
- return point_object;
- };
- auto keyword_to_string = [&](auto keyword) {
- auto css_keyword = [](auto keyword) {
- if constexpr (IsSame<decltype(keyword), Compositing::SnapStrictness>)
- return static_cast<CSS::ScrollSnapStrictness>(to_underlying(keyword));
- else
- return static_cast<CSS::ScrollSnapAlign>(to_underlying(keyword));
- };
- return JS::PrimitiveString::create(realm.vm(), Utf16String::from_utf8(CSS::to_string(css_keyword(keyword))));
- };
-
- auto snap_containers = MUST(JS::Array::create(realm, state.snap_containers.size()));
- for (size_t i = 0; i < state.snap_containers.size(); ++i) {
- auto const& snap_container = state.snap_containers[i];
- auto container = JS::Object::create(realm, nullptr);
- container->define_direct_property("documentID"_utf16_fly_string, JS::Value(static_cast<double>(snap_container.node_id.document_id.value())), JS::default_attributes);
- container->define_direct_property("scrollNodeIndex"_utf16_fly_string, JS::Value(snap_container.node_id.scroll_node_index.value()), JS::default_attributes);
- container->define_direct_property("snapport"_utf16_fly_string, rect_to_object(snap_container.geometry.snapport), JS::default_attributes);
- container->define_direct_property("minScrollOffset"_utf16_fly_string, point_to_object(snap_container.geometry.min_scroll_offset), JS::default_attributes);
- container->define_direct_property("maxScrollOffset"_utf16_fly_string, point_to_object(snap_container.geometry.max_scroll_offset), JS::default_attributes);
- container->define_direct_property("strictness"_utf16_fly_string, keyword_to_string(snap_container.geometry.strictness), JS::default_attributes);
- container->define_direct_property("snapsX"_utf16_fly_string, JS::Value(snap_container.geometry.axes.x), JS::default_attributes);
- container->define_direct_property("snapsY"_utf16_fly_string, JS::Value(snap_container.geometry.axes.y), JS::default_attributes);
- container->define_direct_property("horizontalWritingMode"_utf16_fly_string, JS::Value(snap_container.geometry.horizontal_writing_mode), JS::default_attributes);
-
- auto areas = MUST(JS::Array::create(realm, snap_container.areas.size()));
- for (size_t area_index = 0; area_index < snap_container.areas.size(); ++area_index) {
- auto const& snap_area = snap_container.areas[area_index];
- auto area = JS::Object::create(realm, nullptr);
- area->define_direct_property("nodeID"_utf16_fly_string, JS::Value(static_cast<double>(snap_area.identity.node_id.value())), JS::default_attributes);
- area->define_direct_property("pseudoElementType"_utf16_fly_string, JS::Value(snap_area.identity.pseudo_element_type), JS::default_attributes);
- area->define_direct_property("rect"_utf16_fly_string, rect_to_object(snap_area.rect), JS::default_attributes);
- area->define_direct_property("alignX"_utf16_fly_string, keyword_to_string(snap_area.align_x), JS::default_attributes);
- area->define_direct_property("alignY"_utf16_fly_string, keyword_to_string(snap_area.align_y), JS::default_attributes);
- area->define_direct_property("alwaysStop"_utf16_fly_string, JS::Value(snap_area.always_stop), JS::default_attributes);
- MUST(areas->create_data_property_or_throw(area_index, area));
- }
- container->define_direct_property("areas"_utf16_fly_string, areas, JS::default_attributes);
- MUST(snap_containers->create_data_property_or_throw(i, container));
- }
-
- object->define_direct_property("scrollNodeCount"_utf16_fly_string, JS::Value(state.scroll_nodes.size()), JS::default_attributes);
- object->define_direct_property("scrollNodes"_utf16_fly_string, scroll_nodes, JS::default_attributes);
- object->define_direct_property("snapContainers"_utf16_fly_string, snap_containers, JS::default_attributes);
- object->define_direct_property("devicePixelsPerCssPixel"_utf16_fly_string, JS::Value(state.device_pixels_per_css_pixel), JS::default_attributes);
- object->define_direct_property("hasBlockingWheelEventListeners"_utf16_fly_string, JS::Value(state.has_blocking_wheel_event_listeners), JS::default_attributes);
- object->define_direct_property("blockingWheelEventRegionCount"_utf16_fly_string, JS::Value(state.blocking_wheel_event_regions.size()), JS::default_attributes);
- object->define_direct_property("mainThreadWheelEventRegionCount"_utf16_fly_string, JS::Value(state.main_thread_wheel_event_regions.size()), JS::default_attributes);
- object->define_direct_property("wheelEventListenerStateGeneration"_utf16_fly_string, JS::Value(state.wheel_event_listener_state_generation), JS::default_attributes);
- object->define_direct_property("blockingWheelEventRegionsAreCurrent"_utf16_fly_string, JS::Value(state.has_blocking_wheel_event_listeners), JS::default_attributes);
- object->define_direct_property("hasBlockingWheelEventRegionCoveringViewport"_utf16_fly_string, JS::Value(state.has_blocking_wheel_event_region_covering_viewport), JS::default_attributes);
- return object;
-}
-
GC::Ref<JS::Object> Internals::async_scrolling_state_object()
{
- return async_scrolling_state_to_object(window(), async_scrolling_state());
+ return scrolling_state_report_to_object(window(), Compositing::async_scrolling_state_to_json(async_scrolling_state()));
}
GC::Ref<JS::Object> Internals::recorded_async_scrolling_state_object()
{
auto* display_list = window().associated_document().paint_state().display_list_used_as_paint_command_cache_source();
auto state = display_list ? Compositing::async_scrolling_state_from_display_list(*display_list) : Compositing::AsyncScrollingState {};
- return async_scrolling_state_to_object(window(), state);
+ return scrolling_state_report_to_object(window(), Compositing::async_scrolling_state_to_json(state));
}
}
diff --git a/Libraries/LibWeb/Internals/Internals.h b/Libraries/LibWeb/Internals/Internals.h
index 775fa4d8092..279ab9c8291 100644
--- a/Libraries/LibWeb/Internals/Internals.h
+++ b/Libraries/LibWeb/Internals/Internals.h
@@ -113,8 +113,7 @@ public:
void click_and_hold(double x, double y, WebIDL::UnsignedShort click_count, WebIDL::UnsignedShort button, WebIDL::UnsignedShort modifiers);
void wheel(GC::Ref<WebIDL::Promise>, double x, double y, double delta_x, double delta_y, bool precise, Bindings::ScrollGesturePhase);
void wheel(double x, double y, double delta_x, double delta_y, bool precise, Bindings::ScrollGesturePhase, GC::Ref<WebIDL::Promise>);
- double elastic_overscroll_stretch_x(GC::Ptr<DOM::Element> scroller);
- double elastic_overscroll_stretch_y(GC::Ptr<DOM::Element> scroller);
+ GC::Ref<JS::Object> compositor_scroll_state(GC::Ptr<DOM::Element> scroller);
void pinch(double x, double y, double scale_delta, WebIDL::UnsignedShort modifiers);
void reset_zoom();
diff --git a/Libraries/LibWeb/Internals/Internals.idl b/Libraries/LibWeb/Internals/Internals.idl
index c9b9bd5791f..fd28a36c423 100644
--- a/Libraries/LibWeb/Internals/Internals.idl
+++ b/Libraries/LibWeb/Internals/Internals.idl
@@ -88,10 +88,10 @@ interface Internals {
undefined click(double x, double y, optional unsigned short clickCount = 1, optional unsigned short button = 0, optional unsigned short modifiers = 0);
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");
- // How far, in CSS pixels, the compositor presents a scroller past the edges of its scroll range. The scroller is
- // the viewport if none is given.
- double elasticOverscrollStretchX(optional Element? scroller = null);
- double elasticOverscrollStretchY(optional Element? scroller = null);
+ // 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.
+ object compositorScrollState(optional Element? scroller = null);
undefined pinch(double x, double y, double scaleDelta, optional unsigned short modifiers = 0);
undefined resetZoom();
diff --git a/Services/Compositor/CompositorState.cpp b/Services/Compositor/CompositorState.cpp
index 8768aaddb6a..1d62de7a70e 100644
--- a/Services/Compositor/CompositorState.cpp
+++ b/Services/Compositor/CompositorState.cpp
@@ -1212,12 +1212,12 @@ void CompositorState::set_scrolls_elastically(bool scrolls_elastically)
context_entry.value->set_scrolls_elastically(scrolls_elastically);
}
-Gfx::FloatPoint CompositorState::elastic_overscroll_stretch_for_testing(Web::CompositorContextId context_id, Web::AsyncScrollNodeStableID stable_node_id) const
+String CompositorState::scroll_state_for_testing(Web::CompositorContextId context_id, Web::AsyncScrollNodeStableID stretched_scroller) const
{
auto const* context = context_if_present(context_id);
if (!context)
return {};
- return context->elastic_overscroll_stretch_for_testing(stable_node_id);
+ return context->scroll_state_for_testing(stretched_scroller);
}
Optional<Compositing::FirstWheelStepRouteForTesting> CompositorState::route_first_wheel_step_for_testing(Web::CompositorContextId context_id, Gfx::FloatPoint position, Gfx::FloatPoint delta_in_css_pixels)
diff --git a/Services/Compositor/CompositorState.h b/Services/Compositor/CompositorState.h
index 13973a6d7e0..b0f0acdf3d6 100644
--- a/Services/Compositor/CompositorState.h
+++ b/Services/Compositor/CompositorState.h
@@ -126,7 +126,7 @@ public:
void set_client_gpu_presentation_capability(bool supported, u64 adapter_luid);
void set_synthesizes_scroll_momentum(bool);
void set_scrolls_elastically(bool);
- Gfx::FloatPoint elastic_overscroll_stretch_for_testing(Web::CompositorContextId, Web::AsyncScrollNodeStableID) const;
+ String scroll_state_for_testing(Web::CompositorContextId, Web::AsyncScrollNodeStableID stretched_scroller) const;
Optional<Compositing::FirstWheelStepRouteForTesting> route_first_wheel_step_for_testing(Web::CompositorContextId, Gfx::FloatPoint position, Gfx::FloatPoint delta_in_css_pixels);
void begin_input_trace_for_testing(Web::CompositorContextId);
Vector<Web::InputTraceRecord> take_input_trace_for_testing(Web::CompositorContextId);
diff --git a/Services/Compositor/CompositorWebContentServer.ipc b/Services/Compositor/CompositorWebContentServer.ipc
index 407cf411c9d..424a4729003 100644
--- a/Services/Compositor/CompositorWebContentServer.ipc
+++ b/Services/Compositor/CompositorWebContentServer.ipc
@@ -63,7 +63,7 @@ endpoint CompositorWebContentServer
async_scroll_by(Web::CompositorContextId context_id, Web::UniqueNodeID document_id, Gfx::FloatPoint position, Gfx::FloatPoint delta, Gfx::IntRect viewport_rect, Web::WheelDeltaPrecision wheel_delta_precision, Web::ScrollGesturePhase scroll_gesture_phase, u32 modifiers, Compositing::AsyncScrollOperationTracking operation_tracking, Compositing::WheelStepDispatch wheel_step_dispatch, u64 input_event_id) => (Compositing::AsyncScrollEnqueueResult result)
smooth_scroll_to(Web::CompositorContextId context_id, Web::AsyncScrollNodeStableID stable_node_id, Gfx::FloatPoint offset, Gfx::FloatPoint main_thread_offset, Gfx::IntRect viewport_rect, Compositing::ScrollAnimationKind animation_kind, Compositing::SmoothScrollInitiator initiator, Optional<Compositing::AsyncScrollOperationID> operation_to_continue) => (Compositing::AsyncScrollEnqueueResult result)
cancel_smooth_scroll(Web::CompositorContextId context_id, Web::AsyncScrollNodeStableID stable_node_id) =|
- elastic_overscroll_stretch_for_testing(Web::CompositorContextId context_id, Web::AsyncScrollNodeStableID stable_node_id) => (Gfx::FloatPoint stretch)
+ scroll_state_for_testing(Web::CompositorContextId context_id, Web::AsyncScrollNodeStableID stretched_scroller) => (String scroll_state)
// Returns once the compositor has handled every message WebContent sent before it.
synchronize_for_testing() => ()
route_first_wheel_step_for_testing(Web::CompositorContextId context_id, Gfx::FloatPoint position, Gfx::FloatPoint delta_in_css_pixels) => (Optional<Web::InputRoutingDecision> decision, Optional<Web::AsyncScrollNodeStableID> scroller, Optional<Web::UniqueNodeID> document_id)
diff --git a/Services/Compositor/ConnectionFromWebContent.cpp b/Services/Compositor/ConnectionFromWebContent.cpp
index 6cc48fe8478..563349548f7 100644
--- a/Services/Compositor/ConnectionFromWebContent.cpp
+++ b/Services/Compositor/ConnectionFromWebContent.cpp
@@ -427,11 +427,11 @@ Messages::CompositorWebContentServer::SmoothScrollToResponse ConnectionFromWebCo
return result;
}
-Messages::CompositorWebContentServer::ElasticOverscrollStretchForTestingResponse ConnectionFromWebContent::elastic_overscroll_stretch_for_testing(Web::CompositorContextId context_id, Web::AsyncScrollNodeStableID stable_node_id)
+Messages::CompositorWebContentServer::ScrollStateForTestingResponse ConnectionFromWebContent::scroll_state_for_testing(Web::CompositorContextId context_id, Web::AsyncScrollNodeStableID stretched_scroller)
{
if (!context_is_owned_by_this_connection(context_id))
- return Gfx::FloatPoint {};
- return m_compositor_state->elastic_overscroll_stretch_for_testing(context_id, stable_node_id);
+ return String {};
+ return m_compositor_state->scroll_state_for_testing(context_id, stretched_scroller);
}
Messages::CompositorWebContentServer::RouteFirstWheelStepForTestingResponse ConnectionFromWebContent::route_first_wheel_step_for_testing(Web::CompositorContextId context_id, Gfx::FloatPoint position, Gfx::FloatPoint delta_in_css_pixels)
diff --git a/Services/Compositor/ConnectionFromWebContent.h b/Services/Compositor/ConnectionFromWebContent.h
index 9429b0fedeb..5720ef01b4b 100644
--- a/Services/Compositor/ConnectionFromWebContent.h
+++ b/Services/Compositor/ConnectionFromWebContent.h
@@ -76,7 +76,7 @@ private:
virtual void invalidate_keyboard_scroll_state(Web::CompositorContextId, u64 generation) override;
virtual Messages::CompositorWebContentServer::AsyncScrollByResponse async_scroll_by(Web::CompositorContextId, Web::UniqueNodeID document_id, Gfx::FloatPoint position, Gfx::FloatPoint delta, Gfx::IntRect viewport_rect, Web::WheelDeltaPrecision, Web::ScrollGesturePhase, u32 modifiers, Compositing::AsyncScrollOperationTracking, Compositing::WheelStepDispatch, u64 input_event_id) override;
virtual Messages::CompositorWebContentServer::SmoothScrollToResponse smooth_scroll_to(Web::CompositorContextId, Web::AsyncScrollNodeStableID, Gfx::FloatPoint offset, Gfx::FloatPoint main_thread_offset, Gfx::IntRect viewport_rect, Compositing::ScrollAnimationKind, Compositing::SmoothScrollInitiator, Optional<Compositing::AsyncScrollOperationID> operation_to_continue) override;
- virtual Messages::CompositorWebContentServer::ElasticOverscrollStretchForTestingResponse elastic_overscroll_stretch_for_testing(Web::CompositorContextId, Web::AsyncScrollNodeStableID) override;
+ virtual Messages::CompositorWebContentServer::ScrollStateForTestingResponse scroll_state_for_testing(Web::CompositorContextId, Web::AsyncScrollNodeStableID) override;
virtual void synchronize_for_testing() override { }
virtual Messages::CompositorWebContentServer::RouteFirstWheelStepForTestingResponse route_first_wheel_step_for_testing(Web::CompositorContextId, Gfx::FloatPoint position, Gfx::FloatPoint delta_in_css_pixels) override;
virtual void begin_input_trace_for_testing(Web::CompositorContextId) override;
diff --git a/Services/Compositor/ContextState.cpp b/Services/Compositor/ContextState.cpp
index 111cf79976a..853bcafd809 100644
--- a/Services/Compositor/ContextState.cpp
+++ b/Services/Compositor/ContextState.cpp
@@ -5,6 +5,7 @@
*/
#include <AK/GenericShorthands.h>
+#include <AK/JsonObject.h>
#include <AK/Math.h>
#include <AK/StdLibExtras.h>
#include <Compositor/CompositorState.h>
@@ -1255,9 +1256,23 @@ 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), document_id };
}
-Gfx::FloatPoint ContextState::elastic_overscroll_stretch_for_testing(Web::AsyncScrollNodeStableID stable_node_id) const
+String ContextState::scroll_state_for_testing(Web::AsyncScrollNodeStableID stretched_scroller) const
{
- return m_elastic_overscroll_controller.stretch_of(stable_node_id);
+ 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 {});
+
+ auto admission = m_wheel_gesture_routing.admission();
+ auto admission_name = admission == Compositing::WheelRoutingAdmission::Accepted
+ ? "accepted"sv
+ : 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()));
+ JsonObject stretch_object;
+ stretch_object.set("x"sv, stretch.x());
+ stretch_object.set("y"sv, stretch.y());
+ scroll_state.set("stretch"sv, move(stretch_object));
+ return scroll_state.serialized();
}
Optional<Compositing::ScrollStateSnapshot> ContextState::scroll_state_snapshot_stretched_by_elastic_overscrolls() const
diff --git a/Services/Compositor/ContextState.h b/Services/Compositor/ContextState.h
index 92e1ded21da..637c4dc68c2 100644
--- a/Services/Compositor/ContextState.h
+++ b/Services/Compositor/ContextState.h
@@ -155,7 +155,8 @@ public:
Optional<ScrollFlingStep> interrupt_scroll_fling(Web::MouseEvent const&, Optional<MonotonicTime> now_for_testing = {});
void set_scrolls_elastically(bool);
Optional<Gfx::IntRect> advance_elastic_overscroll_rebounds(MonotonicTime frame_time);
- Gfx::FloatPoint elastic_overscroll_stretch_for_testing(Web::AsyncScrollNodeStableID) const;
+ // 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;
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);
diff --git a/Tests/LibWeb/Text/expected/Internals/internals-object-results-receiver-realm.txt b/Tests/LibWeb/Text/expected/Internals/internals-object-results-receiver-realm.txt
index 52ab8753e2c..524e5a65e12 100644
--- a/Tests/LibWeb/Text/expected/Internals/internals-object-results-receiver-realm.txt
+++ b/Tests/LibWeb/Text/expected/Internals/internals-object-results-receiver-realm.txt
@@ -1,5 +1,5 @@
style counters has null prototype: true
style counters has reaction batches: true
-async state has null prototype: true
-async scrollNodes uses iframe Array: false
-async scrollNodes uses top Array: true
+compositor scroll state has null prototype: true
+compositor scroll state scrollNodes uses iframe Array: false
+compositor scroll state scrollNodes uses top Array: true
diff --git a/Tests/LibWeb/Text/expected/async-scrolling/blocking-wheel-event-regions.txt b/Tests/LibWeb/Text/expected/async-scrolling/blocking-wheel-event-regions.txt
index bafc24231f9..66f7710f228 100644
--- a/Tests/LibWeb/Text/expected/async-scrolling/blocking-wheel-event-regions.txt
+++ b/Tests/LibWeb/Text/expected/async-scrolling/blocking-wheel-event-regions.txt
@@ -1,25 +1,25 @@
initial:
- regions current: false
+ blocking listeners: false
viewport blocked: false
blocking regions: 0
passive element listener:
- regions current: false
+ blocking listeners: false
viewport blocked: false
blocking regions: 0
blocking element listener:
- regions current: true
+ blocking listeners: true
viewport blocked: false
blocking regions: 1
removed element listener:
- regions current: false
+ blocking listeners: false
viewport blocked: false
blocking regions: 0
blocking window listener:
- regions current: true
+ blocking listeners: true
viewport blocked: true
blocking regions: 0
removed window listener:
- regions current: false
+ blocking listeners: false
viewport blocked: false
blocking regions: 0
display list after blocking element listener:
diff --git a/Tests/LibWeb/Text/input/Internals/internals-object-results-receiver-realm.html b/Tests/LibWeb/Text/input/Internals/internals-object-results-receiver-realm.html
index 7d1f86e4c90..ab4f4bcf1de 100644
--- a/Tests/LibWeb/Text/input/Internals/internals-object-results-receiver-realm.html
+++ b/Tests/LibWeb/Text/input/Internals/internals-object-results-receiver-realm.html
@@ -10,9 +10,9 @@
println(`style counters has null prototype: ${Object.getPrototypeOf(counters) === null}`);
println(`style counters has reaction batches: ${"styleEngineReactionBatchRuns" in counters}`);
- const asyncState = other.internals.asyncScrollingState.call(internals);
- println(`async state has null prototype: ${Object.getPrototypeOf(asyncState) === null}`);
- println(`async scrollNodes uses iframe Array: ${asyncState.scrollNodes instanceof other.Array}`);
- println(`async scrollNodes uses top Array: ${asyncState.scrollNodes instanceof Array}`);
+ const scrollState = other.internals.compositorScrollState.call(internals);
+ println(`compositor scroll state has null prototype: ${Object.getPrototypeOf(scrollState) === null}`);
+ println(`compositor scroll state scrollNodes uses iframe Array: ${scrollState.scrollNodes instanceof other.Array}`);
+ println(`compositor scroll state scrollNodes uses top Array: ${scrollState.scrollNodes instanceof Array}`);
});
</script>
diff --git a/Tests/LibWeb/Text/input/async-scrolling/blocking-wheel-event-regions.html b/Tests/LibWeb/Text/input/async-scrolling/blocking-wheel-event-regions.html
index a1f0ad32536..cfe94d01b8b 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/blocking-wheel-event-regions.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/blocking-wheel-event-regions.html
@@ -36,7 +36,7 @@
function dump(output, label) {
const state = internals.asyncScrollingState();
output.push(`${label}:`);
- output.push(` regions current: ${state.blockingWheelEventRegionsAreCurrent}`);
+ output.push(` blocking listeners: ${state.hasBlockingWheelEventListeners}`);
output.push(` viewport blocked: ${state.hasBlockingWheelEventRegionCoveringViewport}`);
output.push(` blocking regions: ${state.blockingWheelEventRegionCount}`);
}
diff --git a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-after-the-page-cancels-the-first-step.html b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-after-the-page-cancels-the-first-step.html
index ab0c55f2a2a..bc02d2de648 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-after-the-page-cancels-the-first-step.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-after-the-page-cancels-the-first-step.html
@@ -22,18 +22,18 @@
// The page cancels the first step, which neither scrolls nor stretches anything.
await internals.wheelThroughUIProcess(400, 300, 0, -200, true, "ongoing");
- println(`after the canceled step: viewport stretch=${internals.elasticOverscrollStretchY()} window.scrollY=${window.scrollY}`);
+ println(`after the canceled step: viewport stretch=${internals.compositorScrollState().stretch.y} window.scrollY=${window.scrollY}`);
// The page can cancel the next step too. Once it lets a step through, that step and the rest of the gesture
// stretch the page without asking the page again.
await internals.wheelThroughUIProcess(400, 300, 0, -200, true, "ongoing");
await internals.wheelThroughUIProcess(400, 300, 0, -200, true, "ongoing");
- println(`after the steps let through: viewport stretch=${internals.elasticOverscrollStretchY()} window.scrollY=${window.scrollY}`);
+ println(`after the steps let through: viewport stretch=${internals.compositorScrollState().stretch.y} window.scrollY=${window.scrollY}`);
println(`wheel events the page could have canceled: ${cancelableWheelEvents} of ${wheelEvents}`);
await internals.wheelThroughUIProcess(400, 300, 0, 0, true, "ended");
- while (internals.elasticOverscrollStretchY() !== 0)
+ while (internals.compositorScrollState().stretch.y !== 0)
await animationFrame();
- println(`sprung back: viewport stretch=${internals.elasticOverscrollStretchY()} window.scrollY=${window.scrollY}`);
+ println(`sprung back: viewport stretch=${internals.compositorScrollState().stretch.y} window.scrollY=${window.scrollY}`);
});
</script>
diff --git a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-gesture-starting-at-an-edge.html b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-gesture-starting-at-an-edge.html
index f02c34089cf..d977049fb63 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-gesture-starting-at-an-edge.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-gesture-starting-at-an-edge.html
@@ -17,11 +17,11 @@
<div id="nested"><div></div></div>
<script>
function printState(label) {
- println(`${label}: viewport stretch=${internals.elasticOverscrollStretchX()},${internals.elasticOverscrollStretchY()} window.scrollY=${window.scrollY} nested stretch=${internals.elasticOverscrollStretchY(nested)} nested.scrollTop=${nested.scrollTop}`);
+ println(`${label}: viewport stretch=${internals.compositorScrollState().stretch.x},${internals.compositorScrollState().stretch.y} window.scrollY=${window.scrollY} nested stretch=${internals.compositorScrollState(nested).stretch.y} nested.scrollTop=${nested.scrollTop}`);
}
async function viewportSprungBack() {
- while (internals.elasticOverscrollStretchY() !== 0)
+ while (internals.compositorScrollState().stretch.y !== 0)
await animationFrame();
}
diff --git a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-needs-a-touchpad-gesture.html b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-needs-a-touchpad-gesture.html
index 0da0aca70b0..982a297a50d 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-needs-a-touchpad-gesture.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-needs-a-touchpad-gesture.html
@@ -24,10 +24,10 @@
// Precise deltas without a gesture phase never say when the fingers lift.
await internals.wheel(50, 50, 0, 410, true, "none");
- println(`precise wheel without a phase: nested.scrollTop=${nested.scrollTop} stretch=${internals.elasticOverscrollStretchY(nested)}`);
+ println(`precise wheel without a phase: nested.scrollTop=${nested.scrollTop} stretch=${internals.compositorScrollState(nested).stretch.y}`);
await scrollSettled(nested, () => nested.scrollTo(0, 190));
await scrollSettled(nested, () => internals.wheel(50, 50, 0, 410));
- println(`mouse wheel: nested.scrollTop=${nested.scrollTop} stretch=${internals.elasticOverscrollStretchY(nested)}`);
+ println(`mouse wheel: nested.scrollTop=${nested.scrollTop} stretch=${internals.compositorScrollState(nested).stretch.y}`);
});
</script>
diff --git a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-nested-navigable-at-its-extent-scrolls-the-page.html b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-nested-navigable-at-its-extent-scrolls-the-page.html
index 8c81ef626f8..623f905aa43 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-nested-navigable-at-its-extent-scrolls-the-page.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-nested-navigable-at-its-extent-scrolls-the-page.html
@@ -30,7 +30,7 @@
// A document in a frame passes a gesture it cannot scroll by on to the page instead of stretching.
await internals.wheel(100, 100, 0, 100, true, "ongoing");
- println(`after a gesture over the frame: window.scrollY=${window.scrollY} frame scrollY=${frameWindow.scrollY} viewport stretch=${internals.elasticOverscrollStretchY()}`);
+ println(`after a gesture over the frame: window.scrollY=${window.scrollY} frame scrollY=${frameWindow.scrollY} viewport stretch=${internals.compositorScrollState().stretch.y}`);
await internals.wheel(100, 100, 0, 0, true, "ended");
});
</script>
diff --git a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-of-a-scroller-under-a-wheel-listener.html b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-of-a-scroller-under-a-wheel-listener.html
index 60a9858242b..95e2b1d75d4 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-of-a-scroller-under-a-wheel-listener.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-of-a-scroller-under-a-wheel-listener.html
@@ -32,13 +32,13 @@
// the scroller to its top and stretches it past there, while the page neither scrolls nor stretches.
await internals.wheelThroughUIProcess(100, 100, 0, -100, true, "ongoing");
await internals.wheelThroughUIProcess(100, 100, 0, -100, true, "ongoing");
- println(`pulled past the top: scroller stretch=${internals.elasticOverscrollStretchY(scroller)} viewport stretch=${internals.elasticOverscrollStretchY()}`);
+ println(`pulled past the top: scroller stretch=${internals.compositorScrollState(scroller).stretch.y} viewport stretch=${internals.compositorScrollState().stretch.y}`);
println(`scroller.scrollTop=${scroller.scrollTop} window.scrollY=${window.scrollY}`);
println(`wheel events the page could have canceled: ${cancelableWheelEvents} of ${wheelEvents}`);
await internals.wheelThroughUIProcess(100, 100, 0, 0, true, "ended");
- while (internals.elasticOverscrollStretchY(scroller) !== 0)
+ while (internals.compositorScrollState(scroller).stretch.y !== 0)
await animationFrame();
- println(`sprung back: scroller stretch=${internals.elasticOverscrollStretchY(scroller)}`);
+ println(`sprung back: scroller stretch=${internals.compositorScrollState(scroller).stretch.y}`);
});
</script>
diff --git a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-springs-back.html b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-springs-back.html
index f027ea00235..1d8d7a4450f 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-springs-back.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-springs-back.html
@@ -23,10 +23,10 @@
await scrollSettled(nested, () => nested.scrollTo(0, 190));
await internals.wheel(50, 50, 0, 410, true, "ongoing");
- println(`held by the fingers: nested.scrollTop=${nested.scrollTop} stretch=${internals.elasticOverscrollStretchY(nested)}`);
+ println(`held by the fingers: nested.scrollTop=${nested.scrollTop} stretch=${internals.compositorScrollState(nested).stretch.y}`);
for (let frame = 0; frame < 5; frame++)
await animationFrame();
- println(`still held: stretch=${internals.elasticOverscrollStretchY(nested)}`);
+ println(`still held: stretch=${internals.compositorScrollState(nested).stretch.y}`);
let scrollEventCount = 0;
nested.addEventListener("scroll", () => scrollEventCount++);
@@ -34,10 +34,10 @@
let scrollTopChangedDuringRebound = false;
await internals.wheel(50, 50, 0, 0, true, "ended");
- let previousStretch = internals.elasticOverscrollStretchY(nested);
+ let previousStretch = internals.compositorScrollState(nested).stretch.y;
while (previousStretch !== 0) {
await animationFrame();
- const stretch = internals.elasticOverscrollStretchY(nested);
+ const stretch = internals.compositorScrollState(nested).stretch.y;
if (stretch > previousStretch)
stretchGrewDuringRebound = true;
if (nested.scrollTop !== 200)
@@ -47,7 +47,7 @@
await animationFrame();
await animationFrame();
- println(`sprung back: nested.scrollTop=${nested.scrollTop} stretch=${internals.elasticOverscrollStretchY(nested)}`);
+ println(`sprung back: nested.scrollTop=${nested.scrollTop} stretch=${internals.compositorScrollState(nested).stretch.y}`);
println(`stretch grew during the rebound: ${stretchGrewDuringRebound}`);
println(`scrollTop changed during the rebound: ${scrollTopChangedDuringRebound}`);
println(`scroll events during the rebound: ${scrollEventCount}`);
diff --git a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-stretches-scroller-at-its-edge.html b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-stretches-scroller-at-its-edge.html
index eca33d9bf18..239bd8afafb 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-stretches-scroller-at-its-edge.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-stretches-scroller-at-its-edge.html
@@ -17,7 +17,7 @@
<div id="nested"><div></div></div>
<script>
function printState(label) {
- println(`${label}: nested.scrollTop=${nested.scrollTop} nested stretch=${internals.elasticOverscrollStretchY(nested)} window.scrollY=${window.scrollY} viewport stretch=${internals.elasticOverscrollStretchY()}`);
+ println(`${label}: nested.scrollTop=${nested.scrollTop} nested stretch=${internals.compositorScrollState(nested).stretch.y} window.scrollY=${window.scrollY} viewport stretch=${internals.compositorScrollState().stretch.y}`);
}
promiseTest(async () => {
@@ -33,7 +33,7 @@
await internals.wheel(50, 50, 3, 100, true, "ongoing");
printState("pulling at the edge");
- println(`horizontal stretch: ${internals.elasticOverscrollStretchX(nested)}`);
+ println(`horizontal stretch: ${internals.compositorScrollState(nested).stretch.x}`);
// Fingers moving back relax the stretch before they scroll.
await internals.wheel(50, 50, 0, -100, true, "ongoing");
diff --git a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-through-the-ui-process.html b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-through-the-ui-process.html
index 644b620f5b7..366a041b3ae 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-through-the-ui-process.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-through-the-ui-process.html
@@ -22,18 +22,18 @@
// from, and stretches the page without asking the page first.
await internals.wheelThroughUIProcess(400, 300, 0, -200, true, "ongoing");
await internals.wheelThroughUIProcess(400, 300, 0, -200, true, "ongoing");
- println(`pulled past the top: viewport stretch=${internals.elasticOverscrollStretchY()} window.scrollY=${window.scrollY}`);
+ println(`pulled past the top: viewport stretch=${internals.compositorScrollState().stretch.y} window.scrollY=${window.scrollY}`);
println(`wheel events the page could have canceled: ${cancelableWheelEvents} of ${wheelEvents}`);
await internals.wheelThroughUIProcess(400, 300, 0, 0, true, "ended");
- while (internals.elasticOverscrollStretchY() !== 0)
+ while (internals.compositorScrollState().stretch.y !== 0)
await animationFrame();
- println(`sprung back: viewport stretch=${internals.elasticOverscrollStretchY()} window.scrollY=${window.scrollY}`);
+ println(`sprung back: viewport stretch=${internals.compositorScrollState().stretch.y} window.scrollY=${window.scrollY}`);
// A mouse wheel from the UI at the top of the page never stretches it.
await internals.wheelThroughUIProcess(400, 300, 0, -400);
await animationFrame();
await animationFrame();
- println(`mouse wheel: viewport stretch=${internals.elasticOverscrollStretchY()} window.scrollY=${window.scrollY}`);
+ println(`mouse wheel: viewport stretch=${internals.compositorScrollState().stretch.y} window.scrollY=${window.scrollY}`);
});
</script>
diff --git a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-under-a-wheel-listener-covering-the-viewport.html b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-under-a-wheel-listener-covering-the-viewport.html
index b994b2fe0ad..b95464bf36e 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-under-a-wheel-listener-covering-the-viewport.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/elastic-overscroll-under-a-wheel-listener-covering-the-viewport.html
@@ -22,12 +22,12 @@
// page past its top, and scrolls the rest of the gesture without asking the page again.
await internals.wheelThroughUIProcess(400, 300, 0, -200, true, "ongoing");
await internals.wheelThroughUIProcess(400, 300, 0, -200, true, "ongoing");
- println(`pulled past the top: viewport stretch=${internals.elasticOverscrollStretchY()} window.scrollY=${window.scrollY}`);
+ println(`pulled past the top: viewport stretch=${internals.compositorScrollState().stretch.y} window.scrollY=${window.scrollY}`);
println(`wheel events the page could have canceled: ${cancelableWheelEvents} of ${wheelEvents}`);
await internals.wheelThroughUIProcess(400, 300, 0, 0, true, "ended");
- while (internals.elasticOverscrollStretchY() !== 0)
+ while (internals.compositorScrollState().stretch.y !== 0)
await animationFrame();
- println(`sprung back: viewport stretch=${internals.elasticOverscrollStretchY()} window.scrollY=${window.scrollY}`);
+ println(`sprung back: viewport stretch=${internals.compositorScrollState().stretch.y} window.scrollY=${window.scrollY}`);
});
</script>
diff --git a/Tests/LibWeb/Text/input/async-scrolling/overscroll-behavior-decides-what-stretches.html b/Tests/LibWeb/Text/input/async-scrolling/overscroll-behavior-decides-what-stretches.html
index cc013d7ab26..46513de93dc 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/overscroll-behavior-decides-what-stretches.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/overscroll-behavior-decides-what-stretches.html
@@ -17,8 +17,8 @@
</style>
<div id="scroller"><div></div></div>
<script>
- const scrollerStretch = () => internals.elasticOverscrollStretchY(scroller);
- const pageStretch = () => internals.elasticOverscrollStretchY();
+ const scrollerStretch = () => internals.compositorScrollState(scroller).stretch.y;
+ const pageStretch = () => internals.compositorScrollState().stretch.y;
async function nothingIsStretched() {
while (scrollerStretch() !== 0 || pageStretch() !== 0)
diff --git a/Tests/LibWeb/Text/input/async-scrolling/overscroll-behavior-on-a-box-with-nothing-to-scroll.html b/Tests/LibWeb/Text/input/async-scrolling/overscroll-behavior-on-a-box-with-nothing-to-scroll.html
index 179196dbd2a..a997db87e42 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/overscroll-behavior-on-a-box-with-nothing-to-scroll.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/overscroll-behavior-on-a-box-with-nothing-to-scroll.html
@@ -29,7 +29,7 @@
for (let frame = 0; frame < 6; frame++)
await animationFrame();
await scrollOffsetStopsChanging(() => `${pageOffset()},${scroller.scrollTop}`);
- while (internals.elasticOverscrollStretchY(scroller) !== 0 || internals.elasticOverscrollStretchY() !== 0)
+ while (internals.compositorScrollState(scroller).stretch.y !== 0 || internals.compositorScrollState().stretch.y !== 0)
await animationFrame();
}
diff --git a/Tests/LibWeb/Text/input/async-scrolling/overscroll-behavior-stops-wheel-chaining.html b/Tests/LibWeb/Text/input/async-scrolling/overscroll-behavior-stops-wheel-chaining.html
index 399492fe539..d35512020ee 100644
--- a/Tests/LibWeb/Text/input/async-scrolling/overscroll-behavior-stops-wheel-chaining.html
+++ b/Tests/LibWeb/Text/input/async-scrolling/overscroll-behavior-stops-wheel-chaining.html
@@ -25,7 +25,7 @@
for (let frame = 0; frame < 6; frame++)
await animationFrame();
await scrollOffsetStopsChanging(() => `${pageOffset()},${scroller.scrollLeft},${scroller.scrollTop}`);
- while (internals.elasticOverscrollStretchX(scroller) !== 0 || internals.elasticOverscrollStretchY(scroller) !== 0)
+ while (internals.compositorScrollState(scroller).stretch.x !== 0 || internals.compositorScrollState(scroller).stretch.y !== 0)
await animationFrame();
}