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

This commit is contained in:
Jeremy Rose 2024-04-08 10:30:23 -07:00 committed by GitHub
parent 22c149812c
commit 76f7bbb0a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 31 additions and 34 deletions

View file

@ -77,6 +77,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
WebContentsView::Create(isolate, web_preferences);
DCHECK(web_contents_view.get());
window_->AddDraggableRegionProvider(web_contents_view.get());
web_contents_view_.Reset(isolate, web_contents_view.ToV8());
// Save a reference of the WebContents.
gin::Handle<WebContents> web_contents =
@ -92,7 +93,14 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
InitWithArgs(args);
// Install the content view after BaseWindow's JS code is initialized.
SetContentView(gin::CreateHandle<View>(isolate, web_contents_view.get()));
// The WebContentsView is added a sibling of BaseWindow's contentView (before
// it in the paint order) so that any views added to BrowserWindow's
// contentView will be painted on top of the BrowserWindow's WebContentsView.
// See https://github.com/electron/electron/pull/41256.
// Note that |GetContentsView|, confusingly, does not refer to the same thing
// as |BaseWindow::GetContentView|.
window()->GetContentsView()->AddChildViewAt(web_contents_view->view(), 0);
window()->GetContentsView()->DeprecatedLayoutImmediately();
// Init window after everything has been setup.
window()->InitFromOptions(options);