Skip to content

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

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

fix: move BrowserWindow's WebContentsView to be a child of rootview#41256
nornagon merged 12 commits intomainfrom
hide-browserwindow-webcontentsview

Conversation

@nornagon
Copy link
Contributor

@nornagon nornagon commented Feb 6, 2024

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
Copy link
Member

@samuelmaddock samuelmaddock left a comment

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
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
Copy link
Contributor

@zcbenz zcbenz left a comment

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
Copy link
Contributor

zcbenz commented Feb 28, 2024

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
Copy link
Contributor

zcbenz commented Mar 4, 2024

WoA still crashes, maybe just remove the line?

@release-clerk
Copy link

release-clerk bot commented Apr 8, 2024

Release Notes Persisted

Fixed an issue where child views in a BrowserWindow could sometimes be

@trop
Copy link
Contributor

trop bot commented Apr 8, 2024

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

@trop trop bot added needs-manual-bp/30-x-y and removed target/30-x-y PR should also be added to the "30-x-y" branch. labels Apr 8, 2024
@dsanders11 dsanders11 added target/30-x-y PR should also be added to the "30-x-y" branch. needs-manual-bp/30-x-y and removed needs-manual-bp/30-x-y target/30-x-y PR should also be added to the "30-x-y" branch. labels Apr 8, 2024
@dsanders11
Copy link
Member

/trop run backport-to 30-x-y

@trop
Copy link
Contributor

trop bot commented Apr 8, 2024

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

trop bot added a commit that referenced this pull request Apr 8, 2024
@trop
Copy link
Contributor

trop bot commented Apr 8, 2024

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 <jeremya@chromium.org>
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
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