pub struct A11yTree { /* private fields */ }Expand description
Immutable snapshot of the accessibility tree after a render pass.
The tree is a flat map keyed by node ID; parent/child relationships
are encoded inside each A11yNodeInfo. This makes traversal O(1)
per hop and diffing O(n) in the number of nodes.
Implementations§
Source§impl A11yTree
impl A11yTree
Sourcepub fn node(&self, id: u64) -> Option<&A11yNodeInfo>
pub fn node(&self, id: u64) -> Option<&A11yNodeInfo>
Look up a node by ID.
Sourcepub fn root(&self) -> Option<&A11yNodeInfo>
pub fn root(&self) -> Option<&A11yNodeInfo>
The root node, if set and present.
Sourcepub fn focused(&self) -> Option<&A11yNodeInfo>
pub fn focused(&self) -> Option<&A11yNodeInfo>
The focused node, if set and present.
Sourcepub fn focused_id(&self) -> Option<u64>
pub fn focused_id(&self) -> Option<u64>
The focused node ID, if set.
Sourcepub fn nodes(&self) -> impl Iterator<Item = &A11yNodeInfo>
pub fn nodes(&self) -> impl Iterator<Item = &A11yNodeInfo>
Iterate over all nodes in unspecified order.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Total number of nodes.
Sourcepub fn children_of(&self, id: u64) -> Vec<&A11yNodeInfo>
pub fn children_of(&self, id: u64) -> Vec<&A11yNodeInfo>
Get all children of a given node ID, in the order stored.
Sourcepub fn dump_text(&self, order: &[u64]) -> String
pub fn dump_text(&self, order: &[u64]) -> String
One text line per node in order (document order as collected by the
frame): {indent}{role:?} "{name}" [{states}] @{x},{y} {w}x{h}, with
the indent equal to the node’s depth. This is the format the
accessibility panel and the tree snapshots share. Ids missing from the
tree are skipped.
Sourcepub fn ancestors(&self, id: u64) -> Vec<u64>
pub fn ancestors(&self, id: u64) -> Vec<u64>
Walk ancestors from id up to the root (inclusive), returning
their IDs. Returns an empty vec if id is not found.
Includes cycle protection: stops after visiting 1000 nodes to prevent infinite loops on malformed cyclic parent chains.
Sourcepub fn screen_reader_mirror(
&self,
policy: ScreenReaderPolicy,
) -> ScreenReaderMirror
pub fn screen_reader_mirror( &self, policy: ScreenReaderPolicy, ) -> ScreenReaderMirror
Produce deterministic screen-reader mirror lines for this snapshot.
Traversal starts at the root and follows explicit child order. Any disconnected nodes are appended by sorted node ID so malformed partial trees still produce stable diagnostics. Presentational nodes are skipped.
Sourcepub fn screen_reader_announcements_since(
&self,
previous: &A11yTree,
policy: ScreenReaderPolicy,
) -> ScreenReaderAnnouncements
pub fn screen_reader_announcements_since( &self, previous: &A11yTree, policy: ScreenReaderPolicy, ) -> ScreenReaderAnnouncements
Extract bounded screen-reader announcements from the previous snapshot.
Sourcepub fn diff(&self, previous: &A11yTree) -> A11yTreeDiff
pub fn diff(&self, previous: &A11yTree) -> A11yTreeDiff
Diff this tree against a previous snapshot to find changes.
Returns an A11yTreeDiff describing additions, removals,
property changes, and focus transitions.