From e63b7f7a40e643c9ce2cb71db4e576c5f169c19b Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Wed, 22 Aug 2007 05:00:00 +0000 Subject: [PATCH] Don't save sidebar elements in tab focus memory (bug 254056). r=neil, sr=ben. git-svn-id: svn://10.0.0.236/trunk@232647 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/browser/base/content/tabbrowser.xml | 34 +++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/mozilla/browser/base/content/tabbrowser.xml b/mozilla/browser/base/content/tabbrowser.xml index 4015e856f0f..ac6e42eb47c 100644 --- a/mozilla/browser/base/content/tabbrowser.xml +++ b/mozilla/browser/base/content/tabbrowser.xml @@ -539,8 +539,38 @@ return; if (this.mCurrentBrowser) { - this.mCurrentBrowser.focusedWindow = document.commandDispatcher.focusedWindow; - this.mCurrentBrowser.focusedElement = document.commandDispatcher.focusedElement; + // Only save the focused element if it is in our content window + // or in an ancestor window. + var focusedWindow = document.commandDispatcher.focusedWindow; + var saveFocus = false; + + if (focusedWindow.top == window.content) { + saveFocus = true; + } else { + var contentWindow = window; + + while (contentWindow) { + if (contentWindow == focusedWindow) { + saveFocus = true; + break; + } + + if (contentWindow.parent == contentWindow) { + break; + } + + contentWindow = contentWindow.parent; + } + } + + if (saveFocus) { + // Preserve the currently-focused element or DOM window for + // this tab. + + this.mCurrentBrowser.focusedWindow = focusedWindow; + this.mCurrentBrowser.focusedElement = document.commandDispatcher.focusedElement; + } + if (this.mCurrentBrowser.focusedElement) { // Clear focus outline before we draw on top of it this.mCurrentBrowser.focusedElement.blur();