From 40d99f05401b08e701a692e4f1ff8f2c670243b9 Mon Sep 17 00:00:00 2001 From: "bryner%uiuc.edu" Date: Wed, 28 Mar 2001 02:08:06 +0000 Subject: [PATCH] Bug 44257 -- fix tabbing from URL bar to document. r=saari, sr=shaver. --- docshell/base/nsDocShell.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 055ee76cd0c..755d0d39198 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -71,6 +71,7 @@ #include "nsIPrincipal.h" #include "nsPIDOMWindow.h" +#include "nsIDOMDocument.h" // For reporting errors with the console service. // These can go away if error reporting is propagated up past nsDocShell. @@ -1971,11 +1972,19 @@ NS_IMETHODIMP nsDocShell::GetMainWidget(nsIWidget** aMainWidget) NS_IMETHODIMP nsDocShell::SetFocus() { - nsCOMPtr mainWidget; - GetMainWidget(getter_AddRefs(mainWidget)); - if(mainWidget) - mainWidget->SetFocus(); - return NS_OK; + nsCOMPtr domDoc; + mContentViewer->GetDOMDocument(getter_AddRefs(domDoc)); + nsCOMPtr doc(do_QueryInterface(domDoc)); + if (doc) { + nsCOMPtr sgo; + doc->GetScriptGlobalObject(getter_AddRefs(sgo)); + if (sgo) { + nsCOMPtr domwin(do_QueryInterface(sgo)); + if (domwin) + domwin->Focus(); + } + } + return NS_OK; } NS_IMETHODIMP nsDocShell::FocusAvailable(nsIBaseWindow* aCurrentFocus,