Don't store WebContents in NativeWindow

This commit is contained in:
Cheng Zhao 2018-03-06 16:12:10 +09:00
parent 9000bd6679
commit 78468098c5
5 changed files with 4 additions and 15 deletions

View file

@ -48,10 +48,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
base::Closure callback) {
if (!native_window)
return;
brightray::InspectableWebContents* web_contents =
native_window->inspectable_web_contents();
if (!web_contents)
return;
NSWindow* nswindow = native_window->GetNativeWindow();
auto close_callback = base::Bind(
&MenuMac::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback);
@ -59,7 +56,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
[[AtomMenuController alloc] initWithModel:model()
useDefaultAccelerator:NO]);
NSMenu* menu = [popup_controllers_[window_id] menu];
NSView* view = web_contents->GetView()->GetNativeView();
NSView* view = [nswindow contentView];
// Which menu item to show.
NSMenuItem* item = nil;
@ -69,7 +66,6 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
// (-1, -1) means showing on mouse location.
NSPoint position;
if (x == -1 || y == -1) {
NSWindow* nswindow = native_window->GetNativeWindow();
position = [view convertPoint:[nswindow mouseLocationOutsideOfEventStream]
fromView:nil];
} else {

View file

@ -17,6 +17,7 @@
#include "base/strings/sys_string_conversions.h"
#include "brightray/common/application_info.h"
#include "net/base/mac/url_conversions.h"
#include "ui/gfx/image/image.h"
#include "url/gurl.h"
namespace atom {

View file

@ -34,7 +34,6 @@ NativeWindow::NativeWindow(
is_modal_(false),
is_osr_dummy_(false),
browser_view_(nullptr),
inspectable_web_contents_(inspectable_web_contents),
weak_factory_(this) {
options.Get(options::kFrame, &has_frame_);
options.Get(options::kTransparent, &transparent_);

View file

@ -265,10 +265,6 @@ class NativeWindow : public base::SupportsUserData {
observers_.RemoveObserver(obs);
}
brightray::InspectableWebContents* inspectable_web_contents() const {
return inspectable_web_contents_;
}
bool has_frame() const { return has_frame_; }
void set_has_frame(bool has_frame) { has_frame_ = has_frame; }
@ -329,9 +325,6 @@ class NativeWindow : public base::SupportsUserData {
// The browser view layer.
NativeBrowserView* browser_view_;
// The page this window is viewing.
brightray::InspectableWebContents* inspectable_web_contents_;
// Observers of this window.
base::ObserverList<NativeWindowObserver> observers_;

View file

@ -953,7 +953,7 @@ NativeWindowMac::NativeWindowMac(
options.Get(options::kDisableAutoHideCursor, &disableAutoHideCursor);
[window_ setDisableAutoHideCursor:disableAutoHideCursor];
NSView* view = inspectable_web_contents()->GetView()->GetNativeView();
NSView* view = web_contents->GetView()->GetNativeView();
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
// Use an NSEvent monitor to listen for the wheel event.