Expand description
Pure scroll state management — the single source of truth for scroll offsets.
§Architecture
ScrollManager is the exclusive owner of all scroll state. Other modules
interact with scrolling only through its public API:
- Platform shell (macos/events.rs, etc.): Calls
record_scroll_from_hit_test()to queue trackpad/mouse wheel input for the physics timer. - Scroll physics timer (
scroll_timer.rs): Consumes inputs viaScrollInputQueue, applies physics, and pushesCallbackChange::ScrollTofor each updated node. - Event processing (
event_v2.rs): ProcessesScrollTochanges, sets scroll positions, and checksVirtualViewre-invocation transparently. - Gesture manager (gesture.rs): Tracks drag state and emits
AutoScrollDirection— does NOT modify scroll offsets directly. - Render loop: Calls
tick()every frame to advance easing animations. WebRendersync (wr_translate2.rs): Reads offsets viaget_scroll_states_for_dom()to synchronize scroll frames.- Layout (cache.rs): Registers scroll nodes via
register_or_update_scroll_node()after layout completes.
§Scroll Flow
Platform Event Handler
→ record_scroll_from_hit_test() → ScrollInputQueue
→ starts SCROLL_MOMENTUM_TIMER_ID if not running
Timer fires (every ~16ms):
→ queue.take_all() → physics integration
→ push_change(CallbackChange::ScrollTo)
ScrollTo processing (event_v2.rs):
→ scroll_manager.set_scroll_position()
→ virtual_view_manager.check_reinvoke() (transparent VirtualView support)
→ repaintThis module provides:
- Smooth scroll animations with easing
- Event source classification for scroll events
- Scrollbar geometry and hit-testing
- Virtual scroll bounds for
VirtualViewnodes
Structs§
- Animated
Scroll State - The complete scroll state for a single node (with animation support)
- Scroll
Animation - Details of an in-progress smooth scroll animation.
- Scroll
Input - A single scroll input event to be processed by the physics timer.
- Scroll
Input Queue - Thread-safe queue for scroll inputs, shared between event handlers and timer callbacks.
- Scroll
Manager - Manages all scroll state and animations for a window
- Scroll
Node Info - Read-only snapshot of a scroll node’s state, returned by
CallbackInfoqueries. - Scroll
Tick Result - Result of a scroll tick, indicating what actions are needed
- Scrollbar
Hit - Result of a scrollbar hit-test
- Scrollbar
State - Scrollbar geometry state (calculated per frame, used for hit-testing and rendering)
Enums§
- Scroll
Input Source - Classifies the source of a scroll input event.
- Scrollbar
Component - Which component of a scrollbar was hit during hit-testing