From ba17471efe1842e64905e0868379f0f0d4965541 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 30 Jan 2008 04:19:37 +0000 Subject: [PATCH] Followup patch for bug 409888: make replace loads work more like they used to. r=biesi, sr=jst git-svn-id: svn://10.0.0.236/trunk@244459 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 57 +++++++++++++++------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 41c0dac79dd..88c669586c5 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -6436,8 +6436,7 @@ class InternalLoadEvent : public nsRunnable public: InternalLoadEvent(nsDocShell* aDocShell, nsIURI * aURI, nsIURI * aReferrer, nsISupports * aOwner, PRUint32 aFlags, - const PRUnichar *aWindowTarget, const char* aTypeHint, - nsIInputStream * aPostData, + const char* aTypeHint, nsIInputStream * aPostData, nsIInputStream * aHeadersData, PRUint32 aLoadType, nsISHEntry * aSHEntry, PRBool aFirstParty) : mDocShell(aDocShell), @@ -6452,9 +6451,6 @@ public: mFirstParty(aFirstParty) { // Make sure to keep null things null as needed - if (aWindowTarget) { - mWindowTarget = aWindowTarget; - } if (aTypeHint) { mTypeHint = aTypeHint; } @@ -6462,7 +6458,7 @@ public: NS_IMETHOD Run() { return mDocShell->InternalLoad(mURI, mReferrer, mOwner, mFlags, - mWindowTarget.get(), mTypeHint.get(), + nsnull, mTypeHint.get(), mPostData, mHeadersData, mLoadType, mSHEntry, mFirstParty, nsnull, nsnull); } @@ -6527,21 +6523,6 @@ nsDocShell::InternalLoad(nsIURI * aURI, NS_ENSURE_TRUE(!mIsBeingDestroyed, NS_ERROR_NOT_AVAILABLE); - if (mFiredUnloadEvent) { - if (IsOKToLoadURI(aURI)) { - // Do this asynchronously - nsCOMPtr ev = - new InternalLoadEvent(this, aURI, aReferrer, aOwner, aFlags, - aWindowTarget, aTypeHint, - aPostData, aHeadersData, aLoadType, - aSHEntry, aFirstParty); - return NS_DispatchToCurrentThread(ev); - } - - // Just ignore this load attempt - return NS_OK; - } - // wyciwyg urls can only be loaded through history. Any normal load of // wyciwyg through docshell is illegal. Disallow such loads. if (aLoadType & LOAD_CMD_NORMAL) { @@ -6795,6 +6776,35 @@ nsDocShell::InternalLoad(nsIURI * aURI, return NS_ERROR_FAILURE; } + rv = CheckLoadingPermissions(); + if (NS_FAILED(rv)) { + return rv; + } + + if (mFiredUnloadEvent) { + if (IsOKToLoadURI(aURI)) { + NS_PRECONDITION(!aWindowTarget || !*aWindowTarget, + "Shouldn't have a window target here!"); + + // If this is a replace load, make whatever load triggered + // the unload event also a replace load, so we don't + // create extra history entries. + if (LOAD_TYPE_HAS_FLAGS(aLoadType, LOAD_FLAGS_REPLACE_HISTORY)) { + mLoadType = LOAD_NORMAL_REPLACE; + } + + // Do this asynchronously + nsCOMPtr ev = + new InternalLoadEvent(this, aURI, aReferrer, aOwner, aFlags, + aTypeHint, aPostData, aHeadersData, + aLoadType, aSHEntry, aFirstParty); + return NS_DispatchToCurrentThread(ev); + } + + // Just ignore this load attempt + return NS_OK; + } + // Before going any further vet loads initiated by external programs. if (aLoadType == LOAD_NORMAL_EXTERNAL) { // Disallow external chrome: loads targetted at content windows @@ -6814,11 +6824,6 @@ nsDocShell::InternalLoad(nsIURI * aURI, aLoadType = LOAD_NORMAL; } - rv = CheckLoadingPermissions(); - if (NS_FAILED(rv)) { - return rv; - } - mAllowKeywordFixup = (aFlags & INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) != 0; mURIResultedInDocument = PR_FALSE; // reset the clock...