Bug 1354078 - update labels for customization context menus for Photon, r=bgrins
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 24 May 2017 11:17:54 +0100
changeset 409106 1ff36fd8109735209ac0888d30e1ffbf37a20076
parent 409105 fd1d772083aacbddb21a0bb23dfe85eb49fb3d8d
child 409107 741ff163078d8904b162803157a5f4eb9689476a
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1354078
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1354078 - update labels for customization context menus for Photon, r=bgrins MozReview-Commit-ID: 1qMCkzxuT4M
browser/base/content/browser.xul
browser/components/customizableui/content/panelUI.inc.xul
browser/components/customizableui/content/panelUI.js
browser/locales/en-US/chrome/browser/browser.dtd
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -328,16 +328,18 @@
       <toolbarbutton label="&sidebarMenuClose.label;"
                      class="subviewbutton"
                      oncommand="SidebarUI.hide()"/>
     </panel>
 
     <menupopup id="toolbar-context-menu"
                onpopupshowing="onViewToolbarsPopupShowing(event, document.getElementById('viewToolbarsMenuSeparator'));">
       <menuitem oncommand="gCustomizeMode.addToPanel(document.popupNode)"
+                photonaccesskey="&customizeMenu.pinToOverflowMenu.accesskey;"
+                photonlabel="&customizeMenu.pinToOverflowMenu.label;"
                 accesskey="&customizeMenu.moveToPanel.accesskey;"
                 label="&customizeMenu.moveToPanel.label;"
                 contexttype="toolbaritem"
                 class="customize-context-moveToPanel"/>
       <menuitem oncommand="gCustomizeMode.removeFromArea(document.popupNode)"
                 accesskey="&customizeMenu.removeFromToolbar.accesskey;"
                 label="&customizeMenu.removeFromToolbar.label;"
                 contexttype="toolbaritem"
--- a/browser/components/customizableui/content/panelUI.inc.xul
+++ b/browser/components/customizableui/content/panelUI.inc.xul
@@ -453,37 +453,43 @@
     </popupnotificationcontent>
   </popupnotification>
 </panel>
 
 <menupopup id="customizationPanelItemContextMenu">
   <menuitem oncommand="gCustomizeMode.addToToolbar(document.popupNode)"
             closemenu="single"
             class="customize-context-moveToToolbar"
+            photonaccesskey="&customizeMenu.unpinFromOverflowMenu.accesskey;"
+            photonlabel="&customizeMenu.unpinFromOverflowMenu.label;"
             accesskey="&customizeMenu.moveToToolbar.accesskey;"
             label="&customizeMenu.moveToToolbar.label;"/>
   <menuitem oncommand="gCustomizeMode.removeFromArea(document.popupNode)"
             closemenu="single"
             class="customize-context-removeFromPanel"
+            photonaccesskey="&customizeMenu.removeFromToolbar.accesskey;"
+            photonlabel="&customizeMenu.removeFromToolbar.label;"
             accesskey="&customizeMenu.removeFromMenu.accesskey;"
             label="&customizeMenu.removeFromMenu.label;"/>
   <menuseparator/>
   <menuitem command="cmd_CustomizeToolbars"
             class="viewCustomizeToolbar"
             accesskey="&viewCustomizeToolbar.accesskey;"
             label="&viewCustomizeToolbar.label;"/>
 </menupopup>
 
 <menupopup id="customizationPaletteItemContextMenu">
   <menuitem oncommand="gCustomizeMode.addToToolbar(document.popupNode)"
             class="customize-context-addToToolbar"
             accesskey="&customizeMenu.addToToolbar.accesskey;"
             label="&customizeMenu.addToToolbar.label;"/>
   <menuitem oncommand="gCustomizeMode.addToPanel(document.popupNode)"
             class="customize-context-addToPanel"
+            photonaccesskey="&customizeMenu.addToOverflowMenu.accesskey;"
+            photonlabel="&customizeMenu.addToOverflowMenu.label;"
             accesskey="&customizeMenu.addToPanel.accesskey;"
             label="&customizeMenu.addToPanel.label;"/>
 </menupopup>
 
 <menupopup id="customizationPanelContextMenu">
   <menuitem command="cmd_CustomizeToolbars"
             accesskey="&customizeMenu.addMoreItems.accesskey;"
             label="&customizeMenu.addMoreItems.label;"/>
