Skip to main content

Module focus_query

Module focus_query 

Source
Expand description

Pure, zero-allocation focusability, modal-overlay, and subtree query helpers over &NodeStore.

Functions§

first_focusable_in_subtree
first_matching_in_subtree
Finds the first node inside root’s subtree matching predicate in document pre-order, pruning dead, display: none (per oracle), closed-overlay and disabled subtrees, so the predicate only judges the node itself (e.g. is_focusable_self).
is_composite_aria_group
Returns true when id is a composite roving-focus group (Interaction::roving_focus_group or a composite ARIA widget role).
is_focusable_node
Returns true when id is live and focusable itself (is_focusable_self, tested first: it is O(1) and rejects almost every node), displayed (per oracle: cascaded @media / @container / state display on native scenes, static rows where the platform applies CSS), enabled, inside no closed overlay, not visibility: hidden (CSS-inherited) and not inert under the topmost modal (SemanticStyleOracle::is_inert). The one focusability rule: engine focus moves and the runtime’s focusable scene fact both read it.
is_focusable_self
Whether live id is itself a focus target (text entry, focusable, a tab_index or focus listeners), without the O(depth) ancestor checks of is_focusable_node: for callers that already pruned display: none, closed-overlay and disabled nodes and their subtrees (the first_matching_in_subtree DFS, tab-order walks).
is_open_modal
Whether id is an open modal Overlay in the top layer (is_top_layer_root).
is_subtree_closed_overlay
Returns true when id or any ancestor owns a closed Overlay row.
is_subtree_disabled
Returns true when id or any ancestor has Interaction::disabled == true.
is_tabbable_self
is_focusable_self without a negative tab_index (same pruned-DFS contract).
is_text_entry_node
Returns true when id is a live text-entry / text-key-capturing control (Interaction::captures_text_keys).
is_within_subtree
Returns true when node equals ancestor or descends from ancestor.
press_focus_target
Focus target of a primary press on hit for every host that moves focus on press: the nearest focusable ancestor-or-self (None blurs), or current unchanged when the press lands inside an Interaction::keep_focus_on_press node first (HTML mousedown preventDefault).
topmost_open_modal
Finds the topmost (last in document order) open modal Overlay in the top layer (zero allocs on a warm dfs_scratch). The single definition ([INV:top-layer-single-definition]) shared by focus management, semantic queries, and — through TopLayerIndex, which applies walk_top_layer_chain with the same oracle and document order — layout, hit-testing, scroll latching and accessibility.