From 984462be447593a1a7fe64964105b51a3154b344 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 22 Jan 2016 11:59:08 -0700 Subject: [PATCH] Remove Menu::Popup --- atom/browser/api/atom_api_menu.cc | 7 +------ atom/browser/api/atom_api_menu.h | 1 - atom/browser/api/lib/menu.js | 15 +++++++++------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/atom/browser/api/atom_api_menu.cc b/atom/browser/api/atom_api_menu.cc index ec565073900..e40ba17f464 100644 --- a/atom/browser/api/atom_api_menu.cc +++ b/atom/browser/api/atom_api_menu.cc @@ -69,10 +69,6 @@ void Menu::MenuWillShow(ui::SimpleMenuModel* source) { menu_will_show_.Run(); } -void Menu::Popup(Window* window) { - PopupAt(window); -} - void Menu::InsertItemAt( int index, int command_id, const base::string16& label) { model_->InsertItemAt(index, command_id, label); @@ -173,8 +169,7 @@ void Menu::BuildPrototype(v8::Isolate* isolate, .SetMethod("isItemCheckedAt", &Menu::IsItemCheckedAt) .SetMethod("isEnabledAt", &Menu::IsEnabledAt) .SetMethod("isVisibleAt", &Menu::IsVisibleAt) - .SetMethod("_popup", &Menu::Popup) - .SetMethod("_popupAt", &Menu::PopupAt); + .SetMethod("popupAt", &Menu::PopupAt); } } // namespace api diff --git a/atom/browser/api/atom_api_menu.h b/atom/browser/api/atom_api_menu.h index 18cfae6a348..1ae708863a7 100644 --- a/atom/browser/api/atom_api_menu.h +++ b/atom/browser/api/atom_api_menu.h @@ -51,7 +51,6 @@ class Menu : public mate::TrackableObject, void ExecuteCommand(int command_id, int event_flags) override; void MenuWillShow(ui::SimpleMenuModel* source) override; - void Popup(Window* window); virtual void PopupAt(Window* window, int x = -1, int y = -1, int positioning_item = 0) = 0; diff --git a/atom/browser/api/lib/menu.js b/atom/browser/api/lib/menu.js index 506922fd4a8..62c771af6c6 100644 --- a/atom/browser/api/lib/menu.js +++ b/atom/browser/api/lib/menu.js @@ -159,17 +159,20 @@ Menu.prototype._init = function() { }; Menu.prototype.popup = function(window, x, y, positioningItem) { - if ((window != null ? window.constructor : void 0) !== BrowserWindow) { + if (typeof window != 'object' || window.constructor !== BrowserWindow) { // Shift. + positioningItem = y; y = x; x = window; window = BrowserWindow.getFocusedWindow(); } - if ((x != null) && (y != null)) { - return this._popupAt(window, x, y, positioningItem || 0); - } else { - return this._popup(window); - } + + // Default parameters. + if (typeof x !== 'number') x = -1; + if (typeof y !== 'number') y = -1; + if (typeof positioningItem !== 'number') positioningItem = 0; + + this.popupAt(window, x, y, positioningItem); }; Menu.prototype.append = function(item) {