Skip to main content

Module a11y

Module a11y 

Expand description

Accessibility semantic model: the data layer. Defines the toolkit-ergonomic semantic types — Role, AccessNode, AccessState, and Action — that every Widget describes itself with via Widget::accessibility.

Deliberately a thin convenience layer: the export layer maps these onto AccessKit’s far richer schema (182 roles, 22 actions) and exports the assembled tree over AT-SPI2, while an in-process channel feeds the same nodes to the built-in screen reader. A widget author implements semantics once with a handful of variants.

Everything here is pure data, no behaviour — no D-Bus, no AccessKit dependency. Each field maps cleanly onto an AccessKit concept (e.g. our AccessState::multiline + Role::TextInput → accesskit::Role::MultilineTextInput).

Structs§

A11ySettings
Stored in the per-user settings CRDT and mirrored into spawned sandboxes via TILO_A11Y_* env vars. Defaults are all-off so existing single-user setups are unaffected until a user opts in.
AccessBounds
Serializable absolute logical-pixel geometry for a synthetic AccessNode. This mirrors Rect without requiring widget authors to depend on its serialization feature.
AccessNode
The per-widget local accessibility semantics returned by Widget::accessibility; name/description must already be FTL-resolved strings (via i18n!), not translation keys, since AccessKit/AT-SPI consume final text.
AccessState
Tri-state fields use Option<bool> where None means “the state does not apply” (e.g. a Role::Button is never checked) — matching ARIA’s aria-checked="false" vs. absent distinction.
AccessibleTextSelection
Editable-text selection in the widget’s native UTF-8 document space.

Enums§

AccessibilityRequest
A change to the person’s accessibility preferences that a control asked for, such as the sign-in screen’s larger-text or high-contrast toggle. The host applies it to the whole window, exactly as the matching system preference would.
Action
Requested by an assistive technology or the built-in screen reader. Consumed by the future Widget::perform_action hook, routed through the same CRDT-mutating path as handle_event.
Politeness
How urgently a live region narrates its own update without moving focus — a toast appearing, a status line changing.
Role
A thin subset of AccessKit’s 182 roles covering the widgets the toolkit supports; unknown/rare cases fall back to Role::Generic.

Functions§

contrast_ratio
WCAG 2.1 contrast ratio between two colours, in [1.0, 21.0] (1.0 = same luminance, 21.0 = black on white). WCAG AA body text wants ≥ 4.5:1; AAA wants ≥ 7:1.
hash_key
Hash any hashable value into the u64 key space used by AccessNode::key.
relative_luminance
WCAG 2.1 relative luminance of an sRGB colour, in [0.0, 1.0]. Alpha is ignored (colours are assumed opaque for contrast purposes).
texts
Every name and value root and its descendants expose to assistive technology, depth first.