Expand description
Layer 2: the semantics seam — a pull-based accessibility tree pass.
Each widget optionally contributes an accesskit::Node describing its
role, label, and state (Widget::semantics,
defaulted to a no-op so no existing widget is affected). The collection pass
mirrors paint, not the arena tree-walk: a container’s children are
ChildPods outside the arena, so — exactly like
ChildPod::paint_child threads an
absolute origin down — ChildPod::semantics_child
translates the current absolute origin into the child’s space and recurses.
RenderRoot::semantics drives it after
layout (so bounds are valid) and returns a SemanticsUpdate: a flat
(NodeId, Node) list plus the root id and the focused node id, ready for a
platform adapter (accesskit_*) to consume. This crate owns no platform
wiring or per-frame scheduling — those live in each platform shell.
§Contributing a node
A leaf widget calls SemanticsCtx::push_node with its role and a closure
that sets label/state; bounds are filled from the current absolute
origin/size automatically. A widget that also has semantics-visible children
(e.g. a scroll view) uses SemanticsCtx::push_container, whose visit
closure recurses into the children (via semantics_child) so they become the
node’s accesskit children. A transparent container (Flex/Stack/Padding/…)
contributes no node of its own — it just calls semantics_child for each
child, so their nodes attach to whatever encloses the container.
Structs§
- Semantics
Ctx - Collects
accesskit::Nodes during a semantics pass, tracking the current absolute origin/size (mirroring paint’s origin threading) and the parent/child structure. - Semantics
Update - A collected accessibility tree produced by
RenderRoot::semantics.
Constants§
- ROOT_
NODE_ ID - The reserved
NodeIdof the synthetic window/root node (RenderRoot::semanticsalways roots the tree here). It is a fixed constant — the one id never drawn from the per-ChildPodallocator — so a platform adapter can treat “the root” as a stable anchor across every frame. Pod-derived ids start well above it (seeSemanticsCtx::alloc_base).