Bug 1890718 - remove hamburger menu mainview inline command listeners, r=mossop

Differential Revision: https://phabricator.services.mozilla.com/D207120
This commit is contained in:
Gijs Kruitbosch
2024-04-15 14:45:51 +00:00
parent bee5c98c47
commit 9d2dbb58f2
2 changed files with 56 additions and 16 deletions

View File

@@ -132,6 +132,7 @@ const PanelUI = {
"ViewShowing",
this._onHelpViewShow
);
this.mainView.addEventListener("command", this);
this._eventListenersAdded = true;
},
@@ -143,6 +144,7 @@ const PanelUI = {
document,
"PanelUI-helpView"
).removeEventListener("ViewShowing", this._onHelpViewShow);
this.mainView.removeEventListener("command", this);
this._eventListenersAdded = false;
},
@@ -299,6 +301,54 @@ const PanelUI = {
case "activate":
this.updateNotifications();
break;
case "command":
this.onCommand(aEvent);
break;
}
},
// Note that we listen for bubbling command events. In the case where the
// button that the user clicks has a command attribute, those events are
// redirected to the relevant command element, and we never see them in
// here. Bear this in mind if you want to write code that applies to
// all commands, for which this wouldn't work well.
onCommand(aEvent) {
let { target } = aEvent;
switch (target.id) {
case "appMenu-update-banner":
this._onBannerItemSelected(aEvent);
break;
case "appMenu-fxa-label2":
gSync.toggleAccountPanel(target, aEvent);
break;
case "appMenu-profiles-button":
gProfiles.updateView(target);
break;
case "appMenu-bookmarks-button":
BookmarkingUI.showSubView(target);
break;
case "appMenu-history-button":
this.showSubView("PanelUI-history", target);
break;
case "appMenu-passwords-button":
LoginHelper.openPasswordManager(window, { entryPoint: "mainmenu" });
break;
case "appMenu-fullscreen-button2":
// Note that we're custom-handling the hiding of the panel to make
// sure it disappears before entering fullscreen. Otherwise it can
// end up moving around on the screen during the fullscreen transition.
target.closest("panel").hidePopup();
setTimeout(() => BrowserCommands.fullScreen(), 0);
break;
case "appMenu-settings-button":
openPreferences();
break;
case "appMenu-more-button2":
this.showMoreToolsPanel(target);
break;
case "appMenu-help-button2":
this.showSubView("PanelUI-helpView", target);
break;
}
},