diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 66904192aae..8c4761b88d3 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -2735,9 +2735,7 @@ function OpenSearch(tabName, searchStr, newTabFlag) loadURI(defaultSearchURL, null, null); } else { - var newTab = getBrowser().addTab(defaultSearchURL); - if (!gPrefService.getBoolPref("browser.tabs.loadInBackground")) - getBrowser().selectedTab = newTab; + getBrowser().loadOneTab(defaultSearchURL); } } } diff --git a/browser/components/bookmarks/content/bookmarks.js b/browser/components/bookmarks/content/bookmarks.js index bbf1d2f5040..af316d5a92b 100644 --- a/browser/components/bookmarks/content/bookmarks.js +++ b/browser/components/bookmarks/content/bookmarks.js @@ -742,8 +742,13 @@ var BookmarksCommand = { // focus the first tab if prefs say to if (!loadInBackground || doReplace) { // Select the first tab in the group. + // Set newly selected tab after quick timeout, otherwise hideous focus problems + // can occur because new presshell is not ready to handle events + function selectNewForegroundTab(browser, tab) { + browser.selectedTab = tab; + } var tabs = browser.mTabContainer.childNodes; - browser.selectedTab = tabs[index0]; + setTimeout(selectNewForegroundTab, 0, browser, tabs[index0]); } // Close any remaining open tabs that are left over. diff --git a/toolkit/content/contentAreaUtils.js b/toolkit/content/contentAreaUtils.js index 7e4db424168..0f53163b92d 100644 --- a/toolkit/content/contentAreaUtils.js +++ b/toolkit/content/contentAreaUtils.js @@ -76,9 +76,7 @@ function openNewTabWith(href, linkNode, event, securityCheck, postData, sendRefe // If sendReferrer is not specified, default to true var referrer = (sendReferrer == false) ? null : getReferrer(document); - var theTab = browser.addTab(href, referrer, originCharset, postData); - if (!loadInBackground) - browser.selectedTab = theTab; + browser.loadOneTab(href, referrer, originCharset, postData, loadInBackground); if (linkNode) markLinkVisited(href, linkNode); diff --git a/toolkit/content/widgets/tabbrowser.xml b/toolkit/content/widgets/tabbrowser.xml index 0a17aed512f..8eee4e3ae45 100644 --- a/toolkit/content/widgets/tabbrowser.xml +++ b/toolkit/content/widgets/tabbrowser.xml @@ -953,6 +953,30 @@ + + + + + + + + + + + @@ -1457,20 +1481,15 @@ this.dragDropSecurityCheck(aEvent, aDragSession, url); - var bgLoad = this.mPrefs.getBoolPref("browser.tabs.loadInBackground"); - - var tab = null; if (aEvent.originalTarget.localName != "tab") { // We're adding a new tab. - tab = this.addTab(getShortcutOrURI(url)); + this.loadOneTab(getShortcutOrURI(url)); } else { // Load in an existing tab. - tab = aEvent.originalTarget; + var tab = aEvent.originalTarget; this.getBrowserForTab(tab).loadURI(getShortcutOrURI(url)); } - if (this.mCurrentTab != tab && !bgLoad) - this.selectedTab = tab; } ]]>