Bug 1888756, part 3 - Text Fragments: Preserve information if a load is a same-document load in `nsILoadInfo`. r=farre,dom-core,necko-reviewers,kershaw,peterv

This commit is a prerequisite for part 5 of this patch set.

There is no changed behavior in this commit.

Differential Revision: https://phabricator.services.mozilla.com/D212818
This commit is contained in:
Jan-Niklas Jaeschke 2024-06-26 14:24:32 +00:00
Родитель 3b545a84ce
Коммит 091c1ba3aa
6 изменённых файлов: 51 добавлений и 5 удалений

Просмотреть файл

@ -8693,7 +8693,11 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
MOZ_ASSERT(sameExceptHashes);
}
#endif
const nsCOMPtr<nsILoadInfo> loadInfo =
doc->GetChannel() ? doc->GetChannel()->LoadInfo() : nullptr;
if (loadInfo) {
loadInfo->SetIsSameDocumentNavigation(true);
}
// Save the position of the scrollers.
nsPoint scrollPos = GetCurScrollPos();

Просмотреть файл

@ -879,6 +879,9 @@ nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& loadInfoArgs,
loadInfoArgs.skipContentSniffing(), loadInfoArgs.httpsOnlyStatus(),
loadInfoArgs.hstsStatus(), loadInfoArgs.hasValidUserGestureActivation(),
loadInfoArgs.textDirectiveUserActivation(),
// This function is only called for moving LoadInfo across processes.
// Same-document navigation won't cross process boundaries.
/* aIsSameDocumentNavigation */ false,
loadInfoArgs.allowDeprecatedSystemRequests(),
loadInfoArgs.isInDevToolsContext(), loadInfoArgs.parserCreatedScript(),
loadInfoArgs.storagePermission(), overriddenFingerprintingSettings,

Просмотреть файл

@ -732,8 +732,8 @@ LoadInfo::LoadInfo(
const nsAString& aIntegrityMetadata, bool aSkipContentSniffing,
uint32_t aHttpsOnlyStatus, bool aHstsStatus,
bool aHasValidUserGestureActivation, bool aTextDirectiveUserActivation,
bool aAllowDeprecatedSystemRequests, bool aIsInDevToolsContext,
bool aParserCreatedScript,
bool aIsSameDocumentNavigation, bool aAllowDeprecatedSystemRequests,
bool aIsInDevToolsContext, bool aParserCreatedScript,
nsILoadInfo::StoragePermissionState aStoragePermission,
const Maybe<RFPTarget>& aOverriddenFingerprintingSettings,
bool aIsMetaRefresh, uint32_t aRequestBlockingReason,
@ -808,6 +808,7 @@ LoadInfo::LoadInfo(
mHstsStatus(aHstsStatus),
mHasValidUserGestureActivation(aHasValidUserGestureActivation),
mTextDirectiveUserActivation(aTextDirectiveUserActivation),
mIsSameDocumentNavigation(aIsSameDocumentNavigation),
mAllowDeprecatedSystemRequests(aAllowDeprecatedSystemRequests),
mIsInDevToolsContext(aIsInDevToolsContext),
mParserCreatedScript(aParserCreatedScript),
@ -2000,6 +2001,18 @@ LoadInfo::SetTextDirectiveUserActivation(bool aTextDirectiveUserActivation) {
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::GetIsSameDocumentNavigation(bool* aIsSameDocumentNavigation) {
*aIsSameDocumentNavigation = mIsSameDocumentNavigation;
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::SetIsSameDocumentNavigation(bool aIsSameDocumentNavigation) {
mIsSameDocumentNavigation = aIsSameDocumentNavigation;
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::GetAllowDeprecatedSystemRequests(
bool* aAllowDeprecatedSystemRequests) {

Просмотреть файл

@ -250,8 +250,8 @@ class LoadInfo final : public nsILoadInfo {
const nsAString& aIntegrityMetadata, bool aSkipContentSniffing,
uint32_t aHttpsOnlyStatus, bool aHstsStatus,
bool aHasValidUserGestureActivation, bool aTextDirectiveUserActivation,
bool aAllowDeprecatedSystemRequests, bool aIsInDevToolsContext,
bool aParserCreatedScript,
bool aIsSameDocumentNavigation, bool aAllowDeprecatedSystemRequests,
bool aIsInDevToolsContext, bool aParserCreatedScript,
nsILoadInfo::StoragePermissionState aStoragePermission,
const Maybe<RFPTarget>& aOverriddenFingerprintingSettings,
bool aIsMetaRefresh, uint32_t aRequestBlockingReason,
@ -369,6 +369,7 @@ class LoadInfo final : public nsILoadInfo {
bool mHstsStatus = false;
bool mHasValidUserGestureActivation = false;
bool mTextDirectiveUserActivation = false;
bool mIsSameDocumentNavigation = false;
bool mAllowDeprecatedSystemRequests = false;
bool mIsUserTriggeredSave = false;
bool mIsInDevToolsContext = false;

Просмотреть файл

@ -776,6 +776,16 @@ TRRLoadInfo::SetTextDirectiveUserActivation(bool aTextDirectiveUserActivation) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
TRRLoadInfo::GetIsSameDocumentNavigation(bool* aTextDirectiveUserActivation) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
TRRLoadInfo::SetIsSameDocumentNavigation(bool aTextDirectiveUserActivation) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
TRRLoadInfo::GetInternalContentPolicyType(nsContentPolicyType* aResult) {
*aResult = mInternalContentPolicyType;

Просмотреть файл

@ -554,6 +554,21 @@ interface nsILoadInfo : nsISupports
*/
[infallible] attribute boolean textDirectiveUserActivation;
/**
* Returns true if the current load is a same-document navigation.
*
* Note: There exists no IPC plumbing for this field. If this object crosses
* a process boundary, it is not same-document, and the value defaults
* to false.
* Also note: This flag is only meant to be used for a specific case when
* scrolling to a text fragment: If a same-doc load is triggered
* during the initial document load, and the target text has not
* been parsed.
* The flag is not being reset. If you want to use this flag for
* another reason, don't. Check Bug 1777171 for a stable solution.
*/
[infallible] attribute boolean isSameDocumentNavigation;
/**
* We disallow the SystemPrincipal to initiate requests to
* the public web. This flag is to allow exceptions.