Bug 1909074. Don't pass OFFSET_BY_ORIGIN to GetResultingTransformMatrix when it's...
[gecko.git] / browser / base / content / browser-menubar.js
blobeabcac0673c85278a90d45caf359b80319f4b545
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /* eslint-env mozilla/browser-window */
8 document.addEventListener(
9   "DOMContentLoaded",
10   () => {
11     let mainMenuBar = document.getElementById("main-menubar");
13     mainMenuBar.addEventListener("command", event => {
14       switch (event.target.id) {
15         // == edit-menu ==
16         case "menu_preferences":
17           openPreferences(undefined);
18           break;
20         // == view-menu ==
21         case "menu_pageStyleNoStyle":
22           gPageStyleMenu.disableStyle();
23           break;
24         case "menu_pageStylePersistentOnly":
25           gPageStyleMenu.switchStyleSheet(null);
26           break;
27         case "repair-text-encoding":
28           BrowserCommands.forceEncodingDetection();
29           break;
30         case "documentDirection-swap":
31           gBrowser.selectedBrowser.sendMessageToActor(
32             "SwitchDocumentDirection",
33             {},
34             "SwitchDocumentDirection",
35             "roots"
36           );
37           break;
39         // == history-menu ==
40         case "sync-tabs-menuitem":
41           gSync.openSyncedTabsPanel();
42           break;
43         case "hiddenTabsMenu":
44           gTabsPanel.showHiddenTabsPanel(event, "hidden-tabs-menuitem");
45           break;
46         case "sync-setup":
47           gSync.openPrefs("menubar");
48           break;
49         case "sync-enable":
50           gSync.openPrefs("menubar");
51           break;
52         case "sync-unverifieditem":
53           gSync.openPrefs("menubar");
54           break;
55         case "sync-syncnowitem":
56           gSync.doSync(event);
57           break;
58         case "sync-reauthitem":
59           gSync.openSignInAgainPage("menubar");
60           break;
61         case "menu_openFirefoxView":
62           FirefoxViewHandler.openTab();
63           break;
65         // == menu_HelpPopup ==
66         // (Duplicated in PanelUI._onHelpCommand)
67         case "menu_openHelp":
68           openHelpLink("firefox-help");
69           break;
70         case "menu_layout_debugger":
71           toOpenWindowByType(
72             "mozapp:layoutdebug",
73             "chrome://layoutdebug/content/layoutdebug.xhtml"
74           );
75           break;
76         case "feedbackPage":
77           openFeedbackPage();
78           break;
79         case "helpSafeMode":
80           safeModeRestart();
81           break;
82         case "troubleShooting":
83           openTroubleshootingPage();
84           break;
85         case "help_reportSiteIssue":
86           ReportSiteIssue();
87           break;
88         case "menu_HelpPopup_reportPhishingtoolmenu":
89           openUILink(gSafeBrowsing.getReportURL("Phish"), event, {
90             triggeringPrincipal:
91               Services.scriptSecurityManager.createNullPrincipal({}),
92           });
93           break;
94         case "menu_HelpPopup_reportPhishingErrortoolmenu":
95           ReportFalseDeceptiveSite();
96           break;
97         case "helpSwitchDevice":
98           openSwitchingDevicesPage();
99           break;
100         case "aboutName":
101           openAboutDialog();
102           break;
103         case "helpPolicySupport":
104           openTrustedLinkIn(Services.policies.getSupportMenu().URL.href, "tab");
105           break;
106       }
107     });
109     document
110       .getElementById("historyMenuPopup")
111       .addEventListener("command", event => {
112         // Handle commands/clicks on the descending menuitems that are
113         // history entries.
114         let historyMenu = document.getElementById("history-menu");
115         historyMenu._placesView._onCommand(event);
116       });
118     mainMenuBar.addEventListener("popupshowing", event => {
119       // On macOS, we don't track whether activation of the native menubar happened
120       // with the keyboard.
121       if (AppConstants.platform != "macosx") {
122         // We only set the "openedwithkey" if a specific menu like "Edit" was opened
123         // instead of the general menu bar. (e.g. Alt+E instead of just Alt)
124         if (event.target.parentNode.parentNode == this) {
125           this.setAttribute(
126             "openedwithkey",
127             event.target.parentNode.openedWithKey
128           );
129         }
130       }
132       switch (event.target.id) {
133         case "menu_FilePopup":
134           gFileMenu.onPopupShowing(event);
135           break;
136         case "menu_newUserContextPopup":
137           createUserContextMenu(event);
138           break;
139         case "menu_EditPopup":
140           updateEditUIVisibility();
141           break;
142         case "view-menu-popup":
143           onViewToolbarsPopupShowing(event);
144           break;
145         case "pageStyleMenuPopup":
146           gPageStyleMenu.fillPopup(event.target);
147           break;
148         case "historyMenuPopup":
149           if (!event.target.parentNode._placesView) {
150             new HistoryMenu(event);
151           }
152           break;
153         case "historyUndoPopup":
154           document
155             .getElementById("history-menu")
156             ._placesView.populateUndoSubmenu();
157           break;
158         case "historyUndoWindowPopup":
159           document
160             .getElementById("history-menu")
161             ._placesView.populateUndoWindowSubmenu();
162           break;
163         case "bookmarksMenuPopup":
164           BookmarkingUI.onMainMenuPopupShowing(event);
165           if (!event.target.parentNode._placesView) {
166             new PlacesMenu(
167               event,
168               `place:parent=${PlacesUtils.bookmarks.menuGuid}`
169             );
170           }
171           break;
172         case "bookmarksToolbarFolderPopup":
173           if (!event.target.parentNode._placesView) {
174             new PlacesMenu(
175               event,
176               `place:parent=${PlacesUtils.bookmarks.toolbarGuid}`
177             );
178           }
179           break;
180         case "otherBookmarksFolderPopup":
181           if (!event.target.parentNode._placesView) {
182             new PlacesMenu(
183               event,
184               `place:parent=${PlacesUtils.bookmarks.unfiledGuid}`
185             );
186           }
187           break;
188         case "mobileBookmarksFolderPopup":
189           if (!event.target.parentNode._placesView) {
190             new PlacesMenu(
191               event,
192               `place:parent=${PlacesUtils.bookmarks.mobileGuid}`
193             );
194           }
195           break;
196         case "menu_HelpPopup":
197           buildHelpMenu();
198           break;
199       }
200     });
202     document
203       .getElementById("menu_EditPopup")
204       .addEventListener("popuphidden", () => {
205         updateEditUIVisibility();
206       });
207   },
208   { once: true }