Bug 1404651 - keep focus in the tabstrip when the focus has shifted with the arrow keys, r=dao
☠☠ backed out by 6771bdd9b24e ☠ ☠
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 04 Oct 2017 13:29:53 +0100
changeset 428030 6bec02f9a646f11777dbc12ceeb90af76198242d
parent 428029 c02a1d8cfbe195fb7247ed6948fa2d6dabf3fd09
child 428031 8388d2ebc0d04bada3c9d3f44b1deef6a3a28a6f
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewersdao
bugs1404651
milestone58.0a1
Bug 1404651 - keep focus in the tabstrip when the focus has shifted with the arrow keys, r=dao MozReview-Commit-ID: Brm9jImW9bc
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -1418,23 +1418,21 @@
           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.
-            newTab.focus();
-          } else if (gMultiProcessBrowser && document.activeElement !== newBrowser) {
-
+          let activeEl = document.activeElement;
+          // In e10s, if focus isn't already in the tabstrip or on the new browser,
+          // and the new browser's previous focus wasn't in the url bar but focus is
+          // there now, we need to adjust focus further.
+          if (gMultiProcessBrowser && activeEl != newBrowser && activeEl != newTab) {
             let keepFocusOnUrlBar = newBrowser &&
                                     newBrowser._urlbarFocused &&
                                     gURLBar &&
                                     gURLBar.focused;
             if (!keepFocusOnUrlBar) {
               // Clear focus so that _adjustFocusAfterTabSwitch can detect if
               // some element has been focused and respect that.
               document.activeElement.blur();