Skip to main content

A11yTree

Struct A11yTree 

Source
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

Source

pub fn empty() -> A11yTree

Create an empty tree (no nodes, no root, no focus).

Source

pub fn node(&self, id: u64) -> Option<&A11yNodeInfo>

Look up a node by ID.

Source

pub fn root(&self) -> Option<&A11yNodeInfo>

The root node, if set and present.

Source

pub fn root_id(&self) -> Option<u64>

The root node ID, if set.

Source

pub fn focused(&self) -> Option<&A11yNodeInfo>

The focused node, if set and present.

Source

pub fn focused_id(&self) -> Option<u64>

The focused node ID, if set.

Source

pub fn nodes(&self) -> impl Iterator<Item = &A11yNodeInfo>

Iterate over all nodes in unspecified order.

Source

pub fn node_count(&self) -> usize

Total number of nodes.

Source

pub fn is_empty(&self) -> bool

Whether the tree contains zero nodes.

Source

pub fn children_of(&self, id: u64) -> Vec<&A11yNodeInfo>

Get all children of a given node ID, in the order stored.

Source

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.

Source

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.

Source

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.

Source

pub fn screen_reader_announcements_since( &self, previous: &A11yTree, policy: ScreenReaderPolicy, ) -> ScreenReaderAnnouncements

Extract bounded screen-reader announcements from the previous snapshot.

Source

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.

Trait Implementations§

Source§

impl Clone for A11yTree

Source§

fn clone(&self) -> A11yTree

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for A11yTree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for A11yTree

Source§

fn default() -> A11yTree

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more