Bug 445725. Copy over the history entry owner to the clone on anchor scroll, so that we get the right owners on reload of scrolled file:// pages. r+sr=jst

This commit is contained in:
Boris Zbarsky 2008-12-11 14:16:05 -05:00
parent 5039056a9e
commit 08121c0b9d
2 changed files with 30 additions and 13 deletions

View File

@ -3276,7 +3276,7 @@ nsDocShell::LoadErrorPage(nsIURI *aURI, const PRUnichar *aURL,
OnLoadingSite(aFailedChannel, PR_TRUE, PR_FALSE);
} else if (aURI) {
mURIResultedInDocument = PR_TRUE;
OnNewURI(aURI, nsnull, mLoadType, PR_TRUE, PR_FALSE);
OnNewURI(aURI, nsnull, nsnull, mLoadType, PR_TRUE, PR_FALSE);
}
// Be sure to have a correct mLSHE, it may have been cleared by
// EndPageLoad. See bug 302115.
@ -5041,7 +5041,8 @@ nsDocShell::OnStateChange(nsIWebProgress * aProgress, nsIRequest * aRequest,
!equalUri) {
// This is a document.write(). Get the made-up url
// from the channel and store it in session history.
rv = AddToSessionHistory(uri, wcwgChannel, getter_AddRefs(mLSHE));
rv = AddToSessionHistory(uri, wcwgChannel, nsnull,
getter_AddRefs(mLSHE));
SetCurrentURI(uri, aRequest, PR_TRUE);
// Save history state of the previous page
rv = PersistLayoutHistoryState();
@ -7092,7 +7093,11 @@ nsDocShell::InternalLoad(nsIURI * aURI,
* call OnNewURI() so that, this traversal will be
* recorded in session and global history.
*/
OnNewURI(aURI, nsnull, mLoadType, PR_TRUE);
nsCOMPtr<nsISupports> owner;
if (mOSHE) {
mOSHE->GetOwner(getter_AddRefs(owner));
}
OnNewURI(aURI, nsnull, owner, mLoadType, PR_TRUE);
nsCOMPtr<nsIInputStream> postData;
PRUint32 pageIdent = PR_UINT32_MAX;
nsCOMPtr<nsISupports> cacheKey;
@ -7999,11 +8004,13 @@ nsDocShell::SetupReferrerFromChannel(nsIChannel * aChannel)
}
PRBool
nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel,
nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel, nsISupports* aOwner,
PRUint32 aLoadType, PRBool aFireOnLocationChange,
PRBool aAddToGlobalHistory)
{
NS_ASSERTION(aURI, "uri is null");
NS_PRECONDITION(aURI, "uri is null");
NS_PRECONDITION(!aChannel || !aOwner, "Shouldn't have both set");
#if defined(PR_LOGGING) && defined(DEBUG)
if (PR_LOG_TEST(gDocShellLog, PR_LOG_DEBUG)) {
nsCAutoString spec;
@ -8131,7 +8138,8 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel,
*.Create a Entry for it and add it to SH, if this is the
* rootDocShell
*/
(void) AddToSessionHistory(aURI, aChannel, getter_AddRefs(mLSHE));
(void) AddToSessionHistory(aURI, aChannel, aOwner,
getter_AddRefs(mLSHE));
}
// Update Global history
@ -8174,7 +8182,7 @@ nsDocShell::OnLoadingSite(nsIChannel * aChannel, PRBool aFireOnLocationChange,
NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
NS_ENSURE_TRUE(uri, PR_FALSE);
return OnNewURI(uri, aChannel, mLoadType, aFireOnLocationChange,
return OnNewURI(uri, aChannel, nsnull, mLoadType, aFireOnLocationChange,
aAddToGlobalHistory);
}
@ -8215,9 +8223,12 @@ nsDocShell::ShouldAddToSessionHistory(nsIURI * aURI)
}
nsresult
nsDocShell::AddToSessionHistory(nsIURI * aURI,
nsIChannel * aChannel, nsISHEntry ** aNewEntry)
nsDocShell::AddToSessionHistory(nsIURI * aURI, nsIChannel * aChannel,
nsISupports* aOwner, nsISHEntry ** aNewEntry)
{
NS_PRECONDITION(aURI, "uri is null");
NS_PRECONDITION(!aChannel || !aOwner, "Shouldn't have both set");
#if defined(PR_LOGGING) && defined(DEBUG)
if (PR_LOG_TEST(gDocShellLog, PR_LOG_DEBUG)) {
nsCAutoString spec;
@ -8280,7 +8291,7 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI,
nsCOMPtr<nsIURI> referrerURI;
nsCOMPtr<nsISupports> cacheKey;
nsCOMPtr<nsISupports> cacheToken;
nsCOMPtr<nsISupports> owner;
nsCOMPtr<nsISupports> owner = aOwner;
PRBool expired = PR_FALSE;
PRBool discardLayoutState = PR_FALSE;
if (aChannel) {
@ -8318,7 +8329,7 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI,
nsnull, // LayoutHistory state
cacheKey, // CacheKey
mContentTypeHint, // Content-type
owner); // Channel owner
owner); // Channel or provided owner
entry->SetReferrerURI(referrerURI);
/* If cache got a 'no-store', ask SH not to store
* HistoryLayoutState. By default, SH will set this

View File

@ -322,7 +322,10 @@ protected:
// In this case it is the caller's responsibility to ensure
// FireOnLocationChange is called.
// In all other cases PR_FALSE is returned.
PRBool OnNewURI(nsIURI * aURI, nsIChannel * aChannel, PRUint32 aLoadType,
// Either aChannel or aOwner must be null. If aChannel is
// present, the owner should be gotten from it.
PRBool OnNewURI(nsIURI * aURI, nsIChannel * aChannel, nsISupports* aOwner,
PRUint32 aLoadType,
PRBool aFireOnLocationChange,
PRBool aAddToGlobalHistory = PR_TRUE);
@ -330,8 +333,11 @@ protected:
// Session History
virtual PRBool ShouldAddToSessionHistory(nsIURI * aURI);
// Either aChannel or aOwner must be null. If aChannel is
// present, the owner should be gotten from it.
virtual nsresult AddToSessionHistory(nsIURI * aURI, nsIChannel * aChannel,
nsISHEntry ** aNewEntry);
nsISupports* aOwner,
nsISHEntry ** aNewEntry);
nsresult DoAddChildSHEntry(nsISHEntry* aNewEntry, PRInt32 aChildOffset);
NS_IMETHOD LoadHistoryEntry(nsISHEntry * aEntry, PRUint32 aLoadType);