Update shell_platform_delegate_views.cc

This commit is contained in:
Alexander David Frick 2022-08-03 16:44:49 -05:00 committed by GitHub
parent 0b2e2e3e59
commit 5340fa043a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,4 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Copyright 2022 The Chromium Authors and Alex313031. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -99,9 +99,11 @@ class ShellView : public views::BoxLayoutView,
void SetWebContents(WebContents* web_contents, const gfx::Size& size) {
// If there was a previous WebView in this Shell it should be removed and
// deleted.
if (web_view_)
contents_view_->RemoveChildViewT(web_view_.get());
if (web_view_) {
// ExtractAsDangling clears the underlying pointer and returns another
// raw_ptr instance that is allowed to dangle.
contents_view_->RemoveChildViewT(web_view_.ExtractAsDangling().get());
}
views::Builder<views::View>(contents_view_)
.AddChild(views::Builder<views::WebView>()
.CopyAddressTo(&web_view_)
@ -304,7 +306,7 @@ class ShellView : public views::BoxLayoutView,
// Contents view contains the web contents view
raw_ptr<views::View> contents_view_ = nullptr;
raw_ptr<views::WebView, DanglingUntriaged> web_view_ = nullptr;
raw_ptr<views::WebView> web_view_ = nullptr;
};
BEGIN_METADATA(ShellView, views::View)