Add browser accessibility for Chromium windows

Chromium-based Windows applications under Wine (Electron, CEF) exposed only
what the legacy MSAA path could announce, one event at a time. The helper now
starts a publisher for each Chromium window: a PE worker reads the page
through MSAA and IAccessible2 inside the prefix, and a native ATK publisher
presents it on the accessibility bus as toolkit Chromium, matching native
Linux Chromium, so the reader's own browser support handles browse mode,
structural navigation, forms, tables and live regions. Once a window is
published, legacy announcements for it stop, so nothing is spoken twice; if
the publisher fails, the window returns to the legacy path and the helper
retries with backoff. Publishers follow the helper's lifetime.

The publisher marks itself with WINE_ACCESS_BROWSER_PUBLISHER=1 and gives each
frame a wine-access-x11-window attribute so readers can verify window
ownership. Password text, values and boundaries never leave the worker.
Design, mapping rules and verification are in docs/browser.md; the
IAccessible2 IDL is vendored in third_party/ia2.

Checked: xvfb-run ctest (all 10, including the new
browser-publisher-snapshot comparison with native Chromium 158 and Electron
42), menu_integration.py with the menu and edit fixtures, the Orca extension
unit tests, and tests/browser/live_checks.sh against Electron 45: worker
protocol, helper lifecycle (publish, no legacy announcements while typing,
restart, no orphans), and live tree, text boundaries and AT-SPI event
sequence matching native Chromium. A live test with Cthulhu on Electron 45
read the fixture page correctly.

Remaining live checks: Orca with the extension, Firefox, WebView2, 32-bit
browsers, iframes, and window switching under other window managers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Storm DragonandClaude Opus 5.5 committed 2026-12-02 23:15:21 -05:00
1 parent 13b25b581a
commit 9c1fc644ba
52 files changed
+12448 -10

No files matched your search

