feat: replace BrowserView with WebContentsView (#35658)

This commit is contained in:
Jeremy Rose 2023-12-13 13:01:03 -08:00 committed by GitHub
parent a94fb2cb5d
commit 15c6014324
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
76 changed files with 2987 additions and 1531 deletions

View file

@ -15,9 +15,13 @@ DelayedNativeViewHost::~DelayedNativeViewHost() = default;
void DelayedNativeViewHost::ViewHierarchyChanged(
const views::ViewHierarchyChangedDetails& details) {
NativeViewHost::ViewHierarchyChanged(details);
if (details.is_add && GetWidget())
Attach(native_view_);
// NativeViewHost doesn't expect to have children, so filter the
// ViewHierarchyChanged events before passing them on.
if (details.child == this) {
NativeViewHost::ViewHierarchyChanged(details);
if (details.is_add && GetWidget() && !native_view())
Attach(native_view_);
}
}
bool DelayedNativeViewHost::OnMousePressed(const ui::MouseEvent& ui_event) {

View file

@ -22,7 +22,6 @@ class RootViewMac : public views::View {
RootViewMac& operator=(const RootViewMac&) = delete;
// views::View:
void Layout() override;
gfx::Size GetMinimumSize() const override;
gfx::Size GetMaximumSize() const override;

View file

@ -4,23 +4,20 @@
#include "shell/browser/ui/cocoa/root_view_mac.h"
#include <memory>
#include "shell/browser/native_window.h"
#include "ui/views/layout/fill_layout.h"
namespace electron {
RootViewMac::RootViewMac(NativeWindow* window) : window_(window) {
set_owned_by_client();
SetLayoutManager(std::make_unique<views::FillLayout>());
}
RootViewMac::~RootViewMac() = default;
void RootViewMac::Layout() {
if (!window_->content_view()) // Not ready yet.
return;
window_->content_view()->SetBoundsRect(gfx::Rect(gfx::Point(), size()));
}
gfx::Size RootViewMac::GetMinimumSize() const {
return window_->GetMinimumSize();
}