Truly independent web browser
LibCompositing+Compositor: Key scroll nodes by their spatial node index
Aliaksandr Kalenik3706d790d392
diff --git a/Libraries/LibCompositing/Scrolling/AsyncScrollTree.cpp b/Libraries/LibCompositing/Scrolling/AsyncScrollTree.cppindex 740e1460851..18fc640104a 100644--- a/Libraries/LibCompositing/Scrolling/AsyncScrollTree.cpp+++ b/Libraries/LibCompositing/Scrolling/AsyncScrollTree.cpp@@ -50,10 +50,10 @@ Web::InputRoutingDecision input_routing_decision_for_first_wheel_step(WheelHitTeVERIFY_NOT_REACHED();}-AsyncScrollNode const* AsyncScrollTree::scroll_node_for_id(AsyncScrollNodeID node_id) const+AsyncScrollNode const* AsyncScrollTree::scroll_node_for_index(Compositing::SpatialNodeIndex scroll_node_index) const{for (auto const& node : m_scroll_nodes) {- if (node.node_id == node_id)+ if (node.scroll_node_index == scroll_node_index)return &node;}return nullptr;@@ -72,7 +72,7 @@ static bool node_chains_scroll_to_ancestors(AsyncScrollNode const& node, Gfx::Flreturn delta_is_mainly_vertical(delta) ? node.chains_scroll_to_ancestors_vertically : node.chains_scroll_to_ancestors_horizontally;}-WheelHitTestResult AsyncScrollTree::hit_test_result_for_scroll_node(AsyncScrollNodeID node_id, Gfx::FloatPoint delta, Function<Optional<Gfx::FloatPoint>(Web::AsyncScrollNodeStableID)> const& in_flight_destination_for, ReadonlySpan<AsyncScrollNodeID> scroll_nodes_behind_scroll_chaining_barriers) const+WheelHitTestResult AsyncScrollTree::hit_test_result_for_scroll_node(Compositing::SpatialNodeIndex scroll_node_index, Gfx::FloatPoint delta, Function<Optional<Gfx::FloatPoint>(Web::AsyncScrollNodeStableID)> const& in_flight_destination_for, ReadonlySpan<Compositing::SpatialNodeIndex> scroll_nodes_behind_scroll_chaining_barriers) const{auto can_take_step = [&](AsyncScrollNode const& node) {Optional<Gfx::FloatPoint> in_flight_destination;@@ -81,43 +81,43 @@ WheelHitTestResult AsyncScrollTree::hit_test_result_for_scroll_node(AsyncScrollNreturn can_scroll_node_from_offset_by_delta(node, in_flight_destination.value_or(scroll_offset_for_node(node, m_scroll_state_snapshot)), delta);};- for (auto const* node = scroll_node_for_id(node_id); node;) {+ for (auto const* node = scroll_node_for_index(scroll_node_index); node;) {// Only the main thread sees the box that keeps the scroll from this scroller, so it finds out whether the wheel// is under that box.- if (scroll_nodes_behind_scroll_chaining_barriers.contains_slow(node->node_id))+ if (scroll_nodes_behind_scroll_chaining_barriers.contains_slow(node->scroll_node_index))return { .outcome = WheelHitTestOutcome::BlockedByMainThreadRegion };if (can_take_step(*node))- return { .outcome = WheelHitTestOutcome::FoundScrollTarget, .node_id = node->node_id, .innermost_scroll_node_id = node_id };+ return { .outcome = WheelHitTestOutcome::FoundScrollTarget, .scroll_node_index = node->scroll_node_index, .innermost_scroll_node_index = scroll_node_index };if (!node_chains_scroll_to_ancestors(*node, delta))- return { .outcome = WheelHitTestOutcome::NoScrollTarget, .innermost_scroll_node_id = node_id, .node_keeping_the_scroll = node->node_id };- if (!node->parent_node_id.has_value())+ return { .outcome = WheelHitTestOutcome::NoScrollTarget, .innermost_scroll_node_index = scroll_node_index, .scroll_node_index_keeping_the_scroll = node->scroll_node_index };+ if (!node->parent_scroll_node_index.has_value())break;- node = scroll_node_for_id(*node->parent_node_id);+ node = scroll_node_for_index(*node->parent_scroll_node_index);}- return { .outcome = WheelHitTestOutcome::NoScrollTarget, .innermost_scroll_node_id = node_id };+ return { .outcome = WheelHitTestOutcome::NoScrollTarget, .innermost_scroll_node_index = scroll_node_index };}-Optional<AsyncScrollNodeID> AsyncScrollTree::outermost_scroll_node_wheel_scrollable_along_main_axis_of(AsyncScrollNodeID innermost_node_id, Gfx::FloatPoint delta) const+Optional<Compositing::SpatialNodeIndex> AsyncScrollTree::outermost_scroll_node_wheel_scrollable_along_main_axis_of(Compositing::SpatialNodeIndex innermost_scroll_node_index, Gfx::FloatPoint delta) const{- Optional<AsyncScrollNodeID> outermost_node_id;- auto node_id = innermost_node_id;+ Optional<Compositing::SpatialNodeIndex> outermost_scroll_node_index;+ auto scroll_node_index = innermost_scroll_node_index;for (size_t remaining_ancestors = m_scroll_nodes.size(); remaining_ancestors > 0; --remaining_ancestors) {- auto const* node = scroll_node_for_id(node_id);+ auto const* node = scroll_node_for_index(scroll_node_index);if (!node)break;if (delta_is_mainly_vertical(delta) ? node->can_be_wheel_scrolled_vertically : node->can_be_wheel_scrolled_horizontally)- outermost_node_id = node->node_id;- if (!node_chains_scroll_to_ancestors(*node, delta) || !node->parent_node_id.has_value())+ outermost_scroll_node_index = node->scroll_node_index;+ if (!node_chains_scroll_to_ancestors(*node, delta) || !node->parent_scroll_node_index.has_value())break;- node_id = *node->parent_node_id;+ scroll_node_index = *node->parent_scroll_node_index;}- return outermost_node_id;+ return outermost_scroll_node_index;}-AsyncSnapContainer const* AsyncScrollTree::snap_container_for_node(AsyncScrollNodeID node_id) const+AsyncSnapContainer const* AsyncScrollTree::snap_container_for_node(Compositing::SpatialNodeIndex scroll_node_index) const{for (auto const& snap_container : m_snap_containers) {- if (snap_container.node_id == node_id)+ if (snap_container.scroll_node_index == scroll_node_index)return &snap_container;}return nullptr;@@ -141,7 +141,7 @@ Gfx::FloatPoint AsyncScrollTree::clamp_scroll_offset_to_node(AsyncScrollNode conGfx::FloatPoint AsyncScrollTree::scroll_offset_for_node(AsyncScrollNode const& node, Compositing::ScrollStateSnapshot const& scroll_state_snapshot){- auto device_offset = scroll_state_snapshot.device_offset_for_index(node.node_id.scroll_node_index);+ auto device_offset = scroll_state_snapshot.device_offset_for_index(node.scroll_node_index);return { -device_offset.x(), -device_offset.y() };}@@ -163,18 +163,18 @@ bool AsyncScrollTree::can_scroll_node_from_offset_by_delta(AsyncScrollNode constreturn false;}-Optional<AsyncScrollNodeID> AsyncScrollTree::scrollable_ancestor_for_node(AsyncScrollNodeID node_id, Compositing::ScrollStateSnapshot const& scroll_state_snapshot, Gfx::FloatPoint delta) const+Optional<Compositing::SpatialNodeIndex> AsyncScrollTree::scrollable_ancestor_for_node(Compositing::SpatialNodeIndex scroll_node_index, Compositing::ScrollStateSnapshot const& scroll_state_snapshot, Gfx::FloatPoint delta) const{- auto const* node = scroll_node_for_id(node_id);+ auto const* node = scroll_node_for_index(scroll_node_index);if (!node)return {};- while (node_chains_scroll_to_ancestors(*node, delta) && node->parent_node_id.has_value()) {- node = scroll_node_for_id(*node->parent_node_id);+ while (node_chains_scroll_to_ancestors(*node, delta) && node->parent_scroll_node_index.has_value()) {+ node = scroll_node_for_index(*node->parent_scroll_node_index);if (!node)return {};if (can_scroll_node_by_delta(*node, scroll_state_snapshot, delta))- return node->node_id;+ return node->scroll_node_index;}return {};}@@ -189,18 +189,18 @@ Gfx::FloatPoint AsyncScrollTree::apply_scroll_delta_to_node(AsyncScrollNode consauto new_scroll_offset = clamp_scroll_offset_to_node(node, old_scroll_offset.translated(wheel_scrollable_delta));if (new_scroll_offset == old_scroll_offset) {dbgln_if(COMPOSITOR_DEBUG, "[Compositor] Async scroll node {} did not move for delta {},{} (offset={},{} max={},{})",- node.node_id.scroll_node_index.value(), delta.x(), delta.y(), old_scroll_offset.x(), old_scroll_offset.y(), node.max_scroll_offset.x(), node.max_scroll_offset.y());+ node.scroll_node_index.value(), delta.x(), delta.y(), old_scroll_offset.x(), old_scroll_offset.y(), node.max_scroll_offset.x(), node.max_scroll_offset.y());return delta;}- scroll_state_snapshot.set_device_offset_for_index(node.node_id.scroll_node_index, { -new_scroll_offset.x(), -new_scroll_offset.y() });+ scroll_state_snapshot.set_device_offset_for_index(node.scroll_node_index, { -new_scroll_offset.x(), -new_scroll_offset.y() });Gfx::FloatPoint consumed_delta {new_scroll_offset.x() - old_scroll_offset.x(),new_scroll_offset.y() - old_scroll_offset.y()};dbgln_if(COMPOSITOR_DEBUG, "[Compositor] Async scroll node {} moved from {},{} to {},{} (consumed={},{} remaining={},{})",- node.node_id.scroll_node_index.value(),+ node.scroll_node_index.value(),old_scroll_offset.x(), old_scroll_offset.y(),new_scroll_offset.x(), new_scroll_offset.y(),consumed_delta.x(), consumed_delta.y(),@@ -211,12 +211,12 @@ Gfx::FloatPoint AsyncScrollTree::apply_scroll_delta_to_node(AsyncScrollNode cons};}-Optional<AsyncScrollOffset> AsyncScrollTree::apply_scroll_delta(AsyncScrollNodeID node_id, Gfx::FloatPoint delta, Compositing::AccumulatedVisualContextTree const& visual_context_tree, Compositing::ScrollStateSnapshot& scroll_state_snapshot, ScrollChaining scroll_chaining)+Optional<AsyncScrollOffset> AsyncScrollTree::apply_scroll_delta(Compositing::SpatialNodeIndex scroll_node_index, Gfx::FloatPoint delta, Compositing::AccumulatedVisualContextTree const& visual_context_tree, Compositing::ScrollStateSnapshot& scroll_state_snapshot, ScrollChaining scroll_chaining){// The compositor can advance only the scroll offsets it owns in this snapshot. Hit testing already selects an// ancestor when the target cannot scroll in the wheel direction at all, so once a node moves it consumes the event.for (size_t remaining_handoffs = m_scroll_nodes.size(); remaining_handoffs > 0 && !delta.is_zero(); --remaining_handoffs) {- auto const* node = scroll_node_for_id(node_id);+ auto const* node = scroll_node_for_index(scroll_node_index);if (!node)break;@@ -236,10 +236,10 @@ Optional<AsyncScrollOffset> AsyncScrollTree::apply_scroll_delta(AsyncScrollNodeIif (scroll_chaining == ScrollChaining::None)break;- auto ancestor_node_id = scrollable_ancestor_for_node(node_id, scroll_state_snapshot, delta);- if (!ancestor_node_id.has_value())+ auto ancestor_scroll_node_index = scrollable_ancestor_for_node(scroll_node_index, scroll_state_snapshot, delta);+ if (!ancestor_scroll_node_index.has_value())break;- node_id = *ancestor_node_id;+ scroll_node_index = *ancestor_scroll_node_index;}dbgln_if(COMPOSITOR_DEBUG, "[Compositor] Async scroll tree did not scroll any node for delta {},{}",@@ -247,12 +247,12 @@ Optional<AsyncScrollOffset> AsyncScrollTree::apply_scroll_delta(AsyncScrollNodeIreturn {};}-Optional<WheelScrollTarget> AsyncScrollTree::select_wheel_scroll_target(AsyncScrollNodeID node_id, Gfx::FloatPoint delta, Compositing::ScrollStateSnapshot const& scroll_state_snapshot, Function<Optional<Gfx::FloatPoint>(Web::AsyncScrollNodeStableID)> const& in_flight_destination_for, ScrollChaining scroll_chaining) const+Optional<WheelScrollTarget> AsyncScrollTree::select_wheel_scroll_target(Compositing::SpatialNodeIndex scroll_node_index, Gfx::FloatPoint delta, Compositing::ScrollStateSnapshot const& scroll_state_snapshot, Function<Optional<Gfx::FloatPoint>(Web::AsyncScrollNodeStableID)> const& in_flight_destination_for, ScrollChaining scroll_chaining) const{// Each box is measured from where its scroll in flight is headed, so a box already headed for its extent passes the// first step of a gesture on to an ancestor.for (size_t remaining_handoffs = m_scroll_nodes.size(); remaining_handoffs > 0; --remaining_handoffs) {- auto const* node = scroll_node_for_id(node_id);+ auto const* node = scroll_node_for_index(scroll_node_index);if (!node)return {};@@ -271,9 +271,9 @@ Optional<WheelScrollTarget> AsyncScrollTree::select_wheel_scroll_target(AsyncScr};}- if (scroll_chaining == ScrollChaining::None || !node_chains_scroll_to_ancestors(*node, delta) || !node->parent_node_id.has_value())+ if (scroll_chaining == ScrollChaining::None || !node_chains_scroll_to_ancestors(*node, delta) || !node->parent_scroll_node_index.has_value())return {};- node_id = *node->parent_node_id;+ scroll_node_index = *node->parent_scroll_node_index;}return {};}@@ -309,7 +309,7 @@ void AsyncScrollTree::rebuild_wheel_hit_test_targets(RefPtr<Compositing::Displayif (!context_is_valid(target.context))continue;m_cached_wheel_hit_test_targets.append({- .target_node_id = target.target_node_id,+ .target_scroll_node_index = target.target_scroll_node_index,.context = target.context,.rect = target.rect,.corner_radii = target.corner_radii,@@ -371,9 +371,9 @@ static bool wheel_hit_test_target_contains_point(CachedWheelHitTestTarget const&return rounded_rect_contains_point(target.rect, target.corner_radii, position_in_context);}-Optional<Gfx::FloatPoint> AsyncScrollTree::scroll_offset_for_node(AsyncScrollNodeID node_id, Compositing::ScrollStateSnapshot const& scroll_state_snapshot) const+Optional<Gfx::FloatPoint> AsyncScrollTree::scroll_offset_for_node(Compositing::SpatialNodeIndex scroll_node_index, Compositing::ScrollStateSnapshot const& scroll_state_snapshot) const{- if (auto const* node = scroll_node_for_id(node_id))+ if (auto const* node = scroll_node_for_index(scroll_node_index))return scroll_offset_for_node(*node, scroll_state_snapshot);return {};}@@ -394,32 +394,24 @@ Gfx::FloatPoint AsyncScrollTree::device_offset_from_css_pixels(Web::CSSPixelPoin};}-Optional<Web::CSSPixelPoint> AsyncScrollTree::css_scroll_offset_for_node(AsyncScrollNodeID node_id, Compositing::ScrollStateSnapshot const& scroll_state_snapshot) const+Optional<Web::CSSPixelPoint> AsyncScrollTree::css_scroll_offset_for_node(Compositing::SpatialNodeIndex scroll_node_index, Compositing::ScrollStateSnapshot const& scroll_state_snapshot) const{- return scroll_offset_for_node(node_id, scroll_state_snapshot).map([&](auto device_offset) { return css_pixels_from_device_offset(device_offset); });+ return scroll_offset_for_node(scroll_node_index, scroll_state_snapshot).map([&](auto device_offset) { return css_pixels_from_device_offset(device_offset); });}-Optional<Web::UniqueNodeID> AsyncScrollTree::document_id() const-{- // The scroll nodes belong to the same document, whose viewport need not itself be scrollable.- if (m_scroll_nodes.is_empty())- return m_document_id;- return m_scroll_nodes.first().node_id.document_id;-}--Optional<AsyncScrollNodeID> AsyncScrollTree::viewport_scroll_node_id() const+Optional<Compositing::SpatialNodeIndex> AsyncScrollTree::viewport_scroll_node_index() const{for (auto const& node : m_scroll_nodes) {if (node.is_viewport)- return node.node_id;+ return node.scroll_node_index;}return {};}-Optional<AsyncScrollNodeID> AsyncScrollTree::scroll_node_id_for_stable_id(Web::AsyncScrollNodeStableID stable_node_id) const+Optional<Compositing::SpatialNodeIndex> AsyncScrollTree::scroll_node_index_for_stable_id(Web::AsyncScrollNodeStableID stable_node_id) const{if (auto const* node = scroll_node_for_stable_id(stable_node_id))- return node->node_id;+ return node->scroll_node_index;return {};}@@ -540,7 +532,7 @@ WheelHitTestResult AsyncScrollTree::hit_test_scroll_node_for_wheel(Compositing::// https://drafts.csswg.org/css-overscroll-1/#scroll-chaining-and-boundary-default-actions// If a scroll container has no potential to scroll, because it does not overflow in the direction of the scroll,// the element is always considered to be at the scroll boundary.- Vector<AsyncScrollNodeID, 2> scroll_nodes_behind_scroll_chaining_barriers;+ Vector<Compositing::SpatialNodeIndex, 2> scroll_nodes_behind_scroll_chaining_barriers;for (auto const& cached_barrier : m_cached_scroll_chaining_barriers) {auto const& barrier = cached_barrier.barrier;bool keeps_the_scroll = delta_is_mainly_vertical(delta) ? barrier.keeps_vertical_scrolls : barrier.keeps_horizontal_scrolls;@@ -552,7 +544,7 @@ WheelHitTestResult AsyncScrollTree::hit_test_scroll_node_for_wheel(Compositing::continue;auto position_in_context = visual_context_tree.transform_point_for_hit_test(barrier.context, position, m_scroll_state_snapshot);if (position_in_context.has_value() && barrier.rect.contains(*position_in_context))- scroll_nodes_behind_scroll_chaining_barriers.append(barrier.scroll_node_id_above_barrier);+ scroll_nodes_behind_scroll_chaining_barriers.append(barrier.scroll_node_index_above_barrier);}for (auto const& target : m_cached_wheel_hit_test_targets.in_reverse()) {@@ -563,18 +555,18 @@ WheelHitTestResult AsyncScrollTree::hit_test_scroll_node_for_wheel(Compositing::auto position_in_context = visual_context_tree.transform_point_for_hit_test(target.context, position, m_scroll_state_snapshot);if (!position_in_context.has_value() || !wheel_hit_test_target_contains_point(target, *position_in_context))continue;- if (!target.target_node_id.has_value())+ if (!target.target_scroll_node_index.has_value())return { .outcome = WheelHitTestOutcome::NoScrollTarget };- return hit_test_result_for_scroll_node(*target.target_node_id, delta, in_flight_destination_for, scroll_nodes_behind_scroll_chaining_barriers);+ return hit_test_result_for_scroll_node(*target.target_scroll_node_index, delta, in_flight_destination_for, scroll_nodes_behind_scroll_chaining_barriers);}- auto viewport_node_id = viewport_scroll_node_id();- if (!viewport_node_id.has_value())+ auto index_of_viewport_scroll_node = viewport_scroll_node_index();+ if (!index_of_viewport_scroll_node.has_value())return { .outcome = WheelHitTestOutcome::NoScrollTarget };- auto const* viewport_node = scroll_node_for_id(*viewport_node_id);+ auto const* viewport_node = scroll_node_for_index(*index_of_viewport_scroll_node);if (!viewport_node || !viewport_node->scrollport_rect.to_type<float>().contains(position))return { .outcome = WheelHitTestOutcome::NoScrollTarget };- return hit_test_result_for_scroll_node(*viewport_node_id, delta, in_flight_destination_for, scroll_nodes_behind_scroll_chaining_barriers);+ return hit_test_result_for_scroll_node(*index_of_viewport_scroll_node, delta, in_flight_destination_for, scroll_nodes_behind_scroll_chaining_barriers);}FirstWheelStepRoute AsyncScrollTree::route_first_wheel_step(WheelRoutingAdmission admission, Compositing::AccumulatedVisualContextTree const& visual_context_tree, Gfx::FloatPoint position, Gfx::FloatPoint delta, NestedContextRegions nested_context_regions) const@@ -583,8 +575,8 @@ FirstWheelStepRoute AsyncScrollTree::route_first_wheel_step(WheelRoutingAdmissioreturn { input_routing_decision_for_wheel_step_not_admitted_by(admission) };auto scroll_target = hit_test_scroll_node_for_wheel(visual_context_tree, position, delta, {}, WheelStepDispatch::NotYetDispatched, nested_context_regions);FirstWheelStepRoute route { input_routing_decision_for_first_wheel_step(scroll_target.outcome) };- if (scroll_target.node_id.has_value()) {- if (auto const* node = scroll_node_for_id(*scroll_target.node_id))+ if (scroll_target.scroll_node_index.has_value()) {+ if (auto const* node = scroll_node_for_index(*scroll_target.scroll_node_index))route.scroller = node->stable_node_id;}return route;@@ -609,7 +601,7 @@ bool AsyncScrollTree::is_covered_by_hit_test_target_painted_after(u32 paint_ordereturn false;}-Optional<AsyncScrollNodeID> AsyncScrollTree::scroll_node_for_keyboard_scroll(Web::AsyncScrollNodeStableID stable_node_id, Gfx::FloatPoint delta, Compositing::ScrollStateSnapshot const& scroll_state_snapshot) const+Optional<Compositing::SpatialNodeIndex> AsyncScrollTree::scroll_node_for_keyboard_scroll(Web::AsyncScrollNodeStableID stable_node_id, Gfx::FloatPoint delta, Compositing::ScrollStateSnapshot const& scroll_state_snapshot) const{auto const* node = scroll_node_for_stable_id(stable_node_id);if (!node)@@ -617,21 +609,21 @@ Optional<AsyncScrollNodeID> AsyncScrollTree::scroll_node_for_keyboard_scroll(Web// Keyboard routing does not depend on pointer or wheel-listener regions.if (can_scroll_node_by_delta(*node, scroll_state_snapshot, delta))- return node->node_id;- return scrollable_ancestor_for_node(node->node_id, scroll_state_snapshot, delta);+ return node->scroll_node_index;+ return scrollable_ancestor_for_node(node->scroll_node_index, scroll_state_snapshot, delta);}-Gfx::FloatPoint AsyncScrollTree::clamped_scroll_offset_for_node(AsyncScrollNodeID node_id, Gfx::FloatPoint scroll_offset) const+Gfx::FloatPoint AsyncScrollTree::clamped_scroll_offset_for_node(Compositing::SpatialNodeIndex scroll_node_index, Gfx::FloatPoint scroll_offset) const{- auto const* node = scroll_node_for_id(node_id);+ auto const* node = scroll_node_for_index(scroll_node_index);if (!node)return scroll_offset;return clamp_scroll_offset_to_node(*node, scroll_offset);}-bool AsyncScrollTree::scroll_node_is_viewport(AsyncScrollNodeID node_id) const+bool AsyncScrollTree::scroll_node_is_viewport(Compositing::SpatialNodeIndex scroll_node_index) const{- auto const* node = scroll_node_for_id(node_id);+ auto const* node = scroll_node_for_index(scroll_node_index);return node && node->is_viewport;}@@ -640,14 +632,14 @@ bool AsyncScrollTree::viewport_keeps_scrolls_along_main_axis_of(Gfx::FloatPointreturn delta_is_mainly_vertical(delta) ? m_viewport_keeps_vertical_scrolls : m_viewport_keeps_horizontal_scrolls;}-Optional<Gfx::FloatPoint> AsyncScrollTree::set_scroll_offset(AsyncScrollNodeID node_id, Gfx::FloatPoint scroll_offset, Compositing::AccumulatedVisualContextTree const& visual_context_tree, Compositing::ScrollStateSnapshot& scroll_state_snapshot)+Optional<Gfx::FloatPoint> AsyncScrollTree::set_scroll_offset(Compositing::SpatialNodeIndex scroll_node_index, Gfx::FloatPoint scroll_offset, Compositing::AccumulatedVisualContextTree const& visual_context_tree, Compositing::ScrollStateSnapshot& scroll_state_snapshot){- auto const* node = scroll_node_for_id(node_id);+ auto const* node = scroll_node_for_index(scroll_node_index);if (!node)return {};auto new_scroll_offset = clamp_scroll_offset_to_node(*node, scroll_offset);- scroll_state_snapshot.set_device_offset_for_index(node->node_id.scroll_node_index, { -new_scroll_offset.x(), -new_scroll_offset.y() });+ scroll_state_snapshot.set_device_offset_for_index(node->scroll_node_index, { -new_scroll_offset.x(), -new_scroll_offset.y() });Compositing::resolve_sticky_offsets(visual_context_tree, scroll_state_snapshot);return new_scroll_offset;}diff --git a/Libraries/LibCompositing/Scrolling/AsyncScrollTree.h b/Libraries/LibCompositing/Scrolling/AsyncScrollTree.hindex d886d7c0a84..a744b1d28f5 100644--- a/Libraries/LibCompositing/Scrolling/AsyncScrollTree.h+++ b/Libraries/LibCompositing/Scrolling/AsyncScrollTree.h@@ -33,13 +33,13 @@ enum class WheelHitTestOutcome : u8 {struct WheelHitTestResult {WheelHitTestOutcome outcome { WheelHitTestOutcome::NoScrollTarget };// Set exactly when the outcome is FoundScrollTarget.- Optional<AsyncScrollNodeID> node_id {};- // The scroller the wheel is over, which is where the search for `node_id` started. It is set even if neither it- // nor any scroller around it can scroll by the delta.- Optional<AsyncScrollNodeID> innermost_scroll_node_id {};+ Optional<Compositing::SpatialNodeIndex> scroll_node_index {};+ // The scroller the wheel is over, which is where the search for `scroll_node_index` started. It is set even if+ // neither it nor any scroller around it can scroll by the delta.+ Optional<Compositing::SpatialNodeIndex> innermost_scroll_node_index {};// The scroller that keeps the delta from the scrollers around it, when the outcome is NoScrollTarget for that// reason rather than because no scroller is left to offer it to.- Optional<AsyncScrollNodeID> node_keeping_the_scroll {};+ Optional<Compositing::SpatialNodeIndex> scroll_node_index_keeping_the_scroll {};bool is_blocked_by_a_region() const{@@ -92,7 +92,7 @@ struct WheelScrollTarget {};struct CachedWheelHitTestTarget {- Optional<AsyncScrollNodeID> target_node_id;+ Optional<Compositing::SpatialNodeIndex> target_scroll_node_index;Compositing::ContextRef context;Gfx::FloatRect rect;Gfx::CornerRadii corner_radii;@@ -135,20 +135,20 @@ public:void rebuild_wheel_hit_test_targets(RefPtr<Compositing::DisplayList const> const&, Compositing::AccumulatedVisualContextTree const*, Compositing::ScrollStateSnapshot const&);- Optional<Gfx::FloatPoint> scroll_offset_for_node(AsyncScrollNodeID, Compositing::ScrollStateSnapshot const&) const;- Optional<Web::UniqueNodeID> document_id() const;- Optional<AsyncScrollNodeID> viewport_scroll_node_id() const;- Optional<AsyncScrollNodeID> scroll_node_id_for_stable_id(Web::AsyncScrollNodeStableID) const;- AsyncScrollNode const* scroll_node_for_id(AsyncScrollNodeID) const;+ Optional<Gfx::FloatPoint> scroll_offset_for_node(Compositing::SpatialNodeIndex, Compositing::ScrollStateSnapshot const&) const;+ Optional<Web::UniqueNodeID> document_id() const { return m_document_id; }+ Optional<Compositing::SpatialNodeIndex> viewport_scroll_node_index() const;+ Optional<Compositing::SpatialNodeIndex> scroll_node_index_for_stable_id(Web::AsyncScrollNodeStableID) const;+ AsyncScrollNode const* scroll_node_for_index(Compositing::SpatialNodeIndex) const;ReadonlySpan<AsyncScrollNode> scroll_nodes() const { return m_scroll_nodes; }- AsyncSnapContainer const* snap_container_for_node(AsyncScrollNodeID) const;+ AsyncSnapContainer const* snap_container_for_node(Compositing::SpatialNodeIndex) const;// Scroll offsets are held in the device pixels of the display list; snap geometry is in the CSS pixels it was// recorded from, at the scale the display list carries.double device_pixels_per_css_pixel() const { return m_device_pixels_per_css_pixel; }Web::CSSPixelPoint css_pixels_from_device_offset(Gfx::FloatPoint) const;Gfx::FloatPoint device_offset_from_css_pixels(Web::CSSPixelPoint) const;- Optional<Web::CSSPixelPoint> css_scroll_offset_for_node(AsyncScrollNodeID, Compositing::ScrollStateSnapshot const&) const;+ Optional<Web::CSSPixelPoint> css_scroll_offset_for_node(Compositing::SpatialNodeIndex, Compositing::ScrollStateSnapshot const&) const;bool blocks_wheel_event_at_position(Compositing::AccumulatedVisualContextTree const&, Gfx::FloatPoint position) const;WheelHitTestResult hit_test_scroll_node_for_wheel(Compositing::AccumulatedVisualContextTree const&, Gfx::FloatPoint position, Gfx::FloatPoint delta, Function<Optional<Gfx::FloatPoint>(Web::AsyncScrollNodeStableID)> const& in_flight_destination_for = {}, WheelStepDispatch = WheelStepDispatch::NotYetDispatched, NestedContextRegions = NestedContextRegions::LeaveToMainThread) const;// The nested context whose content is the topmost thing taking pointer input at the position, if any.@@ -163,7 +163,7 @@ public:// Whether something painted above the given place in paint order takes pointer input at the position. It is taken// to be covered whenever that cannot be told.bool is_covered_by_hit_test_target_painted_after(u32 paint_order_index, Compositing::AccumulatedVisualContextTree const&, Gfx::FloatPoint position) const;- bool scroll_node_is_viewport(AsyncScrollNodeID) const;+ bool scroll_node_is_viewport(Compositing::SpatialNodeIndex) const;// Whether the viewport keeps a scroll by the delta from the document it is nested in, whether or not it has a// scroll node.bool viewport_keeps_scrolls_along_main_axis_of(Gfx::FloatPoint delta) const;@@ -172,12 +172,12 @@ public:FirstWheelStepRoute route_first_wheel_step(WheelRoutingAdmission, Compositing::AccumulatedVisualContextTree const&, Gfx::FloatPoint position, Gfx::FloatPoint delta, NestedContextRegions = NestedContextRegions::LeaveToMainThread) const;// Of the scroller and the scrollers around it that a scroll by the delta may be passed on to, the outermost one a// wheel can scroll along the main axis of the delta at all, wherever it is scrolled to.- Optional<AsyncScrollNodeID> outermost_scroll_node_wheel_scrollable_along_main_axis_of(AsyncScrollNodeID innermost_node_id, Gfx::FloatPoint delta) const;- Optional<AsyncScrollNodeID> scroll_node_for_keyboard_scroll(Web::AsyncScrollNodeStableID, Gfx::FloatPoint delta, Compositing::ScrollStateSnapshot const&) const;- Gfx::FloatPoint clamped_scroll_offset_for_node(AsyncScrollNodeID, Gfx::FloatPoint) const;- Optional<AsyncScrollOffset> apply_scroll_delta(AsyncScrollNodeID, Gfx::FloatPoint delta, Compositing::AccumulatedVisualContextTree const&, Compositing::ScrollStateSnapshot&, ScrollChaining);- Optional<WheelScrollTarget> select_wheel_scroll_target(AsyncScrollNodeID, Gfx::FloatPoint delta, Compositing::ScrollStateSnapshot const&, Function<Optional<Gfx::FloatPoint>(Web::AsyncScrollNodeStableID)> const& in_flight_destination_for, ScrollChaining scroll_chaining) const;- Optional<Gfx::FloatPoint> set_scroll_offset(AsyncScrollNodeID, Gfx::FloatPoint, Compositing::AccumulatedVisualContextTree const&, Compositing::ScrollStateSnapshot&);+ Optional<Compositing::SpatialNodeIndex> outermost_scroll_node_wheel_scrollable_along_main_axis_of(Compositing::SpatialNodeIndex innermost_scroll_node_index, Gfx::FloatPoint delta) const;+ Optional<Compositing::SpatialNodeIndex> scroll_node_for_keyboard_scroll(Web::AsyncScrollNodeStableID, Gfx::FloatPoint delta, Compositing::ScrollStateSnapshot const&) const;+ Gfx::FloatPoint clamped_scroll_offset_for_node(Compositing::SpatialNodeIndex, Gfx::FloatPoint) const;+ Optional<AsyncScrollOffset> apply_scroll_delta(Compositing::SpatialNodeIndex, Gfx::FloatPoint delta, Compositing::AccumulatedVisualContextTree const&, Compositing::ScrollStateSnapshot&, ScrollChaining);+ Optional<WheelScrollTarget> select_wheel_scroll_target(Compositing::SpatialNodeIndex, Gfx::FloatPoint delta, Compositing::ScrollStateSnapshot const&, Function<Optional<Gfx::FloatPoint>(Web::AsyncScrollNodeStableID)> const& in_flight_destination_for, ScrollChaining scroll_chaining) const;+ Optional<Gfx::FloatPoint> set_scroll_offset(Compositing::SpatialNodeIndex, Gfx::FloatPoint, Compositing::AccumulatedVisualContextTree const&, Compositing::ScrollStateSnapshot&);private:static Gfx::FloatPoint clamp_scroll_offset_to_node(AsyncScrollNode const&, Gfx::FloatPoint);@@ -185,7 +185,7 @@ private:static bool can_scroll_node_by_delta(AsyncScrollNode const&, Compositing::ScrollStateSnapshot const&, Gfx::FloatPoint);static bool can_scroll_node_from_offset_by_delta(AsyncScrollNode const&, Gfx::FloatPoint scroll_offset, Gfx::FloatPoint delta);- WheelHitTestResult hit_test_result_for_scroll_node(AsyncScrollNodeID, Gfx::FloatPoint delta, Function<Optional<Gfx::FloatPoint>(Web::AsyncScrollNodeStableID)> const& in_flight_destination_for, ReadonlySpan<AsyncScrollNodeID> scroll_nodes_behind_scroll_chaining_barriers) const;+ WheelHitTestResult hit_test_result_for_scroll_node(Compositing::SpatialNodeIndex, Gfx::FloatPoint delta, Function<Optional<Gfx::FloatPoint>(Web::AsyncScrollNodeStableID)> const& in_flight_destination_for, ReadonlySpan<Compositing::SpatialNodeIndex> scroll_nodes_behind_scroll_chaining_barriers) const;AsyncScrollNode const* scroll_node_for_stable_id(Web::AsyncScrollNodeStableID) const;bool main_thread_wheel_event_region_contains(Compositing::AccumulatedVisualContextTree const&, Gfx::FloatPoint position) const;struct NestedContextWheelRegionHit {@@ -193,7 +193,7 @@ private:Gfx::FloatPoint position_in_context;};Optional<NestedContextWheelRegionHit> topmost_nested_context_wheel_region_at(Compositing::AccumulatedVisualContextTree const&, Gfx::FloatPoint position) const;- Optional<AsyncScrollNodeID> scrollable_ancestor_for_node(AsyncScrollNodeID, Compositing::ScrollStateSnapshot const&, Gfx::FloatPoint delta) const;+ Optional<Compositing::SpatialNodeIndex> scrollable_ancestor_for_node(Compositing::SpatialNodeIndex, Compositing::ScrollStateSnapshot const&, Gfx::FloatPoint delta) const;Gfx::FloatPoint apply_scroll_delta_to_node(AsyncScrollNode const&, Gfx::FloatPoint delta, Compositing::ScrollStateSnapshot&);Optional<Web::UniqueNodeID> m_document_id;diff --git a/Libraries/LibCompositing/Scrolling/AsyncScrollingState.cpp b/Libraries/LibCompositing/Scrolling/AsyncScrollingState.cppindex 6c4723c3b64..13874f937a8 100644--- a/Libraries/LibCompositing/Scrolling/AsyncScrollingState.cpp+++ b/Libraries/LibCompositing/Scrolling/AsyncScrollingState.cpp@@ -12,11 +12,6 @@namespace Compositing {-static AsyncScrollNodeID scroll_node_id_for(Web::UniqueNodeID document_id, Compositing::SpatialNodeIndex scroll_node_index)-{- return { .document_id = document_id, .scroll_node_index = scroll_node_index };-}-Web::AsyncScrollNodeKind async_scroll_node_kind_for(Compositing::CompositorScrollNodeKind kind){switch (kind) {@@ -57,14 +52,14 @@ AsyncScrollingState async_scrolling_state_from_display_list(Compositing::Displaydisplay_list.for_each_compositor_metadata([&](Compositing::ContextRef context, Compositing::DisplayListCommandType command_type, ReadonlyBytes payload) {auto append_wheel_hit_test_target = [&](auto const& command, Gfx::CornerRadii corner_radii) {- Optional<AsyncScrollNodeID> target_node_id;+ Optional<Compositing::SpatialNodeIndex> target_scroll_node_index;if (command.target_scroll_node_index.value())- target_node_id = scroll_node_id_for(command.document_id, command.target_scroll_node_index);+ target_scroll_node_index = command.target_scroll_node_index;async_scrolling_state.wheel_hit_test_targets.append({.context = context,.rect = command.rect,.corner_radii = corner_radii,- .target_node_id = target_node_id,+ .target_scroll_node_index = target_scroll_node_index,.paint_order_index = next_paint_order_index++,});};@@ -81,13 +76,13 @@ AsyncScrollingState async_scrolling_state_from_display_list(Compositing::Display}case Compositing::DisplayListCommandType::CompositorScrollNode: {auto command = Compositing::read_display_list_object<Compositing::CompositorScrollNode>(payload);- Optional<AsyncScrollNodeID> parent_node_id;+ Optional<Compositing::SpatialNodeIndex> parent_scroll_node_index;if (command.parent_scroll_node_index.value())- parent_node_id = scroll_node_id_for(command.document_id, command.parent_scroll_node_index);+ parent_scroll_node_index = command.parent_scroll_node_index;async_scrolling_state.scroll_nodes.append({- .node_id = scroll_node_id_for(command.document_id, command.scroll_node_index),+ .scroll_node_index = command.scroll_node_index,.stable_node_id = stable_scroll_node_id_for(command.scrollable_node_id, command.scroll_node_kind, command.pseudo_element_type),- .parent_node_id = parent_node_id,+ .parent_scroll_node_index = parent_scroll_node_index,.scrollport_rect = command.scrollport_rect,.min_scroll_offset = command.min_scroll_offset,.max_scroll_offset = command.max_scroll_offset,@@ -135,7 +130,7 @@ AsyncScrollingState async_scrolling_state_from_display_list(Compositing::Displayasync_scrolling_state.scroll_chaining_barriers.append({.context = context,.rect = command.rect,- .scroll_node_id_above_barrier = scroll_node_id_for(command.document_id, command.scroll_node_index_above_barrier),+ .scroll_node_index_above_barrier = command.scroll_node_index_above_barrier,.keeps_horizontal_scrolls = command.keeps_horizontal_scrolls,.keeps_vertical_scrolls = command.keeps_vertical_scrolls,});@@ -144,7 +139,6 @@ AsyncScrollingState async_scrolling_state_from_display_list(Compositing::Displaycase Compositing::DisplayListCommandType::CompositorScrollbar: {auto command = Compositing::read_display_list_object<Compositing::CompositorScrollbar>(payload);async_scrolling_state.scrollbars.append({- .scroll_node_id = scroll_node_id_for(command.document_id, command.scroll_node_index),.scroller_stable_node_id = {},.scroll_node_index = command.scroll_node_index,.context = context,@@ -168,7 +162,7 @@ AsyncScrollingState async_scrolling_state_from_display_list(Compositing::Displaycase Compositing::DisplayListCommandType::CompositorSnapContainer: {auto command = Compositing::read_display_list_object<Compositing::CompositorSnapContainer>(payload);async_scrolling_state.snap_containers.append({- .node_id = scroll_node_id_for(command.document_id, command.scroll_node_index),+ .scroll_node_index = command.scroll_node_index,.geometry = {.snapport = command.snapport,.min_scroll_offset = command.min_scroll_offset,@@ -185,7 +179,7 @@ AsyncScrollingState async_scrolling_state_from_display_list(Compositing::Displayauto command = Compositing::read_display_list_object<Compositing::CompositorSnapArea>(payload);auto& snap_containers = async_scrolling_state.snap_containers;// A snap container's areas are recorded right after it.- if (snap_containers.is_empty() || snap_containers.last().node_id != scroll_node_id_for(command.document_id, command.scroll_node_index)) {+ if (snap_containers.is_empty() || snap_containers.last().scroll_node_index != command.scroll_node_index) {dbgln("Ignoring a snap area recorded without its snap container");break;}@@ -205,7 +199,7 @@ AsyncScrollingState async_scrolling_state_from_display_list(Compositing::Displayfor (auto& scrollbar : async_scrolling_state.scrollbars) {for (auto const& scroll_node : async_scrolling_state.scroll_nodes) {- if (scroll_node.node_id == scrollbar.scroll_node_id) {+ if (scroll_node.scroll_node_index == scrollbar.scroll_node_index) {scrollbar.scroller_stable_node_id = scroll_node.stable_node_id;break;}@@ -266,10 +260,8 @@ 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("scrollNodeIndex"sv, scroll_node.scroll_node_index.value());+ node.set("parentScrollNodeIndex"sv, scroll_node.parent_scroll_node_index.has_value() ? scroll_node.parent_scroll_node_index->value() : 0);node.set("isViewport"sv, scroll_node.is_viewport);scroll_nodes.must_append(move(node));}@@ -277,8 +269,7 @@ JsonObject async_scrolling_state_to_json(AsyncScrollingState const& state)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("scrollNodeIndex"sv, snap_container.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));diff --git a/Libraries/LibCompositing/Scrolling/AsyncScrollingState.h b/Libraries/LibCompositing/Scrolling/AsyncScrollingState.hindex 05c2c9772f9..5e2e0b3d817 100644--- a/Libraries/LibCompositing/Scrolling/AsyncScrollingState.h+++ b/Libraries/LibCompositing/Scrolling/AsyncScrollingState.h@@ -30,14 +30,6 @@ namespace Compositing {using AsyncScrollOperationID = u64;-// Stable identifier for a scroll node in a document; the node index alone is not unique across nested documents.-struct AsyncScrollNodeID {- Web::UniqueNodeID document_id;- Compositing::SpatialNodeIndex scroll_node_index;-- bool operator==(AsyncScrollNodeID const&) const = default;-};-COMPOSITING_API Web::AsyncScrollNodeKind async_scroll_node_kind_for(Compositing::CompositorScrollNodeKind);struct AsyncScrollOffset {@@ -71,9 +63,9 @@ struct AsyncScrollOffset {// One scrollable area from the paint snapshot.struct AsyncScrollNode {- AsyncScrollNodeID node_id;+ Compositing::SpatialNodeIndex scroll_node_index;Web::AsyncScrollNodeStableID stable_node_id;- Optional<AsyncScrollNodeID> parent_node_id;+ Optional<Compositing::SpatialNodeIndex> parent_scroll_node_index;Gfx::IntRect scrollport_rect;Gfx::FloatPoint min_scroll_offset;Gfx::FloatPoint max_scroll_offset;@@ -98,7 +90,7 @@ struct WheelHitTestTarget {Compositing::ContextRef context;Gfx::FloatRect rect;Gfx::CornerRadii corner_radii;- Optional<AsyncScrollNodeID> target_node_id;+ Optional<Compositing::SpatialNodeIndex> target_scroll_node_index;// Position among the wheel hit test targets and scrollbars of the display list, which are recorded in paint order.u32 paint_order_index { 0 };};@@ -124,13 +116,12 @@ struct NestedContextWheelRegion {struct ScrollChainingBarrier {Compositing::ContextRef context;Gfx::FloatRect rect;- AsyncScrollNodeID scroll_node_id_above_barrier;+ Compositing::SpatialNodeIndex scroll_node_index_above_barrier;bool keeps_horizontal_scrolls { false };bool keeps_vertical_scrolls { false };};struct AsyncScrollbar {- AsyncScrollNodeID scroll_node_id;Optional<Web::AsyncScrollNodeStableID> scroller_stable_node_id;Compositing::SpatialNodeIndex scroll_node_index;// The rects of a scrollbar the display list paints are in the space of this context.@@ -155,7 +146,7 @@ struct AsyncScrollbar {// A scroll node that is a snap container, with the geometry snap positions are selected from.struct AsyncSnapContainer {- AsyncScrollNodeID node_id;+ Compositing::SpatialNodeIndex scroll_node_index;SnapContainerGeometry geometry;Vector<SnapAreaGeometry> areas;};diff --git a/Services/Compositor/ContextState.cpp b/Services/Compositor/ContextState.cppindex c9c1b9dc5f4..6cdad7eb068 100644--- a/Services/Compositor/ContextState.cpp+++ b/Services/Compositor/ContextState.cpp@@ -281,14 +281,14 @@ Optional<ContextState::KeyScroll> ContextState::key_scroll_for(Web::KeyEvent conauto key_step = m_keyboard_scroll_controller.step_for_key(event, m_async_scroll_tree);if (!key_step.has_value())return {};- auto target = m_async_scroll_tree.scroll_node_for_keyboard_scroll(key_step->keyboard_scroll_target, key_step->delta, scroll_state_snapshot_at_keyboard_step_starts());+ auto target_scroll_node_index = m_async_scroll_tree.scroll_node_for_keyboard_scroll(key_step->keyboard_scroll_target, key_step->delta, scroll_state_snapshot_at_keyboard_step_starts());// If every destination is at its boundary, consume repeats while a scrolling box can still move toward it.// Falling back would cancel the running animation and lose the steps already accumulated in its destination.- if (!target.has_value())- target = m_async_scroll_tree.scroll_node_for_keyboard_scroll(key_step->keyboard_scroll_target, key_step->delta, m_scroll_state_snapshot);- if (!target.has_value())+ if (!target_scroll_node_index.has_value())+ target_scroll_node_index = m_async_scroll_tree.scroll_node_for_keyboard_scroll(key_step->keyboard_scroll_target, key_step->delta, m_scroll_state_snapshot);+ if (!target_scroll_node_index.has_value())return {};- return KeyScroll { .step = key_step.release_value(), .target = target.value() };+ return KeyScroll { .step = key_step.release_value(), .target_scroll_node_index = target_scroll_node_index.value() };}Optional<Web::AsyncScrollNodeStableID> ContextState::box_scrolled_for_key_event(Web::KeyEvent const& event) const@@ -298,7 +298,7 @@ Optional<Web::AsyncScrollNodeStableID> ContextState::box_scrolled_for_key_event(auto key_scroll = key_scroll_for(event);if (!key_scroll.has_value())return {};- return m_async_scroll_tree.scroll_node_for_id(key_scroll->target)->stable_node_id;+ return m_async_scroll_tree.scroll_node_for_index(key_scroll->target_scroll_node_index)->stable_node_id;}ContextState::ContextUpdateResult ContextState::handle_key_event(Web::KeyEvent const& event)@@ -324,11 +324,11 @@ ContextState::ContextUpdateResult ContextState::handle_key_event(Web::KeyEvent cauto delta = key_step.delta;auto scrolls_to_extent = key_step.scrolls_to_extent;auto now = MonotonicTime::now();- auto target = key_scroll->target;+ auto target_scroll_node_index = key_scroll->target_scroll_node_index;m_keyboard_scroll_controller.hold_key(event.key);- auto stable_node_id = m_async_scroll_tree.scroll_node_for_id(target)->stable_node_id;+ auto stable_node_id = m_async_scroll_tree.scroll_node_for_index(target_scroll_node_index)->stable_node_id;if (!m_boxes_scrolled_by_held_keys.contains_slow(stable_node_id))m_boxes_scrolled_by_held_keys.append(stable_node_id);Optional<Gfx::FloatPoint> scroll_in_flight_destination;@@ -337,11 +337,11 @@ ContextState::ContextUpdateResult ContextState::handle_key_event(Web::KeyEvent cscroll_in_flight_destination = running_animation.animation.destination_offset();}auto css_scroll_in_flight_destination = scroll_in_flight_destination.map([&](auto offset) { return m_async_scroll_tree.css_pixels_from_device_offset(offset); });- if (auto decision = m_scroll_snap_controller.decide_key_step(m_async_scroll_tree, m_scroll_state_snapshot, target, m_async_scroll_tree.css_pixels_from_device_offset(delta), key_step.snap_selection_intent, css_scroll_in_flight_destination, now); decision.has_value()) {+ if (auto decision = m_scroll_snap_controller.decide_key_step(m_async_scroll_tree, m_scroll_state_snapshot, target_scroll_node_index, m_async_scroll_tree.css_pixels_from_device_offset(delta), key_step.snap_selection_intent, css_scroll_in_flight_destination, now); decision.has_value()) {schedule_end_of_scroll_step_gestures(now);if (auto* snap_scroll = decision->get_pointer<ScrollSnapController::SnapScrollStart>()) {snap_scroll->is_absolute_scroll = scrolls_to_extent;- start_snap_scroll(target, move(*snap_scroll), false, now);+ start_snap_scroll(target_scroll_node_index, move(*snap_scroll), false, now);return {.accepted = true,.frame_to_present = PendingFrame::repainting_changes(m_async_scrolling_viewport_rect),@@ -356,11 +356,11 @@ ContextState::ContextUpdateResult ContextState::handle_key_event(Web::KeyEvent creturn { .accepted = true, .frame_to_present = {}, .should_request_rendering_update = true };}- auto current_offset = m_async_scroll_tree.scroll_offset_for_node(target, m_scroll_state_snapshot);+ auto current_offset = m_async_scroll_tree.scroll_offset_for_node(target_scroll_node_index, m_scroll_state_snapshot);VERIFY(current_offset.has_value());// A plain step continues toward the animation's destination, including any snap on the other axis.auto step_start = scroll_in_flight_destination.value_or(*current_offset);- auto destination = m_async_scroll_tree.clamped_scroll_offset_for_node(target, { step_start.x() + delta.x(), step_start.y() + delta.y() });+ auto destination = m_async_scroll_tree.clamped_scroll_offset_for_node(target_scroll_node_index, { step_start.x() + delta.x(), step_start.y() + delta.y() });if (destination == step_start)return { .accepted = true, .frame_to_present = {}, .should_request_rendering_update = true };@@ -377,7 +377,7 @@ ContextState::ContextUpdateResult ContextState::handle_key_event(Web::KeyEvent c};}- cancel_smooth_scroll_taken_over_by_user_input(target);+ cancel_smooth_scroll_taken_over_by_user_input(target_scroll_node_index);auto operation_id = m_async_scroll_update_outbox.allocate_operation_id();m_smooth_scroll_animations.append({.stable_node_id = stable_node_id,@@ -402,14 +402,14 @@ Compositing::ScrollStateSnapshot ContextState::scroll_state_snapshot_at_keyboard// A key continues a keyboard animation, but takes over other animations from the presented offset.if (!running_animation.is_user_scroll || running_animation.animation.kind() != Compositing::ScrollAnimationKind::SmoothScroll)continue;- auto node_id = m_async_scroll_tree.scroll_node_id_for_stable_id(running_animation.stable_node_id);- if (!node_id.has_value())+ auto scroll_node_index = m_async_scroll_tree.scroll_node_index_for_stable_id(running_animation.stable_node_id);+ if (!scroll_node_index.has_value())continue;auto destination = running_animation.animation.destination_offset();// A snap destination at the boundary can still consume steps until their accumulated input reaches it.if (auto unsnapped_destination = m_scroll_snap_controller.unsnapped_destination_for_snap_scroll(running_animation.stable_node_id, running_animation.operation_id); unsnapped_destination.has_value())destination = m_async_scroll_tree.device_offset_from_css_pixels(*unsnapped_destination);- snapshot.set_device_offset_for_index(node_id->scroll_node_index, { -destination.x(), -destination.y() });+ snapshot.set_device_offset_for_index(*scroll_node_index, { -destination.x(), -destination.y() });}return snapshot;}@@ -525,7 +525,7 @@ ContextState::ContextUpdateResult ContextState::handle_mouse_event_at(Web::Mouseauto press_jumps = m_scrollbar_track_press_jumps != static_cast<bool>(event.modifiers & scrollbar_track_press_inverting_modifier);if (drag->is_press_beside_thumb && !press_jumps) {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);+ auto scroll_offset = m_async_scroll_tree.scroll_offset_for_node(scrollbar.scroll_node_index, 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),@@ -736,7 +736,7 @@ ContextState::ContextUpdateResult ContextState::handle_pinch_event(Web::PinchEve};}-Compositing::AsyncScrollOperationID ContextState::start_snap_scroll(Compositing::AsyncScrollNodeID node_id, ScrollSnapController::SnapScrollStart&& snap_scroll, bool settles_gesture, MonotonicTime now)+Compositing::AsyncScrollOperationID ContextState::start_snap_scroll(Compositing::SpatialNodeIndex scroll_node_index, ScrollSnapController::SnapScrollStart&& snap_scroll, bool settles_gesture, MonotonicTime now){auto const& stable_node_id = snap_scroll.stable_node_id;// A snap scroll of this context's own that is still running is replaced by the new one; any other scroll of the@@ -749,7 +749,7 @@ Compositing::AsyncScrollOperationID ContextState::start_snap_scroll(Compositing:retire_smooth_scroll_animation(stable_node_id);}- auto current_offset = m_async_scroll_tree.scroll_offset_for_node(node_id, m_scroll_state_snapshot);+ auto current_offset = m_async_scroll_tree.scroll_offset_for_node(scroll_node_index, m_scroll_state_snapshot);VERIFY(current_offset.has_value());auto destination = snap_scroll.selection.position;auto operation_id = m_async_scroll_update_outbox.allocate_operation_id();@@ -782,7 +782,7 @@ Optional<Compositing::AsyncScrollOperationID> ContextState::snap_at_gesture_end({Optional<Compositing::AsyncScrollOperationID> operation_id;for (auto& snap : m_scroll_snap_controller.decide_gesture_end(m_async_scroll_tree, m_scroll_state_snapshot)) {- auto started_operation_id = start_snap_scroll(snap.node_id, move(snap.snap_scroll), true, now);+ auto started_operation_id = start_snap_scroll(snap.scroll_node_index, move(snap.snap_scroll), true, now);if (!operation_id.has_value())operation_id = started_operation_id;}@@ -793,21 +793,21 @@ Optional<Compositing::AsyncScrollOperationID> ContextState::snap_at_gesture_end(Gfx::IntRect ContextState::note_async_scrolling_viewport_rect(Gfx::IntRect viewport_rect, Optional<Compositing::AsyncScrollOffset> const& scroll_offset){if (scroll_offset.has_value()) {- auto node_id = m_async_scroll_tree.scroll_node_id_for_stable_id(scroll_offset->stable_node_id);- if (node_id.has_value() && m_async_scroll_tree.scroll_node_is_viewport(*node_id))+ auto scroll_node_index = m_async_scroll_tree.scroll_node_index_for_stable_id(scroll_offset->stable_node_id);+ if (scroll_node_index.has_value() && m_async_scroll_tree.scroll_node_is_viewport(*scroll_node_index))viewport_rect.set_location(scroll_offset->compositor_scroll_offset.to_type<int>());}m_async_scrolling_viewport_rect = viewport_rect;return viewport_rect;}-ContextState::WheelScrollOutcome ContextState::perform_wheel_scroll_of_node(Compositing::AsyncScrollNodeID node_id, Gfx::FloatPoint delta, Web::WheelDeltaPrecision wheel_delta_precision, Web::ScrollGesturePhase scroll_gesture_phase, Compositing::AsyncScrollOperationTracking operation_tracking, Gfx::IntRect viewport_rect, MonotonicTime now, Compositing::ScrollChaining scroll_chaining, VisualViewportPanning visual_viewport_panning)+ContextState::WheelScrollOutcome ContextState::perform_wheel_scroll_of_node(Compositing::SpatialNodeIndex scroll_node_index, Gfx::FloatPoint delta, Web::WheelDeltaPrecision wheel_delta_precision, Web::ScrollGesturePhase scroll_gesture_phase, Compositing::AsyncScrollOperationTracking operation_tracking, Gfx::IntRect viewport_rect, MonotonicTime now, Compositing::ScrollChaining scroll_chaining, VisualViewportPanning visual_viewport_panning){bool pans_visual_viewport = visual_viewport_panning == VisualViewportPanning::BeforeScrolling;auto magnification = pans_visual_viewport ? m_scene.visual_viewport_magnification() : 1.0f;auto step_delta = delta.scaled(1.0f / magnification);- auto const* latched_node = m_async_scroll_tree.scroll_node_for_id(node_id);+ auto const* latched_node = m_async_scroll_tree.scroll_node_for_index(scroll_node_index);bool step_can_stretch_elastically = wheel_step_can_stretch_elastically(wheel_delta_precision, scroll_gesture_phase);bool fingers_can_stretch_latched_scroller = step_can_stretch_elastically && scroll_gesture_phase == Web::ScrollGesturePhase::Ongoing && latched_node;bool momentum_can_bounce_latched_scroller = step_can_stretch_elastically && scroll_gesture_phase == Web::ScrollGesturePhase::Momentum && latched_node@@ -851,7 +851,7 @@ ContextState::WheelScrollOutcome ContextState::perform_wheel_scroll_of_node(CompOptional<Gfx::FloatPoint> delta_the_scroller_did_not_scroll_by;if (!visual_viewport_took_rest_of_step) {- auto node_scroll = scroll_node_by_wheel_delta(node_id, delta_left.scaled(1.0f / magnification), wheel_delta_precision, scroll_gesture_phase, operation_tracking, viewport_rect, now, scroll_chaining);+ auto node_scroll = scroll_node_by_wheel_delta(scroll_node_index, delta_left.scaled(1.0f / magnification), wheel_delta_precision, scroll_gesture_phase, operation_tracking, viewport_rect, now, scroll_chaining);outcome.operation_id = node_scroll.outcome.operation_id;if (node_scroll.outcome.viewport_rect_to_present.has_value())outcome.viewport_rect_to_present = node_scroll.outcome.viewport_rect_to_present;@@ -876,14 +876,14 @@ ContextState::WheelScrollOutcome ContextState::perform_wheel_scroll_of_node(Compreturn outcome;}-ContextState::NodeScrollByWheelDelta ContextState::scroll_node_by_wheel_delta(Compositing::AsyncScrollNodeID node_id, Gfx::FloatPoint delta, Web::WheelDeltaPrecision wheel_delta_precision, Web::ScrollGesturePhase scroll_gesture_phase, Compositing::AsyncScrollOperationTracking operation_tracking, Gfx::IntRect viewport_rect, MonotonicTime now, Compositing::ScrollChaining scroll_chaining)+ContextState::NodeScrollByWheelDelta ContextState::scroll_node_by_wheel_delta(Compositing::SpatialNodeIndex scroll_node_index, Gfx::FloatPoint delta, Web::WheelDeltaPrecision wheel_delta_precision, Web::ScrollGesturePhase scroll_gesture_phase, Compositing::AsyncScrollOperationTracking operation_tracking, Gfx::IntRect viewport_rect, MonotonicTime now, Compositing::ScrollChaining scroll_chaining){WheelScrollOutcome outcome;Optional<Compositing::WheelScrollTarget> wheel_scroll_target;if (wheel_delta_precision == Web::WheelDeltaPrecision::Discrete) {- wheel_scroll_target = m_async_scroll_tree.select_wheel_scroll_target(node_id, delta, m_scroll_state_snapshot, [this](auto stable_node_id) { return in_flight_wheel_destination(stable_node_id); }, scroll_chaining);+ wheel_scroll_target = m_async_scroll_tree.select_wheel_scroll_target(scroll_node_index, delta, m_scroll_state_snapshot, [this](auto stable_node_id) { return in_flight_wheel_destination(stable_node_id); }, scroll_chaining);if (wheel_scroll_target.has_value()) {- node_id = *m_async_scroll_tree.scroll_node_id_for_stable_id(wheel_scroll_target->stable_node_id);+ scroll_node_index = *m_async_scroll_tree.scroll_node_index_for_stable_id(wheel_scroll_target->stable_node_id);m_wheel_gesture_routing.relatch_to(wheel_scroll_target->stable_node_id);}}@@ -892,11 +892,11 @@ ContextState::NodeScrollByWheelDelta ContextState::scroll_node_by_wheel_delta(CoOptional<ScrollSnapController::StepDecision> decision;if (wheel_delta_precision == Web::WheelDeltaPrecision::Discrete) {Optional<Web::CSSPixelPoint> scroll_in_flight_destination;- if (auto const* node = m_async_scroll_tree.scroll_node_for_id(node_id))+ if (auto const* node = m_async_scroll_tree.scroll_node_for_index(scroll_node_index))scroll_in_flight_destination = in_flight_wheel_destination(node->stable_node_id).map([&](auto offset) { return m_async_scroll_tree.css_pixels_from_device_offset(offset); });- decision = m_scroll_snap_controller.decide_discrete_step(m_async_scroll_tree, m_scroll_state_snapshot, node_id, css_delta, scroll_in_flight_destination, now);+ decision = m_scroll_snap_controller.decide_discrete_step(m_async_scroll_tree, m_scroll_state_snapshot, scroll_node_index, css_delta, scroll_in_flight_destination, now);} else if (scroll_gesture_phase == Web::ScrollGesturePhase::Momentum) {- decision = m_scroll_snap_controller.decide_momentum_delta(m_async_scroll_tree, m_scroll_state_snapshot, node_id, css_delta);+ decision = m_scroll_snap_controller.decide_momentum_delta(m_async_scroll_tree, m_scroll_state_snapshot, scroll_node_index, css_delta);}if (decision.has_value()) {@@ -904,7 +904,7 @@ ContextState::NodeScrollByWheelDelta ContextState::scroll_node_by_wheel_delta(Coif (auto* snap_scroll = decision->get_pointer<ScrollSnapController::SnapScrollStart>()) {if (wheel_delta_precision == Web::WheelDeltaPrecision::Discrete)snap_scroll->animation_kind = Compositing::ScrollAnimationKind::Wheel;- auto operation_id = start_snap_scroll(node_id, move(*snap_scroll), false, now);+ auto operation_id = start_snap_scroll(scroll_node_index, move(*snap_scroll), false, now);if (operation_tracking == Compositing::AsyncScrollOperationTracking::Yes)outcome.operation_id = operation_id;outcome.viewport_rect_to_present = note_async_scrolling_viewport_rect(viewport_rect, {});@@ -925,11 +925,11 @@ ContextState::NodeScrollByWheelDelta ContextState::scroll_node_by_wheel_delta(Coreturn { outcome, {} };}- cancel_smooth_scroll_taken_over_by_user_input(node_id);+ cancel_smooth_scroll_taken_over_by_user_input(scroll_node_index);if (operation_tracking == Compositing::AsyncScrollOperationTracking::Yes)outcome.operation_id = m_async_scroll_update_outbox.allocate_operation_id();- auto scroll_offset = m_async_scroll_tree.apply_scroll_delta(node_id, delta, m_scene.current_visual_context_tree(), m_scroll_state_snapshot, scroll_chaining);+ auto scroll_offset = m_async_scroll_tree.apply_scroll_delta(scroll_node_index, delta, m_scene.current_visual_context_tree(), m_scroll_state_snapshot, scroll_chaining);if (!scroll_offset.has_value()) {if (outcome.operation_id.has_value())m_async_scroll_update_outbox.complete_operation(*outcome.operation_id);@@ -939,7 +939,7 @@ ContextState::NodeScrollByWheelDelta ContextState::scroll_node_by_wheel_delta(Conote_user_input_scrolled(scroll_offset->stable_node_id);// On the first step of a gesture, scroll node chaining may have scrolled an ancestor instead, which took the delta.- auto const* node = m_async_scroll_tree.scroll_node_for_id(node_id);+ auto const* node = m_async_scroll_tree.scroll_node_for_index(scroll_node_index);bool an_ancestor_scrolled = node && scroll_offset->stable_node_id != node->stable_node_id;Optional<Gfx::FloatPoint> delta_the_node_did_not_scroll_by;if (!an_ancestor_scrolled)@@ -1007,14 +1007,14 @@ ContextState::AsyncScrollResult ContextState::async_scroll_by(// The compositor hands every step of a gesture latched to a nested context's scroller to that context itself.if (latch.nested_context_id.has_value())return AsyncScrollResult::declined(Web::InputRoutingDecision::ScrollerInOtherDocument);- auto latched_node_id = latch.node_id;+ auto latched_scroll_node_index = latch.scroll_node_index;// The end of the gesture before this one may never have arrived. Whether a step of the UI starts another gesture// was decided when the UI sent it.- if (!latched_node_id.has_value() && !step_came_from_ui)+ if (!latched_scroll_node_index.has_value() && !step_came_from_ui)m_elastic_overscroll_controller.end_gesture(now);if (!m_wheel_gesture_routing.admits_async_wheel()- && !step_continues_touchpad_gesture_the_page_let_through(latched_node_id, wheel_delta_precision, scroll_gesture_phase)+ && !step_continues_touchpad_gesture_the_page_let_through(latched_scroll_node_index, wheel_delta_precision, scroll_gesture_phase)&& !(page_let_touchpad_step_through && only_blocking_wheel_event_listeners_hold_steps_back))return AsyncScrollResult::declined(Compositing::input_routing_decision_for_wheel_step_not_admitted_by(m_wheel_gesture_routing.admission()));@@ -1036,16 +1036,16 @@ ContextState::AsyncScrollResult ContextState::async_scroll_by(};}- bool is_first_step_of_gesture = !latched_node_id.has_value();+ bool is_first_step_of_gesture = !latched_scroll_node_index.has_value();auto routing_decision = Web::InputRoutingDecision::ContinuedLatch;if (is_first_step_of_gesture) {auto wheel_step_dispatch_for_hit_test = page_let_touchpad_step_through ? Compositing::WheelStepDispatch::DispatchedAndNotCanceled : Compositing::WheelStepDispatch::NotYetDispatched;auto latch_attempt = hit_test_and_latch_wheel_gesture(position, delta, wheel_delta_precision, scroll_gesture_phase, expected_document_id, wheel_step_dispatch_for_hit_test, Compositing::NestedContextRegions::LeaveToMainThread);- if (!latch_attempt.latched_node_id.has_value())+ if (!latch_attempt.latched_scroll_node_index.has_value())return AsyncScrollResult::declined(latch_attempt.decision);- latched_node_id = latch_attempt.latched_node_id;+ latched_scroll_node_index = latch_attempt.latched_scroll_node_index;routing_decision = latch_attempt.decision;- } else if (latched_node_id->document_id != expected_document_id) {+ } else if (m_async_scroll_tree.document_id() != expected_document_id) {// A step over another document than the latched scroller's is left to the navigable hosting that scroller,// which reports the same step with its own document.return AsyncScrollResult::declined(Web::InputRoutingDecision::ScrollerInOtherDocument);@@ -1054,7 +1054,7 @@ ContextState::AsyncScrollResult ContextState::async_scroll_by(m_wheel_gesture_routing.note_page_let_latched_gesture_through();auto scroll_chaining = is_first_step_of_gesture ? Compositing::ScrollChaining::ToScrollableAncestors : Compositing::ScrollChaining::None;- auto outcome = perform_wheel_scroll_of_node(*latched_node_id, delta, wheel_delta_precision, scroll_gesture_phase, operation_tracking, viewport_rect, now, scroll_chaining, VisualViewportPanning::No);+ auto outcome = perform_wheel_scroll_of_node(*latched_scroll_node_index, delta, wheel_delta_precision, scroll_gesture_phase, operation_tracking, viewport_rect, now, scroll_chaining, VisualViewportPanning::No);return {.enqueue_result = {.accepted = true,@@ -1071,14 +1071,14 @@ void ContextState::note_user_input_scrolled(Web::AsyncScrollNodeStableID stable_m_user_input_scroll_counts.ensure(stable_node_id)++;}-Optional<Gfx::Orientation> ContextState::axis_held_by_scrollbar_of(Compositing::AsyncScrollNodeID node_id) const+Optional<Gfx::Orientation> ContextState::axis_held_by_scrollbar_of(Compositing::SpatialNodeIndex scroll_node_index) const{// Paging steps toward the pointer like keys do, and takes a script's scroll along like them.auto scrollbar_index = m_scrollbar_controller.captured_scrollbar_index();if (!scrollbar_index.has_value() || m_scrollbar_paging.has_value())return {};auto const& scrollbar = m_scrollbar_controller.scrollbars()[scrollbar_index.value()];- if (scrollbar.scroll_node_id != node_id)+ if (scrollbar.scroll_node_index != scroll_node_index)return {};return scrollbar.vertical ? Gfx::Orientation::Vertical : Gfx::Orientation::Horizontal;}@@ -1098,10 +1098,10 @@ Optional<PendingFrame> ContextState::apply_scroll_requests(ReadonlySpan<Compositcontinue;}- Optional<Compositing::AsyncScrollNodeID> node_id;+ Optional<Compositing::SpatialNodeIndex> scroll_node_index;if (m_has_async_scrolling_state)- node_id = m_async_scroll_tree.scroll_node_id_for_stable_id(scroll_request.stable_node_id);- auto old_offset = node_id.has_value() ? m_async_scroll_tree.scroll_offset_for_node(node_id.value(), m_scroll_state_snapshot) : Optional<Gfx::FloatPoint> {};+ scroll_node_index = m_async_scroll_tree.scroll_node_index_for_stable_id(scroll_request.stable_node_id);+ auto old_offset = scroll_node_index.has_value() ? m_async_scroll_tree.scroll_offset_for_node(scroll_node_index.value(), m_scroll_state_snapshot) : Optional<Gfx::FloatPoint> {};if (!old_offset.has_value()) {if (scroll_request.smooth_scroll.has_value())m_async_scroll_update_outbox.complete_operation(scroll_request.smooth_scroll->operation_id);@@ -1110,9 +1110,9 @@ Optional<PendingFrame> ContextState::apply_scroll_requests(ReadonlySpan<Composit// The answer tells the main thread where the box went for the request, even where it stayed where it was.auto answer_with_the_offset_of_the_box = [&] {- auto new_offset = m_async_scroll_tree.scroll_offset_for_node(node_id.value(), m_scroll_state_snapshot).value();+ auto new_offset = m_async_scroll_tree.scroll_offset_for_node(scroll_node_index.value(), m_scroll_state_snapshot).value();moved_the_box = new_offset != old_offset.value();- if (m_async_scroll_tree.scroll_node_is_viewport(node_id.value()))+ if (m_async_scroll_tree.scroll_node_is_viewport(scroll_node_index.value()))m_async_scrolling_viewport_rect.set_location(new_offset.to_type<int>());answers.append({.stable_node_id = scroll_request.stable_node_id,@@ -1159,7 +1159,7 @@ Optional<PendingFrame> ContextState::apply_scroll_requests(ReadonlySpan<Composit// The thumb of a scrollbar that the user holds stays under the pointer: the user scrolls the box along that axis// from the moment a script does, which aborts a smooth scroll of the script's.- auto axis_held_by_scrollbar = axis_held_by_scrollbar_of(node_id.value());+ auto axis_held_by_scrollbar = axis_held_by_scrollbar_of(scroll_node_index.value());if (axis_held_by_scrollbar.has_value() && smooth_scroll_is_for_script) {m_async_scroll_update_outbox.note_operation_taken_over_by_user_input(smooth_scroll->operation_id);m_async_scroll_update_outbox.complete_operation(smooth_scroll->operation_id);@@ -1186,32 +1186,32 @@ Optional<PendingFrame> ContextState::apply_scroll_requests(ReadonlySpan<Compositm_scroll_snap_controller.did_start_main_thread_scroll(scroll_request.stable_node_id);}- auto offset_before_instant_scroll = m_async_scroll_tree.scroll_offset_for_node(node_id.value(), m_scroll_state_snapshot).value();+ auto offset_before_instant_scroll = m_async_scroll_tree.scroll_offset_for_node(scroll_node_index.value(), m_scroll_state_snapshot).value();if (scroll_request.jump_offset.has_value())- (void)m_async_scroll_tree.set_scroll_offset(node_id.value(), scroll_request.jump_offset.value(), m_scene.current_visual_context_tree(), m_scroll_state_snapshot);+ (void)m_async_scroll_tree.set_scroll_offset(scroll_node_index.value(), scroll_request.jump_offset.value(), m_scene.current_visual_context_tree(), m_scroll_state_snapshot);// A box new to this context took its offset from the frame's snapshot, which has the frame's scrolls in it.bool offset_has_the_request_in_it = m_scroll_nodes_seeded_by_last_frame.contains(scroll_request.stable_node_id);if (auto const& relative_scroll = scroll_request.relative_scroll; relative_scroll.has_value() && !offset_has_the_request_in_it) {- if (scroll_request.relative_scroll_moves_visual_viewport_first && m_async_scroll_tree.scroll_node_is_viewport(node_id.value())) {- scroll_visual_viewport_position_in_page(node_id.value(), relative_scroll.value(), answers);+ if (scroll_request.relative_scroll_moves_visual_viewport_first && m_async_scroll_tree.scroll_node_is_viewport(scroll_node_index.value())) {+ scroll_visual_viewport_position_in_page(scroll_node_index.value(), relative_scroll.value(), answers);} else {- auto offset = m_async_scroll_tree.scroll_offset_for_node(node_id.value(), m_scroll_state_snapshot).value();- (void)m_async_scroll_tree.set_scroll_offset(node_id.value(), relative_scroll->applied_to(offset), m_scene.current_visual_context_tree(), m_scroll_state_snapshot);+ auto offset = m_async_scroll_tree.scroll_offset_for_node(scroll_node_index.value(), m_scroll_state_snapshot).value();+ (void)m_async_scroll_tree.set_scroll_offset(scroll_node_index.value(), relative_scroll->applied_to(offset), m_scene.current_visual_context_tree(), m_scroll_state_snapshot);}}if (axis_held_by_scrollbar.has_value() && instant_scroll_is_for_script) {- auto offset = m_async_scroll_tree.scroll_offset_for_node(node_id.value(), m_scroll_state_snapshot).value();+ auto offset = m_async_scroll_tree.scroll_offset_for_node(scroll_node_index.value(), m_scroll_state_snapshot).value();offset.set_primary_offset_for_orientation(axis_held_by_scrollbar.value(), offset_before_instant_scroll.primary_offset_for_orientation(axis_held_by_scrollbar.value()));- (void)m_async_scroll_tree.set_scroll_offset(node_id.value(), offset, m_scene.current_visual_context_tree(), m_scroll_state_snapshot);+ (void)m_async_scroll_tree.set_scroll_offset(scroll_node_index.value(), offset, m_scene.current_visual_context_tree(), m_scroll_state_snapshot);}- auto instant_scroll_delta = m_async_scroll_tree.scroll_offset_for_node(node_id.value(), m_scroll_state_snapshot).value() - offset_before_instant_scroll;+ auto instant_scroll_delta = m_async_scroll_tree.scroll_offset_for_node(scroll_node_index.value(), m_scroll_state_snapshot).value() - offset_before_instant_scroll;if (shifts_running_animation) {// A step that goes to an end of the scroll range still goes there.if (!running_animation->heads_to_an_extent) {running_animation->animation.shift_by(instant_scroll_delta);auto destination_offset = running_animation->animation.destination_offset();- auto clamped_destination_offset = m_async_scroll_tree.clamped_scroll_offset_for_node(node_id.value(), destination_offset);+ auto clamped_destination_offset = m_async_scroll_tree.clamped_scroll_offset_for_node(scroll_node_index.value(), destination_offset);if (clamped_destination_offset != destination_offset)running_animation->animation.retarget(clamped_destination_offset, MonotonicTime::now() - running_animation->started_at);}@@ -1225,16 +1225,16 @@ Optional<PendingFrame> ContextState::apply_scroll_requests(ReadonlySpan<Compositif (smooth_scroll.has_value()) {auto destination_offset = smooth_scroll->destination_offset;if (smooth_scroll->destination_is_relative) {- auto relative_scroll_start = m_async_scroll_tree.scroll_offset_for_node(node_id.value(), m_scroll_state_snapshot).value();+ auto relative_scroll_start = m_async_scroll_tree.scroll_offset_for_node(scroll_node_index.value(), m_scroll_state_snapshot).value();if (smooth_scroll->initiator == Compositing::SmoothScrollInitiator::UserInput && destination_of_running_user_scroll.has_value())relative_scroll_start = destination_of_running_user_scroll.value();destination_offset.translate_by(relative_scroll_start);}- destination_offset = m_async_scroll_tree.clamped_scroll_offset_for_node(node_id.value(), destination_offset);+ destination_offset = m_async_scroll_tree.clamped_scroll_offset_for_node(scroll_node_index.value(), destination_offset);if (retargets_running_animation) {retarget_user_scroll(*running_animation, destination_offset, MonotonicTime::now());} else {- auto start_offset = m_async_scroll_tree.scroll_offset_for_node(node_id.value(), m_scroll_state_snapshot).value();+ auto start_offset = m_async_scroll_tree.scroll_offset_for_node(scroll_node_index.value(), m_scroll_state_snapshot).value();Compositing::SmoothScrollAnimation animation { start_offset, destination_offset, m_async_scroll_tree.device_pixels_per_css_pixel(), smooth_scroll->animation_kind };if (animation.duration().is_zero()) {m_async_scroll_update_outbox.complete_operation(smooth_scroll->operation_id);@@ -1267,9 +1267,9 @@ Optional<PendingFrame> ContextState::apply_scroll_requests(ReadonlySpan<Composit// https://drafts.csswg.org/cssom-view/#viewport-perform-a-scroll// The visual viewport takes as much of the scroll as it can before the layout viewport takes the rest.-void ContextState::scroll_visual_viewport_position_in_page(Compositing::AsyncScrollNodeID viewport_node_id, Compositing::RequestedRelativeScroll const& relative_scroll, Vector<Compositing::AsyncScrollOffset>& answers)+void ContextState::scroll_visual_viewport_position_in_page(Compositing::SpatialNodeIndex viewport_scroll_node_index, Compositing::RequestedRelativeScroll const& relative_scroll, Vector<Compositing::AsyncScrollOffset>& answers){- auto layout_viewport_offset = m_async_scroll_tree.scroll_offset_for_node(viewport_node_id, m_scroll_state_snapshot).value();+ auto layout_viewport_offset = m_async_scroll_tree.scroll_offset_for_node(viewport_scroll_node_index, m_scroll_state_snapshot).value();auto transform = m_scene.visual_viewport_transform();auto scale = transform.matrix[0, 0];auto old_visual_viewport_offset = visual_viewport_scroll_offset(transform);@@ -1286,7 +1286,7 @@ void ContextState::scroll_visual_viewport_position_in_page(Compositing::AsyncScrAK::clamp(old_visual_viewport_offset.y() + delta.y(), 0.0f, maximum_visual_viewport_offset.y()),};auto visual_delta = new_visual_viewport_offset - old_visual_viewport_offset;- (void)m_async_scroll_tree.set_scroll_offset(viewport_node_id, layout_viewport_offset.translated(delta - visual_delta), m_scene.current_visual_context_tree(), m_scroll_state_snapshot);+ (void)m_async_scroll_tree.set_scroll_offset(viewport_scroll_node_index, layout_viewport_offset.translated(delta - visual_delta), m_scene.current_visual_context_tree(), m_scroll_state_snapshot);if (visual_delta.is_zero())return;@@ -1414,8 +1414,8 @@ void ContextState::retire_smooth_scroll_animation(Web::AsyncScrollNodeStableID scontinue;if (m_scroll_snap_controller.is_snap_scroll(stable_node_id, smooth_scroll_animation.operation_id)) {Optional<Web::CSSPixelPoint> scroll_offset;- if (auto node_id = m_async_scroll_tree.scroll_node_id_for_stable_id(stable_node_id); node_id.has_value())- scroll_offset = m_async_scroll_tree.css_scroll_offset_for_node(*node_id, m_scroll_state_snapshot);+ if (auto scroll_node_index = m_async_scroll_tree.scroll_node_index_for_stable_id(stable_node_id); scroll_node_index.has_value())+ scroll_offset = m_async_scroll_tree.css_scroll_offset_for_node(*scroll_node_index, m_scroll_state_snapshot);m_scroll_snap_controller.did_end_snap_scroll(stable_node_id, smooth_scroll_animation.operation_id, scroll_offset);}m_async_scroll_update_outbox.complete_operation(smooth_scroll_animation.operation_id);@@ -1433,15 +1433,15 @@ Optional<Gfx::IntRect> ContextState::advance_smooth_scroll_animations(MonotonicTfor (size_t index = 0; index < m_smooth_scroll_animations.size();) {auto& active_animation = m_smooth_scroll_animations[index];- auto node_id = m_async_scroll_tree.scroll_node_id_for_stable_id(active_animation.stable_node_id);- if (!node_id.has_value()) {+ auto scroll_node_index = m_async_scroll_tree.scroll_node_index_for_stable_id(active_animation.stable_node_id);+ if (!scroll_node_index.has_value()) {m_async_scroll_update_outbox.complete_operation(active_animation.operation_id);completed_operation = true;m_smooth_scroll_animations.remove(index);continue;}- auto old_offset = m_async_scroll_tree.scroll_offset_for_node(*node_id, m_scroll_state_snapshot);+ auto old_offset = m_async_scroll_tree.scroll_offset_for_node(*scroll_node_index, m_scroll_state_snapshot);if (!old_offset.has_value()) {m_async_scroll_update_outbox.complete_operation(active_animation.operation_id);completed_operation = true;@@ -1450,7 +1450,7 @@ Optional<Gfx::IntRect> ContextState::advance_smooth_scroll_animations(MonotonicT}auto sample = active_animation.animation.sample(now - active_animation.started_at);- auto new_offset = m_async_scroll_tree.set_scroll_offset(*node_id, sample.offset, m_scene.current_visual_context_tree(), m_scroll_state_snapshot);+ auto new_offset = m_async_scroll_tree.set_scroll_offset(*scroll_node_index, sample.offset, m_scene.current_visual_context_tree(), m_scroll_state_snapshot);VERIFY(new_offset.has_value());auto scroll_delta = *new_offset - *old_offset;if (!scroll_delta.is_zero()) {@@ -1464,7 +1464,7 @@ Optional<Gfx::IntRect> ContextState::advance_smooth_scroll_animations(MonotonicT.user_input_scroll_count = 0,});changed_scroll_offset = true;- if (m_async_scroll_tree.scroll_node_is_viewport(*node_id))+ if (m_async_scroll_tree.scroll_node_is_viewport(*scroll_node_index))m_async_scrolling_viewport_rect.set_location(new_offset->to_type<int>());}@@ -1515,9 +1515,9 @@ Gfx::FloatPoint ContextState::wheel_event_delta_in_device_pixels(Web::MouseEvent.scaled(static_cast<float>(m_async_scroll_tree.device_pixels_per_css_pixel()));}-bool ContextState::step_continues_touchpad_gesture_the_page_let_through(Optional<Compositing::AsyncScrollNodeID> const& latched_node_id, Web::WheelDeltaPrecision wheel_delta_precision, Web::ScrollGesturePhase scroll_gesture_phase) const+bool ContextState::step_continues_touchpad_gesture_the_page_let_through(Optional<Compositing::SpatialNodeIndex> const& latched_scroll_node_index, Web::WheelDeltaPrecision wheel_delta_precision, Web::ScrollGesturePhase scroll_gesture_phase) const{- return latched_node_id.has_value() && presents_to_client() && m_wheel_gesture_routing.page_let_latched_touchpad_gesture_through(wheel_delta_precision, scroll_gesture_phase);+ return latched_scroll_node_index.has_value() && presents_to_client() && m_wheel_gesture_routing.page_let_latched_touchpad_gesture_through(wheel_delta_precision, scroll_gesture_phase);}Web::WheelGestureMark ContextState::note_wheel_event_from_ui(Web::MouseEvent const& event, Optional<MonotonicTime> now_for_testing)@@ -1637,7 +1637,7 @@ ContextState::ContextUpdateResult ContextState::scroll_for_wheel_event(Web::Mous// The first step of a gesture over the content of a nested context goes to that context. A gesture whose first step// went elsewhere is not handed to a nested context that comes under the pointer later.auto nested_context_regions = Compositing::NestedContextRegions::LeaveToMainThread;- bool may_hand_step_to_nested_context = !latch.node_id.has_value()+ bool may_hand_step_to_nested_context = !latch.scroll_node_index.has_value()&& m_wheel_gesture_routing.is_first_wheel_event_with_delta(event.id)&& may_hand_first_wheel_steps_to_nested_contexts();if (may_hand_step_to_nested_context) {@@ -1645,7 +1645,7 @@ ContextState::ContextUpdateResult ContextState::scroll_for_wheel_event(Web::Mousif (auto hit = nested_context_for_wheel_at(position); hit.has_value())return { .nested_context_wheel_step = NestedContextWheelStep { .context_id = hit->child_context_id, .hit = hit } };}- return scroll_for_wheel_event_in_this_context(event, latch.node_id, nested_context_regions, now);+ return scroll_for_wheel_event_in_this_context(event, latch.scroll_node_index, nested_context_regions, now);}ContextState::ContextUpdateResult ContextState::scroll_for_wheel_event_passed_on_by_nested_context(Web::MouseEvent const& event, MonotonicTime now)@@ -1653,7 +1653,7 @@ ContextState::ContextUpdateResult ContextState::scroll_for_wheel_event_passed_onreturn scroll_for_wheel_event_in_this_context(event, {}, Compositing::NestedContextRegions::Ignore, now);}-ContextState::ContextUpdateResult ContextState::scroll_for_wheel_event_in_this_context(Web::MouseEvent const& event, Optional<Compositing::AsyncScrollNodeID> latched_node_id, Compositing::NestedContextRegions nested_context_regions, MonotonicTime now)+ContextState::ContextUpdateResult ContextState::scroll_for_wheel_event_in_this_context(Web::MouseEvent const& event, Optional<Compositing::SpatialNodeIndex> latched_scroll_node_index, Compositing::NestedContextRegions nested_context_regions, MonotonicTime now){auto position = wheel_event_position(event);auto delta = wheel_event_delta_in_device_pixels(event);@@ -1662,7 +1662,7 @@ ContextState::ContextUpdateResult ContextState::scroll_for_wheel_event_in_this_cauto can_pan_zoomed_visual_viewport = m_wheel_gesture_routing.admission() == Compositing::WheelRoutingAdmission::NoScrollNode&& m_scene.visual_viewport_scale().value_or(1.0f) > 1.0f;if (!m_wheel_gesture_routing.admits_async_wheel() && !can_pan_zoomed_visual_viewport- && !step_continues_touchpad_gesture_the_page_let_through(latched_node_id, event.wheel_delta_precision, event.scroll_gesture_phase))+ && !step_continues_touchpad_gesture_the_page_let_through(latched_scroll_node_index, event.wheel_delta_precision, event.scroll_gesture_phase))return ContextUpdateResult::declined(Compositing::input_routing_decision_for_wheel_step_not_admitted_by(m_wheel_gesture_routing.admission()));m_scroll_snap_controller.note_gesture_phase(event.scroll_gesture_phase);@@ -1680,7 +1680,7 @@ ContextState::ContextUpdateResult ContextState::scroll_for_wheel_event_in_this_c// Whether a gesture scrolls here or on the main thread is decided by its first step; the steps of a latched// gesture are not held back by regions the cursor moves over later.- bool is_first_step_of_gesture = !latched_node_id.has_value();+ bool is_first_step_of_gesture = !latched_scroll_node_index.has_value();if (is_first_step_of_gesture) {auto initial_scroll_target = m_async_scroll_tree.hit_test_scroll_node_for_wheel(m_scene.visual_context_tree_for_compositing(), position, delta, {}, Compositing::WheelStepDispatch::NotYetDispatched, nested_context_regions);if (initial_scroll_target.is_blocked_by_a_region())@@ -1702,12 +1702,12 @@ ContextState::ContextUpdateResult ContextState::scroll_for_wheel_event_in_this_cauto routing_decision = Web::InputRoutingDecision::ContinuedLatch;if (is_first_step_of_gesture) {auto latch_attempt = hit_test_and_latch_wheel_gesture(position, delta.scaled(1.0f / m_scene.visual_viewport_magnification()), event.wheel_delta_precision, event.scroll_gesture_phase, {}, Compositing::WheelStepDispatch::NotYetDispatched, nested_context_regions);- latched_node_id = latch_attempt.latched_node_id;+ latched_scroll_node_index = latch_attempt.latched_scroll_node_index;routing_decision = latch_attempt.decision;}// A zoomed page still pans its visual viewport by a gesture that no scroller takes.- if (!latched_node_id.has_value()) {+ if (!latched_scroll_node_index.has_value()) {if (pan_visual_viewport_by(delta).is_zero())return ContextUpdateResult::declined(routing_decision);return {@@ -1719,7 +1719,7 @@ ContextState::ContextUpdateResult ContextState::scroll_for_wheel_event_in_this_c}auto scroll_chaining = is_first_step_of_gesture ? Compositing::ScrollChaining::ToScrollableAncestors : Compositing::ScrollChaining::None;- auto outcome = perform_wheel_scroll_of_node(*latched_node_id, delta, event.wheel_delta_precision, event.scroll_gesture_phase, Compositing::AsyncScrollOperationTracking::No, m_async_scrolling_viewport_rect, now, scroll_chaining, VisualViewportPanning::BeforeScrolling);+ auto outcome = perform_wheel_scroll_of_node(*latched_scroll_node_index, delta, event.wheel_delta_precision, event.scroll_gesture_phase, Compositing::AsyncScrollOperationTracking::No, m_async_scrolling_viewport_rect, now, scroll_chaining, VisualViewportPanning::BeforeScrolling);return {.accepted = true,.frame_to_present = outcome.viewport_rect_to_present.map([](auto const& rect) { return PendingFrame::repainting_changes(rect); }),@@ -1783,11 +1783,11 @@ ContextState::FirstWheelStepRoute ContextState::route_first_wheel_step_from_contif (wheel_delta_precision == Web::WheelDeltaPrecision::Discrete)in_flight_destination_for = [this](auto stable_node_id) { return in_flight_wheel_destination(stable_node_id); };auto scroll_target = m_async_scroll_tree.hit_test_scroll_node_for_wheel(visual_context_tree, position, delta, in_flight_destination_for, Compositing::WheelStepDispatch::NotYetDispatched, nested_context_regions);- auto scroller_of = [&](Optional<Compositing::AsyncScrollNodeID> node_id) {- return node_id.map([&](auto id) { return m_async_scroll_tree.scroll_node_for_id(id)->stable_node_id; });+ auto scroller_of = [&](Optional<Compositing::SpatialNodeIndex> scroll_node_index) {+ return scroll_node_index.map([&](auto index) { return m_async_scroll_tree.scroll_node_for_index(index)->stable_node_id; });};if (scroll_target.outcome == Compositing::WheelHitTestOutcome::FoundScrollTarget)- return { .kind = Kind::ScrollNode, .decision = Web::InputRoutingDecision::Latched, .node_id = scroll_target.node_id, .scroller = scroller_of(scroll_target.node_id) };+ return { .kind = Kind::ScrollNode, .decision = Web::InputRoutingDecision::Latched, .scroll_node_index = scroll_target.scroll_node_index, .scroller = scroller_of(scroll_target.scroll_node_index) };if (scroll_target.outcome != Compositing::WheelHitTestOutcome::NoScrollTarget)return { Kind::Declined, Compositing::input_routing_decision_for_first_wheel_step(scroll_target.outcome) };@@ -1795,10 +1795,10 @@ ContextState::FirstWheelStepRoute ContextState::route_first_wheel_step_from_cont// A nested context does not stretch at its edge. It passes the step on to the document around it unless a scroller// keeps it, the viewport included.bool viewport_keeps_the_scroll = m_async_scroll_tree.viewport_keeps_scrolls_along_main_axis_of(delta);- if (!scroll_target.node_keeping_the_scroll.has_value() && !viewport_keeps_the_scroll)+ if (!scroll_target.scroll_node_index_keeping_the_scroll.has_value() && !viewport_keeps_the_scroll)return { Kind::PassedOn, Web::InputRoutingDecision::NestedContextPassedStepOn };- auto node_keeping_the_scroll = scroll_target.node_keeping_the_scroll.has_value() ? scroll_target.node_keeping_the_scroll : m_async_scroll_tree.viewport_scroll_node_id();- return { .kind = Kind::Kept, .decision = Web::InputRoutingDecision::ScrollKeptByOverscrollBehavior, .node_id = node_keeping_the_scroll, .scroller = scroller_of(node_keeping_the_scroll) };+ auto scroll_node_index_keeping_the_scroll = scroll_target.scroll_node_index_keeping_the_scroll.has_value() ? scroll_target.scroll_node_index_keeping_the_scroll : m_async_scroll_tree.viewport_scroll_node_index();+ return { .kind = Kind::Kept, .decision = Web::InputRoutingDecision::ScrollKeptByOverscrollBehavior, .scroll_node_index = scroll_node_index_keeping_the_scroll, .scroller = scroller_of(scroll_node_index_keeping_the_scroll) };}ContextState::ContextUpdateResult ContextState::take_first_wheel_step_from_containing_context(FirstWheelStepRoute const& route, WheelStepFromContainingContext const& step, MonotonicTime now)@@ -1812,7 +1812,7 @@ ContextState::ContextUpdateResult ContextState::take_first_wheel_step_from_contareturn { .accepted = true, .routing_decision = route.decision, .routed_scroller = route.scroller };}m_wheel_gesture_routing.latch(*route.scroller, step.scroll_gesture_phase);- return take_wheel_step_from_containing_context(*route.node_id, route.decision, step, Compositing::ScrollChaining::ToScrollableAncestors, now);+ return take_wheel_step_from_containing_context(*route.scroll_node_index, route.decision, step, Compositing::ScrollChaining::ToScrollableAncestors, now);}ContextState::ContextUpdateResult ContextState::take_latched_wheel_step_from_containing_context(WheelStepFromContainingContext const& step, MonotonicTime now)@@ -1827,7 +1827,7 @@ ContextState::ContextUpdateResult ContextState::take_latched_wheel_step_from_conauto latch = m_wheel_gesture_routing.resolve_latch(m_async_scroll_tree, m_scene.current_visual_context_tree(), step.scroll_gesture_phase);if (latch.keeps_steps)return { .accepted = true, .routing_decision = Web::InputRoutingDecision::ScrollKeptByOverscrollBehavior };- if (!latch.node_id.has_value())+ if (!latch.scroll_node_index.has_value())return ContextUpdateResult::declined(Web::InputRoutingDecision::NestedContextUnavailable);if (step.scroll_gesture_phase == Web::ScrollGesturePhase::Ended && step.delta_in_css_pixels.is_zero()) {@@ -1842,14 +1842,14 @@ ContextState::ContextUpdateResult ContextState::take_latched_wheel_step_from_con.routed_scroller = m_wheel_gesture_routing.latched_scroller(),};}- return take_wheel_step_from_containing_context(*latch.node_id, Web::InputRoutingDecision::ContinuedLatch, step, Compositing::ScrollChaining::None, now);+ return take_wheel_step_from_containing_context(*latch.scroll_node_index, Web::InputRoutingDecision::ContinuedLatch, step, Compositing::ScrollChaining::None, now);}-ContextState::ContextUpdateResult ContextState::take_wheel_step_from_containing_context(Compositing::AsyncScrollNodeID node_id, Web::InputRoutingDecision decision, WheelStepFromContainingContext const& step, Compositing::ScrollChaining scroll_chaining, MonotonicTime now)+ContextState::ContextUpdateResult ContextState::take_wheel_step_from_containing_context(Compositing::SpatialNodeIndex scroll_node_index, Web::InputRoutingDecision decision, WheelStepFromContainingContext const& step, Compositing::ScrollChaining scroll_chaining, MonotonicTime now){m_scroll_snap_controller.note_gesture_phase(step.scroll_gesture_phase);auto delta = step.delta_in_css_pixels.scaled(static_cast<float>(m_async_scroll_tree.device_pixels_per_css_pixel()));- auto outcome = perform_wheel_scroll_of_node(node_id, delta, step.wheel_delta_precision, step.scroll_gesture_phase, Compositing::AsyncScrollOperationTracking::No, m_async_scrolling_viewport_rect, now, scroll_chaining, VisualViewportPanning::No);+ auto outcome = perform_wheel_scroll_of_node(scroll_node_index, delta, step.wheel_delta_precision, step.scroll_gesture_phase, Compositing::AsyncScrollOperationTracking::No, m_async_scrolling_viewport_rect, now, scroll_chaining, VisualViewportPanning::No);return {.accepted = true,.frame_to_present = outcome.viewport_rect_to_present.map([](auto const& rect) { return PendingFrame::repainting_changes(rect); }),@@ -1866,7 +1866,7 @@ bool ContextState::wheel_step_can_stretch_elastically(Web::WheelDeltaPrecision wbool ContextState::pull_elastic_overscroll_by(Compositing::AsyncScrollNode const& node, Gfx::FloatPoint step_delta, Gfx::FloatPoint delta_the_scroller_did_not_scroll_by){- auto scroll_offset = m_async_scroll_tree.scroll_offset_for_node(node.node_id, m_scroll_state_snapshot);+ auto scroll_offset = m_async_scroll_tree.scroll_offset_for_node(node.scroll_node_index, m_scroll_state_snapshot);if (!scroll_offset.has_value())return false;return m_elastic_overscroll_controller.pull_by(node, *scroll_offset, step_delta, delta_the_scroller_did_not_scroll_by, m_scene.visual_viewport_magnification());@@ -1979,7 +1979,7 @@ Vector<Web::CompositorScrollOffset> ContextState::scroll_offsets() constVector<Web::CompositorScrollOffset> scroll_offsets;scroll_offsets.ensure_capacity(scroll_nodes.size());for (auto const& node : scroll_nodes) {- if (auto offset = m_async_scroll_tree.css_scroll_offset_for_node(node.node_id, m_scroll_state_snapshot); offset.has_value())+ if (auto offset = m_async_scroll_tree.css_scroll_offset_for_node(node.scroll_node_index, m_scroll_state_snapshot); offset.has_value())scroll_offsets.unchecked_append({ node.stable_node_id, *offset });}return scroll_offsets;@@ -1995,7 +1995,7 @@ ContextPresenter::FrameContent ContextState::frame_content(Compositing::ScrollStreturn {.presented_scroll_state_snapshot = presented_scroll_state_snapshot,.scrollbar_controller = m_scrollbar_controller,- .viewport_scroll_node_index = m_async_scroll_tree.viewport_scroll_node_id().map([](auto const& node_id) { return node_id.scroll_node_index; }),+ .viewport_scroll_node_index = m_async_scroll_tree.viewport_scroll_node_index(),.composited_context_resolver = composited_context_resolver,};}@@ -2155,7 +2155,7 @@ HashMap<Web::AsyncScrollNodeStableID, Gfx::FloatPoint> ContextState::scroll_offsif (!m_has_async_scrolling_state)return scroll_offsets;for (auto const& node : m_async_scroll_tree.scroll_nodes()) {- if (auto offset = m_async_scroll_tree.scroll_offset_for_node(node.node_id, m_scroll_state_snapshot); offset.has_value())+ if (auto offset = m_async_scroll_tree.scroll_offset_for_node(node.scroll_node_index, m_scroll_state_snapshot); offset.has_value())scroll_offsets.set(node.stable_node_id, offset.value());}return scroll_offsets;@@ -2176,9 +2176,9 @@ Optional<Gfx::FloatPoint> ContextState::keep_scroll_offsets_of_known_nodes(HashMm_scroll_nodes_seeded_by_last_frame.set(node.stable_node_id);continue;}- if (m_async_scroll_tree.scroll_offset_for_node(node.node_id, m_scroll_state_snapshot) != known_scroll_offset)+ if (m_async_scroll_tree.scroll_offset_for_node(node.scroll_node_index, m_scroll_state_snapshot) != known_scroll_offset)m_scroll_offsets_differ_from_last_frame = true;- auto kept_scroll_offset = m_async_scroll_tree.set_scroll_offset(node.node_id, known_scroll_offset.value(), m_scene.current_visual_context_tree(), m_scroll_state_snapshot);+ auto kept_scroll_offset = m_async_scroll_tree.set_scroll_offset(node.scroll_node_index, known_scroll_offset.value(), m_scene.current_visual_context_tree(), m_scroll_state_snapshot);if (!kept_scroll_offset.has_value())continue;if (node.is_viewport)@@ -2236,32 +2236,32 @@ ContextState::WheelGestureLatchAttempt ContextState::hit_test_and_latch_wheel_geif (scroll_target.is_blocked_by_a_region())return { Compositing::input_routing_decision_for_first_wheel_step(scroll_target.outcome) };- auto node_id_to_latch = scroll_target.node_id;+ auto scroll_node_index_to_latch = scroll_target.scroll_node_index;auto decision = Web::InputRoutingDecision::Latched;// Fingers that start to pull where every scroller under them is already at its edge stretch the outermost one. A// context nested in another one turns the gesture away instead, which passes it on to the document around it.- bool fingers_start_a_gesture_at_an_edge = !node_id_to_latch.has_value() && scroll_target.innermost_scroll_node_id.has_value() && !delta.is_zero()+ bool fingers_start_a_gesture_at_an_edge = !scroll_node_index_to_latch.has_value() && scroll_target.innermost_scroll_node_index.has_value() && !delta.is_zero()&& scroll_gesture_phase == Web::ScrollGesturePhase::Ongoing && wheel_step_can_stretch_elastically(wheel_delta_precision, scroll_gesture_phase);if (fingers_start_a_gesture_at_an_edge) {- node_id_to_latch = m_async_scroll_tree.outermost_scroll_node_wheel_scrollable_along_main_axis_of(*scroll_target.innermost_scroll_node_id, delta);+ scroll_node_index_to_latch = m_async_scroll_tree.outermost_scroll_node_wheel_scrollable_along_main_axis_of(*scroll_target.innermost_scroll_node_index, delta);decision = Web::InputRoutingDecision::LatchedOutermostScrollerToStretch;}- if (!node_id_to_latch.has_value())+ if (!scroll_node_index_to_latch.has_value())return { Compositing::input_routing_decision_for_first_wheel_step(scroll_target.outcome) };- if (expected_document_id.has_value() && node_id_to_latch->document_id != *expected_document_id)+ if (expected_document_id.has_value() && m_async_scroll_tree.document_id() != *expected_document_id)return { Web::InputRoutingDecision::ScrollerInOtherDocument };- auto const* node = m_async_scroll_tree.scroll_node_for_id(*node_id_to_latch);+ auto const* node = m_async_scroll_tree.scroll_node_for_index(*scroll_node_index_to_latch);VERIFY(node);m_wheel_gesture_routing.latch(node->stable_node_id, scroll_gesture_phase);- return { decision, node_id_to_latch };+ return { decision, scroll_node_index_to_latch };}void ContextState::report_started_user_scroll(Compositing::AsyncScrollOperationID operation_id, Web::AsyncScrollNodeStableID stable_node_id, Gfx::FloatPoint step_start_offset, Gfx::FloatPoint destination_offset, Compositing::ScrollAnimationKind animation_kind, bool is_absolute_scroll){- auto node_id = m_async_scroll_tree.scroll_node_id_for_stable_id(stable_node_id);- VERIFY(node_id.has_value());- auto current_offset = m_async_scroll_tree.css_scroll_offset_for_node(*node_id, m_scroll_state_snapshot);+ auto scroll_node_index = m_async_scroll_tree.scroll_node_index_for_stable_id(stable_node_id);+ VERIFY(scroll_node_index.has_value());+ auto current_offset = m_async_scroll_tree.css_scroll_offset_for_node(*scroll_node_index, m_scroll_state_snapshot);VERIFY(current_offset.has_value());auto destination = m_async_scroll_tree.css_pixels_from_device_offset(destination_offset);note_user_input_scrolled(stable_node_id);@@ -2278,11 +2278,11 @@ void ContextState::report_started_user_scroll(Compositing::AsyncScrollOperationI});}-void ContextState::cancel_smooth_scroll_taken_over_by_user_input(Compositing::AsyncScrollNodeID node_id)+void ContextState::cancel_smooth_scroll_taken_over_by_user_input(Compositing::SpatialNodeIndex scroll_node_index){for (auto const& smooth_scroll_animation : m_smooth_scroll_animations) {- auto animated_node_id = m_async_scroll_tree.scroll_node_id_for_stable_id(smooth_scroll_animation.stable_node_id);- if (animated_node_id != node_id)+ auto animated_scroll_node_index = m_async_scroll_tree.scroll_node_index_for_stable_id(smooth_scroll_animation.stable_node_id);+ if (animated_scroll_node_index != scroll_node_index)continue;m_async_scroll_update_outbox.note_operation_taken_over_by_user_input(smooth_scroll_animation.operation_id);cancel_smooth_scroll(smooth_scroll_animation.stable_node_id);@@ -2387,8 +2387,8 @@ Optional<PendingFrame> ContextState::page_captured_scrollbar()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);+ auto const* node = m_async_scroll_tree.scroll_node_for_index(scrollbar.scroll_node_index);+ auto old_scroll_offset = m_async_scroll_tree.scroll_offset_for_node(scrollbar.scroll_node_index, m_scroll_state_snapshot);if (!node || !old_scroll_offset.has_value())return {};@@ -2401,7 +2401,7 @@ Optional<PendingFrame> ContextState::page_captured_scrollbar()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);+ destination = m_async_scroll_tree.clamped_scroll_offset_for_node(scrollbar.scroll_node_index, destination);if (destination == step_start)return {};@@ -2410,7 +2410,7 @@ Optional<PendingFrame> ContextState::page_captured_scrollbar()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);+ cancel_smooth_scroll_taken_over_by_user_input(scrollbar.scroll_node_index);return start_scrollbar_press_scroll(*node, *old_scroll_offset, destination, false);}@@ -2440,12 +2440,12 @@ Optional<PendingFrame> ContextState::apply_scrollbar_drag(ScrollbarController::Dreturn {};// A scrollbar scrolls its own scroller to where the thumb was dragged, and never hands any of that to an ancestor.- auto node_id = dragged_to->scroll_node_id;- auto const* node = m_async_scroll_tree.scroll_node_for_id(node_id);- auto old_scroll_offset = m_async_scroll_tree.scroll_offset_for_node(node_id, m_scroll_state_snapshot);+ auto scroll_node_index = dragged_to->scroll_node_index;+ auto const* node = m_async_scroll_tree.scroll_node_for_index(scroll_node_index);+ auto old_scroll_offset = m_async_scroll_tree.scroll_offset_for_node(scroll_node_index, m_scroll_state_snapshot);if (!node || !old_scroll_offset.has_value())return {};- auto destination = m_async_scroll_tree.clamped_scroll_offset_for_node(node_id, dragged_to->scroll_offset);+ auto destination = m_async_scroll_tree.clamped_scroll_offset_for_node(scroll_node_index, dragged_to->scroll_offset);// A press beside the thumb scrolls there smoothly, as a page step does. Dragging on before that scroll has ended// moves where it goes.@@ -2460,12 +2460,12 @@ Optional<PendingFrame> ContextState::apply_scrollbar_drag(ScrollbarController::Dif (destination == *old_scroll_offset)return {};- cancel_smooth_scroll_taken_over_by_user_input(node_id);+ cancel_smooth_scroll_taken_over_by_user_input(scroll_node_index);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);+ auto new_scroll_offset = m_async_scroll_tree.set_scroll_offset(scroll_node_index, dragged_to->scroll_offset, m_scene.current_visual_context_tree(), m_scroll_state_snapshot);note_user_input_scrolled(node->stable_node_id);VERIFY(new_scroll_offset.has_value());rebuild_wheel_hit_test_targets();diff --git a/Services/Compositor/ContextState.h b/Services/Compositor/ContextState.hindex c07bbfedac9..433e132b9c8 100644--- a/Services/Compositor/ContextState.h+++ b/Services/Compositor/ContextState.h@@ -121,7 +121,7 @@ public:};Kind kind;Web::InputRoutingDecision decision;- Optional<Compositing::AsyncScrollNodeID> node_id {};+ Optional<Compositing::SpatialNodeIndex> scroll_node_index {};Optional<Web::AsyncScrollNodeStableID> scroller {};Optional<Compositing::NestedContextHit> nested_context_hit {};};@@ -306,7 +306,7 @@ private:void end_keyboard_scroll_gesture();struct KeyScroll {KeyboardScrollController::KeyStep step;- Compositing::AsyncScrollNodeID target;+ Compositing::SpatialNodeIndex target_scroll_node_index;};Optional<KeyScroll> key_scroll_for(Web::KeyEvent const&) const;Optional<Web::MouseEvent> interrupt_reported_scroll_momentum();@@ -314,8 +314,8 @@ private:void adopt_keyboard_scroll_state(Compositing::KeyboardScrollState);Optional<VisualViewportScrollDelta> apply_visual_viewport_scroll_delta(Gfx::FloatPoint);void note_user_input_scrolled(Web::AsyncScrollNodeStableID);- Optional<Gfx::Orientation> axis_held_by_scrollbar_of(Compositing::AsyncScrollNodeID) const;- void scroll_visual_viewport_position_in_page(Compositing::AsyncScrollNodeID viewport_node_id, Compositing::RequestedRelativeScroll const&, Vector<Compositing::AsyncScrollOffset>& answers);+ Optional<Gfx::Orientation> axis_held_by_scrollbar_of(Compositing::SpatialNodeIndex) const;+ void scroll_visual_viewport_position_in_page(Compositing::SpatialNodeIndex viewport_scroll_node_index, Compositing::RequestedRelativeScroll const&, Vector<Compositing::AsyncScrollOffset>& answers);// Returns whether the request moved the visual viewport.bool apply_visual_viewport_scroll_request(Compositing::ScrollRequest const&, Vector<Compositing::AsyncScrollOffset>& answers);// Pans the visual viewport of a zoomed page by as much of a delta in screen pixels as it has room for, and returns@@ -341,34 +341,34 @@ private:// A step of a wheel gesture that is latched to the node. A stretch of the node is relaxed before the visual// viewport is panned, the node only scrolls by what both leave of the step, and what the node cannot scroll by// either is what pulls it past its edge.- WheelScrollOutcome perform_wheel_scroll_of_node(Compositing::AsyncScrollNodeID, Gfx::FloatPoint delta, Web::WheelDeltaPrecision, Web::ScrollGesturePhase, Compositing::AsyncScrollOperationTracking, Gfx::IntRect viewport_rect, MonotonicTime now, Compositing::ScrollChaining, VisualViewportPanning);+ WheelScrollOutcome perform_wheel_scroll_of_node(Compositing::SpatialNodeIndex, Gfx::FloatPoint delta, Web::WheelDeltaPrecision, Web::ScrollGesturePhase, Compositing::AsyncScrollOperationTracking, Gfx::IntRect viewport_rect, MonotonicTime now, Compositing::ScrollChaining, VisualViewportPanning);struct NodeScrollByWheelDelta {WheelScrollOutcome outcome;// Empty when a wheel animation or a snap scroll took the delta, and when it scrolled an ancestor of the node.Optional<Gfx::FloatPoint> delta_the_node_did_not_scroll_by;};- NodeScrollByWheelDelta scroll_node_by_wheel_delta(Compositing::AsyncScrollNodeID, Gfx::FloatPoint delta, Web::WheelDeltaPrecision, Web::ScrollGesturePhase, Compositing::AsyncScrollOperationTracking, Gfx::IntRect viewport_rect, MonotonicTime now, Compositing::ScrollChaining);+ NodeScrollByWheelDelta scroll_node_by_wheel_delta(Compositing::SpatialNodeIndex, Gfx::FloatPoint delta, Web::WheelDeltaPrecision, Web::ScrollGesturePhase, Compositing::AsyncScrollOperationTracking, Gfx::IntRect viewport_rect, MonotonicTime now, Compositing::ScrollChaining);WheelGestureRouting::ResolvedLatch resolve_wheel_scroll_latch(Web::ScrollGesturePhase);struct WheelGestureLatchAttempt {Web::InputRoutingDecision decision;- Optional<Compositing::AsyncScrollNodeID> latched_node_id {};+ Optional<Compositing::SpatialNodeIndex> latched_scroll_node_index {};};// The scroller the first step of a wheel gesture is routed to, which the gesture is latched to.WheelGestureLatchAttempt hit_test_and_latch_wheel_gesture(Gfx::FloatPoint position, Gfx::FloatPoint delta, Web::WheelDeltaPrecision, Web::ScrollGesturePhase, Optional<Web::UniqueNodeID> expected_document_id, Compositing::WheelStepDispatch, Compositing::NestedContextRegions);- ContextUpdateResult take_wheel_step_from_containing_context(Compositing::AsyncScrollNodeID, Web::InputRoutingDecision, WheelStepFromContainingContext const&, Compositing::ScrollChaining, MonotonicTime now);+ ContextUpdateResult take_wheel_step_from_containing_context(Compositing::SpatialNodeIndex, Web::InputRoutingDecision, WheelStepFromContainingContext const&, Compositing::ScrollChaining, MonotonicTime now);Gfx::IntRect note_async_scrolling_viewport_rect(Gfx::IntRect viewport_rect, Optional<Compositing::AsyncScrollOffset> const&);Optional<Compositing::AsyncScrollOperationID> snap_at_gesture_end(MonotonicTime now);- Compositing::AsyncScrollOperationID start_snap_scroll(Compositing::AsyncScrollNodeID, ScrollSnapController::SnapScrollStart&&, bool settles_gesture, MonotonicTime now);+ Compositing::AsyncScrollOperationID start_snap_scroll(Compositing::SpatialNodeIndex, ScrollSnapController::SnapScrollStart&&, bool settles_gesture, MonotonicTime now);bool has_active_smooth_scroll_animations() const { return !m_smooth_scroll_animations.is_empty(); }void retire_smooth_scroll_animation(Web::AsyncScrollNodeStableID);- void cancel_smooth_scroll_taken_over_by_user_input(Compositing::AsyncScrollNodeID);+ void cancel_smooth_scroll_taken_over_by_user_input(Compositing::SpatialNodeIndex);bool wheel_step_can_stretch_elastically(Web::WheelDeltaPrecision, Web::ScrollGesturePhase) const;bool pull_elastic_overscroll_by(Compositing::AsyncScrollNode const&, Gfx::FloatPoint step_delta, Gfx::FloatPoint delta_the_scroller_did_not_scroll_by);Optional<Compositing::ScrollStateSnapshot> scroll_state_snapshot_stretched_by_elastic_overscrolls() const;ContextUpdateResult scroll_for_wheel_event(Web::MouseEvent const&, MonotonicTime now);- ContextUpdateResult scroll_for_wheel_event_in_this_context(Web::MouseEvent const&, Optional<Compositing::AsyncScrollNodeID> latched_node_id, Compositing::NestedContextRegions, MonotonicTime now);+ ContextUpdateResult scroll_for_wheel_event_in_this_context(Web::MouseEvent const&, Optional<Compositing::SpatialNodeIndex> latched_scroll_node_index, Compositing::NestedContextRegions, MonotonicTime now);Gfx::FloatPoint wheel_event_delta_in_device_pixels(Web::MouseEvent const&) const;- bool step_continues_touchpad_gesture_the_page_let_through(Optional<Compositing::AsyncScrollNodeID> const& latched_node_id, Web::WheelDeltaPrecision, Web::ScrollGesturePhase) const;+ bool step_continues_touchpad_gesture_the_page_let_through(Optional<Compositing::SpatialNodeIndex> const& latched_scroll_node_index, Web::WheelDeltaPrecision, Web::ScrollGesturePhase) const;Optional<Gfx::FloatPoint> in_flight_wheel_destination(Web::AsyncScrollNodeStableID) const;AsyncScrollResult smooth_wheel_scroll_by(Optional<Compositing::WheelScrollTarget> const&, Gfx::IntRect viewport_rect, MonotonicTime now);void retarget_user_scroll(ActiveSmoothScrollAnimation&, Gfx::FloatPoint destination_offset, MonotonicTime now);diff --git a/Services/Compositor/ElasticOverscrollController.cpp b/Services/Compositor/ElasticOverscrollController.cppindex fc3a41d0244..72593995b9e 100644--- a/Services/Compositor/ElasticOverscrollController.cpp+++ b/Services/Compositor/ElasticOverscrollController.cpp@@ -137,8 +137,8 @@ void ElasticOverscrollController::forget()void ElasticOverscrollController::did_install_scrolling_state(Compositing::AsyncScrollTree const& async_scroll_tree){m_active_overscrolls.remove_all_matching([&](auto const& active) {- auto node_id = async_scroll_tree.scroll_node_id_for_stable_id(active.stable_node_id);- auto const* node = node_id.has_value() ? async_scroll_tree.scroll_node_for_id(*node_id) : nullptr;+ auto scroll_node_index = async_scroll_tree.scroll_node_index_for_stable_id(active.stable_node_id);+ auto const* node = scroll_node_index.has_value() ? async_scroll_tree.scroll_node_for_index(*scroll_node_index) : nullptr;if (!node)return true;// A scroller that has been told not to stretch along an axis since it was pulled lets go at once.@@ -174,15 +174,14 @@ Optional<Compositing::ScrollStateSnapshot> ElasticOverscrollController::stretcheauto stretch = active.overscroll.stretch();if (stretch.is_zero())continue;- auto node_id = async_scroll_tree.scroll_node_id_for_stable_id(active.stable_node_id);- if (!node_id.has_value())+ auto scroll_node_index = async_scroll_tree.scroll_node_index_for_stable_id(active.stable_node_id);+ if (!scroll_node_index.has_value())continue;if (!stretched_scroll_state_snapshot.has_value())stretched_scroll_state_snapshot = scroll_state_snapshot;// Only the scroller's own entry moves. The sticky boxes in it keep the shifts resolved for the scroll offset// it really has, so they move with its content.- auto index = node_id->scroll_node_index;- stretched_scroll_state_snapshot->set_device_offset_for_index(index, stretched_scroll_state_snapshot->device_offset_for_index(index) - stretch);+ stretched_scroll_state_snapshot->set_device_offset_for_index(*scroll_node_index, stretched_scroll_state_snapshot->device_offset_for_index(*scroll_node_index) - stretch);}return stretched_scroll_state_snapshot;}diff --git a/Services/Compositor/ScrollSnapController.cpp b/Services/Compositor/ScrollSnapController.cppindex c8164e1f542..98916427d31 100644--- a/Services/Compositor/ScrollSnapController.cpp+++ b/Services/Compositor/ScrollSnapController.cpp@@ -14,7 +14,7 @@ void ScrollSnapController::did_install_scrolling_state(Compositing::AsyncScrollT{m_candidates.clear();m_nodes.remove_all_matching([&](auto const& stable_node_id, auto const&) {- return !scroll_tree.scroll_node_id_for_stable_id(stable_node_id).has_value();+ return !scroll_tree.scroll_node_index_for_stable_id(stable_node_id).has_value();});}@@ -148,11 +148,11 @@ Compositing::SnapAxisCandidates const& ScrollSnapController::candidates_for(Web:});}-Optional<ScrollSnapController::SnapTarget> ScrollSnapController::snap_target_for(Compositing::AsyncScrollTree const& scroll_tree, Compositing::ScrollStateSnapshot const& scroll_state_snapshot, Compositing::AsyncScrollNodeID node_id)+Optional<ScrollSnapController::SnapTarget> ScrollSnapController::snap_target_for(Compositing::AsyncScrollTree const& scroll_tree, Compositing::ScrollStateSnapshot const& scroll_state_snapshot, Compositing::SpatialNodeIndex scroll_node_index){- auto const* node = scroll_tree.scroll_node_for_id(node_id);- auto const* snap_container = scroll_tree.snap_container_for_node(node_id);- auto current_scroll_offset = scroll_tree.css_scroll_offset_for_node(node_id, scroll_state_snapshot);+ auto const* node = scroll_tree.scroll_node_for_index(scroll_node_index);+ auto const* snap_container = scroll_tree.snap_container_for_node(scroll_node_index);+ auto current_scroll_offset = scroll_tree.css_scroll_offset_for_node(scroll_node_index, scroll_state_snapshot);if (!node || !snap_container || !current_scroll_offset.has_value())return {};return SnapTarget { .stable_node_id = node->stable_node_id, .snap_container = snap_container, .current_scroll_offset = *current_scroll_offset };@@ -172,9 +172,9 @@ static bool selected_snap_position_along_travel(Compositing::SnapDestination conreturn (selection.snapped_x && displacement.x() != 0) || (selection.snapped_y && displacement.y() != 0);}-Optional<ScrollSnapController::StepDecision> ScrollSnapController::decide_discrete_step(Compositing::AsyncScrollTree const& scroll_tree, Compositing::ScrollStateSnapshot const& scroll_state_snapshot, Compositing::AsyncScrollNodeID node_id, Web::CSSPixelPoint delta, Optional<Web::CSSPixelPoint> scroll_in_flight_destination, MonotonicTime now)+Optional<ScrollSnapController::StepDecision> ScrollSnapController::decide_discrete_step(Compositing::AsyncScrollTree const& scroll_tree, Compositing::ScrollStateSnapshot const& scroll_state_snapshot, Compositing::SpatialNodeIndex scroll_node_index, Web::CSSPixelPoint delta, Optional<Web::CSSPixelPoint> scroll_in_flight_destination, MonotonicTime now){- auto target = snap_target_for(scroll_tree, scroll_state_snapshot, node_id);+ auto target = snap_target_for(scroll_tree, scroll_state_snapshot, scroll_node_index);if (!target.has_value())return {};auto const& geometry = target->snap_container->geometry;@@ -231,9 +231,9 @@ Optional<ScrollSnapController::StepDecision> ScrollSnapController::decide_discre} };}-Optional<ScrollSnapController::StepDecision> ScrollSnapController::decide_key_step(Compositing::AsyncScrollTree const& scroll_tree, Compositing::ScrollStateSnapshot const& scroll_state_snapshot, Compositing::AsyncScrollNodeID node_id, Web::CSSPixelPoint delta, Compositing::SnapSelectionStrategy::Type strategy_type, Optional<Web::CSSPixelPoint> scroll_in_flight_destination, MonotonicTime now)+Optional<ScrollSnapController::StepDecision> ScrollSnapController::decide_key_step(Compositing::AsyncScrollTree const& scroll_tree, Compositing::ScrollStateSnapshot const& scroll_state_snapshot, Compositing::SpatialNodeIndex scroll_node_index, Web::CSSPixelPoint delta, Compositing::SnapSelectionStrategy::Type strategy_type, Optional<Web::CSSPixelPoint> scroll_in_flight_destination, MonotonicTime now){- auto target = snap_target_for(scroll_tree, scroll_state_snapshot, node_id);+ auto target = snap_target_for(scroll_tree, scroll_state_snapshot, scroll_node_index);if (!target.has_value())return {};auto const& geometry = target->snap_container->geometry;@@ -295,7 +295,7 @@ Optional<ScrollSnapController::StepDecision> ScrollSnapController::decide_key_st} };}-Optional<ScrollSnapController::StepDecision> ScrollSnapController::decide_momentum_delta(Compositing::AsyncScrollTree const& scroll_tree, Compositing::ScrollStateSnapshot const& scroll_state_snapshot, Compositing::AsyncScrollNodeID node_id, Web::CSSPixelPoint momentum_delta)+Optional<ScrollSnapController::StepDecision> ScrollSnapController::decide_momentum_delta(Compositing::AsyncScrollTree const& scroll_tree, Compositing::ScrollStateSnapshot const& scroll_state_snapshot, Compositing::SpatialNodeIndex scroll_node_index, Web::CSSPixelPoint momentum_delta){if (m_momentum_snap_position_selection == MomentumSnapPositionSelection::ScrollingToSelectedPosition)return StepDecision { StepConsumed {} };@@ -306,7 +306,7 @@ Optional<ScrollSnapController::StepDecision> ScrollSnapController::decide_momentif (!remaining_displacement.has_value())return {};- auto target = snap_target_for(scroll_tree, scroll_state_snapshot, node_id);+ auto target = snap_target_for(scroll_tree, scroll_state_snapshot, scroll_node_index);if (!target.has_value()) {m_momentum_snap_position_selection = MomentumSnapPositionSelection::NoPositionSelected;return {};@@ -355,10 +355,10 @@ Vector<ScrollSnapController::GestureEndSnap> ScrollSnapController::decide_gesturif (state.snap_scroll.has_value())continue;- auto node_id = scroll_tree.scroll_node_id_for_stable_id(stable_node_id);- if (!node_id.has_value())+ auto scroll_node_index = scroll_tree.scroll_node_index_for_stable_id(stable_node_id);+ if (!scroll_node_index.has_value())continue;- auto target = snap_target_for(scroll_tree, scroll_state_snapshot, *node_id);+ auto target = snap_target_for(scroll_tree, scroll_state_snapshot, *scroll_node_index);if (!target.has_value())continue;auto const& geometry = target->snap_container->geometry;@@ -381,7 +381,7 @@ Vector<ScrollSnapController::GestureEndSnap> ScrollSnapController::decide_gesturcontinue;snaps.append({- .node_id = *node_id,+ .scroll_node_index = *scroll_node_index,.snap_scroll = {.stable_node_id = stable_node_id,.initial_scroll_offset = current_scroll_offset,diff --git a/Services/Compositor/ScrollSnapController.h b/Services/Compositor/ScrollSnapController.hindex be47d130817..72d6ce6b6aa 100644--- a/Services/Compositor/ScrollSnapController.h+++ b/Services/Compositor/ScrollSnapController.h@@ -57,7 +57,7 @@ public:using StepDecision = Variant<StepConsumed, SnapScrollStart>;struct GestureEndSnap {- Compositing::AsyncScrollNodeID node_id;+ Compositing::SpatialNodeIndex scroll_node_index;SnapScrollStart snap_scroll;};@@ -76,14 +76,14 @@ public:// https://drafts.csswg.org/css-scroll-snap-1/#scroll-types// A discrete wheel step is a relative scroll with only an intended direction.- Optional<StepDecision> decide_discrete_step(Compositing::AsyncScrollTree const&, Compositing::ScrollStateSnapshot const&, Compositing::AsyncScrollNodeID, Web::CSSPixelPoint delta, Optional<Web::CSSPixelPoint> scroll_in_flight_destination, MonotonicTime now);+ Optional<StepDecision> decide_discrete_step(Compositing::AsyncScrollTree const&, Compositing::ScrollStateSnapshot const&, Compositing::SpatialNodeIndex, Web::CSSPixelPoint delta, Optional<Web::CSSPixelPoint> scroll_in_flight_destination, MonotonicTime now);// The momentum of a flick is a relative scroll with an intended direction and, once its decay tells where it is// headed, an intended end position.- Optional<StepDecision> decide_momentum_delta(Compositing::AsyncScrollTree const&, Compositing::ScrollStateSnapshot const&, Compositing::AsyncScrollNodeID, Web::CSSPixelPoint delta);+ Optional<StepDecision> decide_momentum_delta(Compositing::AsyncScrollTree const&, Compositing::ScrollStateSnapshot const&, Compositing::SpatialNodeIndex, Web::CSSPixelPoint delta);// A scroll key is a command of its own rather than a step of a gesture: while a scroll is in flight it travels on// from the offset the steps before it asked for, otherwise from the scrolling box itself. An arrow key has only// an intended direction; a paging key has an intended end position as well.- Optional<StepDecision> decide_key_step(Compositing::AsyncScrollTree const&, Compositing::ScrollStateSnapshot const&, Compositing::AsyncScrollNodeID, Web::CSSPixelPoint delta, Compositing::SnapSelectionStrategy::Type, Optional<Web::CSSPixelPoint> scroll_in_flight_destination, MonotonicTime now);+ Optional<StepDecision> decide_key_step(Compositing::AsyncScrollTree const&, Compositing::ScrollStateSnapshot const&, Compositing::SpatialNodeIndex, Web::CSSPixelPoint delta, Compositing::SnapSelectionStrategy::Type, Optional<Web::CSSPixelPoint> scroll_in_flight_destination, MonotonicTime now);// The end of a gesture snaps each scrolling box it panned to the snap position nearest where it was released,// and ends the gesture.Vector<GestureEndSnap> decide_gesture_end(Compositing::AsyncScrollTree const&, Compositing::ScrollStateSnapshot const&);@@ -135,7 +135,7 @@ private:Compositing::AsyncSnapContainer const* snap_container;Web::CSSPixelPoint current_scroll_offset;};- static Optional<SnapTarget> snap_target_for(Compositing::AsyncScrollTree const&, Compositing::ScrollStateSnapshot const&, Compositing::AsyncScrollNodeID);+ static Optional<SnapTarget> snap_target_for(Compositing::AsyncScrollTree const&, Compositing::ScrollStateSnapshot const&, Compositing::SpatialNodeIndex);NodeState& node_state(Web::AsyncScrollNodeStableID);Compositing::SnapAxisCandidates const& candidates_for(Web::AsyncScrollNodeStableID, Compositing::AsyncSnapContainer const&);diff --git a/Services/Compositor/ScrollbarController.cpp b/Services/Compositor/ScrollbarController.cppindex b0475bf3b5b..4f6826c4bb8 100644--- a/Services/Compositor/ScrollbarController.cpp+++ b/Services/Compositor/ScrollbarController.cpp@@ -22,13 +22,13 @@ static Gfx::Orientation orientation_for_scrollbar(Compositing::AsyncScrollbar co// stable id of its scroller wherever both display lists name one.struct ScrollbarIdentity {Optional<Web::AsyncScrollNodeStableID> scroller_stable_node_id;- Compositing::AsyncScrollNodeID scroll_node_id;+ Compositing::SpatialNodeIndex scroll_node_index;bool vertical { false };};static ScrollbarIdentity scrollbar_identity(Compositing::AsyncScrollbar const& scrollbar){- return { scrollbar.scroller_stable_node_id, scrollbar.scroll_node_id, scrollbar.vertical };+ return { scrollbar.scroller_stable_node_id, scrollbar.scroll_node_index, scrollbar.vertical };}static Optional<ScrollbarIdentity> scrollbar_identity_at(ReadonlySpan<Compositing::AsyncScrollbar> scrollbars, Optional<size_t> scrollbar_index)@@ -44,7 +44,7 @@ static bool scrollbar_has_identity(Compositing::AsyncScrollbar const& scrollbar,return false;if (scrollbar.scroller_stable_node_id.has_value() && identity.scroller_stable_node_id.has_value())return *scrollbar.scroller_stable_node_id == *identity.scroller_stable_node_id;- return scrollbar.scroll_node_id == identity.scroll_node_id;+ return scrollbar.scroll_node_index == identity.scroll_node_index;}static Optional<size_t> find_scrollbar_index(ReadonlySpan<Compositing::AsyncScrollbar> scrollbars, ScrollbarIdentity const& identity)@@ -157,7 +157,7 @@ Optional<size_t> ScrollbarController::hit_test_scrollbar_painted_by_compositor(Cauto const& scrollbar = m_scrollbars[i];if (!scrollbar.is_painted_by_compositor)continue;- auto scroll_offset = async_scroll_tree.scroll_offset_for_node(scrollbar.scroll_node_id, scroll_state_snapshot);+ auto scroll_offset = async_scroll_tree.scroll_offset_for_node(scrollbar.scroll_node_index, scroll_state_snapshot);if (!scroll_offset.has_value())continue;@@ -176,7 +176,7 @@ Optional<size_t> ScrollbarController::hit_test_scrollbar_painted_by_display_listauto const& scrollbar = m_scrollbars[i];if (scrollbar.is_painted_by_compositor || !scrollbar.scroller_stable_node_id.has_value() || !is_shown(i))continue;- if (!async_scroll_tree.scroll_offset_for_node(scrollbar.scroll_node_id, scroll_state_snapshot).has_value())+ if (!async_scroll_tree.scroll_offset_for_node(scrollbar.scroll_node_index, scroll_state_snapshot).has_value())continue;auto position_in_scrollbar_space = position_in_space_of_scrollbar(scrollbar, visual_context_tree, scroll_state_snapshot, position, Compositing::AccumulatedVisualContextTree::ClipBehavior::Respect);@@ -203,7 +203,7 @@ Optional<ScrollbarController::Drag> ScrollbarController::begin_drag(Compositing:return {};auto const& scrollbar = m_scrollbars[*scrollbar_index];- auto scroll_offset = async_scroll_tree.scroll_offset_for_node(scrollbar.scroll_node_id, scroll_state_snapshot);+ auto scroll_offset = async_scroll_tree.scroll_offset_for_node(scrollbar.scroll_node_index, scroll_state_snapshot);VERIFY(scroll_offset.has_value());auto position_in_scrollbar_space = position_in_space_of_scrollbar(scrollbar, visual_context_tree, scroll_state_snapshot, position, Compositing::AccumulatedVisualContextTree::ClipBehavior::Respect);VERIFY(position_in_scrollbar_space.has_value());@@ -287,7 +287,7 @@ Optional<ScrollbarController::ScrollOffset> ScrollbarController::scroll_offset_fif (scroll_size == 0)return {};- auto current_scroll_offset = async_scroll_tree.scroll_offset_for_node(scrollbar.scroll_node_id, scroll_state_snapshot);+ auto current_scroll_offset = async_scroll_tree.scroll_offset_for_node(scrollbar.scroll_node_index, scroll_state_snapshot);if (!current_scroll_offset.has_value())return {};@@ -306,7 +306,7 @@ Optional<ScrollbarController::ScrollOffset> ScrollbarController::scroll_offset_fauto scroll_offset = *current_scroll_offset;scroll_offset.set_primary_offset_for_orientation(orientation, target_scroll_offset);- return ScrollOffset { scrollbar.scroll_node_id, scroll_offset };+ return ScrollOffset { scrollbar.scroll_node_index, scroll_offset };}int ScrollbarController::paging_direction(size_t scrollbar_index, float primary_position, Gfx::FloatPoint scroll_offset) constdiff --git a/Services/Compositor/ScrollbarController.h b/Services/Compositor/ScrollbarController.hindex 9d4fdd4919b..78cb80bb3aa 100644--- a/Services/Compositor/ScrollbarController.h+++ b/Services/Compositor/ScrollbarController.h@@ -43,7 +43,7 @@ public:};struct ScrollOffset {- Compositing::AsyncScrollNodeID scroll_node_id;+ Compositing::SpatialNodeIndex scroll_node_index;Gfx::FloatPoint scroll_offset;};diff --git a/Services/Compositor/WheelGestureRouting.cpp b/Services/Compositor/WheelGestureRouting.cppindex dea9a1e32c2..02b9120a014 100644--- a/Services/Compositor/WheelGestureRouting.cpp+++ b/Services/Compositor/WheelGestureRouting.cpp@@ -108,8 +108,8 @@ WheelGestureRouting::ResolvedLatch WheelGestureRouting::resolve_latch(Compositinm_latch->last_scroll_gesture_phase = scroll_gesture_phase;return { .nested_context_id = m_latch->nested_context_id, .keeps_steps = !m_latch->nested_context_id.has_value() };}- auto node_id = async_scroll_tree.scroll_node_id_for_stable_id(*m_latch->stable_node_id);- if (!node_id.has_value()) {+ auto scroll_node_index = async_scroll_tree.scroll_node_index_for_stable_id(*m_latch->stable_node_id);+ if (!scroll_node_index.has_value()) {m_latch.clear();return {};}@@ -117,7 +117,7 @@ WheelGestureRouting::ResolvedLatch WheelGestureRouting::resolve_latch(Compositinif (!async_scroll_tree.has_wheel_hit_test_targets_for(current_visual_context_tree))return {};m_latch->last_scroll_gesture_phase = scroll_gesture_phase;- return { .node_id = node_id };+ return { .scroll_node_index = scroll_node_index };}Optional<Web::AsyncScrollNodeStableID> WheelGestureRouting::latched_scroller() constdiff --git a/Services/Compositor/WheelGestureRouting.h b/Services/Compositor/WheelGestureRouting.hindex 72b213f0d7f..0d3c758da2f 100644--- a/Services/Compositor/WheelGestureRouting.h+++ b/Services/Compositor/WheelGestureRouting.h@@ -54,7 +54,7 @@ public:// gesture to a scroller of its own, or nothing that scrolls, when this context keeps the steps from the document// around it.struct ResolvedLatch {- Optional<Compositing::AsyncScrollNodeID> node_id {};+ Optional<Compositing::SpatialNodeIndex> scroll_node_index {};Optional<Web::CompositorContextId> nested_context_id {};bool keeps_steps { false };};diff --git a/Tests/Compositor/TestAsyncScrollTree.cpp b/Tests/Compositor/TestAsyncScrollTree.cppindex 33da9446d05..9012a38d1c0 100644--- a/Tests/Compositor/TestAsyncScrollTree.cpp+++ b/Tests/Compositor/TestAsyncScrollTree.cpp@@ -12,16 +12,16 @@#include <LibCompositing/Scrolling/ScrollState.h>#include <LibTest/TestCase.h>-static Compositing::AsyncScrollNodeID const viewport_node_id { .document_id = Web::UniqueNodeID { 1 }, .scroll_node_index = Compositing::SpatialNodeIndex { 1 } };+static Compositing::SpatialNodeIndex const viewport_scroll_node_index { 1 };static Web::UniqueNodeID const viewport_document_node_id { 2 };static Compositing::AsyncScrollingState make_scrolling_state_with_viewport_scroll_node(float max_scroll_offset_y){Compositing::AsyncScrollingState state;state.scroll_nodes.append({- .node_id = viewport_node_id,+ .scroll_node_index = viewport_scroll_node_index,.stable_node_id = { .node_id = viewport_document_node_id, .kind = Web::AsyncScrollNodeKind::Viewport, .pseudo_element_type = 0 },- .parent_node_id = {},+ .parent_scroll_node_index = {},.scrollport_rect = { 0, 0, 800, 600 },.min_scroll_offset = { 0, 0 },.max_scroll_offset = { 0, max_scroll_offset_y },@@ -106,7 +106,7 @@ TEST_CASE(blocking_wheel_event_hit_testing_fails_closed_for_invalid_visual_conteEXPECT(scroll_tree.blocks_wheel_event_at_position(visual_context_tree, { 200, 200 }));auto result = scroll_tree.hit_test_scroll_node_for_wheel(visual_context_tree, { 200, 200 }, { 0, 10 });EXPECT_EQ(result.outcome, Compositing::WheelHitTestOutcome::BlockedByWheelEventRegion);- EXPECT(!result.node_id.has_value());+ EXPECT(!result.scroll_node_index.has_value());}TEST_CASE(first_wheel_step_route_puts_main_thread_region_before_blocking_region_and_viewport_blocker_before_both)@@ -176,7 +176,7 @@ TEST_CASE(async_scrolling_resolves_sticky_offsets_from_the_visual_context_tree)auto scroll_tree = make_scroll_tree_with_viewport_scroll_node(2000);Compositing::ScrollStateSnapshot snapshot;- auto scroll_offset = scroll_tree.apply_scroll_delta(viewport_node_id, { 0, 300 }, visual_context_tree, snapshot, Compositing::ScrollChaining::ToScrollableAncestors);+ auto scroll_offset = scroll_tree.apply_scroll_delta(viewport_scroll_node_index, { 0, 300 }, visual_context_tree, snapshot, Compositing::ScrollChaining::ToScrollableAncestors);EXPECT(scroll_offset.has_value());EXPECT_EQ(snapshot.device_offset_for_index(viewport_scroll_node), (Gfx::FloatPoint { 0, -300 }));// The scrollport top passed the header by 200px, so the header follows it by that much.@@ -185,27 +185,27 @@ TEST_CASE(async_scrolling_resolves_sticky_offsets_from_the_visual_context_tree)EXPECT_EQ(snapshot.device_offset_for_index(bar_node), (Gfx::FloatPoint { 0, 10 }));// Past the end of the containing block, the header pins to the block's bottom edge and the bar to the header's.- EXPECT(scroll_tree.set_scroll_offset(viewport_node_id, { 0, 1960 }, visual_context_tree, snapshot).has_value());+ EXPECT(scroll_tree.set_scroll_offset(viewport_scroll_node_index, { 0, 1960 }, visual_context_tree, snapshot).has_value());EXPECT_EQ(snapshot.device_offset_for_index(header_node), (Gfx::FloatPoint { 0, 1850 }));EXPECT_EQ(snapshot.device_offset_for_index(bar_node), (Gfx::FloatPoint { 0, 20 }));// Scrolled back above the header, nothing sticks.- EXPECT(scroll_tree.set_scroll_offset(viewport_node_id, { 0, 50 }, visual_context_tree, snapshot).has_value());+ EXPECT(scroll_tree.set_scroll_offset(viewport_scroll_node_index, { 0, 50 }, visual_context_tree, snapshot).has_value());EXPECT_EQ(snapshot.device_offset_for_index(header_node), (Gfx::FloatPoint { 0, 0 }));EXPECT_EQ(snapshot.device_offset_for_index(bar_node), (Gfx::FloatPoint { 0, 0 }));}TEST_CASE(a_key_is_not_passed_on_from_a_scroller_that_keeps_its_scrolls){- Compositing::AsyncScrollNodeID const nested_node_id { .document_id = Web::UniqueNodeID { 1 }, .scroll_node_index = Compositing::SpatialNodeIndex { 2 } };+ Compositing::SpatialNodeIndex const nested_scroll_node_index { 2 };Web::AsyncScrollNodeStableID const nested_stable_node_id { .node_id = Web::UniqueNodeID { 3 }, .kind = Web::AsyncScrollNodeKind::Element, .pseudo_element_type = 0 };auto scroll_tree_with_nested_scroller = [&](bool nested_scroller_chains_vertically) {auto state = make_scrolling_state_with_viewport_scroll_node(2000);state.scroll_nodes.append({- .node_id = nested_node_id,+ .scroll_node_index = nested_scroll_node_index,.stable_node_id = nested_stable_node_id,- .parent_node_id = viewport_node_id,+ .parent_scroll_node_index = viewport_scroll_node_index,.scrollport_rect = { 0, 0, 100, 100 },.min_scroll_offset = { 0, 0 },.max_scroll_offset = { 0, 200 },@@ -222,14 +222,14 @@ TEST_CASE(a_key_is_not_passed_on_from_a_scroller_that_keeps_its_scrolls)// The viewport is scrolled down and the nested scroller is at its top, so only the viewport can scroll up.Compositing::ScrollStateSnapshot snapshot;- snapshot.set_device_offset_for_index(viewport_node_id.scroll_node_index, { 0, -300 });+ snapshot.set_device_offset_for_index(viewport_scroll_node_index, { 0, -300 });auto target_of_key_that_is_passed_on = scroll_tree_with_nested_scroller(true).scroll_node_for_keyboard_scroll(nested_stable_node_id, { 0, -100 }, snapshot);- EXPECT(target_of_key_that_is_passed_on.has_value() && *target_of_key_that_is_passed_on == viewport_node_id);+ EXPECT(target_of_key_that_is_passed_on.has_value() && *target_of_key_that_is_passed_on == viewport_scroll_node_index);auto target_of_key_that_is_kept = scroll_tree_with_nested_scroller(false).scroll_node_for_keyboard_scroll(nested_stable_node_id, { 0, -100 }, snapshot);EXPECT(!target_of_key_that_is_kept.has_value());auto target_of_key_the_scroller_can_scroll_by = scroll_tree_with_nested_scroller(false).scroll_node_for_keyboard_scroll(nested_stable_node_id, { 0, 100 }, snapshot);- EXPECT(target_of_key_the_scroller_can_scroll_by.has_value() && *target_of_key_the_scroller_can_scroll_by == nested_node_id);+ EXPECT(target_of_key_the_scroller_can_scroll_by.has_value() && *target_of_key_the_scroller_can_scroll_by == nested_scroll_node_index);}diff --git a/Tests/Compositor/TestScrollbarController.cpp b/Tests/Compositor/TestScrollbarController.cppindex 42528dd8b2b..c5ab4b4aa36 100644--- a/Tests/Compositor/TestScrollbarController.cpp+++ b/Tests/Compositor/TestScrollbarController.cpp@@ -25,22 +25,17 @@ static void show_scrollbars_by_scrolling_away_and_back(Compositor::ScrollbarContstatic Compositor::ScrollbarController::Drag begin_scrollbar_drag(Gfx::Orientation orientation, Gfx::FloatPoint position, Optional<Gfx::IntRect> expanded_thumb_rect = {}){auto vertical = orientation == Gfx::Orientation::Vertical;- auto document_id = Web::UniqueNodeID { 1 };auto scroll_node_index = Compositing::SpatialNodeIndex { 1 };- auto scroll_node_id = Compositing::AsyncScrollNodeID {- .document_id = document_id,- .scroll_node_index = scroll_node_index,- };Compositing::AsyncScrollingState scrolling_state;scrolling_state.scroll_nodes.append({- .node_id = scroll_node_id,+ .scroll_node_index = scroll_node_index,.stable_node_id = {.node_id = Web::UniqueNodeID { 2 },.kind = Web::AsyncScrollNodeKind::Viewport,.pseudo_element_type = 0,},- .parent_node_id = {},+ .parent_scroll_node_index = {},.scrollport_rect = { 0, 0, 100, 100 },.min_scroll_offset = { 0, 0 },.max_scroll_offset = { 100, 100 },@@ -55,7 +50,6 @@ static Compositor::ScrollbarController::Drag begin_scrollbar_drag(Gfx::OrientatiVector<Compositing::AsyncScrollbar> scrollbars;scrollbars.append({- .scroll_node_id = scroll_node_id,.scroller_stable_node_id = {},.scroll_node_index = scroll_node_index,.context = {},@@ -121,10 +115,6 @@ TEST_CASE(starting_scrollbar_drag_uses_expanded_thumb_geometry)static Compositing::AsyncScrollbar scrollbar_painted_by_display_list(){return {- .scroll_node_id = {- .document_id = Web::UniqueNodeID { 1 },- .scroll_node_index = Compositing::SpatialNodeIndex { 1 },- },.scroller_stable_node_id = Web::AsyncScrollNodeStableID {.node_id = Web::UniqueNodeID { 2 },.kind = Web::AsyncScrollNodeKind::Element,diff --git a/Tests/LibCompositing/TestScrollState.cpp b/Tests/LibCompositing/TestScrollState.cppindex d66bfb62e8e..4452373d180 100644--- a/Tests/LibCompositing/TestScrollState.cpp+++ b/Tests/LibCompositing/TestScrollState.cpp@@ -92,18 +92,14 @@ static AccumulatedVisualContextTree make_tree_with_four_spatial_nodes()static Compositing::AsyncScrollNode make_scroll_node(SpatialNodeIndex scroll_node_index){- Compositing::AsyncScrollNodeID node_id {- .document_id = Web::UniqueNodeID { 1 },- .scroll_node_index = scroll_node_index,- };return {- .node_id = node_id,+ .scroll_node_index = scroll_node_index,.stable_node_id = {.node_id = Web::UniqueNodeID { 1 },.kind = Web::AsyncScrollNodeKind::Element,.pseudo_element_type = 0,},- .parent_node_id = {},+ .parent_scroll_node_index = {},.scrollport_rect = Gfx::IntRect { 0, 0, 100, 100 },.min_scroll_offset = Gfx::FloatPoint { 0, 0 },.max_scroll_offset = Gfx::FloatPoint { 100, 100 },@@ -129,7 +125,7 @@ TEST_CASE(async_scroll_tree_ignores_out_of_range_scroll_node_index)ScrollStateSnapshot snapshot;snapshot.set_node_count(tree.spatial_node_count());(void)scroll_tree.apply_scroll_delta(- Compositing::AsyncScrollNodeID { .document_id = Web::UniqueNodeID { 1 }, .scroll_node_index = out_of_range_index },+ out_of_range_index,Gfx::FloatPoint { 10, 10 },tree,snapshot,diff --git a/Tests/LibWeb/Text/expected/async-scrolling/scroll-tree-shape.txt b/Tests/LibWeb/Text/expected/async-scrolling/scroll-tree-shape.txtindex 0d6c496bfde..5355fb38825 100644--- a/Tests/LibWeb/Text/expected/async-scrolling/scroll-tree-shape.txt+++ b/Tests/LibWeb/Text/expected/async-scrolling/scroll-tree-shape.txt@@ -3,7 +3,6 @@ scroll nodes: 2has viewport node: trueviewport parent: 0child nodes: 1-child has same document as viewport: truechild parent is viewport: truedisplay list:AccumulatedVisualContext Tree:diff --git a/Tests/LibWeb/Text/input/async-scrolling/scroll-tree-parent-nodes.html b/Tests/LibWeb/Text/input/async-scrolling/scroll-tree-parent-nodes.htmlindex 7cfab817adc..cbe5ea0c6e3 100644--- a/Tests/LibWeb/Text/input/async-scrolling/scroll-tree-parent-nodes.html+++ b/Tests/LibWeb/Text/input/async-scrolling/scroll-tree-parent-nodes.html@@ -38,10 +38,10 @@await animationFrame();await animationFrame();const state = internals.compositorScrollState();- const scrollNodeIDs = new Set(state.scrollNodes.map(node => `${node.documentID}:${node.scrollNodeIndex}`));+ const scrollNodeIndices = new Set(state.scrollNodes.map(node => node.scrollNodeIndex));const viewportNode = state.scrollNodes.find(node => node.isViewport);const childNodes = state.scrollNodes.filter(node => !node.isViewport);- const danglingParentNodes = state.scrollNodes.filter(node => node.parentScrollNodeIndex !== 0 && !scrollNodeIDs.has(`${node.parentDocumentID}:${node.parentScrollNodeIndex}`));+ const danglingParentNodes = state.scrollNodes.filter(node => node.parentScrollNodeIndex !== 0 && !scrollNodeIndices.has(node.parentScrollNodeIndex));const output = [`scroll nodes: ${state.scrollNodes.length}`,diff --git a/Tests/LibWeb/Text/input/async-scrolling/scroll-tree-shape.html b/Tests/LibWeb/Text/input/async-scrolling/scroll-tree-shape.htmlindex 71de45d745c..c81463fa57d 100644--- a/Tests/LibWeb/Text/input/async-scrolling/scroll-tree-shape.html+++ b/Tests/LibWeb/Text/input/async-scrolling/scroll-tree-shape.html@@ -43,7 +43,6 @@const childNodes = state.scrollNodes.filter(node => !node.isViewport);output.push(`child nodes: ${childNodes.length}`);for (const node of childNodes) {- output.push(`child has same document as viewport: ${node.documentID === viewportNode.documentID}`);output.push(`child parent is viewport: ${node.parentScrollNodeIndex === viewportNode.scrollNodeIndex}`);}printOutputAndDisplayList(output);diff --git a/Tests/LibWeb/Text/input/display_list/paint-cache-scrollability-flip-scope.html b/Tests/LibWeb/Text/input/display_list/paint-cache-scrollability-flip-scope.htmlindex ddb42ac00de..d0db94dcd51 100644--- a/Tests/LibWeb/Text/input/display_list/paint-cache-scrollability-flip-scope.html+++ b/Tests/LibWeb/Text/input/display_list/paint-cache-scrollability-flip-scope.html@@ -16,7 +16,7 @@<script>function nestedElementScrollers() {const nodes = internals.recordedAsyncScrollingState().scrollNodes.filter(node => !node.isViewport);- return nodes.filter(node => nodes.some(parent => parent.documentID === node.parentDocumentID && parent.scrollNodeIndex === node.parentScrollNodeIndex)).length;+ return nodes.filter(node => nodes.some(parent => parent.scrollNodeIndex === node.parentScrollNodeIndex)).length;}displayListTest({setup: () => {