Skip to content

libservo: Per-webview accessibility activation#43029

Merged
delan merged 3 commits into
servo:mainfrom
delan:per-webview-accessibility-activation
Mar 19, 2026
Merged

libservo: Per-webview accessibility activation#43029
delan merged 3 commits into
servo:mainfrom
delan:per-webview-accessibility-activation

Conversation

@delan

@delan delan commented Mar 5, 2026

Copy link
Copy Markdown
Member

in #42336, we added a Servo-global API for controlling whether accessibility is active. the idea was that when the embedder activates accessibility, all webviews and documents activate accessibility and start sending AccessKit tree updates, and vice versa when they deactivate.

we found a problem with this approach in #42338. global activation of accessibility makes it too easy to accidentally cause a panic in AccessKit, and harder than it needs to be for embedders to learn that they are responsible for grafting each webview’s subtree into their main AccessKit tree as soon as accessibility is activated. this is due to an invariant of the AccessKit subtree API: if a subtree starts sending updates before the graft node is created, the program panics.

this patch reworks accessibility activation to make it per-webview. by requiring embedders to explicitly activate accessibility for a webview, we can communicate the AccessKit invariant via our API docs.

Testing: this patch includes an initial accessibility test in libservo
Fixes: part of #4344, extracted from our work in #42338

@delan delan requested a review from mrobinson March 5, 2026 08:28
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 5, 2026
@delan delan force-pushed the per-webview-accessibility-activation branch from 1b8c935 to cbca7fe Compare March 5, 2026 09:26
@delan

delan commented Mar 5, 2026

Copy link
Copy Markdown
Member Author

(cc @DataTriny, this may be interesting re the subtree API design)

@delan

This comment was marked as resolved.

@jdm

This comment was marked as resolved.

@delan

This comment was marked as resolved.

@jdm

This comment was marked as resolved.

@delan

This comment was marked as resolved.

Co-authored-by: delan azabani <dazabani@igalia.com>
Signed-off-by: Alice Boxhall <alice@igalia.com>
Signed-off-by: delan azabani <dazabani@igalia.com>
@delan delan force-pushed the per-webview-accessibility-activation branch from b508b5a to 46532ac Compare March 19, 2026 05:45

@mukilan mukilan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with some nits.

Comment thread components/servo/webview.rs Outdated
Comment thread components/servo/webview.rs
Comment thread components/shared/constellation/lib.rs Outdated
Comment thread components/constellation/constellation.rs Outdated
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Mar 19, 2026
@delan delan added this pull request to the merge queue Mar 19, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Mar 19, 2026
@delan delan removed this pull request from the merge queue due to a manual request Mar 19, 2026
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Mar 19, 2026
delan added 2 commits March 19, 2026 16:34
Signed-off-by: delan azabani <dazabani@igalia.com>
Signed-off-by: delan azabani <dazabani@igalia.com>
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 19, 2026
@delan delan enabled auto-merge March 19, 2026 08:34
@delan delan added this pull request to the merge queue Mar 19, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Mar 19, 2026
Merged via the queue into servo:main with commit 4dbc9f7 Mar 19, 2026
33 checks passed
@delan delan deleted the per-webview-accessibility-activation branch March 19, 2026 09:25
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Mar 19, 2026
Gae24 pushed a commit to Gae24/servo that referenced this pull request Mar 26, 2026
in servo#42336, we added a
[Servo](https://doc.servo.org/servo/struct.Servo.html)-global API for
controlling whether accessibility is active. the idea was that when the
embedder activates accessibility, all webviews and documents activate
accessibility and start sending AccessKit tree updates, and vice versa
when they deactivate.

we found a problem with this approach in servo#42338. global activation of
accessibility makes it too easy to accidentally cause a panic in
AccessKit, and harder than it needs to be for embedders to learn that
they are responsible for grafting each webview’s subtree into their main
AccessKit tree as soon as accessibility is activated. this is due to an
invariant of the AccessKit subtree API: if a subtree starts sending
updates before the graft node is created, the program panics.

this patch reworks accessibility activation to make it per-webview. by
requiring embedders to explicitly activate accessibility for a webview,
we can communicate the AccessKit invariant via our API docs.

Testing: this patch includes an initial accessibility test in libservo
Fixes: part of servo#4344, extracted from our work in servo#42338

---------

Signed-off-by: Alice Boxhall <alice@igalia.com>
Signed-off-by: delan azabani <dazabani@igalia.com>
Co-authored-by: Alice Boxhall <alice@igalia.com>
github-merge-queue Bot pushed a commit that referenced this pull request Mar 26, 2026
in #43029, we defined an accessibility tree for each webview. we create
those trees when accessibility is activated for that webview, then the
embedder can graft it into their main accessibility tree. at the time,
this accessibility tree was empty, but we ultimately want it to contain
the accessibility tree of the documents loaded in the webview at any
given time. to do that, we need to graft the active top-level pipeline’s
accessibility tree into the webview accessibility tree. we should be
able to ignore nested documents inside iframes here, and leave it to
their parent documents to graft those in as part of layout
accessibility.

this patch hooks into the moment in the constellation where we detect
that the top-level document has changed (#43013), and notifies libservo
of the new AccessKit TreeId for the webview-to-pipeline graft node. this
moment covers navigating to a new top-level document and navigating back
or forward, but not the initial document loaded in the webview, so we
also hook into the moment a ConstellationWebView is created, and do the
same for that initial document. now the accessibility tree for a webview
with accessibility activated should look like this:

- embedder’s main tree
  - graft node for webview tree → webview tree
    - ~~graft node for document back in history~~
    - graft node for active top-level document → (nothing yet)
    - ~~graft node for document forward in history~~

Testing: this patch updates the relevant accessibility test in libservo
Fixes: part of #4344, extracted from our work in #42338

---------

Signed-off-by: Alice Boxhall <alice@igalia.com>
Signed-off-by: delan azabani <dazabani@igalia.com>
Co-authored-by: Alice Boxhall <alice@igalia.com>
github-merge-queue Bot pushed a commit that referenced this pull request Apr 1, 2026
this patch plumbs the webview accessibility trees (#43029, #43556) into
servoshell. we add a global flag in servoshell, which is set when the
platform activates accessibility and cleared when the platform
deactivates accessibility. the flag in turn [activates
accessibility](https://doc.servo.org/servo/struct.WebView.html#method.set_accessibility_active)
in existing and new webviews.

Testing: none in this patch, but will be covered by end-to-end platform
a11y tests in WPT
Fixes: part of #4344, extracted from our work in #42338

Signed-off-by: delan azabani <dazabani@igalia.com>
Co-authored-by: Luke Warlow <lwarlow@igalia.com>
Co-authored-by: Alice Boxhall <alice@igalia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants