Bug 311007 - Add onLocationChange2 which distinguishes between same-document and different-document location changes to web progress listeners. r=smaug, sr=bzbarsky
This commit is contained in:
@@ -1726,17 +1726,20 @@ nsDocShell::GetChromeEventHandler(nsIDOMEventTarget** aChromeEventHandler)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] void setCurrentURI (in nsIURI uri); */
|
||||
/* void setCurrentURI (in nsIURI uri); */
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetCurrentURI(nsIURI *aURI)
|
||||
{
|
||||
SetCurrentURI(aURI, nsnull, PR_TRUE);
|
||||
// Note that securityUI will set STATE_IS_INSECURE, even if
|
||||
// the scheme of |aURI| is "https".
|
||||
SetCurrentURI(aURI, nsnull, PR_TRUE,
|
||||
nsIWebProgressListener2::LOCATION_CHANGE_NORMAL);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsDocShell::SetCurrentURI(nsIURI *aURI, nsIRequest *aRequest,
|
||||
PRBool aFireOnLocationChange)
|
||||
PRBool aFireOnLocationChange, PRUint32 aLocationFlags)
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
if (gDocShellLeakLog && PR_LOG_TEST(gDocShellLeakLog, PR_LOG_DEBUG)) {
|
||||
@@ -1780,7 +1783,7 @@ nsDocShell::SetCurrentURI(nsIURI *aURI, nsIRequest *aRequest,
|
||||
}
|
||||
|
||||
if (aFireOnLocationChange) {
|
||||
FireOnLocationChange(this, aRequest, aURI);
|
||||
FireOnLocationChange(this, aRequest, aURI, aLocationFlags);
|
||||
}
|
||||
return !aFireOnLocationChange;
|
||||
}
|
||||
@@ -5870,7 +5873,8 @@ nsDocShell::OnStateChange(nsIWebProgress * aProgress, nsIRequest * aRequest,
|
||||
// a new DOM here.
|
||||
rv = AddToSessionHistory(uri, wcwgChannel, nsnull, PR_FALSE,
|
||||
getter_AddRefs(mLSHE));
|
||||
SetCurrentURI(uri, aRequest, PR_TRUE);
|
||||
SetCurrentURI(uri, aRequest, PR_TRUE,
|
||||
nsIWebProgressListener2::LOCATION_CHANGE_NORMAL);
|
||||
// Save history state of the previous page
|
||||
rv = PersistLayoutHistoryState();
|
||||
// We'll never get an Embed() for this load, so just go ahead
|
||||
@@ -6523,7 +6527,8 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
|
||||
viewer->SetContainer(static_cast<nsIContentViewerContainer *>(this));
|
||||
Embed(viewer, "", 0);
|
||||
|
||||
SetCurrentURI(blankDoc->GetDocumentURI(), nsnull, PR_TRUE);
|
||||
SetCurrentURI(blankDoc->GetDocumentURI(), nsnull, PR_TRUE,
|
||||
nsIWebProgressListener2::LOCATION_CHANGE_NORMAL);
|
||||
rv = mIsBeingDestroyed ? NS_ERROR_NOT_AVAILABLE : NS_OK;
|
||||
}
|
||||
}
|
||||
@@ -7174,7 +7179,8 @@ nsDocShell::RestoreFromHistory()
|
||||
// is still mLSHE or whether it's now mOSHE.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
origLSHE->GetURI(getter_AddRefs(uri));
|
||||
SetCurrentURI(uri, document->GetChannel(), PR_TRUE);
|
||||
SetCurrentURI(uri, document->GetChannel(), PR_TRUE,
|
||||
nsIWebProgressListener2::LOCATION_CHANGE_NORMAL);
|
||||
}
|
||||
|
||||
// This is the end of our CreateContentViewer() replacement.
|
||||
@@ -7513,7 +7519,8 @@ nsDocShell::CreateContentViewer(const char *aContentType,
|
||||
}
|
||||
|
||||
if (onLocationChangeNeeded) {
|
||||
FireOnLocationChange(this, request, mCurrentURI);
|
||||
FireOnLocationChange(this, request, mCurrentURI,
|
||||
nsIWebProgressListener2::LOCATION_CHANGE_NORMAL);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@@ -8384,6 +8391,11 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
// Pass true for aCloneSHChildren, since we're not
|
||||
// changing documents here, so all of our subframes are
|
||||
// still relevant to the new session history entry.
|
||||
//
|
||||
// It also makes OnNewURI(...) set LOCATION_CHANGE_SAME_DOCUMENT
|
||||
// flag on firing onLocationChange(...).
|
||||
// Anyway, aCloneSHChildren param is simply reflecting
|
||||
// doShortCircuitedLoad in this scope.
|
||||
OnNewURI(aURI, nsnull, owner, mLoadType, PR_TRUE, PR_TRUE, PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIInputStream> postData;
|
||||
@@ -9459,8 +9471,14 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel, nsISupports* aOwner,
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// aCloneSHChildren exactly means "we are not loading a new document".
|
||||
PRUint32 locationFlags = aCloneSHChildren?
|
||||
PRUint32(nsIWebProgressListener2::LOCATION_CHANGE_SAME_DOCUMENT) :
|
||||
PRUint32(nsIWebProgressListener2::LOCATION_CHANGE_NORMAL);
|
||||
PRBool onLocationChangeNeeded = SetCurrentURI(aURI, aChannel,
|
||||
aFireOnLocationChange);
|
||||
aFireOnLocationChange,
|
||||
locationFlags);
|
||||
// Make sure to store the referrer from the channel, if any
|
||||
SetupReferrerFromChannel(aChannel);
|
||||
return onLocationChangeNeeded;
|
||||
@@ -9764,8 +9782,15 @@ nsDocShell::AddState(nsIVariant *aData, const nsAString& aTitle,
|
||||
// gets updated and the back button is enabled, but we only need to
|
||||
// explicitly call FireOnLocationChange if we're not calling SetCurrentURI,
|
||||
// since SetCurrentURI will call FireOnLocationChange for us.
|
||||
//
|
||||
// Both SetCurrentURI(...) and FireDummyOnLocationChange() pass
|
||||
// nsnull for aRequest param to FireOnLocationChange(...). Such an update
|
||||
// notification is allowed only when we know docshell is not loading a new
|
||||
// document and it requires LOCATION_CHANGE_SAME_DOCUMENT flag. Otherwise,
|
||||
// FireOnLocationChange(...) breaks security UI.
|
||||
if (!equalURIs) {
|
||||
SetCurrentURI(newURI, nsnull, PR_TRUE);
|
||||
SetCurrentURI(newURI, nsnull, PR_TRUE,
|
||||
nsIWebProgressListener2::LOCATION_CHANGE_SAME_DOCUMENT);
|
||||
document->SetDocumentURI(newURI);
|
||||
|
||||
AddURIVisit(newURI, oldURI, oldURI, 0);
|
||||
|
||||
Reference in New Issue
Block a user