Bug 1297738 - Removing accesskey from container menus that are not accessible via a keyboard r=Gijs
☠☠ backed out by 788b9b276f65 ☠ ☠
authorJonathan Kingston <jkt@mozilla.com>
Thu, 24 Nov 2016 15:05:06 +0000
changeset 324371 bdaebda382c1a6a8e94bb5c3217dfc6be4d0358e
parent 324370 a468efda20dfb3a29bb37ef56292febd992bba4e
child 324372 b6d2c739857fc05296877c8f0ddf4d6748ccebb9
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersGijs
bugs1297738
milestone53.0a1
Bug 1297738 - Removing accesskey from container menus that are not accessible via a keyboard r=Gijs MozReview-Commit-ID: KKBw4k61H9N
browser/base/content/nsContextMenu.js
browser/base/content/tabbrowser.xml
browser/base/content/utilityOverlay.js
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -1845,12 +1845,15 @@ nsContextMenu.prototype = {
   _checkTelemetryForMenu: function(aXulMenu) {
     this._telemetryClickID = null;
     this._telemetryPageContext = this._getTelemetryPageContextInfo();
     this._telemetryHadCustomItems = this.hasPageMenu;
     this._getTelemetryClickInfo(aXulMenu);
   },
 
   createContainerMenu: function(aEvent) {
-    return createUserContextMenu(aEvent, true,
-                                 gContextMenuContentData.userContextId);
+    let createMenuOptions = {
+      iscontextMenu: true,
+      excludeUserContextId: gContextMenuContentData.userContextId,
+    };
+    return createUserContextMenu(aEvent, createMenuOptions);
   },
 };
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -7137,25 +7137,25 @@
         ]]></body>
       </method>
     </implementation>
 
     <handlers>
       <handler event="popupshowing">
       <![CDATA[
         if (event.target.getAttribute("id") == "alltabs_containersMenuTab") {
-          createUserContextMenu(event);
+          createUserContextMenu(event, {useAccessKeys: false});
           return;
         }
 
         let containersEnabled = Services.prefs.getBoolPref("privacy.userContext.enabled");
 
         if (event.target.getAttribute("anonid") == "newtab-popup" ||
             event.target.id == "newtab-popup") {
-          createUserContextMenu(event);
+          createUserContextMenu(event, {useAccessKeys: false});
         } else {
           document.getElementById("alltabs-popup-separator-1").hidden = !containersEnabled;
           let containersTab = document.getElementById("alltabs_containersTab");
 
           containersTab.hidden = !containersEnabled;
           if (PrivateBrowsingUtils.isWindowPrivate(window)) {
             containersTab.setAttribute("disabled", "true");
           }
--- a/browser/base/content/utilityOverlay.js
+++ b/browser/base/content/utilityOverlay.js
@@ -444,17 +444,21 @@ function checkForMiddleClick(node, event
     // If the middle-click was on part of a menu, close the menu.
     // (Menus close automatically with left-click but not with middle-click.)
     closeMenus(event.target);
   }
 }
 
 // Populate a menu with user-context menu items. This method should be called
 // by onpopupshowing passing the event as first argument.
-function createUserContextMenu(event, isContextMenu = false, excludeUserContextId = 0) {
+function createUserContextMenu(event, {
+                                        isContextMenu = false,
+                                        excludeUserContextId = 0,
+                                        useAccessKeys = true
+                                      } = {}) {
   while (event.target.hasChildNodes()) {
     event.target.removeChild(event.target.firstChild);
   }
 
   let bundle = document.getElementById("bundle_browser");
   let docfrag = document.createDocumentFragment();
 
   // If we are excluding a userContextId, we want to add a 'no-container' item.
@@ -478,17 +482,17 @@ function createUserContextMenu(event, is
     if (identity.userContextId == excludeUserContextId) {
       return;
     }
 
     let menuitem = document.createElement("menuitem");
     menuitem.setAttribute("data-usercontextid", identity.userContextId);
     menuitem.setAttribute("label", ContextualIdentityService.getUserContextLabel(identity.userContextId));
 
-    if (identity.accessKey) {
+    if (identity.accessKey && useAccessKeys) {
       menuitem.setAttribute("accesskey", bundle.getString(identity.accessKey));
     }
 
     menuitem.classList.add("menuitem-iconic");
     menuitem.setAttribute("data-identity-color", identity.color);
 
     if (!isContextMenu) {
       menuitem.setAttribute("command", "Browser:NewUserContextTab");
@@ -500,18 +504,20 @@ function createUserContextMenu(event, is
   });
 
   if (!isContextMenu) {
     docfrag.appendChild(document.createElement("menuseparator"));
 
     let menuitem = document.createElement("menuitem");
     menuitem.setAttribute("label",
                           bundle.getString("userContext.aboutPage.label"));
-    menuitem.setAttribute("accesskey",
-                          bundle.getString("userContext.aboutPage.accesskey"));
+    if (useAccessKeys) {
+      menuitem.setAttribute("accesskey",
+                            bundle.getString("userContext.aboutPage.accesskey"));
+    }
     menuitem.setAttribute("command", "Browser:OpenAboutContainers");
     docfrag.appendChild(menuitem);
   }
 
   event.target.appendChild(docfrag);
   return true;
 }