plat/a11y_wire.rs#
Source: lib/plat/a11y_wire.rs
a11y_wire -- the accessibility tree for hosts that keep a mirror of it (the browser's ARIA
shadow tree, Android's virtual views; web_a11y.rs): every published tree becomes its
differences to the tree the host has, in a byte format that web/a11y.js and
android/GalleryAccessibility.java read. Compiled on every target (plattest checks it).
Mirror::default() nothing sent yet: the next update is a full one
Mirror::update(&tree, &changes, place) -> Option<Vec<u8>>
the update for the host (None: nothing it shows changed); place
gives a window's client area in host px (x, y, w, h)
Mirror::reset() the host lost its mirror: the next update is a full one
Mirror::set_version(v) the format the host reads: VERSION (1, the default) or VERSION2 (the
rich node data and announcements; web/a11y.js); a full update follows
The format: integers little-endian, str = u32 byte count + UTF-8, key = u64 (Node::key)
u8 VERSION (or VERSION2), u8 flags (F_FULL: the host drops its mirror first), u8 number of windows
every shown window in the order of the snapshot (later ones lie on top):
u8 window index, u8 flags (W_DIALOG, W_ACTIVE), i32 x, y, w, h (place),
key of the focused node (0: none), str title,
u32 order count (UNCHANGED: the same nodes as before), then per node in tree order:
key, u32 parent (its position in this list; UNCHANGED: a top-level node) --
the nodes of the window that are not in the list are gone
u32 node count, then the nodes that are new or changed: key, u8 role (Role in
declaration order: Group 0 .. Dialog 20, Heading 21), u32 state (S_*), u32 actions
(A_*), i32 x, y, w, h, str name, str text, i32 caret, i32 anchor, i32 caret x, y, w,
h, f64 value (headings: the level), min, max, step;
VERSION2 adds: u8 sub (Sub in declaration order: None 0, Table 1 .. Figure 27),
str desc, str url, u32 position in set, set size, u32 item level, u32 cell row,
column, row span, column span, u32 grid rows, columns, u8 live
windows that are not listed are gone
u32 number of events, each: u8 kind (E_*), u8 window, key, i32 a, i32 b, and for E_TEXT
str old text, for E_ANNOUNCE (VERSION2 only; a: the politeness) str the text -- the events
of plat::a11y::diff without Added / Removed (the order tells those) and Live (the host's
own live regions say those)
/// the first byte of an update
VERSION: u8 = 1
/// the first byte of an update with the rich node data (Mirror::set_version)
VERSION2: u8 = 2
/// update flag: a full update (the host drops what it has)
F_FULL: u8 = 1
/// window flags
W_DIALOG: u8 = 1
W_ACTIVE: u8 = 2
/// order count: the window's nodes are the same as before; parent: a top-level node
UNCHANGED: u32 = u32::MAX
/// events: a window appeared (a 1) or went away
E_WINDOW: u8 = 1
/// the window got (a 1) or lost the keyboard
E_ACTIVE: u8 = 2
/// the keyboard focus moved to the node
E_FOCUS: u8 = 3
/// state bit a (S_*) went on (b 1) or off
E_STATE: u8 = 4
E_NAME: u8 = 5
E_VALUE: u8 = 6
/// the text changed (the old one follows)
E_TEXT: u8 = 7
/// the caret moved to character a
E_CARET: u8 = 8
/// (VERSION2) a text to say: a the politeness (LIVE_*), the text follows
E_ANNOUNCE: u8 = 9
struct Mirrorwhat the host has: the last tree sent and its window headers
impl Mirror
const fn new() -> Selffn reset(&mut self)the host lost its mirror (or turned it off): the next update is a full onefn set_version(&mut self, v: u8)the format the host reads: VERSION2 for the rich node data and announcements, anything else VERSION; the next update is a full onefn version(&self) -> u8the format of the updates (VERSION or VERSION2)fn update(&mut self, s: &Arc<Snapshot>, changes: &[Change], place: &dyn Fn(&WinTree) -> [i32; 4]) -> Option<Vec<u8>>the update that brings the host from the last tree sent to s (changes: plat::a11y::diff of the two); None when nothing the host shows changed