From fea41970b2eb32b1795f75d8d75c7515951e20a6 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 20 Apr 2005 04:41:48 +0000 Subject: [PATCH] Reposting when expired from cache should make sure to use the right history entry; otherwise docshell is confused about which page it currently has loaded. Bug 289301, r=biesi, sr=darin, a=asa git-svn-id: svn://10.0.0.236/trunk@172476 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 10 ++++++++++ mozilla/docshell/base/nsWebShell.cpp | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 64035677768..9b668aebd5f 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -2987,6 +2987,9 @@ nsDocShell::LoadErrorPage(nsIURI *aURI, const PRUnichar *aURL, } #endif // Create an shistory entry for the old load, if we have a channel + // XXXbz except what happens if this got called in EndPageLoad? Then we've + // already cleared out mLSHE, so we're just setting mOSHE to null. That + // can't be a good idea. if (aFailedChannel) { mURIResultedInDocument = PR_TRUE; OnLoadingSite(aFailedChannel, PR_TRUE); @@ -6321,14 +6324,21 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel, if (aChannel && aLoadType == LOAD_RELOAD_BYPASS_CACHE || aLoadType == LOAD_RELOAD_BYPASS_PROXY || aLoadType == LOAD_RELOAD_BYPASS_PROXY_AND_CACHE) { + NS_ASSERTION(!updateHistory, + "We shouldn't be updating history for forced reloads!"); nsCOMPtr cacheChannel(do_QueryInterface(aChannel)); nsCOMPtr cacheKey; // Get the Cache Key and store it in SH. if (cacheChannel) cacheChannel->GetCacheKey(getter_AddRefs(cacheKey)); + // If we already have a loading history entry, store the new cache key + // in it. Otherwise, since we're doing a reload and won't be updating + // our history entry, store the cache key in our current history entry. if (mLSHE) mLSHE->SetCacheKey(cacheKey); + else if (mOSHE) + mOSHE->SetCacheKey(cacheKey); } if (updateHistory && shAvailable) { diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index f954689369b..88322b757d9 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -651,6 +651,11 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress, else mCharsetReloadState = eCharsetReloadInit; + // Save a pointer to the currently-loading history entry. + // nsDocShell::EndPageLoad will clear mLSHE, but we may need this history + // entry further down in this method. + nsCOMPtr loadingSHE = mLSHE; + // // one of many safeguards that prevent death and destruction if // someone is so very very rude as to bring this window down @@ -903,6 +908,15 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress, if (shInternal) shInternal->UpdateIndex(); } + + // Make it look like we really did honestly finish loading the + // history page we were loading, since the "reload" load we're + // about to kick off will reload our current history entry. This + // is a bit of a hack, and if the force-load fails I think we'll + // end up being confused about what page we're on... but we would + // anyway, since we've updated the session history index above. + mOSHE = loadingSHE; + /* The user does want to repost the data to the server. * Initiate a new load again. */