Skip to content

fix: move BrowserWindow's WebContentsView to be a child of rootview - #41256

Merged
nornagon merged 12 commits into
mainfrom
hide-browserwindow-webcontentsview
Apr 8, 2024
Merged

nornagon merged 12 commits into
mainfrom
hide-browserwindow-webcontentsview

Conversation

@nornagon

@nornagon nornagon commented Feb 6, 2024

Copy link
Copy Markdown
Contributor

Description of Change

Fixes #41141.

Previously, BrowserWindow#contentView was a reference to the BrowserWindow's
WebContentsView, and any child views that were added would be children of the
WebContentsView. This caused some strange behavior, including BrowserViews
sometimes being painted behind the BrowserWindow's web contents.

This PR has BrowserWindow's WebContentsView be a sibling to the content view,
inserted before it, so that the BrowserWindow's WebContents will always display
behind its children as intended.

It also prevents users from doing dangerous, unsupported and probably entirely
broken things like swapping out the BrowserWindow's contentView for another
view.

Checklist

Release Notes

Notes: Fixed an issue where child views in a BrowserWindow could sometimes be
painted behind the main web content.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Feb 6, 2024
@nornagon nornagon added semver/minor backwards-compatible functionality no-backport labels Feb 6, 2024

@samuelmaddock samuelmaddock 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.

API LGTM

@samuelmaddock

Copy link
Copy Markdown
Member

Looks like the menu bar is expecting a different amount of children after this PR

if (visible) {
DCHECK_EQ(children().size(), 1ul);
AddChildView(menu_bar_.get());
} else {
DCHECK_EQ(children().size(), 2ul);
RemoveChildView(menu_bar_.get());
}

@nornagon nornagon changed the title fix: hide BrowserWindow's WebContentsView fix: move BrowserWindow's WebContentsView to be a child of rootview Feb 7, 2024

@zcbenz zcbenz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

API LGTM

@nornagon
nornagon force-pushed the hide-browserwindow-webcontentsview branch from 3d3af28 to aa66ce7 Compare February 20, 2024 01:11
@zcbenz

zcbenz commented Feb 28, 2024

Copy link
Copy Markdown
Contributor

The WoA CI consistently fails with a [5812:0228/072758.443:FATAL:frame_subscriber.cc(45)] Check failed: !size.IsEmpty(). crash, can you try merging latest main?

@zcbenz

zcbenz commented Mar 4, 2024

Copy link
Copy Markdown
Contributor

WoA still crashes, maybe just remove the line?

@dsanders11

Copy link
Copy Markdown
Member

/trop run backport-to 30-x-y

@trop

trop Bot commented Apr 8, 2024

Copy link
Copy Markdown
Contributor

The backport process for this PR has been manually initiated - sending your PR to 30-x-y!

@trop

trop Bot commented Apr 8, 2024

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "30-x-y" cleanly;
you will need to perform this backport manually.

codebytere pushed a commit that referenced this pull request Apr 10, 2024
…41802)

fix: move BrowserWindow's WebContentsView to be a child of rootview (#41256)

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Jeremy Rose <[email protected]>
markh-discord added a commit to discord/electron that referenced this pull request Sep 12, 2024
Revert "fix: move BrowserWindow's WebContentsView to be a child of rootview (electron#41256)"

This reverts commit 76f7bbb.

Patch-Filename: fix_revert_change_that_broke_nvda_screen_reader.patch
chrisharris-discord pushed a commit to discord/electron that referenced this pull request Feb 18, 2025
Revert "fix: move BrowserWindow's WebContentsView to be a child of rootview (electron#41256)"

This reverts commit 76f7bbb.

Patch-Filename: fix_revert_change_that_broke_nvda_screen_reader.patch
markh-discord added a commit to discord/electron that referenced this pull request Aug 12, 2025
Revert "fix: move BrowserWindow's WebContentsView to be a child of rootview (electron#41256)"

This reverts commit 76f7bbb.

Additionally reverts commit 7d045dc to support prior revert.

Patch-Filename: fix_revert_change_that_broke_nvda_screen_reader.patch
markh-discord added a commit to discord/electron that referenced this pull request Nov 19, 2025
Revert "fix: move BrowserWindow's WebContentsView to be a child of rootview (electron#41256)"

This reverts commit 76f7bbb.

Additionally reverts commit 7d045dc to support prior revert.

Patch-Filename: fix_revert_change_that_broke_nvda_screen_reader.patch
aconverse pushed a commit to discord/electron that referenced this pull request Nov 21, 2025
Revert "fix: move BrowserWindow's WebContentsView to be a child of rootview (electron#41256)"

This reverts commit 76f7bbb.

Additionally reverts commit 7d045dc to support prior revert.

Patch-Filename: fix_revert_change_that_broke_nvda_screen_reader.patch
wittjeff added a commit to wittjeff/electron that referenced this pull request Sep 3, 2026
Since the BrowserWindow's WebContentsView became a sibling of the
window's contentView painted beneath it (electron#41256), the empty contentView
container has been exposed to assistive technology as an empty pane
covering the whole window. ViewAXPlatformNodeDelegate::HitTestSync
searches children topmost-first and returns the empty pane, so screen
reader hit-tests (e.g. NVDA mouse tracking) can no longer reach the web
contents beneath it.

Mark a default-constructed api::View's plain container as ignored and
invisible to accessibility while it has no children. Ignored removes
the empty pane from the accessibility tree; invisible makes AX
hit-tests skip it so they fall through to the web contents. The state
is cleared as soon as child views are added, so contentView-based
layouts (e.g. multiple WebContentsViews) are still fully exposed to
assistive technology. This follows the pattern of Chromium's
ash::NonAccessibleView.

Fixes electron#42945

Co-Authored-By: Claude Fable 5 <[email protected]>
dyc pushed a commit to discord/electron that referenced this pull request Sep 9, 2026
Revert "fix: move BrowserWindow's WebContentsView to be a child of rootview (electron#41256)"

This reverts commit 76f7bbb.

Additionally reverts commit 7d045dc to support prior revert.

Patch-Filename: fix_revert_change_that_broke_nvda_screen_reader.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-review/approved ✅ merged/30-x-y PR was merged to the "30-x-y" branch. semver/minor backwards-compatible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: BrowserViews doesn't work correctly on macOS

4 participants