Bug 1581859: Part 2a - Add LOCATION_CHANGE_HASHCHANGE onLocationChange flag. r=nika
The naming scheme references the hashchange event. This is required by the extensions framework to call the appropriate navigation listeners when only the reference fragment is updated by a navigation. Differential Revision: https://phabricator.services.mozilla.com/D108725
This commit is contained in:
@@ -8732,7 +8732,6 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState) {
|
||||
targetContext = newBC;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(targetContext, rv);
|
||||
|
||||
@@ -8754,6 +8753,27 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState) {
|
||||
return targetContext->InternalLoad(aLoadState);
|
||||
}
|
||||
|
||||
static nsAutoCString RefMaybeNull(nsIURI* aURI) {
|
||||
nsAutoCString result;
|
||||
if (NS_FAILED(aURI->GetRef(result))) {
|
||||
result.SetIsVoid(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t nsDocShell::GetSameDocumentNavigationFlags(nsIURI* aNewURI) {
|
||||
uint32_t flags = LOCATION_CHANGE_SAME_DOCUMENT;
|
||||
|
||||
bool equal = false;
|
||||
if (mCurrentURI &&
|
||||
NS_SUCCEEDED(mCurrentURI->EqualsExceptRef(aNewURI, &equal)) && equal &&
|
||||
RefMaybeNull(mCurrentURI) != RefMaybeNull(aNewURI)) {
|
||||
flags |= LOCATION_CHANGE_HASHCHANGE;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
bool nsDocShell::IsSameDocumentNavigation(nsDocShellLoadState* aLoadState,
|
||||
SameDocumentNavigationState& aState) {
|
||||
MOZ_ASSERT(aLoadState);
|
||||
@@ -8955,6 +8975,10 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
|
||||
newURIPartitionedPrincipalToInherit = doc->PartitionedPrincipal();
|
||||
newCsp = doc->GetCsp();
|
||||
}
|
||||
|
||||
uint32_t locationChangeFlags =
|
||||
GetSameDocumentNavigationFlags(aLoadState->URI());
|
||||
|
||||
// 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.
|
||||
@@ -9142,8 +9166,7 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
|
||||
}
|
||||
|
||||
if (locationChangeNeeded) {
|
||||
FireOnLocationChange(this, nullptr, aLoadState->URI(),
|
||||
LOCATION_CHANGE_SAME_DOCUMENT);
|
||||
FireOnLocationChange(this, nullptr, aLoadState->URI(), locationChangeFlags);
|
||||
}
|
||||
|
||||
/* Restore the original LSHE if we were loading something
|
||||
@@ -11537,7 +11560,7 @@ nsresult nsDocShell::UpdateURLAndHistory(Document* aDocument, nsIURI* aNewURI,
|
||||
aDocument->SetDocumentURI(aNewURI);
|
||||
SetCurrentURI(aNewURI, nullptr, /* aFireLocationChange */ true,
|
||||
/* aIsInitialAboutBlank */ false,
|
||||
LOCATION_CHANGE_SAME_DOCUMENT);
|
||||
GetSameDocumentNavigationFlags(aNewURI));
|
||||
|
||||
AddURIVisit(aNewURI, aCurrentURI, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user