Don't store WebContents in NativeWindow
This commit is contained in:
parent
9000bd6679
commit
78468098c5
5 changed files with 4 additions and 15 deletions
|
@ -48,10 +48,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||||
base::Closure callback) {
|
base::Closure callback) {
|
||||||
if (!native_window)
|
if (!native_window)
|
||||||
return;
|
return;
|
||||||
brightray::InspectableWebContents* web_contents =
|
NSWindow* nswindow = native_window->GetNativeWindow();
|
||||||
native_window->inspectable_web_contents();
|
|
||||||
if (!web_contents)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto close_callback = base::Bind(
|
auto close_callback = base::Bind(
|
||||||
&MenuMac::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback);
|
&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()
|
[[AtomMenuController alloc] initWithModel:model()
|
||||||
useDefaultAccelerator:NO]);
|
useDefaultAccelerator:NO]);
|
||||||
NSMenu* menu = [popup_controllers_[window_id] menu];
|
NSMenu* menu = [popup_controllers_[window_id] menu];
|
||||||
NSView* view = web_contents->GetView()->GetNativeView();
|
NSView* view = [nswindow contentView];
|
||||||
|
|
||||||
// Which menu item to show.
|
// Which menu item to show.
|
||||||
NSMenuItem* item = nil;
|
NSMenuItem* item = nil;
|
||||||
|
@ -69,7 +66,6 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||||
// (-1, -1) means showing on mouse location.
|
// (-1, -1) means showing on mouse location.
|
||||||
NSPoint position;
|
NSPoint position;
|
||||||
if (x == -1 || y == -1) {
|
if (x == -1 || y == -1) {
|
||||||
NSWindow* nswindow = native_window->GetNativeWindow();
|
|
||||||
position = [view convertPoint:[nswindow mouseLocationOutsideOfEventStream]
|
position = [view convertPoint:[nswindow mouseLocationOutsideOfEventStream]
|
||||||
fromView:nil];
|
fromView:nil];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
#include "brightray/common/application_info.h"
|
#include "brightray/common/application_info.h"
|
||||||
#include "net/base/mac/url_conversions.h"
|
#include "net/base/mac/url_conversions.h"
|
||||||
|
#include "ui/gfx/image/image.h"
|
||||||
#include "url/gurl.h"
|
#include "url/gurl.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
|
@ -34,7 +34,6 @@ NativeWindow::NativeWindow(
|
||||||
is_modal_(false),
|
is_modal_(false),
|
||||||
is_osr_dummy_(false),
|
is_osr_dummy_(false),
|
||||||
browser_view_(nullptr),
|
browser_view_(nullptr),
|
||||||
inspectable_web_contents_(inspectable_web_contents),
|
|
||||||
weak_factory_(this) {
|
weak_factory_(this) {
|
||||||
options.Get(options::kFrame, &has_frame_);
|
options.Get(options::kFrame, &has_frame_);
|
||||||
options.Get(options::kTransparent, &transparent_);
|
options.Get(options::kTransparent, &transparent_);
|
||||||
|
|
|
@ -265,10 +265,6 @@ class NativeWindow : public base::SupportsUserData {
|
||||||
observers_.RemoveObserver(obs);
|
observers_.RemoveObserver(obs);
|
||||||
}
|
}
|
||||||
|
|
||||||
brightray::InspectableWebContents* inspectable_web_contents() const {
|
|
||||||
return inspectable_web_contents_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool has_frame() const { return has_frame_; }
|
bool has_frame() const { return has_frame_; }
|
||||||
void set_has_frame(bool has_frame) { has_frame_ = 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.
|
// The browser view layer.
|
||||||
NativeBrowserView* browser_view_;
|
NativeBrowserView* browser_view_;
|
||||||
|
|
||||||
// The page this window is viewing.
|
|
||||||
brightray::InspectableWebContents* inspectable_web_contents_;
|
|
||||||
|
|
||||||
// Observers of this window.
|
// Observers of this window.
|
||||||
base::ObserverList<NativeWindowObserver> observers_;
|
base::ObserverList<NativeWindowObserver> observers_;
|
||||||
|
|
||||||
|
|
|
@ -953,7 +953,7 @@ NativeWindowMac::NativeWindowMac(
|
||||||
options.Get(options::kDisableAutoHideCursor, &disableAutoHideCursor);
|
options.Get(options::kDisableAutoHideCursor, &disableAutoHideCursor);
|
||||||
[window_ setDisableAutoHideCursor:disableAutoHideCursor];
|
[window_ setDisableAutoHideCursor:disableAutoHideCursor];
|
||||||
|
|
||||||
NSView* view = inspectable_web_contents()->GetView()->GetNativeView();
|
NSView* view = web_contents->GetView()->GetNativeView();
|
||||||
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
|
|
||||||
// Use an NSEvent monitor to listen for the wheel event.
|
// Use an NSEvent monitor to listen for the wheel event.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue