Bug 669207 right click in the empty part of the tabbar doesn't produce menu r=Neil.
authorPhilip Chee <philip.chee@gmail.com>
Wed, 02 Jan 2013 11:32:52 +0800
changeset 11767 470f14ee6470da414b173ed46db2ae1fbffbf45e
parent 11766 769d60c09681a5db9285128d999edb7fa794d9eb
child 11768 fb8ce692fcab80862820574ab0523314105e5156
push id8764
push userphilip.chee@gmail.com
push dateWed, 02 Jan 2013 03:34:32 +0000
treeherdercomm-central@470f14ee6470 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs669207
Bug 669207 right click in the empty part of the tabbar doesn't produce menu r=Neil.
suite/browser/tabbrowser.xml
--- a/suite/browser/tabbrowser.xml
+++ b/suite/browser/tabbrowser.xml
@@ -34,40 +34,43 @@
                   ondragleave="this.parentNode.parentNode._onDragLeave(event);">
           <xul:tooltip onpopupshowing="event.stopPropagation(); return this.parentNode.parentNode.parentNode.doPreview(this);"
                        onpopuphiding="this.parentNode.parentNode.parentNode.resetPreview(this);" orient="vertical">
             <xul:label class="tooltip-label" crop="right"/>
             <xul:label class="tooltip-label" hidden="true"><html:canvas class="tab-tooltip-canvas"/></xul:label>
           </xul:tooltip>
           <xul:menupopup anonid="tabContextMenu" onpopupshowing="return document.getBindingParent(this).updatePopupMenu(this);">
             <xul:menuitem label="&closeTab.label;" accesskey="&closeTab.accesskey;"
+                          tbattr="tabbrowser-tab"
                           oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode;
                                      tabbrowser.removeTab(tabbrowser.mContextTab);"/>
             <xul:menuitem label="&closeOtherTabs.label;" accesskey="&closeOtherTabs.accesskey;"
-                          tbattr="tabbrowser-multiple"
+                          tbattr="tabbrowser-multiple tabbrowser-tab"
                           oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode;
                                      tabbrowser.removeAllTabsBut(tabbrowser.mContextTab);"/>
             <xul:menuseparator/>
             <xul:menuitem label="&newTab.label;" accesskey="&newTab.accesskey;"
                           xbl:inherits="oncommand=onnewtab"/>
-            <xul:menuitem label="&undoCloseTab.label;" accesskey="&undoCloseTab.accesskey;" tbattr="tabbrowser-undoclosetab"
+            <xul:menuitem label="&undoCloseTab.label;" accesskey="&undoCloseTab.accesskey;"
+                          tbattr="tabbrowser-undoclosetab"
                           oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode;
                                      tabbrowser.undoCloseTab(0);"/>
             <xul:menuseparator/>
             <xul:menuitem label="&bookmarkGroup.label;" accesskey="&bookmarkGroup.accesskey;"
                           tbattr="tabbrowser-multiple"
                           xbl:inherits="oncommand=onbookmarkgroup"/>
             <xul:menuseparator/>
             <xul:menuitem label="&reloadTab.label;" accesskey="&reloadTab.accesskey;"
+                          tbattr="tabbrowser-tab"
                           oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode;
                                      tabbrowser.reloadTab(tabbrowser.mContextTab);"/>
             <xul:menuitem label="&reloadAllTabs.label;" accesskey="&reloadAllTabs.accesskey;"
                           tbattr="tabbrowser-multiple"
                           oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode;
-                                     tabbrowser.reloadAllTabs(tabbrowser.mContextTab);"/>
+                                     tabbrowser.reloadAllTabs();"/>
           </xul:menupopup>
 
           <xul:tabs class="tabbrowser-tabs" closebutton="true" flex="1"
                     anonid="tabcontainer"
                     tooltiptextnew="&newTabButton.tooltip;"
                     tooltiptextclose="&closeTabButton.tooltip;"
                     tooltiptextalltabs="&listAllTabs.tooltip;"
                     setfocus="false"
