From 72be990e3fc2c89f96331e7b2e34974c30bb0d40 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 23 Aug 2006 04:10:05 +0000 Subject: [PATCH] Use a better way of detecting a newly-opened window. Bug 346404, r=biesi, sr=jst git-svn-id: svn://10.0.0.236/trunk@208156 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index b6f25745b93..5e2c47138c5 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -6411,14 +6411,16 @@ nsDocShell::InternalLoad(nsIURI * aURI, getter_AddRefs(newWin)); // In some cases the Open call doesn't actually result in a new - // window being opened (i.e. browser.link.open_newwindow is set - // to 1, forcing us to reuse the current window). This will - // protect us against that use case but still isn't totally - // ideal since perhaps in some future use case newWin could be - // some other, already open window. - if (win != newWin) { - isNewWindow = PR_TRUE; - aFlags |= INTERNAL_LOAD_FLAGS_FIRST_LOAD; + // window being opened. We can detect these cases by examining the + // document in |newWin|, if any. + nsCOMPtr piNewWin = do_QueryInterface(newWin); + if (piNewWin) { + nsCOMPtr newDoc = + do_QueryInterface(piNewWin->GetExtantDocument()); + if (!newDoc || newDoc->IsInitialDocument()) { + isNewWindow = PR_TRUE; + aFlags |= INTERNAL_LOAD_FLAGS_FIRST_LOAD; + } } nsCOMPtr webNav = do_GetInterface(newWin);