pub struct ScrollManager {
pub scroll_input_queue: ScrollInputQueue,
/* private fields */
}Expand description
Manages all scroll state and animations for a window
Fields§
§scroll_input_queue: ScrollInputQueueThread-safe queue for scroll inputs (shared with timer callbacks)
Implementations§
Source§impl ScrollManager
impl ScrollManager
Sourcepub fn debug_counts(&self) -> (usize, usize, usize)
pub fn debug_counts(&self) -> (usize, usize, usize)
Sizes of the internal maps — used by AZ_E2E_TEST to watch for
unbounded growth across resize/tick iterations.
Sourcepub fn has_pending_scroll_changes(&self) -> bool
pub fn has_pending_scroll_changes(&self) -> bool
Returns true if any scroll position changed since the last
clear_scroll_dirty() call.
Sourcepub fn clear_scroll_dirty(&mut self)
pub fn clear_scroll_dirty(&mut self)
Clear the dirty flag after the display list has been regenerated.
Sourcepub fn build_scroll_offset_map(
&self,
dom_id: DomId,
scroll_ids: &HashMap<usize, u64>,
) -> HashMap<u64, (f32, f32)>
pub fn build_scroll_offset_map( &self, dom_id: DomId, scroll_ids: &HashMap<usize, u64>, ) -> HashMap<u64, (f32, f32)>
Build a map from scroll_id (LocalScrollId) to current scroll offset.
Used by the CPU renderer to look up scroll positions at render time without embedding them in the display list.
scroll_ids maps layout-tree node index → scroll_id. We need to
convert our (DomId, NodeId) keys to scroll_ids.
Sourcepub fn record_scroll_input(&mut self, input: ScrollInput) -> bool
pub fn record_scroll_input(&mut self, input: ScrollInput) -> bool
Records a scroll input event into the shared queue.
This is the primary entry point for platform event handlers. Instead of directly modifying scroll positions, the input is queued for the scroll physics timer to process. This decouples input from physics simulation.
Returns true if the physics timer should be started (i.e., there are
now pending inputs and no timer is running yet).
Sourcepub fn record_scroll_from_hit_test(
&mut self,
delta_x: f32,
delta_y: f32,
source: ScrollInputSource,
hover_manager: &HoverManager,
input_point_id: &InputPointId,
now: Instant,
) -> Option<(DomId, NodeId, bool)>
pub fn record_scroll_from_hit_test( &mut self, delta_x: f32, delta_y: f32, source: ScrollInputSource, hover_manager: &HoverManager, input_point_id: &InputPointId, now: Instant, ) -> Option<(DomId, NodeId, bool)>
High-level entry point for platform event handlers: performs hit-test lookup and queues the input for the physics timer, instead of directly modifying offsets.
Returns Some((dom_id, node_id, should_start_timer)) if a scrollable node was found.
The caller should start SCROLL_MOMENTUM_TIMER_ID when should_start_timer is true.
Sourcepub fn get_input_queue(&self) -> ScrollInputQueue
pub fn get_input_queue(&self) -> ScrollInputQueue
Get a clone of the scroll input queue (for sharing with timer callbacks).
The timer callback stores this in its RefAny data and calls take_all()
each tick to consume pending inputs.
Sourcepub fn tick(&mut self, now: Instant) -> ScrollTickResult
pub fn tick(&mut self, now: Instant) -> ScrollTickResult
Advances scroll animations by one tick, returns repaint info
Sourcepub fn has_active_animations(&self) -> bool
pub fn has_active_animations(&self) -> bool
Returns true if any scroll node has an active easing animation.
Used by GPU render paths to skip rendering when the UI is completely static (no scroll animations, no layout changes).
Sourcepub fn find_scroll_parent(
&self,
dom_id: DomId,
node_id: NodeId,
node_hierarchy: &[NodeHierarchyItem],
) -> Option<NodeId>
pub fn find_scroll_parent( &self, dom_id: DomId, node_id: NodeId, node_hierarchy: &[NodeHierarchyItem], ) -> Option<NodeId>
Finds the closest scroll-container ancestor for a given node.
Walks up the node hierarchy to find a node that is registered as a
scrollable node in this ScrollManager. Returns None if no scrollable
ancestor is found.
Sourcepub fn set_scroll_position(
&mut self,
dom_id: DomId,
node_id: NodeId,
position: LogicalPosition,
now: Instant,
)
pub fn set_scroll_position( &mut self, dom_id: DomId, node_id: NodeId, position: LogicalPosition, now: Instant, )
Sets scroll position immediately (no animation), clamped to valid bounds.
Sourcepub fn set_scroll_position_unclamped(
&mut self,
dom_id: DomId,
node_id: NodeId,
position: LogicalPosition,
now: Instant,
)
pub fn set_scroll_position_unclamped( &mut self, dom_id: DomId, node_id: NodeId, position: LogicalPosition, now: Instant, )
Sets scroll position immediately without clamping.
Used by the scroll physics timer which does its own rubber-band clamping. Allows the offset to go outside [0, max_scroll] for overscroll/rubber-banding.
Sourcepub fn scroll_by(
&mut self,
dom_id: DomId,
node_id: NodeId,
delta: LogicalPosition,
duration: Duration,
easing: EasingFunction,
now: Instant,
)
pub fn scroll_by( &mut self, dom_id: DomId, node_id: NodeId, delta: LogicalPosition, duration: Duration, easing: EasingFunction, now: Instant, )
Scrolls by a delta amount with animation
Sourcepub fn scroll_to(
&mut self,
dom_id: DomId,
node_id: NodeId,
target: LogicalPosition,
duration: Duration,
easing: EasingFunction,
now: Instant,
)
pub fn scroll_to( &mut self, dom_id: DomId, node_id: NodeId, target: LogicalPosition, duration: Duration, easing: EasingFunction, now: Instant, )
Scrolls to an absolute position with animation
If duration is zero, the position is set immediately without animation.
Sourcepub fn update_node_bounds(
&mut self,
dom_id: DomId,
node_id: NodeId,
container_rect: LogicalRect,
content_rect: LogicalRect,
now: Instant,
)
pub fn update_node_bounds( &mut self, dom_id: DomId, node_id: NodeId, container_rect: LogicalRect, content_rect: LogicalRect, now: Instant, )
Updates the container and content bounds for a scrollable node
Sourcepub fn update_virtual_scroll_bounds(
&mut self,
dom_id: DomId,
node_id: NodeId,
virtual_scroll_size: LogicalSize,
virtual_scroll_offset: Option<LogicalPosition>,
)
pub fn update_virtual_scroll_bounds( &mut self, dom_id: DomId, node_id: NodeId, virtual_scroll_size: LogicalSize, virtual_scroll_offset: Option<LogicalPosition>, )
Updates virtual scroll bounds for a VirtualView node.
Called after VirtualView callback returns to propagate the virtual content size
to the ScrollManager. Clamp logic then uses virtual_scroll_size (when set)
instead of content_rect for max scroll bounds.
If no scroll state exists yet for this node (because register_or_update_scroll_node
hasn’t been called yet), this creates a default state so the virtual size is preserved.
Sourcepub fn get_current_offset(
&self,
dom_id: DomId,
node_id: NodeId,
) -> Option<LogicalPosition>
pub fn get_current_offset( &self, dom_id: DomId, node_id: NodeId, ) -> Option<LogicalPosition>
Returns the current scroll offset for a node
Sourcepub fn get_last_activity_time(
&self,
dom_id: DomId,
node_id: NodeId,
) -> Option<Instant>
pub fn get_last_activity_time( &self, dom_id: DomId, node_id: NodeId, ) -> Option<Instant>
Returns the timestamp of last scroll activity for a node
Sourcepub fn get_scroll_state(
&self,
dom_id: DomId,
node_id: NodeId,
) -> Option<&AnimatedScrollState>
pub fn get_scroll_state( &self, dom_id: DomId, node_id: NodeId, ) -> Option<&AnimatedScrollState>
Returns the internal scroll state for a node
Sourcepub fn get_scroll_node_info(
&self,
dom_id: DomId,
node_id: NodeId,
) -> Option<ScrollNodeInfo>
pub fn get_scroll_node_info( &self, dom_id: DomId, node_id: NodeId, ) -> Option<ScrollNodeInfo>
Returns a read-only snapshot of a scroll node’s state.
This is the preferred way for timer callbacks to query scroll state,
since they only have &CallbackInfo (read-only access).
When virtual_scroll_size is set (for VirtualView nodes), the max scroll
bounds are computed from the virtual size instead of content_rect.
Sourcepub fn get_scroll_states_for_dom(
&self,
dom_id: DomId,
) -> BTreeMap<NodeId, ScrollPosition>
pub fn get_scroll_states_for_dom( &self, dom_id: DomId, ) -> BTreeMap<NodeId, ScrollPosition>
Returns all scroll positions for nodes in a specific DOM
Sourcepub fn register_or_update_scroll_node(
&mut self,
dom_id: DomId,
node_id: NodeId,
container_rect: LogicalRect,
content_size: LogicalSize,
now: Instant,
scrollbar_thickness: f32,
visual_width_px: f32,
has_horizontal_scrollbar: bool,
has_vertical_scrollbar: bool,
)
pub fn register_or_update_scroll_node( &mut self, dom_id: DomId, node_id: NodeId, container_rect: LogicalRect, content_size: LogicalSize, now: Instant, scrollbar_thickness: f32, visual_width_px: f32, has_horizontal_scrollbar: bool, has_vertical_scrollbar: bool, )
Registers or updates a scrollable node with its container and content sizes. This should be called after layout for each node that has overflow:scroll or overflow:auto with overflowing content.
If the node already exists, updates container/content rects without changing scroll offset. If the node is new, initializes with zero scroll offset.
Sourcepub fn register_scroll_node(
&mut self,
dom_id: DomId,
node_id: NodeId,
) -> ExternalScrollId
pub fn register_scroll_node( &mut self, dom_id: DomId, node_id: NodeId, ) -> ExternalScrollId
Register a scroll node and get its ExternalScrollId for WebRender. If the node already has an ID, returns the existing one.
Sourcepub fn get_external_scroll_id(
&self,
dom_id: DomId,
node_id: NodeId,
) -> Option<ExternalScrollId>
pub fn get_external_scroll_id( &self, dom_id: DomId, node_id: NodeId, ) -> Option<ExternalScrollId>
Get the ExternalScrollId for a node (returns None if not registered)
Sourcepub fn iter_external_scroll_ids(
&self,
) -> impl Iterator<Item = ((DomId, NodeId), ExternalScrollId)> + '_
pub fn iter_external_scroll_ids( &self, ) -> impl Iterator<Item = ((DomId, NodeId), ExternalScrollId)> + '_
Iterate over all registered external scroll IDs
Sourcepub fn calculate_scrollbar_states(&mut self)
pub fn calculate_scrollbar_states(&mut self)
Calculate scrollbar states for all visible scrollbars.
This should be called once per frame after layout is complete.
Uses the shared compute_scrollbar_geometry() for consistent geometry.
Sourcepub fn get_scrollbar_state(
&self,
dom_id: DomId,
node_id: NodeId,
orientation: ScrollbarOrientation,
) -> Option<&ScrollbarState>
pub fn get_scrollbar_state( &self, dom_id: DomId, node_id: NodeId, orientation: ScrollbarOrientation, ) -> Option<&ScrollbarState>
Get scrollbar state for hit-testing
Sourcepub fn iter_scrollbar_states(
&self,
) -> impl Iterator<Item = ((DomId, NodeId, ScrollbarOrientation), &ScrollbarState)> + '_
pub fn iter_scrollbar_states( &self, ) -> impl Iterator<Item = ((DomId, NodeId, ScrollbarOrientation), &ScrollbarState)> + '_
Iterate over all visible scrollbar states
Sourcepub fn hit_test_scrollbar(
&self,
dom_id: DomId,
node_id: NodeId,
global_pos: LogicalPosition,
) -> Option<ScrollbarHit>
pub fn hit_test_scrollbar( &self, dom_id: DomId, node_id: NodeId, global_pos: LogicalPosition, ) -> Option<ScrollbarHit>
Hit-test scrollbars for a specific node at the given position. Returns Some if the position is inside a scrollbar for this node.
Sourcepub fn hit_test_scrollbars(
&self,
global_pos: LogicalPosition,
) -> Option<ScrollbarHit>
pub fn hit_test_scrollbars( &self, global_pos: LogicalPosition, ) -> Option<ScrollbarHit>
Perform hit-testing for all scrollbars at the given global position.
This iterates through all visible scrollbars in reverse z-order (top to bottom) and returns the first hit. Use this when you don’t know which node to check.
For better performance, use hit_test_scrollbar() when you already have
a hit-tested node from WebRender.
Source§impl ScrollManager
impl ScrollManager
Trait Implementations§
Source§impl Clone for ScrollManager
impl Clone for ScrollManager
Source§fn clone(&self) -> ScrollManager
fn clone(&self) -> ScrollManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ScrollManager
impl Debug for ScrollManager
Source§impl Default for ScrollManager
impl Default for ScrollManager
Source§fn default() -> ScrollManager
fn default() -> ScrollManager
Auto Trait Implementations§
impl Freeze for ScrollManager
impl RefUnwindSafe for ScrollManager
impl Send for ScrollManager
impl Sync for ScrollManager
impl Unpin for ScrollManager
impl UnsafeUnpin for ScrollManager
impl UnwindSafe for ScrollManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more