Bug 1916559 - Only store pending uninvoked directives for same document navigation. r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D221637
This commit is contained in:
@@ -8431,6 +8431,17 @@ uint32_t nsDocShell::GetSameDocumentNavigationFlags(nsIURI* aNewURI) {
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct SameDocumentNavigationState {
|
||||||
|
nsAutoCString mCurrentHash;
|
||||||
|
nsAutoCString mNewHash;
|
||||||
|
nsTArray<TextDirective> mTextDirectives;
|
||||||
|
bool mCurrentURIHasRef = false;
|
||||||
|
bool mNewURIHasRef = false;
|
||||||
|
bool mSameExceptHashes = false;
|
||||||
|
bool mSecureUpgradeURI = false;
|
||||||
|
bool mHistoryNavBetweenSameDoc = false;
|
||||||
|
};
|
||||||
|
|
||||||
bool nsDocShell::IsSameDocumentNavigation(nsDocShellLoadState* aLoadState,
|
bool nsDocShell::IsSameDocumentNavigation(nsDocShellLoadState* aLoadState,
|
||||||
SameDocumentNavigationState& aState) {
|
SameDocumentNavigationState& aState) {
|
||||||
MOZ_ASSERT(aLoadState);
|
MOZ_ASSERT(aLoadState);
|
||||||
@@ -8451,15 +8462,9 @@ bool nsDocShell::IsSameDocumentNavigation(nsDocShellLoadState* aLoadState,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A Fragment Directive must be removed from the new hash in order to allow
|
// A Fragment Directive must be removed from the new hash in order to allow
|
||||||
// fallback element id scroll. Additionally, the extracted parsed text
|
// fallback element id scroll.
|
||||||
// directives need to be stored for further use.
|
FragmentDirective::ParseAndRemoveFragmentDirectiveFromFragmentString(
|
||||||
nsTArray<TextDirective> textDirectives;
|
aState.mNewHash, &aState.mTextDirectives, aLoadState->URI());
|
||||||
if (FragmentDirective::ParseAndRemoveFragmentDirectiveFromFragmentString(
|
|
||||||
aState.mNewHash, &textDirectives, aLoadState->URI())) {
|
|
||||||
if (Document* doc = GetDocument()) {
|
|
||||||
doc->FragmentDirective()->SetTextDirectives(std::move(textDirectives));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentURI && NS_SUCCEEDED(rvURINew)) {
|
if (currentURI && NS_SUCCEEDED(rvURINew)) {
|
||||||
nsresult rvURIOld = currentURI->GetRef(aState.mCurrentHash);
|
nsresult rvURIOld = currentURI->GetRef(aState.mCurrentHash);
|
||||||
@@ -8596,6 +8601,12 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
|
|||||||
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
||||||
doc->DoNotifyPossibleTitleChange();
|
doc->DoNotifyPossibleTitleChange();
|
||||||
|
|
||||||
|
// Store the pending uninvoked directives if it is a same document navigation.
|
||||||
|
// We need to set it here, in case the navigation happens before the document
|
||||||
|
// has actually finished loading.
|
||||||
|
doc->FragmentDirective()->SetTextDirectives(
|
||||||
|
std::move(aState.mTextDirectives));
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> currentURI = mCurrentURI;
|
nsCOMPtr<nsIURI> currentURI = mCurrentURI;
|
||||||
|
|
||||||
// We need to upgrade the new URI from http: to https:
|
// We need to upgrade the new URI from http: to https:
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ enum eCharsetReloadState {
|
|||||||
eCharsetReloadStopOrigional
|
eCharsetReloadStopOrigional
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SameDocumentNavigationState;
|
||||||
|
|
||||||
class nsDocShell final : public nsDocLoader,
|
class nsDocShell final : public nsDocLoader,
|
||||||
public nsIDocShell,
|
public nsIDocShell,
|
||||||
public nsIWebNavigation,
|
public nsIWebNavigation,
|
||||||
@@ -1032,16 +1034,6 @@ class nsDocShell final : public nsDocLoader,
|
|||||||
// embedder element, for both in-process and OOP embedders.
|
// embedder element, for both in-process and OOP embedders.
|
||||||
void UnblockEmbedderLoadEventForFailure(bool aFireFrameErrorEvent = false);
|
void UnblockEmbedderLoadEventForFailure(bool aFireFrameErrorEvent = false);
|
||||||
|
|
||||||
struct SameDocumentNavigationState {
|
|
||||||
nsAutoCString mCurrentHash;
|
|
||||||
nsAutoCString mNewHash;
|
|
||||||
bool mCurrentURIHasRef = false;
|
|
||||||
bool mNewURIHasRef = false;
|
|
||||||
bool mSameExceptHashes = false;
|
|
||||||
bool mSecureUpgradeURI = false;
|
|
||||||
bool mHistoryNavBetweenSameDoc = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Check to see if we're loading a prior history entry or doing a fragment
|
// Check to see if we're loading a prior history entry or doing a fragment
|
||||||
// navigation in the same document.
|
// navigation in the same document.
|
||||||
// NOTE: In case we are doing a fragment navigation, and HTTPS-Only/ -First
|
// NOTE: In case we are doing a fragment navigation, and HTTPS-Only/ -First
|
||||||
|
|||||||
Reference in New Issue
Block a user