Followup patch for bug 409888: make replace loads work more like they used to. r=biesi, sr=jst

This commit is contained in:
bzbarsky@mit.edu 2008-01-29 20:19:37 -08:00
Родитель 9c3b582081
Коммит 22ed35f251
1 изменённых файлов: 31 добавлений и 26 удалений

Просмотреть файл

@ -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<nsIRunnable> 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<nsIRunnable> 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...