Repository navigation
Conversation
BrowserWindow places its WebContentsView as a sibling of the window content view, below it in the paint order, so that views added to the content view are painted on top of the web content. The content view covers the whole window, so the default bounds check made it win every hit-test: ViewAXPlatformNodeDelegate::HitTestSync returned the empty container instead of the web content, which broke NVDA mouse tracking (electron#42945). Install the same ContentViewTargeterDelegate that macOS already uses, so the content view only intersects a point where one of its children covers it. Accessibility hit-tests and view mouse targeting then fall through to the WebContentsView.
The content view that BaseWindow creates is an empty container covering the whole window. Assistive technology reports it as an empty pane instead of the window content, and it shows up as an extra node when navigating the accessibility tree. Keep that container out of the tree while it has no child view, and make it visible again as soon as it gets one. Only the container created by BaseWindow is treated this way, so a view set by the application through setContentView keeps its accessibility node.
Native accessibility hit-testing is not observable from the JS specs. These files reproduce the window described in electron#42945 and query the Windows UI Automation API, the same layer that NVDA uses for mouse tracking and that Inspect.exe displays.
|
💖 Thanks for opening this pull request! 💖 Semantic PR titlesWe use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Commit signingThis repo enforces commit signatures for all incoming PRs. PR tipsThings that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
|
This PR was automatically closed because the PR template was not properly filled out. The following required sections are missing:
Please update your PR description to include all required sections and reopen the PR. |
|
For more information on signing commits, see GitHub's documentation on Telling Git about your signing key. |
|
This pull request was closed automatically by the template check a few seconds after it was opened: the description did not contain the The description has since been corrected (it now contains the three sections of the template, and it is the description of #55334). GitHub however refuses to reopen this pull request ( The commits are unchanged since this pull request was opened. |
Description of Change
This continues #53460, whose author is unable to follow up on it. The original
branch no longer applies to
main, and the Windows verification the PR waswaiting for was never done. This PR carries the same fix, rebased on current
main, reuses theContentViewTargeterDelegatethatmainalready ships formacOS, and adds the Windows/UIA verification.
Root cause.
BrowserWindowadds itsWebContentsViewas a sibling ofthe window's content view, inserted before it in the paint order, so that
views added to the content view are painted on top of the web content
(#41256). The content view covers the whole window, so the default bounds
check made it win every hit-test:
ViewAXPlatformNodeDelegate::HitTestSyncreturned the empty container instead of the web content. On Windows this
intercepts
AccessibleObjectFromPoint, which is the legacy path NVDA uses formouse tracking, so the screen reader has nothing to report on the content
(#42945).
The fix, in two parts.
NativeWindowViews::SetContentViewinstalls the sameContentViewTargeterDelegatethatNativeWindowMac::SetContentViewandNativeWindowMacRemote::SetContentViewalready install. The content viewthen only intersects a point where one of its children covers it, so
accessibility hit-tests and view mouse targeting fall through to the
WebContentsViewunderneath. Unlike the original PR, this reuses the shareddelegate that already exists in
maininstead of moving it tonative_window.cc.visible child, and reappears as soon as it gets one. The rule is set in
BaseWindow::SetContentView, so it covers the container created byBaseWindowas well as a view installed later throughsetContentView. Aview whose only child is invisible counts as empty, the way the hit-test
transparency ignores invisible children.
AI assistance. This change was prepared with AI assistance (MiniMax M3.1,
through a local assistant), and the commits carry
Assisted-By:trailers asdescribed in the project's AI tool policy. The author is responsible for the
change and reviews the diff before the pull request is merged.
Windows verification
Measured with the procedure in
docs/development/a11y-hit-test-verification/,on Windows 11, 1920x1200, scale factor 1. The application under test opens a
900x700 window with five text blocks at fixed positions and a 40x40 child view
in the corner of the content view.
Both Windows paths are queried at each point:
AutomationElement.FromPoint(UIA) and
AccessibleObjectFromPoint(MSAA, the legacy path NVDA uses forElectron applications, and what Inspect.exe shows in MSAA mode).
Before the fix, with the published Electron 45.0.0:
role=16(ROLE_SYSTEM_PANE), withno name, that is the empty content view. A screen reader on the legacy path
has nothing to announce.
Points raised in review
ContentViewTargeterDelegatewas only listed inlib_sources_mac, so thenew code would not have linked on Windows and Linux. It is now also listed in
lib_sources_views.the one created by
BaseWindow.Related issues
Checklist
to tick after reviewing the diff, as required by the project's AI tool
policy
npm testpasses locally — native accessibility hit-testing is notobservable from the JS specs, so the verification above is done with the
Windows UI Automation and MSAA APIs instead
verification procedure is documented in
docs/development/a11y-hit-test-verification/describe the change in a way relevant to app developers, and are
capitalized, punctuated, and past tense
Release Notes
Notes: Fixed screen readers detecting an empty pane instead of the web contents of a
BrowserWindowon Windows and Linux.