Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Servo accessibility for embedders

Activating accessibility for a WebView

The entry point for activating accessibility is WebView::set_accessibility_active(). This will return a randomly-generated TreeId, which will remain stable for the lifetime of the WebView. The WebView’s TreeId can also be accessed via the accesskit_tree_id() method.

Important

The WebView’s TreeId must be used to create a graft node in the embedder’s application tree by sending a TreeUpdate to the AccessKit Adapter including a node with a tree_id value corresponding to the WebView’s TreeId, before any TreeUpdates are forwarded to AccessKit from the WebView.

Once accessibility is active for the WebView, it will begin to emit TreeUpdates via the WebViewDelegate::notify_accessibility_tree_update() method. Once the graft node has been created, these TreeUpdates can be forwarded directly to the AccessKit adapter.

The WebView will continue to emit TreeUpdates for any change to its accessibility tree until either its set_accessibility_active() method is used to deactivate the accessibility tree, or its lifetime ends. Accessibility tree changes will be triggered by navigations within the webview, as well as any changes to the contents of the currently active document.

Servo manages subtrees within the WebView’s accessibility tree; the embedder only needs to ensure that there is a graft node for the WebView in its top-level tree, and that Servo’s TreeUpdates are sent to the adapter in the order in which they are emitted from Servo.

Diagram showing the data flow between the embedder, the WebView and accesskit as described above.

Note

The updates from the WebView are currently one-way: we don’t yet support ActionRequests.

Per-WebView accessibility activation was added in #42309.