Skip to content

Truly independent web browser

LibWeb+LibCompositing+Compositor: Replace scroll chaining barriers

Aliaksandr Kalenik27c638439bb5
diff --git a/Libraries/LibCompositing/Rust/src/display_list/commands.rs b/Libraries/LibCompositing/Rust/src/display_list/commands.rs
index c9dd7e4573a..934c713096a 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/commands.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/commands.rs
@@ -53,7 +53,6 @@ pub enum DisplayListCommandType {
PaintScrollBar,
CompositorSnapContainer,
CompositorSnapArea,
- CompositorScrollChainingBarrier,
CompositorNestedContextWheelRegion,
Canvas2DFillPath,
Canvas2DStrokePath,
@@ -95,7 +94,6 @@ impl DisplayListCommandType {
| Self::CompositorBlockingWheelEventRegion
| Self::CompositorSnapContainer
| Self::CompositorSnapArea
- | Self::CompositorScrollChainingBarrier
| Self::CompositorNestedContextWheelRegion
)
}
@@ -163,7 +161,6 @@ impl DisplayListCommandType {
Self::PaintScrollBar => "PaintScrollBar",
Self::CompositorSnapContainer => "CompositorSnapContainer",
Self::CompositorSnapArea => "CompositorSnapArea",
- Self::CompositorScrollChainingBarrier => "CompositorScrollChainingBarrier",
Self::CompositorNestedContextWheelRegion => "CompositorNestedContextWheelRegion",
Self::Canvas2DFillPath => "Canvas2DFillPath",
Self::Canvas2DStrokePath => "Canvas2DStrokePath",
@@ -1626,27 +1623,6 @@ impl DisplayListCommand for CompositorWheelHitTestTargetWithCornerRadii {
const COMMAND_TYPE: DisplayListCommandType = DisplayListCommandType::CompositorWheelHitTestTargetWithCornerRadii;
}
-/// A scroll container that has no scroll node, because a wheel can scroll nothing in it, and that keeps the scrolls
-/// along an axis to itself all the same: a wheel inside `rect` is not passed on to the scroll node above it.
-#[derive(Clone, Copy, Debug, PartialEq)]
-#[repr(C)]
-pub struct CompositorScrollChainingBarrier {
- pub scroll_node_index_above_barrier: SpatialNodeIndex,
- pub rect: FloatRect,
- pub keeps_horizontal_scrolls: bool,
- pub keeps_vertical_scrolls: bool,
-}
-ffi_bytes_fields!(CompositorScrollChainingBarrier {
- scroll_node_index_above_barrier,
- rect,
- keeps_horizontal_scrolls,
- keeps_vertical_scrolls
-});
-
-impl DisplayListCommand for CompositorScrollChainingBarrier {
- const COMMAND_TYPE: DisplayListCommandType = DisplayListCommandType::CompositorScrollChainingBarrier;
-}
-
/// Where a nested context is painted: its content box, clipped to the rounded padding edge. The compositor can hand a
/// wheel inside `rect` that nothing painted later covers to the nested context's own scroll nodes.
#[derive(Clone, Copy, Debug, PartialEq)]
diff --git a/Libraries/LibCompositing/Rust/src/display_list/summary.rs b/Libraries/LibCompositing/Rust/src/display_list/summary.rs
index 3fac37e244a..2402c47b952 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/summary.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/summary.rs
@@ -136,7 +136,6 @@ fn note_referenced_ids(command_type: DisplayListCommandType, payload: &[u8], ids
| T::PaintScrollBar
| T::CompositorSnapContainer
| T::CompositorSnapArea
- | T::CompositorScrollChainingBarrier
| T::CompositorNestedContextWheelRegion
// The display list of a page holds none of the commands of the canvas 2D stream.
| T::Canvas2DFillPath
@@ -290,7 +289,6 @@ fn command_blend(
| T::PaintScrollBar
| T::CompositorSnapContainer
| T::CompositorSnapArea
- | T::CompositorScrollChainingBarrier
| T::CompositorNestedContextWheelRegion
// The display list of a page holds none of the commands of the canvas 2D stream.
| T::Canvas2DFillPath
diff --git a/Libraries/LibCompositing/Rust/src/display_list/validate.rs b/Libraries/LibCompositing/Rust/src/display_list/validate.rs
index 677c2f11181..ae0630dc8ac 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/validate.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/validate.rs
@@ -340,7 +340,6 @@ fn command_struct_size(command_type: DisplayListCommandType) -> usize {
T::PaintScrollBar => size_of::<PaintScrollBar>(),
T::CompositorSnapContainer => size_of::<CompositorSnapContainer>(),
T::CompositorSnapArea => size_of::<CompositorSnapArea>(),
- T::CompositorScrollChainingBarrier => size_of::<CompositorScrollChainingBarrier>(),
T::CompositorNestedContextWheelRegion => size_of::<CompositorNestedContextWheelRegion>(),
T::Canvas2DFillPath => size_of::<Canvas2DFillPath>(),
T::Canvas2DStrokePath => size_of::<Canvas2DStrokePath>(),
@@ -533,10 +532,6 @@ fn validate_command_fields(
p.bool_at(offset_of!(CompositorSnapContainer, snaps_y))?;
p.bool_at(offset_of!(CompositorSnapContainer, horizontal_writing_mode))?;
}
- T::CompositorScrollChainingBarrier => {
- p.bool_at(offset_of!(CompositorScrollChainingBarrier, keeps_horizontal_scrolls))?;
- p.bool_at(offset_of!(CompositorScrollChainingBarrier, keeps_vertical_scrolls))?;
- }
T::CompositorSnapArea => {
p.u8_below(offset_of!(CompositorSnapArea, align_x), SNAP_ALIGN_COUNT)?;
p.u8_below(offset_of!(CompositorSnapArea, align_y), SNAP_ALIGN_COUNT)?;
diff --git a/Libraries/LibCompositing/Rust/src/visual_context/mod.rs b/Libraries/LibCompositing/Rust/src/visual_context/mod.rs
index 9b0a72dfc98..98a84823dbe 100644
--- a/Libraries/LibCompositing/Rust/src/visual_context/mod.rs
+++ b/Libraries/LibCompositing/Rust/src/visual_context/mod.rs
@@ -165,8 +165,9 @@ pub struct StickyData {
pub scrollport_size: FloatSize,
pub containing_block_region: FloatRect,
pub needs_parent_offset_adjustment: bool,
- // The nearest scroll container of the box when it has no scrollable overflow, and so no scroll node. Its
- // scrollport never moves, and the geometry above is relative to it rather than to the scroller.
+ // The nearest scroll container of the box when it has no scroll node, because it has no scrollable overflow and
+ // passes its scrolls on. Its scrollport never moves, and the geometry above is relative to it rather than to the
+ // scroller.
pub non_scrolling_scroll_container: NodeSlotId,
pub inset_top: Option<f32>,
pub inset_right: Option<f32>,
diff --git a/Libraries/LibCompositing/Rust/src/visual_context/scroll_state.rs b/Libraries/LibCompositing/Rust/src/visual_context/scroll_state.rs
index 7c1e1d9d216..4df3217d9da 100644
--- a/Libraries/LibCompositing/Rust/src/visual_context/scroll_state.rs
+++ b/Libraries/LibCompositing/Rust/src/visual_context/scroll_state.rs
@@ -40,7 +40,7 @@ pub struct ScrollState {
// Each slot's own scroll offset. A frame a document published shares them, so a write copies
// them only while such a frame still holds them.
own_offsets: Arc<Vec<CssPixelPoint>>,
- // Whether any box but the viewport could take a wheel event. A registry reset keeps it, so
+ // Whether any box but the viewport could take or keep a wheel event. A registry reset keeps it, so
// the rebuild that follows sees a change only when the document's scrollers changed.
pub has_non_viewport_wheel_scroll_target_candidate: bool,
}
diff --git a/Libraries/LibCompositing/Scrolling/AsyncScrollTree.cpp b/Libraries/LibCompositing/Scrolling/AsyncScrollTree.cpp
index 18fc640104a..d995042cc14 100644
--- a/Libraries/LibCompositing/Scrolling/AsyncScrollTree.cpp
+++ b/Libraries/LibCompositing/Scrolling/AsyncScrollTree.cpp
@@ -21,7 +21,6 @@ void AsyncScrollTree::set_state(AsyncScrollingState&& state)
m_main_thread_wheel_event_regions = move(state.main_thread_wheel_event_regions);
m_nested_context_wheel_regions = move(state.nested_context_wheel_regions);
m_blocking_wheel_event_regions = move(state.blocking_wheel_event_regions);
- m_scroll_chaining_barriers = move(state.scroll_chaining_barriers);
m_has_blocking_wheel_event_region_covering_viewport = state.has_blocking_wheel_event_region_covering_viewport;
m_viewport_keeps_horizontal_scrolls = state.viewport_keeps_horizontal_scrolls;
m_viewport_keeps_vertical_scrolls = state.viewport_keeps_vertical_scrolls;
@@ -29,7 +28,6 @@ void AsyncScrollTree::set_state(AsyncScrollingState&& state)
m_cached_main_thread_wheel_event_targets.clear();
m_cached_nested_context_wheel_regions.clear();
m_cached_blocking_wheel_event_targets.clear();
- m_cached_scroll_chaining_barriers.clear();
m_visual_context_tree_structural_epoch.clear();
}
@@ -72,7 +70,7 @@ static bool node_chains_scroll_to_ancestors(AsyncScrollNode const& node, Gfx::Fl
return 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(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
+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) const
{
auto can_take_step = [&](AsyncScrollNode const& node) {
Optional<Gfx::FloatPoint> in_flight_destination;
@@ -82,12 +80,12 @@ WheelHitTestResult AsyncScrollTree::hit_test_result_for_scroll_node(Compositing:
};
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->scroll_node_index))
- return { .outcome = WheelHitTestOutcome::BlockedByMainThreadRegion };
if (can_take_step(*node))
return { .outcome = WheelHitTestOutcome::FoundScrollTarget, .scroll_node_index = node->scroll_node_index, .innermost_scroll_node_index = scroll_node_index };
+ // 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.
+ // NB: A scroll container that keeps its scrolls has a scroll node even when it has nothing to scroll.
if (!node_chains_scroll_to_ancestors(*node, delta))
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())
@@ -284,7 +282,6 @@ void AsyncScrollTree::rebuild_wheel_hit_test_targets(RefPtr<Compositing::Display
m_cached_main_thread_wheel_event_targets.clear();
m_cached_nested_context_wheel_regions.clear();
m_cached_blocking_wheel_event_targets.clear();
- m_cached_scroll_chaining_barriers.clear();
m_visual_context_tree_structural_epoch.clear();
m_scroll_state_snapshot = scroll_state_snapshot;
if (!display_list || !visual_context_tree)
@@ -347,14 +344,6 @@ void AsyncScrollTree::rebuild_wheel_hit_test_targets(RefPtr<Compositing::Display
.viewport_rect = context_is_valid(region.context) ? viewport_rect_for_context(region.context, region.rect) : Optional<Gfx::FloatRect> {},
});
}
-
- for (auto const& barrier : m_scroll_chaining_barriers) {
- // Keep invalid barriers so hit testing fails closed when their extent cannot be determined.
- m_cached_scroll_chaining_barriers.append({
- .barrier = barrier,
- .viewport_rect = context_is_valid(barrier.context) ? viewport_rect_for_context(barrier.context, barrier.rect) : Optional<Gfx::FloatRect> {},
- });
- }
}
static bool rounded_rect_contains_point(Gfx::FloatRect const& rect, Gfx::CornerRadii const& corner_radii, Gfx::FloatPoint position_in_context)
@@ -529,24 +518,6 @@ WheelHitTestResult AsyncScrollTree::hit_test_scroll_node_for_wheel(Compositing::
if (blocking_wheel_event_listeners_hold_the_step_back && blocks_wheel_event_at_position(visual_context_tree, position))
return { .outcome = WheelHitTestOutcome::BlockedByWheelEventRegion };
- // 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<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;
- if (!keeps_the_scroll)
- continue;
- if (!context_is_valid(barrier.context))
- return { .outcome = WheelHitTestOutcome::BlockedByMainThreadRegion };
- if (cached_barrier.viewport_rect.has_value() && !cached_barrier.viewport_rect->contains(position))
- 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_index_above_barrier);
- }
-
for (auto const& target : m_cached_wheel_hit_test_targets.in_reverse()) {
if (target.viewport_rect.has_value() && !target.viewport_rect->contains(position))
continue;
@@ -557,7 +528,7 @@ WheelHitTestResult AsyncScrollTree::hit_test_scroll_node_for_wheel(Compositing::
continue;
if (!target.target_scroll_node_index.has_value())
return { .outcome = WheelHitTestOutcome::NoScrollTarget };
- return hit_test_result_for_scroll_node(*target.target_scroll_node_index, 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);
}
auto index_of_viewport_scroll_node = viewport_scroll_node_index();
@@ -566,7 +537,7 @@ WheelHitTestResult AsyncScrollTree::hit_test_scroll_node_for_wheel(Compositing::
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(*index_of_viewport_scroll_node, 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);
}
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
diff --git a/Libraries/LibCompositing/Scrolling/AsyncScrollTree.h b/Libraries/LibCompositing/Scrolling/AsyncScrollTree.h
index a744b1d28f5..bba47785fd5 100644
--- a/Libraries/LibCompositing/Scrolling/AsyncScrollTree.h
+++ b/Libraries/LibCompositing/Scrolling/AsyncScrollTree.h
@@ -117,11 +117,6 @@ struct CachedBlockingWheelEventTarget {
Optional<Gfx::FloatRect> viewport_rect;
};
-struct CachedScrollChainingBarrier {
- ScrollChainingBarrier barrier;
- Optional<Gfx::FloatRect> viewport_rect;
-};
-
enum class ScrollChaining : u8 {
ToScrollableAncestors,
None,
@@ -185,7 +180,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(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;
+ WheelHitTestResult hit_test_result_for_scroll_node(Compositing::SpatialNodeIndex, Gfx::FloatPoint delta, Function<Optional<Gfx::FloatPoint>(Web::AsyncScrollNodeStableID)> const& in_flight_destination_for) 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 {
@@ -208,8 +203,6 @@ private:
Vector<CachedMainThreadWheelEventTarget> m_cached_main_thread_wheel_event_targets;
Vector<CachedNestedContextWheelRegion> m_cached_nested_context_wheel_regions;
Vector<CachedBlockingWheelEventTarget> m_cached_blocking_wheel_event_targets;
- Vector<ScrollChainingBarrier> m_scroll_chaining_barriers;
- Vector<CachedScrollChainingBarrier> m_cached_scroll_chaining_barriers;
Optional<u64> m_visual_context_tree_structural_epoch;
Compositing::ScrollStateSnapshot m_scroll_state_snapshot;
bool m_has_blocking_wheel_event_region_covering_viewport { false };
diff --git a/Libraries/LibCompositing/Scrolling/AsyncScrollingState.cpp b/Libraries/LibCompositing/Scrolling/AsyncScrollingState.cpp
index 13874f937a8..f54b6ea35af 100644
--- a/Libraries/LibCompositing/Scrolling/AsyncScrollingState.cpp
+++ b/Libraries/LibCompositing/Scrolling/AsyncScrollingState.cpp
@@ -125,17 +125,6 @@ AsyncScrollingState async_scrolling_state_from_display_list(Compositing::Display
});
break;
}
- case Compositing::DisplayListCommandType::CompositorScrollChainingBarrier: {
- auto command = Compositing::read_display_list_object<Compositing::CompositorScrollChainingBarrier>(payload);
- async_scrolling_state.scroll_chaining_barriers.append({
- .context = context,
- .rect = command.rect,
- .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,
- });
- break;
- }
case Compositing::DisplayListCommandType::CompositorScrollbar: {
auto command = Compositing::read_display_list_object<Compositing::CompositorScrollbar>(payload);
async_scrolling_state.scrollbars.append({
diff --git a/Libraries/LibCompositing/Scrolling/AsyncScrollingState.h b/Libraries/LibCompositing/Scrolling/AsyncScrollingState.h
index 5e2e0b3d817..406b7be9c73 100644
--- a/Libraries/LibCompositing/Scrolling/AsyncScrollingState.h
+++ b/Libraries/LibCompositing/Scrolling/AsyncScrollingState.h
@@ -61,7 +61,7 @@ struct AsyncScrollOffset {
}
};
-// One scrollable area from the paint snapshot.
+// One scrollable area from the paint snapshot, or a scroll container with nothing to scroll that keeps its scrolls.
struct AsyncScrollNode {
Compositing::SpatialNodeIndex scroll_node_index;
Web::AsyncScrollNodeStableID stable_node_id;
@@ -111,16 +111,6 @@ struct NestedContextWheelRegion {
u32 paint_order_index { 0 };
};
-// A scroll container without a scroll node of its own that keeps the scrolls along an axis to itself. A wheel inside
-// its rect is not passed on along that axis to the scroll node above it.
-struct ScrollChainingBarrier {
- Compositing::ContextRef context;
- Gfx::FloatRect rect;
- Compositing::SpatialNodeIndex scroll_node_index_above_barrier;
- bool keeps_horizontal_scrolls { false };
- bool keeps_vertical_scrolls { false };
-};
-
struct AsyncScrollbar {
Optional<Web::AsyncScrollNodeStableID> scroller_stable_node_id;
Compositing::SpatialNodeIndex scroll_node_index;
@@ -158,7 +148,6 @@ struct AsyncScrollingState {
Vector<WheelHitTestTarget> wheel_hit_test_targets;
Vector<MainThreadWheelEventRegion> main_thread_wheel_event_regions;
Vector<NestedContextWheelRegion> nested_context_wheel_regions;
- Vector<ScrollChainingBarrier> scroll_chaining_barriers;
Vector<AsyncScrollbar> scrollbars;
// Non-passive wheel listeners can cancel scrolling, so async scrolling must treat them as hard barriers.
diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp
index fc8f25d696c..910d395ce91 100644
--- a/Libraries/LibWeb/Page/EventHandler.cpp
+++ b/Libraries/LibWeb/Page/EventHandler.cpp
@@ -1768,8 +1768,8 @@ EventHandler::KeyboardScrollSnapshot EventHandler::keyboard_scroll_snapshot() co
target = scroll_target->layout_node(read);
if (!target)
return snapshot;
- // The compositor only knows the scrollers that a wheel can scroll. If any other box keeps the scrolls of keys to
- // itself, the keys are scrolled by here, where every box in the chain is seen.
+ // The compositor starts a key scroll at the first box a wheel can scroll. If a box around the target keeps the
+ // scrolls of keys to itself, the keys are scrolled by here, where every box in the chain is seen.
for (auto delta : { Gfx::FloatPoint { 1, 0 }, Gfx::FloatPoint { 0, 1 } }) {
auto const* box_ending_scroll_chain = Painting::box_ending_scroll_chain(*target, delta.x(), delta.y());
if (!box_ending_scroll_chain || box_ending_scroll_chain->is_viewport())
diff --git a/Libraries/LibWeb/Rust/src/css/style/style_invalidation.rs b/Libraries/LibWeb/Rust/src/css/style/style_invalidation.rs
index eec8719e8ba..30425cb7ee0 100644
--- a/Libraries/LibWeb/Rust/src/css/style/style_invalidation.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/style_invalidation.rs
@@ -600,6 +600,22 @@ fn property_invalidation(property: u16, old: ComputedValuesView<'_>, new: Comput
{
result.ensure_visual_context(VISUAL_CONTEXT_UPDATE_VALUES);
}
+ // A scroll container that keeps its scrolls has a scroll node of its own, so a box that starts or stops keeping
+ // them has its visual context nodes built again.
+ if matches!(
+ property,
+ property_id::OVERSCROLL_BEHAVIOR_X | property_id::OVERSCROLL_BEHAVIOR_Y
+ ) {
+ use crate::css::css_enums::overscroll_behavior::{AUTO, CHAIN};
+ let chains = |value: u8| value == AUTO || value == CHAIN;
+ let old_values = old.misc_reset();
+ let new_values = new.misc_reset();
+ if chains(old_values.overscroll_behavior_x) != chains(new_values.overscroll_behavior_x)
+ || chains(old_values.overscroll_behavior_y) != chains(new_values.overscroll_behavior_y)
+ {
+ result.ensure_visual_context(VISUAL_CONTEXT_REBUILD);
+ }
+ }
let will_change_covers_property =
will_change_covers_property(property, old) && will_change_covers_property(property, new);
if property_metadata::property_affects_stacking_context(property)
diff --git a/Libraries/LibWeb/Rust/src/painting/chrome_geometry.rs b/Libraries/LibWeb/Rust/src/painting/chrome_geometry.rs
index 2be53ff65bd..05b91af94cd 100644
--- a/Libraries/LibWeb/Rust/src/painting/chrome_geometry.rs
+++ b/Libraries/LibWeb/Rust/src/painting/chrome_geometry.rs
@@ -185,6 +185,13 @@ pub(crate) fn scroll_boundary_behavior(arena: &impl PaintRead, slot: NodeSlotId)
}
}
+// A scroll container that keeps the scrolls along some axis to itself gets a scroll node even when it has nothing to
+// scroll, so that the compositor stops passing a scroll on at it.
+pub(crate) fn keeps_scrolls_along_some_axis(arena: &impl PaintRead, slot: NodeSlotId) -> bool {
+ let chains_to_ancestors = scroll_boundary_behavior(arena, slot).chains_to_ancestors;
+ !chains_to_ancestors.horizontal || !chains_to_ancestors.vertical
+}
+
// NB: The viewport's own overflow is the one the layout pass propagated to it, as applied to the viewport.
pub(crate) fn wheel_scrollable_axes(arena: &impl PaintRead, slot: NodeSlotId) -> PhysicalAxes {
let Some(style) = arena.node_style_if_live(slot) else {
@@ -402,6 +409,12 @@ impl<'a, Arena: PaintRead> ChromeGeometry<'a, Arena> {
if arena.paintable_data(slot).own_scroll_node_index == VISUAL_VIEWPORT_NODE_INDEX {
return None;
}
+ // NB: A box that keeps its scrolls has a scroll node even when it has nothing to scroll.
+ if arena.node_kind_if_live(slot) != Some(NodeKind::Viewport)
+ && !paintable_geometry::has_scrollable_overflow(arena, slot)
+ {
+ return None;
+ }
let overflow_length = primary_size(paintable_geometry::scrollable_overflow_rect(arena, slot)?, direction);
if overflow_length == CssPixels::from_raw(0) {
return None;
diff --git a/Libraries/LibWeb/Rust/src/painting/display_list/dump.rs b/Libraries/LibWeb/Rust/src/painting/display_list/dump.rs
index 5e4a1d0361e..f5b495cd0e3 100644
--- a/Libraries/LibWeb/Rust/src/painting/display_list/dump.rs
+++ b/Libraries/LibWeb/Rust/src/painting/display_list/dump.rs
@@ -611,21 +611,6 @@ fn dump_command(output: &mut String, command_type: DisplayListCommandType, paylo
write_field(output, "rect", command.rect);
write_corner_radii(output, command.corner_radii);
}
- DisplayListCommandType::CompositorScrollChainingBarrier => {
- let command = read_command::<CompositorScrollChainingBarrier>(payload);
- write_field(
- output,
- "scroll_node_index_above_barrier",
- command.scroll_node_index_above_barrier,
- );
- write_field(output, "rect", command.rect);
- write!(
- output,
- " keeps_horizontal_scrolls={} keeps_vertical_scrolls={}",
- command.keeps_horizontal_scrolls, command.keeps_vertical_scrolls
- )
- .unwrap();
- }
DisplayListCommandType::CompositorScrollbar => {
let command = read_command::<CompositorScrollbar>(payload);
write_field(output, "scroll_node_index", command.scroll_node_index);
diff --git a/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs b/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs
index 93e6830e66d..682edc8a592 100644
--- a/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs
+++ b/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs
@@ -1348,10 +1348,6 @@ impl DisplayListRecorder {
self.append_command(&region, &[]);
}
- pub fn compositor_scroll_chaining_barrier(&mut self, barrier: CompositorScrollChainingBarrier) {
- self.append_command(&barrier, &[]);
- }
-
pub fn compositor_nested_context_wheel_region(&mut self, region: CompositorNestedContextWheelRegion) {
self.append_command(&region, &[]);
}
diff --git a/Libraries/LibWeb/Rust/src/painting/record/async_scroll_metadata.rs b/Libraries/LibWeb/Rust/src/painting/record/async_scroll_metadata.rs
index d1fe0283484..2beeb826ae6 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/async_scroll_metadata.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/async_scroll_metadata.rs
@@ -54,10 +54,14 @@ impl<O: Observer> PaintRecorder<'_, O> {
facts.could_be_scrolled_horizontally || facts.could_be_scrolled_vertically
}
- fn nearest_scrollable_ancestor(&mut self, paintable: NodeSlotId) -> Option<NodeSlotId> {
+ fn has_compositor_scroll_node(&mut self, paintable: NodeSlotId) -> bool {
+ self.kind_of_compositor_scroll_node_recorded_for(paintable).is_some()
+ }
+
+ fn nearest_ancestor_with_compositor_scroll_node(&mut self, paintable: NodeSlotId) -> Option<NodeSlotId> {
let mut candidate = self.data(paintable).containing_block;
while !candidate.is_invalid() && self.source.paintable_row_is_populated(candidate) {
- if self.could_be_scrolled_by_wheel_event(candidate) {
+ if self.has_compositor_scroll_node(candidate) {
return Some(candidate);
}
if style_queries::is_fixed_position(self.source, candidate) {
@@ -79,9 +83,8 @@ impl<O: Observer> PaintRecorder<'_, O> {
}
paintables_to_cache.push(current);
- let own = self.data(current).own_scroll_node_index;
- if own != VISUAL_VIEWPORT_NODE_INDEX && self.could_be_scrolled_by_wheel_event(current) {
- target = own;
+ if self.has_compositor_scroll_node(current) {
+ target = self.data(current).own_scroll_node_index;
break;
}
@@ -92,9 +95,8 @@ impl<O: Observer> PaintRecorder<'_, O> {
if let Some(block) = containing_block
&& style_queries::is_fixed_position(self.source, block)
{
- let block_own = self.data(block).own_scroll_node_index;
- if block_own != VISUAL_VIEWPORT_NODE_INDEX && self.could_be_scrolled_by_wheel_event(block) {
- target = block_own;
+ if self.has_compositor_scroll_node(block) {
+ target = self.data(block).own_scroll_node_index;
}
if target != VISUAL_VIEWPORT_NODE_INDEX {
break;
@@ -156,43 +158,6 @@ impl<O: Observer> PaintRecorder<'_, O> {
}
}
- // The compositor passes a wheel on along its scroll nodes, and a scroll container that a wheel can scroll nothing
- // in has none. One that keeps scrolls to itself is recorded on its own, so that a wheel under it is not passed on
- // from below it to the scroll node above it.
- fn record_scroll_chaining_barrier(&mut self, paintable: NodeSlotId) {
- if self.source.node_kind_if_live(paintable) == Some(NodeKind::Viewport) {
- return;
- }
- let chains_scroll_to_ancestors =
- crate::painting::chrome_geometry::scroll_boundary_behavior(self.source, paintable).chains_to_ancestors;
- if chains_scroll_to_ancestors.horizontal && chains_scroll_to_ancestors.vertical {
- return;
- }
- let has_scroll_node_that_wheels_are_passed_along = self.data(paintable).own_scroll_node_index
- != VISUAL_VIEWPORT_NODE_INDEX
- && self.could_be_scrolled_by_wheel_event(paintable);
- if has_scroll_node_that_wheels_are_passed_along {
- return;
- }
- let scroll_node_index_above_barrier = self.wheel_hit_test_target_scroll_node_index_for(paintable);
- if scroll_node_index_above_barrier == VISUAL_VIEWPORT_NODE_INDEX {
- return;
- }
- for border_box_rect in paintable_geometry::absolute_border_box_rects_of_fragments(self.source, paintable) {
- let rect = css_rect_to_device_rect(border_box_rect, self.inputs.device_pixels_per_css_pixel);
- if rect.is_empty() {
- continue;
- }
- self.recorder
- .compositor_scroll_chaining_barrier(CompositorScrollChainingBarrier {
- scroll_node_index_above_barrier,
- rect,
- keeps_horizontal_scrolls: !chains_scroll_to_ancestors.horizontal,
- keeps_vertical_scrolls: !chains_scroll_to_ancestors.vertical,
- });
- }
- }
-
fn record_blocking_wheel_event_region(&mut self, paintable: NodeSlotId) {
if self.inputs.uncaptured.has_blocking_wheel_event_region_covering_viewport {
return;
@@ -236,12 +201,18 @@ impl<O: Observer> PaintRecorder<'_, O> {
.source
.node_has_dom_paint_fact(paintable, DomPaintFact::NestedNavigableContainer)
|| self.data(paintable).own_scroll_node_index == VISUAL_VIEWPORT_NODE_INDEX
- || !(self.could_be_scrolled_by_wheel_event(paintable)
- || minimum_scroll_offset(self.source, paintable) != maximum_scroll_offset(self.source, paintable))
{
return None;
}
- if self.source.node_kind_if_live(paintable) == Some(NodeKind::Viewport) {
+ let is_viewport = self.source.node_kind_if_live(paintable) == Some(NodeKind::Viewport);
+ if !(self.could_be_scrolled_by_wheel_event(paintable)
+ || minimum_scroll_offset(self.source, paintable) != maximum_scroll_offset(self.source, paintable)
+ || (!is_viewport
+ && crate::painting::chrome_geometry::keeps_scrolls_along_some_axis(self.source, paintable)))
+ {
+ return None;
+ }
+ if is_viewport {
Some(CompositorScrollNodeKind::Viewport)
} else if self.source.node_generated_for(paintable) != 0 {
Some(CompositorScrollNodeKind::PseudoElement)
@@ -259,7 +230,7 @@ impl<O: Observer> PaintRecorder<'_, O> {
node_identity != 0,
"a scroll node's identity is resolved by the visual context update"
);
- let parent_scroll_node_index = match self.nearest_scrollable_ancestor(paintable) {
+ let parent_scroll_node_index = match self.nearest_ancestor_with_compositor_scroll_node(paintable) {
Some(ancestor) => self.data(ancestor).own_scroll_node_index,
None => VISUAL_VIEWPORT_NODE_INDEX,
};
@@ -428,7 +399,6 @@ impl<O: Observer> PaintRecorder<'_, O> {
pub(crate) fn record_async_scrolling_metadata(&mut self, paintable: NodeSlotId) {
self.record_wheel_hit_test_target(paintable);
- self.record_scroll_chaining_barrier(paintable);
self.record_blocking_wheel_event_region(paintable);
if self
diff --git a/Libraries/LibWeb/Rust/src/painting/record/frame_inputs.rs b/Libraries/LibWeb/Rust/src/painting/record/frame_inputs.rs
index e5feb28f56d..69ab6f439dc 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/frame_inputs.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/frame_inputs.rs
@@ -21,7 +21,7 @@ pub(crate) struct FrameInputs {
pub(crate) should_show_line_box_borders: bool,
pub(crate) should_paint_overlay: bool,
pub(crate) uncaptured: UncapturedContentInputs,
- // Whether any box but the viewport could take a wheel event decides if the scroll metadata
+ // Whether any box but the viewport could take or keep a wheel event decides if the scroll metadata
// inside subtree captures carries per-box wheel hit-test targets.
pub(crate) has_non_viewport_wheel_scroll_target_candidate: bool,
}
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/box_build.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/box_build.rs
index 5e20cff5cec..d6ffc6139d9 100644
--- a/Libraries/LibWeb/Rust/src/painting/visual_context/box_build.rs
+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/box_build.rs
@@ -549,7 +549,9 @@ pub(crate) fn build_box_visual_context_nodes<Arena: PaintableRowsRead>(
}
}
- if paintable_geometry::has_scrollable_overflow(layout_arena, slot) {
+ if paintable_geometry::has_scrollable_overflow(layout_arena, slot)
+ || crate::painting::chrome_geometry::keeps_scrolls_along_some_axis(layout_arena, slot)
+ {
let parent_index = if creates_sticky_scroll_node {
sticky_scroll_node_index
} else {
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/incremental.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/incremental.rs
index f26e74f4a9c..64b5196112d 100644
--- a/Libraries/LibWeb/Rust/src/painting/visual_context/incremental.rs
+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/incremental.rs
@@ -278,6 +278,7 @@ pub(crate) fn register_scroll_like_node(
let box_values = style.box_values();
if matches!(box_values.overflow_x, overflow::AUTO | overflow::SCROLL)
|| matches!(box_values.overflow_y, overflow::AUTO | overflow::SCROLL)
+ || crate::painting::chrome_geometry::keeps_scrolls_along_some_axis(layout_arena, owner_paintable)
{
scroll_state.has_non_viewport_wheel_scroll_target_candidate = true;
}
@@ -681,7 +682,7 @@ pub(crate) fn update_visual_context_tree<Arena: PaintableRowsWrite>(
// publishes them again for this one.
tree.clear_visual_animations();
}
- // Whether any box but the viewport could take a wheel event decides if scroll metadata
+ // Whether any box but the viewport could take or keep a wheel event decides if scroll metadata
// everywhere carries per-box wheel targets.
if state.scroll_state.has_non_viewport_wheel_scroll_target_candidate
!= scroll_state.has_non_viewport_wheel_scroll_target_candidate
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/refresh.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/refresh.rs
index 0c6d3b06901..c71c987ddb1 100644
--- a/Libraries/LibWeb/Rust/src/painting/visual_context/refresh.rs
+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/refresh.rs
@@ -180,9 +180,9 @@ pub(crate) fn compute_sticky_data(
return data;
}
- // NB: Only scroll containers with scrollable overflow get a scroll node. When the nearest scroll container has
- // none, it sits inside the scroller of the scroll node, and its scrollport never moves. The box sticks to
- // that scrollport instead.
+ // NB: Only scroll containers with scrollable overflow, or that keep their scrolls, get a scroll node. When the
+ // nearest scroll container has none, it sits inside the scroller of the scroll node, and its scrollport never
+ // moves. The box sticks to that scrollport instead.
if let Some(scroll_container) = nearest_scroll_container_along_containing_blocks(layout_arena, paintable)
&& scroll_container != scroller
&& is_containing_block_descendant_of(layout_arena, scroll_container, scroller)
diff --git a/Services/Compositor/DisplayListPlayerSkia.cpp b/Services/Compositor/DisplayListPlayerSkia.cpp
index e604007ca54..210977fad6a 100644
--- a/Services/Compositor/DisplayListPlayerSkia.cpp
+++ b/Services/Compositor/DisplayListPlayerSkia.cpp
@@ -1450,10 +1450,6 @@ void DisplayListPlayerSkia::play_command(CompositorSnapArea const&)
{
}
-void DisplayListPlayerSkia::play_command(CompositorScrollChainingBarrier const&)
-{
-}
-
void DisplayListPlayerSkia::play_command(CompositorNestedContextWheelRegion const&)
{
}
diff --git a/Tests/LibWeb/Text/expected/async-scrolling/box-that-keeps-its-scrolls-is-a-scroll-node.txt b/Tests/LibWeb/Text/expected/async-scrolling/box-that-keeps-its-scrolls-is-a-scroll-node.txt
new file mode 100644
index 00000000000..b53d1631277
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/async-scrolling/box-that-keeps-its-scrolls-is-a-scroll-node.txt
@@ -0,0 +1,12 @@
+scroll nodes once the box keeps its scrolls: 1 more
+scroll nodes once the box is not a scroll container: 0 more
+up beside the scroller: no-scroll-target
+left beside the scroller: latched scroller=viewport
+up at the top of the scroller: no-scroll-target
+down over the scroller: latched scroller=#scroller
+overflow hidden, up beside the scroller: no-scroll-target
+#1 compositor: no-scroll-target
+#1 compositor: forwarded-to-page
+#2 compositor: gesture-end-with-nothing-to-snap
+#2 compositor: forwarded-to-page
+page at 200,200
diff --git a/Tests/LibWeb/Text/expected/async-scrolling/ui-touchpad-gesture-over-box-that-keeps-its-scrolls-in-iframe-stays-there.txt b/Tests/LibWeb/Text/expected/async-scrolling/ui-touchpad-gesture-over-box-that-keeps-its-scrolls-in-iframe-stays-there.txt
new file mode 100644
index 00000000000..67982a03726
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/async-scrolling/ui-touchpad-gesture-over-box-that-keeps-its-scrolls-in-iframe-stays-there.txt
@@ -0,0 +1,8 @@
+#1 compositor: handed-to-nested-context
+#1 compositor: scroll-kept-by-overscroll-behavior scroller=#box
+#1 compositor: forwarded-to-page
+#2 compositor: continued-latch scroller=#box
+#2 compositor: forwarded-to-page
+#3 compositor: gesture-end-with-nothing-to-snap
+#3 compositor: forwarded-to-page
+window.scrollY: 0
diff --git a/Tests/LibWeb/Text/expected/display_list/scroll-node-of-box-with-nothing-to-scroll-that-keeps-its-scrolls.txt b/Tests/LibWeb/Text/expected/display_list/scroll-node-of-box-with-nothing-to-scroll-that-keeps-its-scrolls.txt
new file mode 100644
index 00000000000..a14f4e78634
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/display_list/scroll-node-of-box-with-nothing-to-scroll-that-keeps-its-scrolls.txt
@@ -0,0 +1,21 @@
+AccumulatedVisualContext Tree:
+ spatial:
+ [s0] transform=[1,0,0,1,0,0] origin=(0,0) (Viewport<#document>)
+ [s1] scroll (Viewport<#document>)
+ [s2] scroll (BlockContainer<DIV>#keeps-its-scrolls)
+ clips:
+ [c0 in s1] clip=[0,0 100x100] (BlockContainer<DIV>#keeps-its-scrolls)
+ [c1 in s1] clip=[0,100 100x100] (BlockContainer<DIV>#passes-its-scrolls-on)
+ effects:
+ [e0 in s0] effects=[]
+
+DisplayList:
+CompositorWheelHitTestTarget@s0/e0 target_scroll_node_index=s0 rect=[0,0 800x600]
+CompositorWheelHitTestTarget@s1/e0 target_scroll_node_index=s0 rect=[0,0 800x213]
+CompositorWheelHitTestTarget@s1/e0 target_scroll_node_index=s0 rect=[0,0 800x200]
+CompositorWheelHitTestTarget@s1/e0 target_scroll_node_index=s2 rect=[0,0 100x100]
+CompositorScrollNode@s1/e0 scroll_node_index=s2 parent_scroll_node_index=s0 scrollport_rect=[0,0 100x100] min_scroll_offset=[0,0] max_scroll_offset=[0,0] is_viewport=false
+CompositorWheelHitTestTarget@s2/c0/e0 target_scroll_node_index=s2 rect=[0,0 50x50]
+CompositorWheelHitTestTarget@s1/e0 target_scroll_node_index=s0 rect=[0,100 100x100]
+CompositorWheelHitTestTarget@s1/c1/e0 target_scroll_node_index=s0 rect=[0,100 50x50]
+
diff --git a/Tests/LibWeb/Text/expected/sticky-in-box-that-keeps-its-scrolls.txt b/Tests/LibWeb/Text/expected/sticky-in-box-that-keeps-its-scrolls.txt
new file mode 100644
index 00000000000..8299ea9be86
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/sticky-in-box-that-keeps-its-scrolls.txt
@@ -0,0 +1,2 @@
+overscroll-behavior: auto, sticky tops: 150,60
+overscroll-behavior: contain, sticky tops: 150,60
diff --git a/Tests/LibWeb/Text/input/async-scrolling/box-that-keeps-its-scrolls-is-a-scroll-node.html b/Tests/LibWeb/Text/input/async-scrolling/box-that-keeps-its-scrolls-is-a-scroll-node.html
new file mode 100644
index 00000000000..331d5d867c1
--- /dev/null
+++ b/Tests/LibWeb/Text/input/async-scrolling/box-that-keeps-its-scrolls-is-a-scroll-node.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ body {
+ margin: 0;
+ padding: 200px 0 0 200px;
+ width: 3000px;
+ height: 3000px;
+ }
+ #box {
+ width: 200px;
+ height: 200px;
+ overflow: auto;
+ }
+ #scroller {
+ width: 100px;
+ height: 100px;
+ overflow: scroll;
+ }
+ #scroller > div {
+ height: 300px;
+ }
+</style>
+<div id="box"><div id="scroller"><div></div></div></div>
+<script>
+ function recordedScrollNodeCount() {
+ internals.recordDisplayListForTesting();
+ return internals.recordedAsyncScrollingState().scrollNodeCount;
+ }
+
+ function recordedWheelTarget(x, y, deltaX, deltaY) {
+ internals.recordDisplayListForTesting();
+ return wheelTargetToString(internals.recordedDisplayListWheelTargetAt(x, y, deltaX, deltaY));
+ }
+
+ promiseTest(async () => {
+ // The box is at the top left of the window with the scroller in its top left quarter.
+ window.scrollTo(200, 200);
+ const besideTheScroller = [130, 130];
+ const overTheScroller = [30, 30];
+
+ // A box with nothing to scroll gets a scroll node of its own once it keeps its scrolls.
+ const scrollNodesWithAuto = recordedScrollNodeCount();
+ box.style.overscrollBehavior = "contain";
+ println(`scroll nodes once the box keeps its scrolls: ${recordedScrollNodeCount() - scrollNodesWithAuto} more`);
+ box.style.overflow = "clip";
+ println(`scroll nodes once the box is not a scroll container: ${recordedScrollNodeCount() - scrollNodesWithAuto} more`);
+ box.style.overflow = "auto";
+
+ // The scroll node keeps the scrolls along the axes the box keeps, and passes the others on.
+ box.style.overscrollBehavior = "auto none";
+ println(`up beside the scroller: ${recordedWheelTarget(...besideTheScroller, 0, -50)}`);
+ println(`left beside the scroller: ${recordedWheelTarget(...besideTheScroller, -50, 0)}`);
+ println(`up at the top of the scroller: ${recordedWheelTarget(...overTheScroller, 0, -50)}`);
+ println(`down over the scroller: ${recordedWheelTarget(...overTheScroller, 0, 50)}`);
+
+ // A box a wheel cannot scroll keeps its scrolls the same way.
+ box.style.overflow = "hidden";
+ box.style.overscrollBehavior = "contain";
+ println(`overflow hidden, up beside the scroller: ${recordedWheelTarget(...besideTheScroller, 0, -50)}`);
+ box.style.overflow = "auto";
+
+ // The compositor scrolls a gesture the box keeps by nothing, and the page stays where it was.
+ box.style.overscrollBehavior = "contain";
+ await waitForCondition(() => internals.compositorWheelTargetAt(...besideTheScroller, 0, -50).decision === "no-scroll-target");
+ internals.beginInputTrace();
+ await internals.wheelThroughUIProcess(...besideTheScroller, 0, -50, true, "ongoing");
+ await internals.wheelThroughUIProcess(...besideTheScroller, 0, 0, true, "ended");
+ printInputTrace(internals.takeInputTrace(), { stages: ["compositor"] });
+ println(`page at ${window.scrollX},${window.scrollY}`);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/async-scrolling/ui-touchpad-gesture-over-box-that-keeps-its-scrolls-in-iframe-stays-there.html b/Tests/LibWeb/Text/input/async-scrolling/ui-touchpad-gesture-over-box-that-keeps-its-scrolls-in-iframe-stays-there.html
new file mode 100644
index 00000000000..3ebd83a6024
--- /dev/null
+++ b/Tests/LibWeb/Text/input/async-scrolling/ui-touchpad-gesture-over-box-that-keeps-its-scrolls-in-iframe-stays-there.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ body {
+ margin: 0;
+ height: 2000px;
+ }
+
+ iframe {
+ display: block;
+ width: 200px;
+ height: 150px;
+ border: 0;
+ }
+</style>
+<script>
+ promiseTest(async () => {
+ const frame = document.createElement("iframe");
+ const frameLoaded = new Promise(resolve => frame.addEventListener("load", resolve, { once: true }));
+ frame.srcdoc = "<style>body { margin: 0; } div { width: 100px; height: 100px; overflow: auto; overscroll-behavior: contain; }</style><div id='box'></div>";
+ document.body.prepend(frame);
+ await frameLoaded;
+ await waitForCondition(() => internals.compositorWheelTargetAt(50, 50, 0, 50).decision === "scroll-kept-by-overscroll-behavior");
+
+ // The box in the frame has nothing to scroll, and keeps its scrolls from the frame and from this document. The
+ // compositor keeps every step of the gesture there, without scrolling anything.
+ internals.beginInputTrace();
+ await internals.wheelThroughUIProcess(50, 50, 0, 50, true, "ongoing");
+ await internals.wheelThroughUIProcess(50, 50, 0, 50, true, "ongoing");
+ await internals.wheelThroughUIProcess(50, 50, 0, 0, true, "ended");
+ printInputTrace(internals.takeInputTrace(), { stages: ["compositor"] });
+ await animationFrame();
+ await animationFrame();
+ println(`window.scrollY: ${window.scrollY}`);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/display_list/scroll-node-of-box-with-nothing-to-scroll-that-keeps-its-scrolls.html b/Tests/LibWeb/Text/input/display_list/scroll-node-of-box-with-nothing-to-scroll-that-keeps-its-scrolls.html
new file mode 100644
index 00000000000..e9979a507ac
--- /dev/null
+++ b/Tests/LibWeb/Text/input/display_list/scroll-node-of-box-with-nothing-to-scroll-that-keeps-its-scrolls.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ body {
+ margin: 0;
+ }
+ div {
+ width: 100px;
+ height: 100px;
+ }
+ #keeps-its-scrolls {
+ overflow: scroll;
+ overscroll-behavior: contain;
+ }
+ #passes-its-scrolls-on {
+ overflow: scroll;
+ }
+ span {
+ display: block;
+ width: 50px;
+ height: 50px;
+ }
+</style>
+<div id="keeps-its-scrolls"><span></span></div>
+<div id="passes-its-scrolls-on"><span></span></div>
+<script>
+ test(() => {
+ internals.recordDisplayListForTesting();
+ println(internals.dumpDisplayList());
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/sticky-in-box-that-keeps-its-scrolls.html b/Tests/LibWeb/Text/input/sticky-in-box-that-keeps-its-scrolls.html
new file mode 100644
index 00000000000..50526ec1329
--- /dev/null
+++ b/Tests/LibWeb/Text/input/sticky-in-box-that-keeps-its-scrolls.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<script src="include.js"></script>
+<style>
+ body {
+ margin: 0;
+ height: 3000px;
+ }
+ #outer-sticky {
+ position: sticky;
+ top: 10px;
+ margin-top: 100px;
+ }
+ #box {
+ height: 200px;
+ overflow: auto;
+ }
+ .sticky {
+ position: sticky;
+ top: 50px;
+ height: 20px;
+ }
+ .spacer {
+ height: 100px;
+ }
+</style>
+<div id="outer-sticky">
+ <div id="box">
+ <div id="sticky" class="sticky"></div>
+ <div class="spacer"></div>
+ </div>
+</div>
+<script>
+ promiseTest(async () => {
+ // The box has nothing to scroll. Once it keeps its scrolls it has a scroll node of its own, which the sticky
+ // box inside it sticks to exactly as it stuck to the box's scrollport before.
+ const stickyTops = async () => {
+ const tops = [];
+ for (const pageOffset of [0, 300]) {
+ window.scrollTo(0, pageOffset);
+ await animationFrame();
+ tops.push(sticky.getBoundingClientRect().top);
+ }
+ return tops.join(",");
+ };
+ const topsWithAuto = await stickyTops();
+ box.style.overscrollBehavior = "contain";
+ const topsWithContain = await stickyTops();
+ println(`overscroll-behavior: auto, sticky tops: ${topsWithAuto}`);
+ println(`overscroll-behavior: contain, sticky tops: ${topsWithContain}`);
+ });
+</script>