Bug 1081156 - [e10s] Switching tabs removes focus from the tab strip. r=mconley
authorDão Gottwald <dao@mozilla.com>
Wed, 15 Oct 2014 14:50:47 +0200
changeset 210438 465460a44f5f05ba5678143e3ccf52c2e74a7374
parent 210437 9c6cd6e14e74405ee3d2ce1030356b7bfbfffc1d
child 210439 31c202376ea813174fee0a425e691b730cc97b78
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmconley
bugs1081156
milestone36.0a1
Bug 1081156 - [e10s] Switching tabs removes focus from the tab strip. r=mconley
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -1175,41 +1175,43 @@
 
               oldBrowser._urlbarFocused = (gURLBar && gURLBar.focused);
               if (this.isFindBarInitialized(oldTab)) {
                 let findBar = this.getFindBar(oldTab);
                 oldTab._findBarFocused = (!findBar.hidden &&
                   findBar._findField.getAttribute("focused") == "true");
               }
 
+              // If focus is in the tab bar, retain it there.
+              if (document.activeElement == oldTab) {
+                // We need to explicitly focus the new tab, because
+                // tabbox.xml does this only in some cases.
+                this.mCurrentTab.focus();
+              }
+
               if (!gMultiProcessBrowser)
-                this._adjustFocusAfterTabSwitch(this.mCurrentTab, oldTab);
+                this._adjustFocusAfterTabSwitch(this.mCurrentTab);
             }
 
             this.tabContainer._setPositionalAttributes();
 
             if (!aForceUpdate)
               TelemetryStopwatch.finish("FX_TAB_SWITCH_UPDATE_MS");
           ]]>
         </body>
       </method>
 
       <method name="_adjustFocusAfterTabSwitch">
         <parameter name="newTab"/>
-        <parameter name="oldTab"/>
         <body><![CDATA[
         let newBrowser = this.getBrowserForTab(newTab);
 
-        // When focus is in the tab bar, retain it there.
-        if (document.activeElement == oldTab) {
-          // We need to explicitly focus the new tab, because
-          // tabbox.xml does this only in some cases.
-          this.mCurrentTab.focus();
+        // Don't steal focus from the tab bar.
+        if (document.activeElement == newTab)
           return;
-        }
 
         // If there's a tabmodal prompt showing, focus it.
         if (newBrowser.hasAttribute("tabmodalPromptShowing")) {
           let XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
           let prompts = newBrowser.parentNode.getElementsByTagNameNS(XUL_NS, "tabmodalprompt");
           let prompt = prompts[prompts.length - 1];
           prompt.Dialog.setDefaultFocus();
           return;
@@ -3314,17 +3316,17 @@
           }
         ]]></body>
       </method>
 
       <method name="_finalizeTabSwitch">
         <parameter name="toTab"/>
         <parameter name="fromTab"/>
         <body><![CDATA[
-          this._adjustFocusAfterTabSwitch(toTab, fromTab);
+          this._adjustFocusAfterTabSwitch(toTab);
           this._deactivateContent(fromTab);
 
           let toBrowser = this.getBrowserForTab(toTab);
           toBrowser.setAttribute("type", "content-primary");
 
           let fromBrowser = this.getBrowserForTab(fromTab);
           // It's possible that the tab we're switching from closed
           // before we were able to finalize, in which case, fromBrowser