From efb03cfbd3002f01e2a4dd8e82fd4087e3af732b Mon Sep 17 00:00:00 2001 From: "bryner%netscape.com" Date: Tue, 21 Aug 2001 21:18:45 +0000 Subject: [PATCH] Bug 92210 - Window steals focus if you switch to another app during "Transferring data from...". r=saari, sr=hyatt. git-svn-id: svn://10.0.0.236/trunk@101548 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 43 +++++++++++++++++++++++++ mozilla/docshell/base/nsDocShell.h | 1 + mozilla/docshell/base/nsIDocShell.idl | 8 ++++- mozilla/dom/src/base/nsGlobalWindow.cpp | 2 +- 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 3ebdac45389..207674c9d2f 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -961,6 +961,31 @@ nsresult nsDocShell::FindTarget(const PRUnichar *aWindowTarget, return NS_OK; } +NS_IMETHODIMP +nsDocShell::GetEldestPresContext(nsIPresContext** aPresContext) +{ + nsresult rv = NS_OK; + + NS_ENSURE_ARG_POINTER(aPresContext); + *aPresContext = nsnull; + + nsCOMPtr viewer = mContentViewer; + while (viewer) { + nsCOMPtr prevViewer; + viewer->GetPreviousViewer(getter_AddRefs(prevViewer)); + if (prevViewer) + viewer = prevViewer; + else { + nsCOMPtr docv(do_QueryInterface(viewer)); + if (docv) + rv = docv->GetPresContext(*aPresContext); + break; + } + } + + return rv; +} + NS_IMETHODIMP nsDocShell::GetPresContext(nsIPresContext ** aPresContext) { @@ -999,6 +1024,24 @@ nsDocShell::GetPresShell(nsIPresShell ** aPresShell) return rv; } +NS_IMETHODIMP +nsDocShell::GetEldestPresShell(nsIPresShell** aPresShell) +{ + nsresult rv = NS_OK; + + NS_ENSURE_ARG_POINTER(aPresShell); + *aPresShell = nsnull; + + nsCOMPtr presContext; + (void) GetEldestPresContext(getter_AddRefs(presContext)); + + if (presContext) { + rv = presContext->GetShell(aPresShell); + } + + return rv; +} + NS_IMETHODIMP nsDocShell::GetContentViewer(nsIContentViewer ** aContentViewer) { diff --git a/mozilla/docshell/base/nsDocShell.h b/mozilla/docshell/base/nsDocShell.h index dfe8d96809b..5d641ae7e92 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -210,6 +210,7 @@ protected: nsIStreamListener ** aContentHandler, nsIContentViewer ** aViewer); NS_IMETHOD SetupNewViewer(nsIContentViewer * aNewViewer); + NS_IMETHOD GetEldestPresContext(nsIPresContext** aPresContext); NS_IMETHOD CreateFixupURI(const PRUnichar * aStringURI, nsIURI ** aURI); NS_IMETHOD GetCurrentDocumentOwner(nsISupports ** aOwner); virtual nsresult DoURILoad(nsIURI * aURI, diff --git a/mozilla/docshell/base/nsIDocShell.idl b/mozilla/docshell/base/nsIDocShell.idl index e4c68f8dfa2..b2fb013cd76 100644 --- a/mozilla/docshell/base/nsIDocShell.idl +++ b/mozilla/docshell/base/nsIDocShell.idl @@ -144,10 +144,16 @@ interface nsIDocShell : nsISupports [noscript] readonly attribute nsIPresContext presContext; /** - * Presentation context for the currently loaded document. This may be null. + * Presentation shell for the currently loaded document. This may be null. */ [noscript] readonly attribute nsIPresShell presShell; + /** + * Presentation shell for the oldest document, if this docshell is + * currently transitioning between documents. + */ + [noscript] readonly attribute nsIPresShell eldestPresShell; + /** * Content Viewer that is currently loaded for this DocShell. This may * change as the underlying content changes. diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index e2514d28c21..fe0cdb3569d 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -1747,7 +1747,7 @@ NS_IMETHODIMP GlobalWindowImpl::Focus() nsCOMPtr presShell; if (mDocShell) { - mDocShell->GetPresShell(getter_AddRefs(presShell)); + mDocShell->GetEldestPresShell(getter_AddRefs(presShell)); } nsresult result = NS_OK;