@@ -916,30 +919,32 @@
         </body>
       </method>
 
       <method name="updatePopupMenu">
         <parameter name="aPopupMenu"/>
         <body>
           <![CDATA[
             this.mContextTab = document.popupNode;
-            // The user might right-click on a non-tab area of the tab strip.
-            if (this.mContextTab.localName != "tab")
-              return false;
-
-            var disabled = this.tabs.length == 1;
-            var menuItems = aPopupMenu.getElementsByAttribute("tbattr", "tabbrowser-multiple");
-            for (var i = 0; i < menuItems.length; i++)
-              menuItems[i].setAttribute("disabled", disabled);
-
-            var undoItem = document.getAnonymousElementByAttribute(this, "tbattr", "tabbrowser-undoclosetab");
-            undoItem.setAttribute("disabled", this.mSessionStore.getClosedTabCount(window) == 0);
-            undoItem.hidden = this.mPrefs.getIntPref("browser.tabs.max_tabs_undo") <= 0 &&
-                              this.mPrefs.getIntPref("browser.sessionstore.max_tabs_undo") <= 0;
-            return true;
+            // The user might right-click on a tab or an empty part of the tabbar.
+            var isTab = this.mContextTab.localName == "tab";
+            var isMultiple = this.tabs.length > 1;
+            var menuItems = aPopupMenu.getElementsByAttribute("tbattr", "*");
+            for (let menuitem of menuItems) {
+              let tbattr = menuitem.getAttribute("tbattr");
+
+              if (tbattr.contains("tabbrowser-undoclosetab")) {
+                menuitem.setAttribute("disabled", this.mSessionStore.getClosedTabCount(window) == 0);
+                menuitem.hidden = this.mPrefs.getIntPref("browser.tabs.max_tabs_undo") <= 0 &&
+                                      this.mPrefs.getIntPref("browser.sessionstore.max_tabs_undo") <= 0;
+              }
+              else
+                menuitem.setAttribute("disabled", tbattr.contains("tabbrowser-multiple") && !isMultiple ||
+                                                  tbattr.contains("tabbrowser-tab") && !isTab)
+            }
           ]]>
         </body>
       </method>
 
       <method name="updateCurrentBrowser">
         <body>
           <![CDATA[
             // we only want to return to the parent tab if no other
@@ -2822,43 +2827,43 @@
         <xul:vbox>
           <xul:spacer flex="1"/>
           <xul:hbox class="tabs-bottom" align="center"/>
         </xul:vbox>
         <xul:vbox>
           <xul:hbox>
             <xul:stack>
               <xul:spacer class="tabs-left"/>
-              <xul:toolbarbutton class="tabs-newbutton"
+              <xul:toolbarbutton class="tabs-newbutton" context=""
                                  anonid="tabstrip-newbutton"
                                  xbl:inherits="oncommand=onnewtab,onclick=onnewtabclick,tooltiptext=tooltiptextnew"/>
             </xul:stack>
             <xul:arrowscrollbox anonid="arrowscrollbox"
                                 class="tabbrowser-arrowscrollbox"
                                 flex="1"
                                 xbl:inherits="smoothscroll"
                                 orient="horizontal"
                                 style="min-width: 1px;">
               <children includes="tab"/>
               <xul:spacer class="tabs-right" flex="1"/>
             </xul:arrowscrollbox>
             <children/>
             <xul:stack>
               <xul:spacer class="tabs-right"/>
               <xul:hbox class="tabs-closebutton-box" align="stretch" pack="end">
-                <xul:toolbarbutton class="tabs-alltabs-button"
+                <xul:toolbarbutton class="tabs-alltabs-button" context=""
                                    anonid="alltabs-button"
                                    type="menu"
                                    xbl:inherits="tooltiptext=tooltiptextalltabs">
                   <xul:menupopup class="tabs-alltabs-popup"
                                  anonid="alltabs-popup"
                                  position="after_end"/>
                 </xul:toolbarbutton>
                 <xul:hbox align="center">
-                  <xul:toolbarbutton class="tabs-closebutton close-button"
+                  <xul:toolbarbutton class="tabs-closebutton close-button" context=""
                                      anonid="tabstrip-closebutton"
                                      xbl:inherits="disabled=disableclose,oncommand=onclosetab,tooltiptext=tooltiptextclose"/>
                 </xul:hbox>
               </xul:hbox>
             </xul:stack>
           </xul:hbox>
           <xul:spacer class="tabs-bottom-spacer"/>
         </xul:vbox>