bug 305236: Don't store the current document in the bfcache if we're going to reuse the current inner window for another page. In this case, the current document never was making it into session history anyway. r=bryner sr=jst

git-svn-id: svn://10.0.0.236/trunk@178653 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mrbkap%gmail.com
2005-08-23 00:24:57 +00:00
parent f8e4647235
commit e51f8de643
5 changed files with 119 additions and 58 deletions

View File

@@ -4810,7 +4810,9 @@ nsDocShell::CreateAboutBlankContentViewer()
}
PRBool
nsDocShell::CanSavePresentation(PRUint32 aLoadType, nsIRequest *aNewRequest)
nsDocShell::CanSavePresentation(PRUint32 aLoadType,
nsIRequest *aNewRequest,
nsIDocument *aNewDocument)
{
if (!mOSHE)
return PR_FALSE; // no entry to save into
@@ -4838,6 +4840,9 @@ nsDocShell::CanSavePresentation(PRUint32 aLoadType, nsIRequest *aNewRequest)
if (!pWin || pWin->IsLoading())
return PR_FALSE;
if (pWin->WouldReuseInnerWindow(aNewDocument))
return PR_FALSE;
// Avoid doing the work of saving the presentation state in the case where
// the content viewer cache is disabled.
PRInt32 maxViewers = 0;
@@ -5166,7 +5171,7 @@ nsDocShell::RestoreFromHistory()
nsIRequest *request = nsnull;
if (doc)
request = doc->GetChannel();
mSavingOldViewer = CanSavePresentation(mLoadType, request);
mSavingOldViewer = CanSavePresentation(mLoadType, request, doc);
}
nsCOMPtr<nsIMarkupDocumentViewer> oldMUDV(do_QueryInterface(mContentViewer));
@@ -5444,7 +5449,10 @@ nsDocShell::CreateContentViewer(const char *aContentType,
// at the time we initiated the new load. We need to check whether
// it's still safe to do so, since there may have been DOM mutations
// or new requests initiated.
mSavingOldViewer = CanSavePresentation(mLoadType, request);
nsCOMPtr<nsIDOMDocument> domDoc;
viewer->GetDOMDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
mSavingOldViewer = CanSavePresentation(mLoadType, request, doc);
}
FirePageHideNotification(!mSavingOldViewer);
@@ -6352,7 +6360,9 @@ nsDocShell::InternalLoad(nsIURI * aURI,
// This is necessary so that we can catch any pending requests.
// Since the new request has not been created yet, we pass null for the
// new request parameter.
PRBool savePresentation = CanSavePresentation(aLoadType, nsnull);
// Also pass nsnull for the document, since it doesn't affect the return
// value for our purposes here.
PRBool savePresentation = CanSavePresentation(aLoadType, nsnull, nsnull);
// Don't stop current network activity for javascript: URL's since
// they might not result in any data, and thus nothing should be

View File

@@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=4 sw=4 et tw=80:
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
@@ -491,8 +492,11 @@ protected:
// |aLoadType| should be the load type that will replace the current
// presentation. |aNewRequest| should be the request for the document to
// be loaded in place of the current document, or null if such a request
// has not been created yet.
PRBool CanSavePresentation(PRUint32 aLoadType, nsIRequest *aNewRequest);
// has not been created yet. |aNewDocument| should be the document that will
// replace the current document.
PRBool CanSavePresentation(PRUint32 aLoadType,
nsIRequest *aNewRequest,
nsIDocument *aNewDocument);
// Captures the state of the supporting elements of the presentation
// (the "window" object, docshell tree, meta-refresh loads, and security