+119
View File
@@ -0,0 +1,119 @@
# Browser accessibility (Chromium under Wine)
Wine Access publishes Windows Chromium windows (Electron, CEF and other
Chromium hosts) on the Linux accessibility bus so that Cthulhu and Orca read
them with their own browser support: browse and focus modes, structural
navigation, tables, forms, live regions, speech and Braille. It is on for every
Chromium window the helper sees; there is no switch to turn it off.
## Components
```text
Chromium window in a Wine prefix
| MSAA + IAccessible2, cross-process through Wine's ia2comproxy.dll
wine-access-browser-worker.exe (PE, one per window, inside the prefix)
| JSON lines over stdin/stdout
wine-access-browser-publisher (native Linux, ATK + atk-bridge)
| AT-SPI on the accessibility bus, toolkit "Chromium"
Cthulhu / Orca browser support
```
- The helper (`browser_bridge.cpp`) starts one publisher for each visible
top-level `Chrome_WidgetWin_1` window that contains a
`Chrome_RenderWidgetHostHWND`. The publisher starts the worker through the
prefix's own Wine loader (`WINELOADER`, which both readers pass, or the
helper's preloader) so it joins the same wineserver.
- When the publisher prints `published`, the helper stops legacy
announcements (WinEvent presentation, control polling) for that window;
otherwise every change would be spoken twice. If the publisher exits while
the window still exists, the window returns to legacy announcements and the
helper retries with backoff (at most three failures per window).
- Publishers follow the helper: they receive SIGTERM when it dies, because
readers stop the helper with a signal that skips its shutdown code. The
worker exits when its input closes.
- The publisher re-executes itself with `WINE_ACCESS_BROWSER_PUBLISHER=1` in
its environment and gives each frame a `wine-access-x11-window` attribute.
Readers that compare the accessible window's PID with the X11 window owner
(Cthulhu) use these to accept the publisher for that window only: same user,
same prefix, matching window. Orca checks window state, not PIDs.
## Worker (`browser_worker.cpp`)
- Activation: Chromium exposes web content only to clients that look like
screen readers. The worker calls `accDefaultAction` on every object of the
initial window tree (the measured trigger), then verifies that content
appeared.
- Identity: objects are keyed by IA2 `uniqueID`. Web content resolves through
the `Chrome_RenderWidgetHostHWND` child's root, browser UI through the
top-level window.
- Threads: the main thread owns the WinEvent hook and sends tree updates; a
query thread with its own COM apartment answers the publisher's synchronous
queries and actions, so long refreshes never delay a reader. Each thread
caches its resolved objects; a stale object is resolved again, and only
read-only queries are retried.
- Events are coalesced per batch and sent in native order: structure, the
newly focused object's caret, focus, property changes, remaining carets and
selections, layout, anchors, then `flush`.
- Privacy: protected (password) text, values and boundaries never leave the
worker; only the length is sent.
## Publisher (`browser_publisher.c`)
The publisher's output must match native Linux Chromium for the same page.
Rules established by comparison with native Chromium 158 and Electron 42:
- Roles follow `map_role`; pairings not yet covered by the fixture are marked.
- Every object exposes Action, Component, Document and Text; text fields lack
Hypertext; everything except DOM text leaves is a hyperlink implementation.
- Chromium's views layer (browser UI) has no IA2 links or actions: links are
rebuilt when its text is one embedded-object character per child, actions
come from the MSAA default action plus `showContextMenu`, and internal
`view_N` ids are dropped. Never inside web content.
- Exactly one focused object (the end of the window's `accFocus` chain); no
read-only state on documents and lists; header cells report no header cells.
- Offsets convert explicitly between UTF-16 (Windows) and characters
(AT-SPI). Boundaries inside a surrogate pair round to whole characters;
native Chromium reports such a word end as `-1`.
- Word, sentence, line and paragraph boundaries come from IA2
`get_textAtOffset` on demand (they depend on layout); at the end of the text
no segment is reported. Character and range extents come from one batched
request per object. Both are cached until the text or the layout changes.
- Events: removals and text changes are emitted at once, additions at the end
of the worker's batch in document order. When a container's children
change, its text is reported as wholly replaced (nothing for text made only
of embedded objects). Scrolling to an anchor moves the caret to the target.
- The frame's extents come from the X11 window, which readers compare with the
window manager's view of the foreground window.
- Every few seconds of activity the publisher logs synchronous request counts
and times; `WINE_ACCESS_BROWSER_TRACE=1` logs every worker message.
## Verification
- `ctest -R browser-publisher-snapshot`: publishes a recorded Electron 45
snapshot (no Wine) and compares the tree, including text boundaries, with
native Chromium 158 and Electron 42.
- `tests/browser/live_checks.sh BUILD_DIR PREFIX`: needs native Chromium and a
prefix with Electron (`WINE_ACCESS_BROWSER_TEST_ELECTRON`, default
`C:\electron\v45\electron.exe`). Runs the worker protocol checks, the
helper lifecycle (publish, no legacy announcements, restart, no orphans),
and the same scripted scenario natively and through the bridge, comparing
trees and AT-SPI event sequences and checking that no password characters
appear.
- Every test runs through `tests/browser/private_session.sh`: a private
runtime directory and no display for the private D-Bus session, with a
tripwire on the user's display. A bare `dbus-run-session` can take over the
user's accessibility bus socket or advertise the test bus on the user's
display.
Recorded results do not prove audible speech, Braille or keyboard behavior;
check those live with each reader.
## Limitations
- Full Chrome does not start under Wine 11.22 (missing
`user32.GetPointerDevice`); Electron and other embedded Chromium work.
- Firefox, WebView2 (a Chromium window inside another application's window),
32-bit browsers and iframes are untested.
- Each Chromium window is its own AT-SPI application.
- The frame's active state follows Wine's foreground events; a Linux window
taking focus may not always deactivate it.