From 3591814a19a565baf1ba972549f601281ed7ada9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?D=C3=A3o=20Gottwald?=
Date: Sat, 31 Oct 2009 01:04:07 +0100
Subject: [PATCH] Bug 509298 - updateCurrentBrowser leaves focus in location
bar if no specific element is focused in that browser. r=enn, ui-r=beltzner
---
.../tests/mochitest/name_nsRootAcc_wnd.xul | 5 +++-
browser/base/content/tabbrowser.xml | 15 +++-------
browser/base/content/test/browser_tabfocus.js | 28 +++++++++----------
3 files changed, 21 insertions(+), 27 deletions(-)
diff --git a/accessible/tests/mochitest/name_nsRootAcc_wnd.xul b/accessible/tests/mochitest/name_nsRootAcc_wnd.xul
index 528f9750e64..70efbe5695d 100644
--- a/accessible/tests/mochitest/name_nsRootAcc_wnd.xul
+++ b/accessible/tests/mochitest/name_nsRootAcc_wnd.xul
@@ -21,7 +21,10 @@
isBusy: false,
setOverLink: function (link, b) {
}
- }
+ };
+ var gFindBar = {
+ hidden: true
+ };
////////////////////////////////////////////////////////////////////////////
// Invoker implementation.
diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml
index b97ccb01386..a39de196a2f 100644
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -872,10 +872,6 @@
this._lastRelatedTab = null;
- var fm = Components.classes["@mozilla.org/focus-manager;1"].
- getService(Components.interfaces.nsIFocusManager);
- var focusedChromeElement = fm.getFocusedElementForWindow(window, false, {});
-
var oldBrowser = this.mCurrentBrowser;
if (oldBrowser)
oldBrowser.setAttribute("type", "content-targetable");
@@ -970,13 +966,10 @@
event.initEvent("TabSelect", true, false);
this.mCurrentTab.dispatchEvent(event);
- // change focus to the new tab if nothing is focused, the old tab
- // is focused or there is something in the new tab to focus. One
- // specific case where focus is not changed is when the new tab
- // has no focused element and a chrome element is focused.
- if ((!focusedChromeElement || focusedChromeElement == oldBrowser ||
- fm.getFocusedElementForWindow(window.content, true, {})))
- fm.setFocus(newBrowser, fm.FLAG_NOSCROLL);
+ // Change focus to the new browser unless the findbar is focused.
+ if (gFindBar.hidden ||
+ gFindBar.getElement("findbar-textbox").getAttribute("focused") != "true")
+ newBrowser.focus();
}
]]>