Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove InspectableWebContentsViewMac in favor of the Views version #41326

Merged
merged 13 commits into from
Mar 4, 2024
3 changes: 1 addition & 2 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ source_set("electron_lib") {
"//ui/native_theme",
"//ui/shell_dialogs",
"//ui/views",
"//ui/views/controls/webview",
"//v8",
"//v8:v8_libplatform",
]
Expand Down Expand Up @@ -637,7 +638,6 @@ source_set("electron_lib") {
"//ui/gtk:gtk_config",
"//ui/linux:linux_ui",
"//ui/linux:linux_ui_factory",
"//ui/views/controls/webview",
"//ui/wm",
]
if (ozone_platform_x11) {
Expand Down Expand Up @@ -666,7 +666,6 @@ source_set("electron_lib") {
deps += [
"//components/crash/core/app:crash_export_thunks",
"//ui/native_theme:native_theme_browser",
"//ui/views/controls/webview",
"//ui/wm",
"//ui/wm/public",
]
Expand Down
9 changes: 1 addition & 8 deletions filenames.gni
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,8 @@ filenames = {
"shell/browser/osr/osr_web_contents_view_mac.mm",
"shell/browser/relauncher_mac.cc",
"shell/browser/ui/certificate_trust_mac.mm",
"shell/browser/ui/cocoa/delayed_native_view_host.h",
"shell/browser/ui/cocoa/delayed_native_view_host.mm",
"shell/browser/ui/cocoa/electron_bundle_mover.h",
"shell/browser/ui/cocoa/electron_bundle_mover.mm",
"shell/browser/ui/cocoa/electron_inspectable_web_contents_view.h",
"shell/browser/ui/cocoa/electron_inspectable_web_contents_view.mm",
"shell/browser/ui/cocoa/electron_menu_controller.h",
"shell/browser/ui/cocoa/electron_menu_controller.mm",
"shell/browser/ui/cocoa/electron_native_widget_mac.h",
Expand All @@ -187,8 +183,6 @@ filenames = {
"shell/browser/ui/cocoa/window_buttons_proxy.mm",
"shell/browser/ui/drag_util_mac.mm",
"shell/browser/ui/file_dialog_mac.mm",
"shell/browser/ui/inspectable_web_contents_view_mac.h",
"shell/browser/ui/inspectable_web_contents_view_mac.mm",
"shell/browser/ui/message_box_mac.mm",
"shell/browser/ui/tray_icon_cocoa.h",
"shell/browser/ui/tray_icon_cocoa.mm",
Expand All @@ -204,6 +198,7 @@ filenames = {
"shell/common/node_bindings_mac.cc",
"shell/common/node_bindings_mac.h",
"shell/common/platform_util_mac.mm",
"shell/browser/ui/views/inspectable_web_contents_view_mac.mm",
]

lib_sources_views = [
Expand All @@ -218,8 +213,6 @@ filenames = {
"shell/browser/ui/views/electron_views_delegate.h",
"shell/browser/ui/views/frameless_view.cc",
"shell/browser/ui/views/frameless_view.h",
"shell/browser/ui/views/inspectable_web_contents_view_views.cc",
"shell/browser/ui/views/inspectable_web_contents_view_views.h",
"shell/browser/ui/views/menu_bar.cc",
"shell/browser/ui/views/menu_bar.h",
"shell/browser/ui/views/menu_delegate.cc",
Expand Down
5 changes: 0 additions & 5 deletions shell/browser/api/electron_api_base_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ BaseWindow::BaseWindow(gin_helper::Arguments* args,
BaseWindow::~BaseWindow() {
CloseImmediately();

// Destroy the native window in next tick because the native code might be
// iterating all windows.
base::SingleThreadTaskRunner::GetCurrentDefault()->DeleteSoon(
FROM_HERE, window_.release());

// Remove global reference so the JS object can be garbage collected.
self_ref_.Reset();
}
Expand Down
17 changes: 1 addition & 16 deletions shell/browser/api/electron_api_web_contents_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,14 @@
#include "ui/views/view_class_properties.h"
#include "ui/views/widget/widget.h"

#if BUILDFLAG(IS_MAC)
#include "shell/browser/ui/cocoa/delayed_native_view_host.h"
#endif

namespace electron::api {

WebContentsView::WebContentsView(v8::Isolate* isolate,
gin::Handle<WebContents> web_contents)
#if BUILDFLAG(IS_MAC)
: View(new DelayedNativeViewHost(web_contents->inspectable_web_contents()
->GetView()
->GetNativeView())),
#else
: View(web_contents->inspectable_web_contents()->GetView()->GetView()),
#endif
: View(web_contents->inspectable_web_contents()->GetView()),
web_contents_(isolate, web_contents.ToV8()),
api_web_contents_(web_contents.get()) {
#if !BUILDFLAG(IS_MAC)
// On macOS the View is a newly-created |DelayedNativeViewHost| and it is our
// responsibility to delete it. On other platforms the View is created and
// managed by InspectableWebContents.
set_delete_view(false);
#endif
view()->SetProperty(
views::kFlexBehaviorKey,
views::FlexSpecification(views::MinimumFlexSizeRule::kScaleToMinimum,
Expand Down
1 change: 1 addition & 0 deletions shell/browser/native_window_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ void ReorderChildWindowAbove(NSWindow* child_window, NSWindow* other_window) {
params.bounds = bounds;
params.delegate = this;
params.type = views::Widget::InitParams::TYPE_WINDOW;
params.headless_mode = true;
params.native_widget =
new ElectronNativeWidgetMac(this, windowType, styleMask, widget());
widget()->Init(std::move(params));
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/native_window_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "content/public/browser/desktop_media_id.h"
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/ui/inspectable_web_contents.h"
#include "shell/browser/ui/views/inspectable_web_contents_view_views.h"
#include "shell/browser/ui/inspectable_web_contents_view.h"
#include "shell/browser/ui/views/root_view.h"
#include "shell/browser/web_contents_preferences.h"
#include "shell/browser/web_view_manager.h"
Expand Down
34 changes: 0 additions & 34 deletions shell/browser/ui/cocoa/delayed_native_view_host.h

This file was deleted.

44 changes: 0 additions & 44 deletions shell/browser/ui/cocoa/delayed_native_view_host.mm

This file was deleted.

55 changes: 0 additions & 55 deletions shell/browser/ui/cocoa/electron_inspectable_web_contents_view.h

This file was deleted.