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’sTreeIdmust be used to create a graft node in the embedder’s application tree by sending aTreeUpdateto the AccessKit Adapter including a node with atree_idvalue corresponding to the WebView’sTreeId, before anyTreeUpdates 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.
Note
The updates from the
WebVieware currently one-way: we don’t yet supportActionRequests.
Per-WebView accessibility activation was added in #42309.