From 37f937ea732bcea3732553a5524096f7e88e7724 Mon Sep 17 00:00:00 2001 From: "aaronleventhal%moonset.net" Date: Sat, 6 Aug 2005 04:20:13 +0000 Subject: [PATCH] Bug 249136. Focus and key navigation broken for links opened in new tabs. r=mconnor, r=timeless, a=bsmedberg --- browser/base/content/browser.js | 4 +-- .../components/bookmarks/content/bookmarks.js | 7 +++- toolkit/content/contentAreaUtils.js | 4 +-- toolkit/content/widgets/tabbrowser.xml | 33 +++++++++++++++---- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 66904192aae2..8c4761b88d3d 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 bbf1d2f50403..af316d5a92b6 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 7e4db424168e..0f53163b92dc 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 0a17aed512fb..8eee4e3ae458 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; } ]]>