Bug 1612720 - Port |Bug 461013 - get rid of |aTab.localName != "tab"| checks in removeAllTabsBut, removeTab and reloadTab| and tidy up. r=frg
authorIan Neal <iann_cvs@blueyonder.co.uk>
Wed, 18 Mar 2020 23:44:02 +0100
changeset 38525 fd76d1b09482266776695945e291fa484ac30ef7
parent 38524 8c6e06c57b4ed35172cb8d63f404fcd37bf86c24
child 38526 9f3138103f30f5064f4e860eb958dd60d22a2b37
push id400
push userclokep@gmail.com
push dateMon, 04 May 2020 18:56:09 +0000
reviewersfrg
bugs1612720, 461013
Bug 1612720 - Port |Bug 461013 - get rid of |aTab.localName != "tab"| checks in removeAllTabsBut, removeTab and reloadTab| and tidy up. r=frg
suite/browser/tabbrowser.xml
--- a/suite/browser/tabbrowser.xml
+++ b/suite/browser/tabbrowser.xml
@@ -1106,26 +1106,27 @@
             // 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.includes("tabbrowser-undoclosetab")) {
-                menuitem.setAttribute("disabled", (this.usePrivateBrowsing ?
+                menuitem.disabled = (this.usePrivateBrowsing ?
                     this.savedBrowsers.length :
-                    this.mSessionStore.getClosedTabCount(window)) == 0);
+                    this.mSessionStore.getClosedTabCount(window)) == 0;
                 menuitem.hidden = (this.usePrivateBrowsing ||
                                    Services.prefs.getIntPref("browser.sessionstore.max_tabs_undo") <= 0) &&
                                   Services.prefs.getIntPref("browser.tabs.max_tabs_undo") <= 0;
               }
               else
-                menuitem.setAttribute("disabled", tbattr.includes("tabbrowser-multiple") && !isMultiple ||
-                                                  tbattr.includes("tabbrowser-tab") && !isTab)
+                menuitem.disabled =
+                    (tbattr.includes("tabbrowser-multiple") && !isMultiple) ||
+                    (tbattr.includes("tabbrowser-tab") && !isTab);
             }
           ]]>
         </body>
       </method>
 
       <field name="mAeroPeek">false</field>
 
       <method name="updateCurrentBrowser">
@@ -1737,20 +1738,17 @@
                                                             warnOnClose);
                 reallyClose = (buttonPressed == 0);
                 //don't set the pref unless they press OK and it's false
                 if (reallyClose && !warnOnClose.value)
                   Services.prefs.setBoolPref(closeOtherTabsPref, false);
               }
 
               if (reallyClose) {
-                if (aTab.localName != "tab")
-                  aTab = this.mCurrentTab;
-                else
-                  this.tabContainer.selectedItem = aTab;
+                this.selectedTab = aTab;
 
                 for (var i = this.tabs.length - 1; i >= 0; --i) {
                   if (this.tabs[i] != aTab)
                     this.removeTab(this.tabs[i]);
                 }
               }
             }
           ]]>
@@ -1860,19 +1858,16 @@
 
       <method name="removeTab">
         <parameter name="aTab"/>
         <parameter name="aParams"/>
         <body>
           <![CDATA[
             this.mLastRelatedIndex = 0;
 
-            if (aTab.localName != "tab")
-              aTab = this.mCurrentTab;
-
             if (!aParams) {
               aParams = {
                 animate: false,
                 disableUndo: false
               };
             }
 
             var oldBrowser = aTab.linkedBrowser;
@@ -2072,20 +2067,17 @@
           ]]>
         </body>
       </method>
 
       <method name="reloadTab">
         <parameter name="aTab"/>
         <body>
           <![CDATA[
-            if (aTab.localName != "tab")
-              aTab = this.mCurrentTab;
-
-            aTab.linkedBrowser.reload();
+            this.getBrowserForTab(aTab).reload();
           ]]>
         </body>
       </method>
 
       <method name="addProgressListener">
         <parameter name="aListener"/>
         <body>
           <![CDATA[
@@ -2179,18 +2171,16 @@
         ]]>
         </body>
       </method>
 
       <method name="getBrowserForTab">
         <parameter name="aTab"/>
         <body>
           <![CDATA[
-            if (aTab.localName != "tab")
-              return null;
             return aTab.linkedBrowser;
           ]]>
         </body>
       </method>
 
       <method name="getBrowserForOuterWindowID">
         <parameter name="aID"/>
         <body>