--- a/browser/components/customizableui/content/panelUI.js
+++ b/browser/components/customizableui/content/panelUI.js
@@ -65,26 +65,28 @@ const PanelUI = {
     window.matchMedia("(-moz-overlay-scrollbars)").addListener(this._overlayScrollListenerBoundFn);
     CustomizableUI.addListener(this);
 
     for (let event of this.kEvents) {
       this.notificationPanel.addEventListener(event, this);
     }
 
     this._initPhotonPanel();
+    this._updateContextMenuLabels();
     Services.obs.notifyObservers(null, "appMenu-notifications-request", "refresh");
 
     this._initialized = true;
   },
 
   reinit() {
     this._removeEventListeners();
     // If the Photon pref changes, we need to re-init our element references.
     this._initElements();
     this._initPhotonPanel();
+    this._updateContextMenuLabels();
     delete this._readyPromise;
     this._isReady = false;
   },
 
   // We do this sync on init because in order to have the overflow button show up
   // we need to know whether anything is in the permanent panel area.
   _initPhotonPanel() {
     if (gPhotonStructure) {
@@ -109,16 +111,42 @@ const PanelUI = {
       let id = v;
       this.__defineGetter__(getKey, function() {
         delete this[getKey];
         return this[getKey] = document.getElementById(id);
       });
     }
   },
 
+  _updateContextMenuLabels() {
+    const kContextMenus = [
+      "customizationPanelItemContextMenu",
+      "customizationPaletteItemContextMenu",
+      "toolbar-context-menu",
+    ];
+    for (let menuId of kContextMenus) {
+      let menu = document.getElementById(menuId);
+      if (gPhotonStructure) {
+        let items = menu.querySelectorAll("menuitem[photonlabel]");
+        for (let item of items) {
+          item.setAttribute("nonphotonlabel", item.getAttribute("label"));
+          item.setAttribute("nonphotonaccesskey", item.getAttribute("accesskey"));
+          item.setAttribute("label", item.getAttribute("photonlabel"));
+          item.setAttribute("accesskey", item.getAttribute("photonaccesskey"));
+        }
+      } else {
+        let items = menu.querySelectorAll("menuitem[nonphotonlabel]");
+        for (let item of items) {
+          item.setAttribute("label", item.getAttribute("nonphotonlabel"));
+          item.setAttribute("accesskey", item.getAttribute("nonphotonaccesskey"));
+        }
+      }
+    }
+  },
+
   _eventListenersAdded: false,
   _ensureEventListenersAdded() {
     if (this._eventListenersAdded)
       return;
     this._addEventListeners();
   },
 
   _addEventListeners() {
--- a/browser/locales/en-US/chrome/browser/browser.dtd
+++ b/browser/locales/en-US/chrome/browser/browser.dtd
@@ -379,25 +379,36 @@ These should match what Safari and other
 <!ENTITY appMenuRemoteTabs.signin.label "Sign in to Sync">
 <!ENTITY appMenuRemoteTabs.managedevices.label "Manage Devices…">
 <!ENTITY appMenuRemoteTabs.sidebar.label "View Synced Tabs Sidebar">
 
 <!ENTITY customizeMenu.addToToolbar.label "Add to Toolbar">
 <!ENTITY customizeMenu.addToToolbar.accesskey "A">
 <!ENTITY customizeMenu.addToPanel.label "Add to Menu">
 <!ENTITY customizeMenu.addToPanel.accesskey "M">
+<!-- LOCALIZATION NOTE (customizeMenu.addToOverflowMenu.label,
+     customizeMenu.pinToOverflowMenu.label, customizeMenu.unpinFromOverflowMenu.label)
+     The overflow menu is the menu that appears if you click the chevron (>> button)
+     in the location bar. These labels are only used in Photon, where you can put
+     items into this menu permanently (pinned). -->
+<!ENTITY customizeMenu.addToOverflowMenu.label "Add to Overflow Menu">
+<!ENTITY customizeMenu.addToOverflowMenu.accesskey "M">
 <!ENTITY customizeMenu.moveToToolbar.label "Move to Toolbar">
 <!ENTITY customizeMenu.moveToToolbar.accesskey "o">
-<!-- LOCALIZATION NOTE (customizeMenu.moveToPanel.accesskey) can appear on the
-     same context menu as menubarCmd and personalbarCmd, so they should have
-     different access keys. customizeMenu.moveToToolbar and 
+<!-- LOCALIZATION NOTE (customizeMenu.moveToPanel.accesskey, customizeMenu.pinToOverflowMenu.accesskey)
+     can appear on the same context menu as menubarCmd and personalbarCmd,
+     so they should have different access keys. customizeMenu.moveToToolbar and
      customizeMenu.moveToPanel are mutually exclusive, so can share access
      keys.  -->
 <!ENTITY customizeMenu.moveToPanel.label "Move to Menu">
 <!ENTITY customizeMenu.moveToPanel.accesskey "o">
+<!ENTITY customizeMenu.pinToOverflowMenu.label "Pin to Overflow Menu">
+<!ENTITY customizeMenu.pinToOverflowMenu.accesskey "P">
+<!ENTITY customizeMenu.unpinFromOverflowMenu.label "Unpin from Overflow Menu">
+<!ENTITY customizeMenu.unpinFromOverflowMenu.accesskey "U">
 <!ENTITY customizeMenu.removeFromToolbar.label "Remove from Toolbar">
 <!ENTITY customizeMenu.removeFromToolbar.accesskey "R">
 <!ENTITY customizeMenu.removeFromMenu.label "Remove from Menu">
 <!ENTITY customizeMenu.removeFromMenu.accesskey "R">
 <!ENTITY customizeMenu.addMoreItems.label "Add More Items…">
 <!ENTITY customizeMenu.addMoreItems.accesskey "A">
 
 <!-- LOCALIZATION NOTE (moreMenu.label) This label is used in the new Photon