Bug #32387,47365, 46331, 46338, 23734 --> reset the load type when we get a redirected url so it gets added to
session history properly. Only add to session history if the url resulted in document being loaded. r=radha git-svn-id: svn://10.0.0.236/trunk@77944 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
03028d636f
commit
8f2702399e
@ -105,6 +105,7 @@ nsDocShell::nsDocShell() :
|
||||
mUseExternalProtocolHandler (PR_FALSE),
|
||||
mParent(nsnull),
|
||||
mTreeOwner(nsnull),
|
||||
mURIResultedInDocument(PR_FALSE),
|
||||
mChromeEventHandler(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
@ -2357,8 +2358,7 @@ NS_IMETHODIMP
|
||||
nsDocShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest,
|
||||
PRInt32 aStateFlags, nsresult aStatus)
|
||||
{
|
||||
// Clear the LSHE reference to indicate document loading has finished
|
||||
// one way or another.
|
||||
|
||||
if ((aStateFlags & STATE_STOP) && (aStateFlags & STATE_IS_NETWORK)) {
|
||||
LSHE = nsnull;
|
||||
}
|
||||
@ -2440,6 +2440,10 @@ NS_IMETHODIMP nsDocShell::CreateContentViewer(const char* aContentType,
|
||||
aContentHandler, getter_AddRefs(viewer))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// we've created a new document so go ahead and call OnLoadingSite
|
||||
mURIResultedInDocument = PR_TRUE;
|
||||
OnLoadingSite(aOpenedChannel);
|
||||
|
||||
// let's try resetting the load group if we need to...
|
||||
nsCOMPtr<nsILoadGroup> currentLoadGroup;
|
||||
NS_ENSURE_SUCCESS(aOpenedChannel->GetLoadGroup(getter_AddRefs(currentLoadGroup)),
|
||||
@ -2683,6 +2687,7 @@ NS_IMETHODIMP nsDocShell::InternalLoad(nsIURI* aURI, nsIURI* aReferrer,
|
||||
nsDocShellInfoLoadType aLoadType)
|
||||
#endif
|
||||
{
|
||||
mURIResultedInDocument = PR_FALSE; // reset the clock...
|
||||
// Check to see if the new URI is an anchor in the existing document.
|
||||
if (aLoadType == nsIDocShellLoadInfo::loadNormal ||
|
||||
aLoadType == nsIDocShellLoadInfo::loadNormalReplace ||
|
||||
@ -2694,7 +2699,9 @@ NS_IMETHODIMP nsDocShell::InternalLoad(nsIURI* aURI, nsIURI* aReferrer,
|
||||
if(wasAnchor)
|
||||
{
|
||||
mLoadType = aLoadType;
|
||||
mURIResultedInDocument = PR_TRUE;
|
||||
OnNewURI(aURI, nsnull, mLoadType);
|
||||
|
||||
/* Clear out LSHE so that further anchor visits get
|
||||
* recorded in SH and SH won't misbehave. i think this is
|
||||
* sufficient for now to take care of any Sh mis-behaviors.
|
||||
@ -3314,7 +3321,7 @@ nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, nsDocShellInfoLoadType
|
||||
|
||||
if (updateHistory) { // Page load not from SH
|
||||
// Update session history if necessary...
|
||||
if (!LSHE && (mItemType == typeContent)) {
|
||||
if (!LSHE && (mItemType == typeContent) && mURIResultedInDocument) {
|
||||
/* This is a fresh page getting loaded for the first time
|
||||
*.Create a Entry for it and add it to SH, if this is the
|
||||
* rootDocShell
|
||||
@ -3500,7 +3507,7 @@ nsresult nsDocShell::AddToSessionHistory(nsIURI *aURI,
|
||||
mSessionHistory->GetIndex(&index);
|
||||
mSessionHistory->GetEntryAtIndex(index, PR_FALSE, getter_AddRefs(entry));
|
||||
}
|
||||
|
||||
|
||||
// Create a new entry if necessary.
|
||||
if(!entry) {
|
||||
entry = do_CreateInstance(NS_SHENTRY_PROGID);
|
||||
@ -3509,7 +3516,7 @@ nsresult nsDocShell::AddToSessionHistory(nsIURI *aURI,
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get the post data
|
||||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
if (aChannel) {
|
||||
@ -3526,9 +3533,8 @@ nsresult nsDocShell::AddToSessionHistory(nsIURI *aURI,
|
||||
nsnull, // DOMDocument
|
||||
inputStream, // Post data stream
|
||||
nsnull); // LayoutHistory state
|
||||
//
|
||||
// Add the new entry to session history.
|
||||
//
|
||||
|
||||
|
||||
// If no Session History component is available in the parent DocShell
|
||||
// heirarchy, then AddChildSHEntry(...) will fail and the new entry
|
||||
// will be deleted when it loses scope...
|
||||
@ -3921,6 +3927,12 @@ nsresult nsDocShell::GetLoadCookie(nsISupports **aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocShell::SetLoadType(nsDocShellInfoLoadType aLoadType)
|
||||
{
|
||||
mLoadType = aLoadType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsDocShellInitInfo* nsDocShell::InitInfo()
|
||||
{
|
||||
|
||||
@ -151,6 +151,9 @@ public:
|
||||
|
||||
nsresult SetLoadCookie(nsISupports *aCookie);
|
||||
nsresult GetLoadCookie(nsISupports **aResult);
|
||||
// used when the docshell gets content that's being redirected (so we don't go through
|
||||
// our own InternalLoad method) to reset the load type...
|
||||
nsresult SetLoadType(nsDocShellInfoLoadType aLoadType);
|
||||
|
||||
protected:
|
||||
// Object Management
|
||||
@ -199,9 +202,8 @@ protected:
|
||||
|
||||
// Session History
|
||||
virtual PRBool ShouldAddToSessionHistory(nsIURI* aURI);
|
||||
|
||||
virtual nsresult AddToSessionHistory(nsIURI* aURI, nsIChannel *aChannel,
|
||||
nsISHEntry **aNewEntry);
|
||||
nsISHEntry **aNewEntry);
|
||||
|
||||
NS_IMETHOD UpdateCurrentSessionHistory();
|
||||
#ifdef SH_IN_FRAMES
|
||||
@ -269,11 +271,13 @@ protected:
|
||||
// Reference to the SHEntry for this docshell until the page is loaded
|
||||
// Somebody give me better name
|
||||
nsCOMPtr<nsISHEntry> LSHE;
|
||||
|
||||
// this flag is for bug #21358. a docshell may load many urls
|
||||
// which don't result in new documents being created (i.e. a new content viewer)
|
||||
// we want to make sure we don't call a on load event more than once for a given
|
||||
// content viewer.
|
||||
PRBool mEODForCurrentDocument;
|
||||
PRBool mURIResultedInDocument;
|
||||
|
||||
// used to keep track of whether user click links should be handle by us
|
||||
// or immediately kicked out to an external application. mscott: eventually
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user