Some coding style fixes
This commit is contained in:
parent
8a736abac7
commit
ff26c3c16f
3 changed files with 30 additions and 14 deletions
|
@ -19,13 +19,17 @@ MenuMac::MenuMac() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuMac::Popup(Window* window) {
|
void MenuMac::Popup(Window* window) {
|
||||||
|
NativeWindow* native_window = window->window();
|
||||||
|
if (!native_window)
|
||||||
|
return;
|
||||||
|
content::WebContents* web_contents = native_window->GetWebContents();
|
||||||
|
if (!web_contents)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NSWindow* nswindow = native_window->GetNativeWindow();
|
||||||
base::scoped_nsobject<AtomMenuController> menu_controller(
|
base::scoped_nsobject<AtomMenuController> menu_controller(
|
||||||
[[AtomMenuController alloc] initWithModel:model_.get()]);
|
[[AtomMenuController alloc] initWithModel:model_.get()]);
|
||||||
|
|
||||||
NativeWindow* native_window = window->window();
|
|
||||||
NSWindow* nswindow = native_window->GetNativeWindow();
|
|
||||||
content::WebContents* web_contents = native_window->GetWebContents();
|
|
||||||
|
|
||||||
// Fake out a context menu event.
|
// Fake out a context menu event.
|
||||||
NSEvent* currentEvent = [NSApp currentEvent];
|
NSEvent* currentEvent = [NSApp currentEvent];
|
||||||
NSPoint position = [nswindow mouseLocationOutsideOfEventStream];
|
NSPoint position = [nswindow mouseLocationOutsideOfEventStream];
|
||||||
|
@ -47,13 +51,17 @@ void MenuMac::Popup(Window* window) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuMac::PopupAt(Window* window, int x, int y) {
|
void MenuMac::PopupAt(Window* window, int x, int y) {
|
||||||
base::scoped_nsobject<AtomMenuController> menu_controller(
|
|
||||||
[[AtomMenuController alloc] initWithModel:model_.get()]);
|
|
||||||
|
|
||||||
NativeWindow* native_window = window->window();
|
NativeWindow* native_window = window->window();
|
||||||
|
if (!native_window)
|
||||||
|
return;
|
||||||
content::WebContents* web_contents = native_window->GetWebContents();
|
content::WebContents* web_contents = native_window->GetWebContents();
|
||||||
|
if (!web_contents)
|
||||||
|
return;
|
||||||
|
|
||||||
NSView* view = web_contents->GetContentNativeView();
|
NSView* view = web_contents->GetContentNativeView();
|
||||||
NSMenu* menu = [menu_controller menu];
|
NSMenu* menu = [menu_controller menu];
|
||||||
|
base::scoped_nsobject<AtomMenuController> menu_controller(
|
||||||
|
[[AtomMenuController alloc] initWithModel:model_.get()]);
|
||||||
|
|
||||||
// Show the menu.
|
// Show the menu.
|
||||||
[menu popUpMenuPositioningItem:[menu itemAtIndex:0]
|
[menu popUpMenuPositioningItem:[menu itemAtIndex:0]
|
||||||
|
|
|
@ -21,14 +21,21 @@ void MenuViews::Popup(Window* window) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuViews::PopupAt(Window* window, int x, int y) {
|
void MenuViews::PopupAt(Window* window, int x, int y) {
|
||||||
NativeWindow* nativeWindowViews =
|
NativeWindow* native_window = static_cast<NativeWindow*>(window->window());
|
||||||
static_cast<NativeWindow*>(window->window());
|
if (!native_window)
|
||||||
gfx::Point viewOrigin = nativeWindowViews->GetWebContents()
|
return;
|
||||||
->GetRenderWidgetHostView()->GetViewBounds().origin();
|
content::WebContents* web_contents = native_window->GetWebContents();
|
||||||
PopupAtPoint(window, gfx::Point(viewOrigin.x() + x, viewOrigin.y() + y));
|
if (!web_contents)
|
||||||
|
return;
|
||||||
|
content::RenderWidgetHostView* view = web_contents->GetRenderWidgetHostView();
|
||||||
|
if (!view)
|
||||||
|
return;
|
||||||
|
|
||||||
|
gfx::Point origin = view->GetViewBounds().origin();
|
||||||
|
PopupAtPoint(window, gfx::Point(origin.x() + x, origin.y() + y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuViews::PopupAtPoint(Window* window, gfx::Point point) {
|
void MenuViews::PopupAtPoint(Window* window, const gfx::Point& point) {
|
||||||
views::MenuRunner menu_runner(
|
views::MenuRunner menu_runner(
|
||||||
model(),
|
model(),
|
||||||
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS);
|
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS);
|
||||||
|
|
|
@ -21,7 +21,8 @@ class MenuViews : public Menu {
|
||||||
virtual void PopupAt(Window* window, int x, int y) OVERRIDE;
|
virtual void PopupAt(Window* window, int x, int y) OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PopupAtPoint(Window* window, gfx::Point point);
|
void PopupAtPoint(Window* window, const gfx::Point& point);
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MenuViews);
|
DISALLOW_COPY_AND_ASSIGN(MenuViews);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue