pub struct LayoutWindow {Show 46 fields
pub skip_gpu_sync: bool,
pub layout_cache: LayoutCache,
pub text_cache: TextShapingCache,
pub font_manager: FontManager<FontRef>,
pub image_cache: ImageCache,
pub layout_results: BTreeMap<DomId, DomLayoutResult>,
pub scroll_manager: ScrollManager,
pub gesture_drag_manager: GestureAndDragManager,
pub focus_manager: FocusManager,
pub text_edit_manager: TextEditManager,
pub file_drop_manager: FileDropManager,
pub clipboard_manager: ClipboardManager,
pub drag_drop_manager: DragDropManager,
pub hover_manager: HoverManager,
pub virtual_view_manager: VirtualViewManager,
pub gpu_state_manager: GpuStateManager,
pub a11y_manager: A11yManager,
pub permission_manager: PermissionManager,
pub geolocation_manager: GeolocationManager,
pub biometric_manager: BiometricManager,
pub keyring_manager: KeyringManager,
pub sensor_manager: SensorManager,
pub gamepad_manager: GamepadManager,
pub safe_area_insets: SafeAreaInsets,
pub timers: BTreeMap<TimerId, Timer>,
pub threads: BTreeMap<ThreadId, Thread>,
pub renderer_resources: RendererResources,
pub renderer_type: Option<RendererType>,
pub previous_window_state: Option<FullWindowState>,
pub current_window_state: FullWindowState,
pub document_id: DocumentId,
pub id_namespace: IdNamespace,
pub epoch: Epoch,
pub gl_texture_cache: GlTextureCache,
pub text_input_manager: TextInputManager,
pub undo_redo_manager: UndoRedoManager,
pub text_constraints_cache: TextConstraintsCache,
pub dirty_text_nodes: BTreeMap<(DomId, NodeId), DirtyTextNode>,
pub pending_virtual_view_updates: BTreeMap<DomId, FastBTreeSet<NodeId>>,
pub pending_lifecycle_events: Vec<SyntheticEvent>,
pub pending_unmount_invocations: Vec<(CoreCallbackData, SyntheticEvent)>,
pub system_style: Option<Arc<SystemStyle>>,
pub monitors: Arc<Mutex<MonitorVec>>,
pub input_interpreter: InputInterpreterCallback,
pub post_filter: PostFilterCallback,
pub routes: RouteVec,
/* private fields */
}Expand description
A window-level layout manager that encapsulates all layout state and caching.
This struct owns the layout and text caches, and provides methods dir_to:
- Perform initial layout
- Incrementally update layout on DOM changes
- Generate display lists for rendering
- Handle window resizes efficiently
- Manage multiple DOMs (for VirtualViews)
Fields§
§skip_gpu_sync: boolM12.7 web/headless: skip the GPU transform/opacity sync in
layout_dom_recursive. That sync only feeds the display list (which
the web backend skips), has no GPU, and GpuValueCache::synchronize
currently mis-lifts to wasm (out-of-bounds). Gated via this heap field
(a normal struct read — reliable in the lift, unlike the
SKIP_DISPLAY_LIST __bss static, whose store/load is inconsistent
in the lifted wasm). Default false → desktop is unaffected.
layout_cache: LayoutCacheLayout cache for solver3 (incremental layout tree) - for the root DOM
text_cache: TextShapingCacheText layout cache for text3 (shaped glyphs, line breaks, etc.)
font_manager: FontManager<FontRef>Font manager for loading and caching fonts
image_cache: ImageCacheCache to store decoded images
layout_results: BTreeMap<DomId, DomLayoutResult>Cached layout results for all DOMs (root + virtualized views)
scroll_manager: ScrollManagerScroll state manager for all nodes across all DOMs
gesture_drag_manager: GestureAndDragManagerGesture and drag manager for multi-frame interactions (moved from FullWindowState)
focus_manager: FocusManagerFocus manager for keyboard focus and tab navigation
text_edit_manager: TextEditManagerUnified text editing manager (cursor + selection + dirty flag)
file_drop_manager: FileDropManagerFile drop manager for cursor state and file drag-drop
clipboard_manager: ClipboardManagerClipboard manager for system clipboard integration
drag_drop_manager: DragDropManagerDrag-drop manager for node and file dragging operations
hover_manager: HoverManagerHover manager for tracking hit test history over multiple frames
virtual_view_manager: VirtualViewManagerVirtualView manager for all nodes across all DOMs
gpu_state_manager: GpuStateManagerGPU state manager for all nodes across all DOMs
a11y_manager: A11yManagerAccessibility manager for screen reader support
permission_manager: PermissionManagerPermission manager — cross-platform capability state for camera /
microphone / geolocation / biometric / sensors / photo-library /
notifications / etc. The platform backend drains
take_pending_permission_events once per frame and routes each
Subscribe / Release through dll::desktop::extra::permission::apply_diff_events.
See SUPER_PLAN_2.md §1.5 + research/08 for the architecture.
geolocation_manager: GeolocationManagerGeolocation manager — LocationFix storage + per-frame diff
against the NodeType::GeolocationProbes in the styled DOM.
The platform backend (dll::desktop::extra::geolocation)
drains diff events and starts / stops native
CLLocationManager / LocationManager / geoclue
subscriptions.
biometric_manager: BiometricManagerCross-platform biometric-auth state — latest result + sync
availability. The platform backend (dll::desktop::extra::biometric)
shows the OS prompt and parks results in the async channel that the
layout pass folds into this manager (request-driven; no probe node).
keyring_manager: KeyringManagerCross-platform keyring state — outcome of the last secret-store op.
The platform backend (dll::desktop::extra::keyring) reads/writes
the OS keyring (Keychain / KeyStore / libsecret / CredentialLocker)
and parks results in the async channel the layout pass folds in here.
sensor_manager: SensorManagerCross-platform motion-sensor state — latest accel / gyro / mag
reading. The platform backend (dll::desktop::extra::sensors)
subscribes to CoreMotion / Android SensorManager and parks
readings in the async channel the layout pass folds in here.
gamepad_manager: GamepadManagerCross-platform gamepad / controller state. The dll’s platform backend (gilrs / GCController / InputDevice) parks per-pad states in the async channel the layout pass folds in here.
safe_area_insets: SafeAreaInsetsSafe-area insets (notch / system-UI margins) for this window, in logical px. Set by the platform shell (macOS NSScreen.safeAreaInsets, iOS UIView.safeAreaInsets, Android WindowInsets); zero where none.
timers: BTreeMap<TimerId, Timer>Timers associated with this window
threads: BTreeMap<ThreadId, Thread>Threads running in the background for this window
renderer_resources: RendererResourcesCurrently loaded fonts and images present in this renderer (window)
renderer_type: Option<RendererType>Renderer type: Hardware-with-software-fallback, pure software or pure hardware renderer?
previous_window_state: Option<FullWindowState>Windows state of the window of (current frame - 1): initialized to None on startup
current_window_state: FullWindowStateWindow state of this current window (current frame): initialized to the state of WindowCreateOptions
document_id: DocumentIdA “document” in WebRender usually corresponds to one tab (i.e. in Azuls case, the whole window).
id_namespace: IdNamespaceID namespace under which every font / image for this window is registered
epoch: EpochThe “epoch” is a frame counter, to remove outdated images, fonts and OpenGL textures when they’re not in use anymore.
gl_texture_cache: GlTextureCacheCurrently GL textures inside the active CachedDisplayList
text_input_manager: TextInputManagerText input manager - centralizes all text editing logic
undo_redo_manager: UndoRedoManagerUndo/Redo manager for text editing operations
text_constraints_cache: TextConstraintsCacheCached text layout constraints for each node This allows us to re-layout text with the same constraints after edits
dirty_text_nodes: BTreeMap<(DomId, NodeId), DirtyTextNode>Tracks which nodes have been edited since last full layout. Key: (DomId, NodeId of IFC root) Value: The edited inline content that should be used for relayout
pending_virtual_view_updates: BTreeMap<DomId, FastBTreeSet<NodeId>>Pending VirtualView updates from callbacks (processed in next frame) Map of DomId -> Set of NodeIds that need re-rendering
pending_lifecycle_events: Vec<SyntheticEvent>Lifecycle events produced by DOM reconciliation, waiting to be dispatched.
regenerate_layout appends diff::reconcile_dom’s DiffResult.events here
(Mount / Update / Resize SyntheticEvents — note: NOT Unmount; see
pending_unmount_invocations). The shell’s event loop drains and
dispatches them via dispatch_events_propagated, which routes
EventFilter::Component(_) filters through matches_component_filter.
Drain-and-clear is the caller’s responsibility; nothing inside
LayoutWindow ages or discards these on its own.
pending_unmount_invocations: Vec<(CoreCallbackData, SyntheticEvent)>Resolved BeforeUnmount invocations queued for dispatch.
Unmount events target OLD NodeIds that disappear once the new layout
is committed to layout_results, so the shell cannot resolve them
via DOM lookup at dispatch time. regenerate_layout resolves the
callback against the OLD node data while it still has access, then
pushes a (CoreCallbackData, SyntheticEvent) pair here. The shell’s
dispatcher invokes each pair directly.
system_style: Option<Arc<SystemStyle>>System style (colors, fonts, metrics) for resolving system color keywords
Set via set_system_style() from the shell after window creation
monitors: Arc<Mutex<MonitorVec>>Shared monitor list — initialized once at app start, updated by the platform
layer on monitor topology changes. Arc
input_interpreter: InputInterpreterCallbackConfigurable input interpreter: maps raw events → SystemChange actions.
Default: default_input_interpreter (standard desktop keybindings).
Replace to implement vim, game controls, accessibility remaps, etc.
post_filter: PostFilterCallbackConfigurable post-callback filter.
Default: default_post_filter (scroll-into-view after cursor ops).
routes: RouteVecRegistered routes from AppConfig. Set once at window creation.
Used by CallbackChange::SwitchRoute to look up layout callbacks.
Implementations§
Source§impl LayoutWindow
impl LayoutWindow
Sourcepub fn new(fc_cache: FcFontCache) -> Result<Self, LayoutError>
pub fn new(fc_cache: FcFontCache) -> Result<Self, LayoutError>
Create a new layout window with empty caches.
For full initialization with WindowInternal compatibility, use new_full().
Sourcepub fn from_font_context(ctx: &FontContext) -> Result<Self, LayoutError>
pub fn from_font_context(ctx: &FontContext) -> Result<Self, LayoutError>
Create a new layout window that shares already-parsed fonts with
Create a LayoutWindow from a FontContext — shares all font data,
starts with fresh layout cache, text cache, and all other state.
Create from shared fc_cache + parsed_fonts Arcs.
Sourcepub fn layout_and_generate_display_list(
&mut self,
root_dom: StyledDom,
window_state: &FullWindowState,
renderer_resources: &RendererResources,
system_callbacks: &ExternalSystemCallbacks,
debug_messages: &mut Option<Vec<LayoutDebugMessage>>,
) -> Result<(), LayoutError>
pub fn layout_and_generate_display_list( &mut self, root_dom: StyledDom, window_state: &FullWindowState, renderer_resources: &RendererResources, system_callbacks: &ExternalSystemCallbacks, debug_messages: &mut Option<Vec<LayoutDebugMessage>>, ) -> Result<(), LayoutError>
Perform layout on a styled DOM and generate a display list.
This is the main entry point for layout. It handles:
- Incremental layout updates using the cached layout tree
- Text shaping and line breaking
- VirtualView callback invocation and recursive layout
- Display list generation for rendering
- Accessibility tree synchronization
§Arguments
styled_dom: The styled DOM to layoutwindow_state: Current window dimensions and staterenderer_resources: Resources for image sizing etc.debug_messages: Optional vector to collect debug/warning messages
§Returns
The display list ready for rendering, or an error if layout fails.
Sourcepub fn layout_dom_recursive(
&mut self,
styled_dom: StyledDom,
window_state: &FullWindowState,
renderer_resources: &RendererResources,
system_callbacks: &ExternalSystemCallbacks,
debug_messages: &mut Option<Vec<LayoutDebugMessage>>,
) -> Result<(), LayoutError>
pub fn layout_dom_recursive( &mut self, styled_dom: StyledDom, window_state: &FullWindowState, renderer_resources: &RendererResources, system_callbacks: &ExternalSystemCallbacks, debug_messages: &mut Option<Vec<LayoutDebugMessage>>, ) -> Result<(), LayoutError>
Run the real layout solver for a single StyledDom + viewport
(taffy block/flex/grid → layout_cache.calculated_positions).
Made pub for the web backend (AzStartup_solveLayoutReal),
which lifts this from ARM to wasm to position the headless
StyledDom. On web the display-list step inside layout_document
is hot-patched out at lift time (web emits TLV patches, not a
display list); positions are written to the cache before that
step, so the lifted path still produces correct geometry.
Sourcepub fn resize_window(
&mut self,
styled_dom: StyledDom,
new_size: LogicalSize,
renderer_resources: &RendererResources,
system_callbacks: &ExternalSystemCallbacks,
debug_messages: &mut Option<Vec<LayoutDebugMessage>>,
) -> Result<DisplayList, LayoutError>
pub fn resize_window( &mut self, styled_dom: StyledDom, new_size: LogicalSize, renderer_resources: &RendererResources, system_callbacks: &ExternalSystemCallbacks, debug_messages: &mut Option<Vec<LayoutDebugMessage>>, ) -> Result<DisplayList, LayoutError>
Handle a window resize by updating the cached layout.
This method leverages solver3’s incremental layout system to efficiently relayout only the affected parts of the tree when the window size changes.
Returns the new display list after the resize.
Sourcepub fn clear_caches(&mut self)
pub fn clear_caches(&mut self)
Clear all caches (useful for testing or when switching documents).
Sourcepub fn set_scroll_position(
&mut self,
dom_id: DomId,
node_id: NodeId,
scroll: ScrollPosition,
)
pub fn set_scroll_position( &mut self, dom_id: DomId, node_id: NodeId, scroll: ScrollPosition, )
Set scroll position for a node
Sourcepub fn get_scroll_position(
&self,
dom_id: DomId,
node_id: NodeId,
) -> Option<ScrollPosition>
pub fn get_scroll_position( &self, dom_id: DomId, node_id: NodeId, ) -> Option<ScrollPosition>
Get scroll position for a node
Sourcepub fn set_selection(&mut self, _dom_id: DomId, _selection: SelectionState)
pub fn set_selection(&mut self, _dom_id: DomId, _selection: SelectionState)
Set selection state for a DOM (no-op: selection_manager removed, multi_cursor handles this)
Sourcepub fn get_selection(&self, _dom_id: DomId) -> Option<&SelectionState>
pub fn get_selection(&self, _dom_id: DomId) -> Option<&SelectionState>
Get selection state for a DOM (always None: selection_manager removed)
Sourcepub fn invoke_virtual_view_callback(
&mut self,
parent_dom_id: DomId,
node_id: NodeId,
bounds: LogicalRect,
window_state: &FullWindowState,
renderer_resources: &RendererResources,
system_callbacks: &ExternalSystemCallbacks,
debug_messages: &mut Option<Vec<LayoutDebugMessage>>,
) -> Option<DomId>
pub fn invoke_virtual_view_callback( &mut self, parent_dom_id: DomId, node_id: NodeId, bounds: LogicalRect, window_state: &FullWindowState, renderer_resources: &RendererResources, system_callbacks: &ExternalSystemCallbacks, debug_messages: &mut Option<Vec<LayoutDebugMessage>>, ) -> Option<DomId>
Invoke a VirtualView callback and perform layout on the returned DOM.
This is the entry point that looks up the necessary VirtualViewNode data before
delegating to the core implementation logic.
Invoke a VirtualView callback for a node. Returns the child DomId if the
callback was invoked and the child DOM was laid out.
This calls the VirtualView’s own RefAny callback (NOT the main layout() callback), swaps the child StyledDom, and re-layouts only the VirtualView sub-tree.
Sourcepub fn get_node_size(&self, node_id: DomNodeId) -> Option<LogicalSize>
pub fn get_node_size(&self, node_id: DomNodeId) -> Option<LogicalSize>
Get the size of a laid-out node
Sourcepub fn get_node_position(&self, node_id: DomNodeId) -> Option<LogicalPosition>
pub fn get_node_position(&self, node_id: DomNodeId) -> Option<LogicalPosition>
Get the position of a laid-out node
Sourcepub fn get_node_hit_test_bounds(
&self,
node_id: DomNodeId,
) -> Option<LogicalRect>
pub fn get_node_hit_test_bounds( &self, node_id: DomNodeId, ) -> Option<LogicalRect>
Get the hit test bounds of a node from the display list
This is more reliable than get_node_position + get_node_size because the display list always contains the correct final rendered positions, including for nodes that may not have entries in calculated_positions.
Sourcepub fn get_parent(&self, node_id: DomNodeId) -> Option<DomNodeId>
pub fn get_parent(&self, node_id: DomNodeId) -> Option<DomNodeId>
Get the parent of a node
Sourcepub fn get_first_child(&self, node_id: DomNodeId) -> Option<DomNodeId>
pub fn get_first_child(&self, node_id: DomNodeId) -> Option<DomNodeId>
Get the first child of a node
Sourcepub fn get_next_sibling(&self, node_id: DomNodeId) -> Option<DomNodeId>
pub fn get_next_sibling(&self, node_id: DomNodeId) -> Option<DomNodeId>
Get the next sibling of a node
Sourcepub fn get_previous_sibling(&self, node_id: DomNodeId) -> Option<DomNodeId>
pub fn get_previous_sibling(&self, node_id: DomNodeId) -> Option<DomNodeId>
Get the previous sibling of a node
Sourcepub fn get_last_child(&self, node_id: DomNodeId) -> Option<DomNodeId>
pub fn get_last_child(&self, node_id: DomNodeId) -> Option<DomNodeId>
Get the last child of a node
Sourcepub fn scan_used_fonts(&self) -> BTreeSet<FontKey>
pub fn scan_used_fonts(&self) -> BTreeSet<FontKey>
Scan all fonts referenced in the current display lists (for resource GC).
Iterates every Text and TextLayout item in each DOM’s display list
and collects the deterministic FontKey derived from the font hash.
Callers can diff the result against renderer_resources.currently_registered_fonts
to find fonts that are no longer used.
Sourcepub fn scan_used_images(
&self,
_css_image_cache: &ImageCache,
) -> BTreeSet<ImageRefHash>
pub fn scan_used_images( &self, _css_image_cache: &ImageCache, ) -> BTreeSet<ImageRefHash>
Scan all images referenced in the current display lists (for resource GC).
Iterates every Image and PushImageMaskClip item and collects
their ImageRefHash. Callers can diff the result against the
currently loaded images to find unused ones.
Sourcepub fn scroll_node_into_view(
&mut self,
node_id: DomNodeId,
options: ScrollIntoViewOptions,
now: Instant,
) -> Vec<ScrollAdjustment>
pub fn scroll_node_into_view( &mut self, node_id: DomNodeId, options: ScrollIntoViewOptions, now: Instant, ) -> Vec<ScrollAdjustment>
Scroll a DOM node into view
This is the main API for scrolling elements into view. It handles:
- Finding scroll ancestors
- Calculating scroll deltas
- Applying scroll animations
§Arguments
node_id- The DOM node to scroll into viewoptions- Scroll alignment and animation optionsnow- Current timestamp for animations
§Returns
A vector of scroll adjustments that were applied
Sourcepub fn scroll_cursor_into_view(
&mut self,
cursor_rect: LogicalRect,
node_id: DomNodeId,
options: ScrollIntoViewOptions,
now: Instant,
) -> Vec<ScrollAdjustment>
pub fn scroll_cursor_into_view( &mut self, cursor_rect: LogicalRect, node_id: DomNodeId, options: ScrollIntoViewOptions, now: Instant, ) -> Vec<ScrollAdjustment>
Scroll a text cursor into view
Used when the cursor moves within a contenteditable element. The cursor rect should be in node-local coordinates.
Sourcepub fn remove_timer(&mut self, timer_id: &TimerId) -> Option<Timer>
pub fn remove_timer(&mut self, timer_id: &TimerId) -> Option<Timer>
Remove a timer from this window
Sourcepub fn get_timer_mut(&mut self, timer_id: &TimerId) -> Option<&mut Timer>
pub fn get_timer_mut(&mut self, timer_id: &TimerId) -> Option<&mut Timer>
Get a mutable reference to a timer
Sourcepub fn get_timer_ids(&self) -> TimerIdVec
pub fn get_timer_ids(&self) -> TimerIdVec
Get all timer IDs
Sourcepub fn tick_timers(&mut self, current_time: Instant) -> Vec<TimerId>
pub fn tick_timers(&mut self, current_time: Instant) -> Vec<TimerId>
Tick all timers (called once per frame) Returns a list of timer IDs that are ready to run
Sourcepub fn time_until_next_timer_ms(
&self,
get_system_time_fn: &GetSystemTimeCallback,
) -> Option<u64>
pub fn time_until_next_timer_ms( &self, get_system_time_fn: &GetSystemTimeCallback, ) -> Option<u64>
Calculate milliseconds until the next timer needs to fire.
Returns None if there are no timers, meaning the caller can block indefinitely.
Returns Some(0) if a timer is already overdue.
Otherwise returns the minimum time in milliseconds until any timer fires.
This is used by Linux (X11/Wayland) to set an efficient poll/select timeout instead of always polling every 16ms.
Sourcepub fn add_thread(&mut self, thread_id: ThreadId, thread: Thread)
pub fn add_thread(&mut self, thread_id: ThreadId, thread: Thread)
Add a thread to this window
Sourcepub fn remove_thread(&mut self, thread_id: &ThreadId) -> Option<Thread>
pub fn remove_thread(&mut self, thread_id: &ThreadId) -> Option<Thread>
Remove a thread from this window
Sourcepub fn get_thread(&self, thread_id: &ThreadId) -> Option<&Thread>
pub fn get_thread(&self, thread_id: &ThreadId) -> Option<&Thread>
Get a reference to a thread
Sourcepub fn get_thread_mut(&mut self, thread_id: &ThreadId) -> Option<&mut Thread>
pub fn get_thread_mut(&mut self, thread_id: &ThreadId) -> Option<&mut Thread>
Get a mutable reference to a thread
Sourcepub fn get_thread_ids(&self) -> ThreadIdVec
pub fn get_thread_ids(&self) -> ThreadIdVec
Get all thread IDs
Sourcepub fn create_cursor_blink_timer(
&self,
_window_state: &FullWindowState,
) -> Timer
pub fn create_cursor_blink_timer( &self, _window_state: &FullWindowState, ) -> Timer
Create the cursor blink timer
This timer toggles cursor visibility at ~530ms intervals. It checks if enough time has passed since the last user input before blinking, to avoid blinking while the user is actively typing.
Sourcepub fn create_tooltip_delay_timer(&self, hover_time_ms: u32) -> Timer
pub fn create_tooltip_delay_timer(&self, hover_time_ms: u32) -> Timer
Create a one-shot tooltip-delay timer.
Fires exactly once after hover_time_ms elapsed. On expiry the callback
looks up the currently-hovered node’s title / alt / aria-label
attribute and emits a ShowTooltip CallbackChange, then terminates.
Sourcepub fn handle_hover_change_for_tooltip(
&self,
hover_time_ms: u32,
) -> TooltipTimerAction
pub fn handle_hover_change_for_tooltip( &self, hover_time_ms: u32, ) -> TooltipTimerAction
Determine what tooltip-timer action the shell should take given a hover transition.
The platform event loop calls this once per event-dispatch cycle (after
hit-testing has updated hover_manager). It compares the current and
previous deepest hovered nodes and returns:
Startif the user just hovered onto a node that has a tooltip source (title/alt/aria-label) — the shell should (re)startTOOLTIP_DELAY_TIMER_IDwith the returned Timer.Stopif the hover moved off a tooltip-bearing node (or left the window) — the shell should stopTOOLTIP_DELAY_TIMER_IDand hide any currently-visible tooltip.NoChangeif the hovered node hasn’t changed between frames.
Sourcepub fn handle_focus_change_for_cursor_blink(
&mut self,
new_focus: Option<DomNodeId>,
current_window_state: &FullWindowState,
) -> CursorBlinkTimerAction
pub fn handle_focus_change_for_cursor_blink( &mut self, new_focus: Option<DomNodeId>, current_window_state: &FullWindowState, ) -> CursorBlinkTimerAction
Handle focus change for cursor blink timer management (W3C “flag and defer” pattern)
This method implements the W3C focus/selection model:
- Focus change is handled immediately (timer start/stop)
- Cursor initialization is DEFERRED until after layout (via flag)
The cursor is NOT initialized here because text layout may not be available
during focus event handling. Instead, we set a flag that is consumed by
finalize_pending_focus_changes() after the layout pass.
§Parameters
new_focus- The newly focused node (None if focus is being cleared)current_window_state- Current window state for timer creation
§Returns
A CursorBlinkTimerAction indicating what timer action the platform
layer should take.
Sourcepub fn finalize_pending_focus_changes(&mut self) -> bool
pub fn finalize_pending_focus_changes(&mut self) -> bool
Finalize pending focus changes after layout pass (W3C “flag and defer” pattern)
This method should be called AFTER the layout pass completes. It checks if there’s a pending contenteditable focus and initializes the cursor now that text layout information is available.
§W3C Conformance
In the W3C model:
- Focus event fires during event handling (layout may not be ready)
- Selection/cursor placement happens after layout is computed
- The cursor is drawn at the position specified by the Selection
This function implements step 2+3 by:
- Checking the
cursor_needs_initializationflag - Getting the (now available) text layout
- Initializing the cursor at the correct position
§Returns
true if cursor was initialized, false if no pending focus or initialization failed.
Sourcepub fn get_inline_layout_for_node(
&self,
dom_id: DomId,
node_id: NodeId,
) -> Option<&Arc<UnifiedLayout>>
pub fn get_inline_layout_for_node( &self, dom_id: DomId, node_id: NodeId, ) -> Option<&Arc<UnifiedLayout>>
Helper: Get inline layout for a node
For text nodes that participate in an IFC, the inline layout is stored on the IFC root node (the block container), not on the text node itself. This method handles both cases:
- The node has its own
inline_layout_result(IFC root) - The node has
ifc_membershippointing to the IFC root
This is a thin wrapper around LayoutTree::get_inline_layout_for_node.
Sourcepub fn apply_selection_op(
&mut self,
target: DomNodeId,
op: &SelectionOp,
) -> bool
pub fn apply_selection_op( &mut self, target: DomNodeId, op: &SelectionOp, ) -> bool
Apply a unified selection operation (navigation, extend, or delete).
Single entry point that replaces the separate ArrowKeyNavigation and DeleteTextSelection handlers, as well as handle_cursor_movement and handle_multi_cursor_movement.
Sourcepub fn move_cursor_in_node<F>(
&self,
dom_id: DomId,
node_id: NodeId,
movement_fn: F,
) -> Option<TextCursor>
pub fn move_cursor_in_node<F>( &self, dom_id: DomId, node_id: NodeId, movement_fn: F, ) -> Option<TextCursor>
Helper: Move cursor using a movement function and return the new cursor if it changed
Sourcepub fn handle_cursor_movement(
&mut self,
dom_id: DomId,
node_id: NodeId,
new_cursor: TextCursor,
extend_selection: bool,
)
pub fn handle_cursor_movement( &mut self, dom_id: DomId, node_id: NodeId, new_cursor: TextCursor, extend_selection: bool, )
Helper: Handle cursor movement with optional selection extension.
When multi-cursor is active, new_cursor is used as the movement applied
to the primary cursor; all other cursors are moved by the same move_fn
via MultiCursorState::move_all_cursors. For single-cursor mode, falls
back to the legacy CursorManager + SelectionManager path.
Sourcepub fn handle_multi_cursor_movement(
&mut self,
dom_id: DomId,
node_id: NodeId,
extend_selection: bool,
move_fn: impl Fn(&TextCursor) -> TextCursor,
)
pub fn handle_multi_cursor_movement( &mut self, dom_id: DomId, node_id: NodeId, extend_selection: bool, move_fn: impl Fn(&TextCursor) -> TextCursor, )
Move all cursors in a MultiCursorState using a movement function. This is the multi-cursor version of handle_cursor_movement.
Sourcepub fn get_gpu_cache(&self, dom_id: &DomId) -> Option<&GpuValueCache>
pub fn get_gpu_cache(&self, dom_id: &DomId) -> Option<&GpuValueCache>
Get the GPU value cache for a specific DOM
Sourcepub fn get_gpu_cache_mut(
&mut self,
dom_id: &DomId,
) -> Option<&mut GpuValueCache>
pub fn get_gpu_cache_mut( &mut self, dom_id: &DomId, ) -> Option<&mut GpuValueCache>
Get a mutable reference to the GPU value cache for a specific DOM
Sourcepub fn get_or_create_gpu_cache(&mut self, dom_id: DomId) -> &mut GpuValueCache
pub fn get_or_create_gpu_cache(&mut self, dom_id: DomId) -> &mut GpuValueCache
Get or create a GPU value cache for a specific DOM
Sourcepub fn get_layout_result(&self, dom_id: &DomId) -> Option<&DomLayoutResult>
pub fn get_layout_result(&self, dom_id: &DomId) -> Option<&DomLayoutResult>
Get a layout result for a specific DOM
Sourcepub fn get_layout_result_mut(
&mut self,
dom_id: &DomId,
) -> Option<&mut DomLayoutResult>
pub fn get_layout_result_mut( &mut self, dom_id: &DomId, ) -> Option<&mut DomLayoutResult>
Get a mutable layout result for a specific DOM
Sourcepub fn get_dom_ids(&self) -> DomIdVec
pub fn get_dom_ids(&self) -> DomIdVec
Get all DOM IDs that have layout results
Sourcepub fn compute_cursor_type_hit_test(
&self,
hit_test: &FullHitTest,
) -> CursorTypeHitTest
pub fn compute_cursor_type_hit_test( &self, hit_test: &FullHitTest, ) -> CursorTypeHitTest
Compute the cursor type hit-test from a full hit-test
This determines which mouse cursor to display based on the CSS cursor properties of the hovered nodes.
Sourcepub fn synchronize_scrollbar_opacity(
gpu_state_manager: &mut GpuStateManager,
scroll_manager: &ScrollManager,
dom_id: DomId,
layout_tree: &LayoutTree,
system_callbacks: &ExternalSystemCallbacks,
fade_delay: Duration,
fade_duration: Duration,
) -> Vec<GpuScrollbarOpacityEvent>
pub fn synchronize_scrollbar_opacity( gpu_state_manager: &mut GpuStateManager, scroll_manager: &ScrollManager, dom_id: DomId, layout_tree: &LayoutTree, system_callbacks: &ExternalSystemCallbacks, fade_delay: Duration, fade_duration: Duration, ) -> Vec<GpuScrollbarOpacityEvent>
Synchronize scrollbar opacity values with the GPU value cache.
Static method that takes individual components instead of &mut self to avoid borrow conflicts.
Sourcepub fn compute_scroll_ids(
layout_tree: &LayoutTree,
styled_dom: &StyledDom,
) -> (HashMap<usize, u64>, HashMap<u64, NodeId>)
pub fn compute_scroll_ids( layout_tree: &LayoutTree, styled_dom: &StyledDom, ) -> (HashMap<usize, u64>, HashMap<u64, NodeId>)
Compute stable scroll IDs for all scrollable nodes in a layout tree
This should be called after layout but before display list generation. It creates stable IDs based on node_data_hash that persist across frames.
Returns:
- scroll_ids: Map from layout node index -> external scroll ID
- scroll_id_to_node_id: Map from scroll ID -> DOM NodeId (for hit testing)
Sourcepub fn get_node_layout_rect(&self, node_id: DomNodeId) -> Option<LogicalRect>
pub fn get_node_layout_rect(&self, node_id: DomNodeId) -> Option<LogicalRect>
Get the layout rectangle for a specific DOM node in logical coordinates
This is useful in callbacks to get the position and size of the hit node for positioning menus, tooltips, or other overlays.
Returns None if the node is not currently laid out (e.g., display:none)
Sourcepub fn update_a11y_tree(&mut self)
pub fn update_a11y_tree(&mut self)
Get the cursor rect for the currently focused text input node in ABSOLUTE coordinates.
This returns the cursor position in absolute window coordinates (not accounting for scroll offsets). This is used for scroll-into-view calculations where you need to compare the cursor position with the scrollable container’s bounds.
Returns None if:
- No node is focused
- Focused node has no text cursor
- Focused node has no layout
- Text cache cannot find cursor position
For IME positioning (viewport-relative coordinates), use
get_focused_cursor_rect_viewport().
Rebuild the accessibility tree from the current layout results, focus,
and cursor state. Called after full layout AND after display-list-only
regeneration so that screen readers see up-to-date bounds, cursor, and
focus information.
Sourcepub fn update_a11y_tree_incremental(&mut self)
pub fn update_a11y_tree_incremental(&mut self)
Incremental a11y update: only push the focused contenteditable node’s updated value + cursor/selection. Falls back to full rebuild if the tree hasn’t been initialized yet or there’s no active editing.
pub fn get_focused_cursor_rect(&self) -> Option<LogicalRect>
Sourcepub fn calculate_selection_bounding_rect(&self) -> Option<LogicalRect>
pub fn calculate_selection_bounding_rect(&self) -> Option<LogicalRect>
Compute the bounding rect of all selection ranges in the focused node. Returns the union of all selection rects in absolute coordinates.
Sourcepub fn select_next_occurrence(&mut self) -> bool
pub fn select_next_occurrence(&mut self) -> bool
Ctrl+D: select the next occurrence of the current selection/word.
If the primary selection is a cursor (no range), first expand it to a word. Then search forward in the text for the next occurrence and add it as a new multi-cursor selection.
Returns true if a new selection was added.
Sourcepub fn get_focused_cursor_rect_viewport(&self) -> Option<LogicalRect>
pub fn get_focused_cursor_rect_viewport(&self) -> Option<LogicalRect>
Get the cursor rect for the currently focused text input node in VIEWPORT coordinates.
This returns the cursor position accounting for:
- Scroll offsets from all scrollable ancestors
- GPU transforms (CSS transforms, animations) from all transformed ancestors
The returned position is viewport-relative (what the user actually sees on screen). This is used for IME window positioning, where the IME popup needs to appear at the visible cursor location, not the absolute layout position.
Returns None if:
- No node is focused
- Focused node has no text cursor
- Focused node has no layout
- Text cache cannot find cursor position
For scroll-into-view calculations (absolute coordinates), use get_focused_cursor_rect().
Sourcepub fn find_scrollable_ancestor(&self, node_id: DomNodeId) -> Option<DomNodeId>
pub fn find_scrollable_ancestor(&self, node_id: DomNodeId) -> Option<DomNodeId>
Find the nearest scrollable ancestor for a given node Returns (DomId, NodeId) of the scrollable container, or None if no scrollable ancestor exists
Sourcepub fn scroll_selection_into_view(
&mut self,
scroll_type: SelectionScrollType,
scroll_mode: ScrollMode,
) -> bool
pub fn scroll_selection_into_view( &mut self, scroll_type: SelectionScrollType, scroll_mode: ScrollMode, ) -> bool
Scroll selection or cursor into view with distance-based acceleration.
Unified Scroll System: This method handles both cursor (0-size selection) and full selection scrolling with a single implementation. For drag-to-scroll, scroll speed increases with distance from container edge.
§Algorithm
- Get bounds to scroll (cursor rect, selection rect, or mouse position)
- Find scrollable ancestor container
- Calculate distance from bounds to container edges
- Compute scroll delta (instant with padding, or accelerated with zones)
- Apply scroll with appropriate animation
§Distance-Based Acceleration (ScrollMode::Accelerated)
Distance from edge: Scroll speed per frame:
0-20px Dead zone (no scroll)
20-50px Slow (2px/frame)
50-100px Medium (4px/frame)
100-200px Fast (8px/frame)
200+px Very fast (16px/frame)§Returns
true if scrolling was applied, false if already visible
Source§impl LayoutWindow
impl LayoutWindow
Sourcepub fn run_single_timer(
&mut self,
timer_id: usize,
frame_start: Instant,
current_window_handle: &RawWindowHandle,
gl_context: &OptionGlContextPtr,
system_style: Arc<SystemStyle>,
system_callbacks: &ExternalSystemCallbacks,
previous_window_state: &Option<FullWindowState>,
current_window_state: &FullWindowState,
renderer_resources: &RendererResources,
) -> (Vec<CallbackChange>, Update)
pub fn run_single_timer( &mut self, timer_id: usize, frame_start: Instant, current_window_handle: &RawWindowHandle, gl_context: &OptionGlContextPtr, system_style: Arc<SystemStyle>, system_callbacks: &ExternalSystemCallbacks, previous_window_state: &Option<FullWindowState>, current_window_state: &FullWindowState, renderer_resources: &RendererResources, ) -> (Vec<CallbackChange>, Update)
Runs a single timer, similar to CallbacksOfHitTest.call()
NOTE: The timer has to be selected first by the calling code and verified that it is ready to run Run a single timer callback and return raw changes + update.
If the timer should terminate, a RemoveTimer change is appended.
Sourcepub fn run_all_threads(
&mut self,
data: &mut RefAny,
current_window_handle: &RawWindowHandle,
gl_context: &OptionGlContextPtr,
system_style: Arc<SystemStyle>,
system_callbacks: &ExternalSystemCallbacks,
previous_window_state: &Option<FullWindowState>,
current_window_state: &FullWindowState,
renderer_resources: &RendererResources,
) -> (Vec<CallbackChange>, Update)
pub fn run_all_threads( &mut self, data: &mut RefAny, current_window_handle: &RawWindowHandle, gl_context: &OptionGlContextPtr, system_style: Arc<SystemStyle>, system_callbacks: &ExternalSystemCallbacks, previous_window_state: &Option<FullWindowState>, current_window_state: &FullWindowState, renderer_resources: &RendererResources, ) -> (Vec<CallbackChange>, Update)
Run all thread writeback callbacks and return raw changes + update.
Sourcepub fn invoke_single_callback(
&mut self,
callback: &mut Callback,
data: &mut RefAny,
current_window_handle: &RawWindowHandle,
gl_context: &OptionGlContextPtr,
system_style: Arc<SystemStyle>,
system_callbacks: &ExternalSystemCallbacks,
previous_window_state: &Option<FullWindowState>,
current_window_state: &FullWindowState,
renderer_resources: &RendererResources,
) -> (Vec<CallbackChange>, Update)
pub fn invoke_single_callback( &mut self, callback: &mut Callback, data: &mut RefAny, current_window_handle: &RawWindowHandle, gl_context: &OptionGlContextPtr, system_style: Arc<SystemStyle>, system_callbacks: &ExternalSystemCallbacks, previous_window_state: &Option<FullWindowState>, current_window_state: &FullWindowState, renderer_resources: &RendererResources, ) -> (Vec<CallbackChange>, Update)
Invokes a single callback and returns the raw changes + update signal.
Caller is responsible for processing each CallbackChange via
PlatformWindowV2::apply_user_change().
Sourcepub fn set_system_style(&mut self, system_style: Arc<SystemStyle>)
pub fn set_system_style(&mut self, system_style: Arc<SystemStyle>)
Set the system style for resolving system color keywords in CSS.
This should be called during window initialization and whenever the system theme changes (dark/light mode switch, accent color change).
The system style is used to resolve CSS system colors like selection-background,
selection-text, accent, etc. If not set, hard-coded fallback values are used.
Source§impl LayoutWindow
impl LayoutWindow
Sourcepub fn find_next_text_node(
&self,
dom_id: &DomId,
current_node: NodeId,
) -> Option<(DomId, NodeId)>
pub fn find_next_text_node( &self, dom_id: &DomId, current_node: NodeId, ) -> Option<(DomId, NodeId)>
Finds the next text node in the DOM tree after the given node.
This function performs a depth-first traversal to find the next node that contains text content and is selectable (user-select != none).
§Arguments
dom_id- The ID of the DOM containing the current nodecurrent_node- The current node ID to start searching from
§Returns
Some((DomId, NodeId))- The next text node if foundNone- If no next text node exists
Sourcepub fn find_prev_text_node(
&self,
dom_id: &DomId,
current_node: NodeId,
) -> Option<(DomId, NodeId)>
pub fn find_prev_text_node( &self, dom_id: &DomId, current_node: NodeId, ) -> Option<(DomId, NodeId)>
Finds the previous text node in the DOM tree before the given node.
This function performs a reverse depth-first traversal to find the previous node that contains text content and is selectable.
§Arguments
dom_id- The ID of the DOM containing the current nodecurrent_node- The current node ID to start searching from
§Returns
Some((DomId, NodeId))- The previous text node if foundNone- If no previous text node exists
Sourcepub fn process_accessibility_action(
&mut self,
dom_id: DomId,
node_id: NodeId,
action: AccessibilityAction,
now: Instant,
) -> BTreeMap<DomNodeId, (Vec<EventFilter>, bool)>
pub fn process_accessibility_action( &mut self, dom_id: DomId, node_id: NodeId, action: AccessibilityAction, now: Instant, ) -> BTreeMap<DomNodeId, (Vec<EventFilter>, bool)>
Process an accessibility action from an assistive technology.
This method dispatches actions to the appropriate managers (scroll, focus, etc.) and returns information about which nodes were affected and how.
§Arguments
dom_id- The DOM containing the target nodenode_id- The target node for the actionaction- The accessibility action to performnow- Current timestamp for animations
§Returns
A BTreeMap of affected nodes with:
- Key: DomNodeId that was affected
- Value: (Vec
synthetic events to dispatch, bool indicating if node needs re-layout)
Empty map = action was not applicable or nothing changed
Sourcepub fn record_text_input(
&mut self,
text_input: &str,
) -> BTreeMap<DomNodeId, (Vec<EventFilter>, bool)>
pub fn record_text_input( &mut self, text_input: &str, ) -> BTreeMap<DomNodeId, (Vec<EventFilter>, bool)>
Process text input from keyboard using cursor/selection/focus managers.
This is the new unified text input handling. The framework manages text editing internally using managers, then fires callbacks (On::TextInput, On::Changed) after the internal state is already updated.
§Workflow
- Check if focus manager has a focused contenteditable node
- Get cursor/selection from managers
- Call edit_text_node to apply the edit and update cache
- Collect affected nodes that need dirty marking
- Return map for re-layout triggering
§Parameters
text_input- The text that was typed (can be multiple chars for IME)
§Returns
BTreeMap of affected nodes with:
- Key: DomNodeId that was affected
- Value: (Vec
synthetic events, bool needs_relayout) - Empty map = no focused contenteditable node
Sourcepub fn apply_text_changeset(&mut self) -> TextChangesetResult
pub fn apply_text_changeset(&mut self) -> TextChangesetResult
Apply the recorded text changeset to the text cache
This is called AFTER user callbacks, if preventDefault was not set. This is where we actually compute the new text and update the cache.
Also updates the cursor position to reflect the edit.
Returns the nodes that need to be marked dirty for re-layout, and whether a full re-layout is needed (text size changed).
Sourcepub fn process_text_input(
&mut self,
text_input: &str,
) -> BTreeMap<DomNodeId, (Vec<EventFilter>, bool)>
pub fn process_text_input( &mut self, text_input: &str, ) -> BTreeMap<DomNodeId, (Vec<EventFilter>, bool)>
Legacy name for backward compatibility
Sourcepub fn get_last_text_changeset(&self) -> Option<&PendingTextEdit>
pub fn get_last_text_changeset(&self) -> Option<&PendingTextEdit>
Get the last text changeset (what was changed in the last text input)
Sourcepub fn get_text_before_textinput(
&self,
dom_id: DomId,
node_id: NodeId,
) -> Vec<InlineContent>
pub fn get_text_before_textinput( &self, dom_id: DomId, node_id: NodeId, ) -> Vec<InlineContent>
Get the current inline content (text before text input is applied)
This is a query function that retrieves the current text state from the node. Returns InlineContent vector if the node has text.
§Implementation Note
This function FIRST checks dirty_text_nodes for optimistic state (edits not yet
committed to StyledDom), then falls back to the StyledDom. This is critical for
correct text input handling - without this, each keystroke would read stale state.
Sourcepub fn extract_text_from_inline_content(
&self,
content: &[InlineContent],
) -> String
pub fn extract_text_from_inline_content( &self, content: &[InlineContent], ) -> String
Extract plain text string from inline content
This is a helper for building the changeset’s resulting_text field.
Sourcepub fn update_text_cache_after_edit(
&mut self,
dom_id: DomId,
node_id: NodeId,
new_inline_content: Vec<InlineContent>,
)
pub fn update_text_cache_after_edit( &mut self, dom_id: DomId, node_id: NodeId, new_inline_content: Vec<InlineContent>, )
Update the text cache after a text edit
This is the ONLY place where we mutate the text cache. All other functions are pure queries or transformations.
This function:
- Stores the new content in
dirty_text_nodesfor tracking - Re-runs the text3 layout pipeline (create_logical_items -> reorder -> shape -> fragment)
- Updates the inline_layout_result on the IFC root node in the layout tree
Sourcepub fn apply_preedit_to_text_cache(&mut self, dom_id: DomId, node_id: NodeId)
pub fn apply_preedit_to_text_cache(&mut self, dom_id: DomId, node_id: NodeId)
Re-apply a dirty text node’s content to the layout cache after a full DOM rebuild.
Called by regenerate_layout() after layout_and_generate_display_list(). The layout just ran on the stale DOM text, so we re-shape the edited text from dirty_text_nodes and update the inline layout result + display list. Inject preedit text into the text cache and regenerate the display list.
Called from the platform IME handler (setMarkedText). Gets the current text content, splices the preedit string at the cursor position, then re-shapes and regenerates the display list so the preedit glyphs appear inline with an underline.
pub fn reapply_dirty_text_node(&mut self, dom_id: DomId, node_id: NodeId)
Sourcepub fn regenerate_display_list_for_dom(&mut self, dom_id: DomId)
pub fn regenerate_display_list_for_dom(&mut self, dom_id: DomId)
Regenerate the display list for a specific DOM from the current layout tree.
This is the critical missing piece for text input: after update_text_cache_after_edit
updates the inline_layout_result on layout tree nodes, the DomLayoutResult.display_list
must be regenerated. Otherwise, generate_frame() sends the OLD display list to WebRender
and the screen shows stale text.
This method creates a temporary LayoutContext from the existing LayoutWindow state
and calls generate_display_list on the already-computed layout tree and positions.
Sourcepub fn get_node_bounds(
&self,
dom_id: DomId,
node_id: NodeId,
) -> Option<LayoutRect>
pub fn get_node_bounds( &self, dom_id: DomId, node_id: NodeId, ) -> Option<LayoutRect>
Get the layout bounds (position and size) of a specific node
Sourcepub fn edit_text_node(
&mut self,
dom_id: DomId,
node_id: NodeId,
edit_type: TextEditType,
) -> Vec<DomNodeId>
pub fn edit_text_node( &mut self, dom_id: DomId, node_id: NodeId, edit_type: TextEditType, ) -> Vec<DomNodeId>
Edit the text content of a node (used for text input actions)
This function applies text edits to nodes that contain text content. The DOM node itself is NOT modified - instead, the text cache is updated with the new shaped text that reflects the edit, cursor, and selection.
It handles:
- ReplaceSelectedText: Replaces the current selection with new text
- SetValue: Sets the entire text value
- SetNumericValue: Converts number to string and sets value
§Returns
Returns a Vec of DomNodeIds (node + parent) that need to be marked dirty for re-layout. The caller MUST use this return value to trigger layout.
Sourcepub fn process_mouse_click_for_selection(
&mut self,
position: LogicalPosition,
time_ms: u64,
) -> Option<Vec<DomNodeId>>
pub fn process_mouse_click_for_selection( &mut self, position: LogicalPosition, time_ms: u64, ) -> Option<Vec<DomNodeId>>
Process mouse click for text selection.
This method handles:
- Single click: Place cursor at click position
- Double click: Select word at click position
- Triple click: Select paragraph (line) at click position
§Workflow
- Use HoverManager’s hit test to find hit nodes
- Find the IFC layout via
inline_layout_result(IFC root) orifc_membership(text node) - Use point_relative_to_item for local cursor position
- Hit-test the text layout to get logical cursor
- Apply appropriate selection based on click count
- Update SelectionManager with new selection
§IFC Architecture
Text nodes don’t store inline_layout_result directly. Instead:
- IFC root nodes (e.g.,
<p>) haveinline_layout_resultwith the complete text layout - Text nodes have
ifc_membershippointing back to their IFC root - This allows efficient lookup without iterating all nodes
§Parameters
position- Click position in logical coordinates (for click count tracking)time_ms- Current time in milliseconds (for multi-click detection)
§Returns
Option<Vec<DomNodeId>>- Affected nodes that need re-rendering, None if click didn’t hit text
Sourcepub fn process_mouse_drag_for_selection(
&mut self,
_start_position: LogicalPosition,
current_position: LogicalPosition,
) -> Option<Vec<DomNodeId>>
pub fn process_mouse_drag_for_selection( &mut self, _start_position: LogicalPosition, current_position: LogicalPosition, ) -> Option<Vec<DomNodeId>>
Process mouse drag for text selection extension.
This method handles drag-to-select by extending the selection from the anchor (mousedown position) to the current focus (drag position).
Uses the anchor/focus model:
- Anchor is fixed at the initial click position (set by process_mouse_click_for_selection)
- Focus moves with the mouse during drag
- Affected nodes between anchor and focus are computed in DOM order
§Parameters
start_position- Initial click position in logical coordinates (unused, anchor is stored)current_position- Current mouse position in logical coordinates
§Returns
Option<Vec<DomNodeId>>- Affected nodes that need re-rendering
Sourcepub fn delete_selection(
&mut self,
target: DomNodeId,
forward: bool,
) -> Option<Vec<DomNodeId>>
pub fn delete_selection( &mut self, target: DomNodeId, forward: bool, ) -> Option<Vec<DomNodeId>>
Delete the currently selected text or one character at the cursor
Handles Backspace/Delete key. If a range selection exists, the selected text is deleted. If only a cursor exists (no range), one character is deleted before (Backspace) or after (Delete) the cursor.
§Arguments
target- The target node (focused contenteditable element)forward- true for Delete key (forward), false for Backspace (backward)
§Returns
Some(Vec<DomNodeId>)- Affected nodes if deletion occurredNone- If no cursor/selection exists or deletion failed
Sourcepub fn get_selected_content_for_clipboard(
&self,
dom_id: &DomId,
) -> Option<ClipboardContent>
pub fn get_selected_content_for_clipboard( &self, dom_id: &DomId, ) -> Option<ClipboardContent>
Extract clipboard content from the current selection
This method extracts both plain text and styled text from the selection ranges. It iterates through all selected text, extracts the actual characters, and preserves styling information from the ShapedGlyph’s StyleProperties.
This is NOT reading from the system clipboard - use clipboard_manager.get_paste_content()
for that. This extracts content FROM the selection TO be copied.
§Arguments
dom_id- The DOM to extract selection from
§Returns
Some(ClipboardContent)- If there is a selection with textNone- If no selection or no text layouts found
Sourcepub fn process_image_callback_updates(
&mut self,
image_callbacks_changed: &BTreeMap<DomId, FastBTreeSet<NodeId>>,
gl_context: &OptionGlContextPtr,
) -> Vec<(DomId, NodeId, Texture)>
pub fn process_image_callback_updates( &mut self, image_callbacks_changed: &BTreeMap<DomId, FastBTreeSet<NodeId>>, gl_context: &OptionGlContextPtr, ) -> Vec<(DomId, NodeId, Texture)>
Process image callback updates from callback changes
This function re-invokes image callbacks for nodes that requested updates (typically from timer callbacks or resize events). It returns the updated textures along with their metadata for the rendering pipeline to process.
§Arguments
image_callbacks_changed- Map of DomId -> Set of NodeIds that need re-renderinggl_context- OpenGL context pointer for rendering
§Returns
Vector of (DomId, NodeId, Texture) tuples for textures that were updated
Sourcepub fn check_and_queue_virtual_view_reinvoke(
&mut self,
dom_id: DomId,
node_id: NodeId,
) -> bool
pub fn check_and_queue_virtual_view_reinvoke( &mut self, dom_id: DomId, node_id: NodeId, ) -> bool
Check if a scrolled node is a VirtualView that needs re-invocation. If so,
queue it in pending_virtual_view_updates for processing before the next frame.
This is the bridge between the scroll system and the VirtualView lifecycle: ScrollTo → scroll_manager.scroll_to() → check_and_queue_virtual_view_reinvoke()
Returns true if a VirtualView update was queued (caller should trigger a
display list rebuild instead of a lightweight repaint).
Sourcepub fn process_virtual_view_updates(
&mut self,
vviews_to_update: &BTreeMap<DomId, FastBTreeSet<NodeId>>,
window_state: &FullWindowState,
renderer_resources: &RendererResources,
system_callbacks: &ExternalSystemCallbacks,
) -> Vec<(DomId, NodeId)>
pub fn process_virtual_view_updates( &mut self, vviews_to_update: &BTreeMap<DomId, FastBTreeSet<NodeId>>, window_state: &FullWindowState, renderer_resources: &RendererResources, system_callbacks: &ExternalSystemCallbacks, ) -> Vec<(DomId, NodeId)>
Process VirtualView updates requested by callbacks
This method handles manual VirtualView re-rendering triggered by trigger_virtual_view_rerender().
It invokes the VirtualView callback with DomRecreated reason and performs layout on the
returned DOM, then submits a new display list to WebRender for that pipeline.
§Arguments
vviews_to_update- Map of DomId -> Set of NodeIds that need re-renderingwindow_state- Current window staterenderer_resources- Renderer resourcessystem_callbacks- External system callbacks
§Returns
Vector of (DomId, NodeId) tuples for VirtualViews that were successfully updated
Sourcepub fn queue_virtual_view_updates(
&mut self,
vviews_to_update: BTreeMap<DomId, FastBTreeSet<NodeId>>,
)
pub fn queue_virtual_view_updates( &mut self, vviews_to_update: BTreeMap<DomId, FastBTreeSet<NodeId>>, )
Queue VirtualView updates to be processed in the next frame
This is called after callbacks to store the vviews_to_update from callback changes
Sourcepub fn process_pending_virtual_view_updates(
&mut self,
window_state: &FullWindowState,
renderer_resources: &RendererResources,
system_callbacks: &ExternalSystemCallbacks,
) -> Vec<(DomId, NodeId)>
pub fn process_pending_virtual_view_updates( &mut self, window_state: &FullWindowState, renderer_resources: &RendererResources, system_callbacks: &ExternalSystemCallbacks, ) -> Vec<(DomId, NodeId)>
Process and clear pending VirtualView updates
This is called during frame generation to re-render updated VirtualViews
Auto Trait Implementations§
impl !Freeze for LayoutWindow
impl !RefUnwindSafe for LayoutWindow
impl Send for LayoutWindow
impl Sync for LayoutWindow
impl Unpin for LayoutWindow
impl UnsafeUnpin for LayoutWindow
impl !UnwindSafe for LayoutWindow
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> 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