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); MOZ_ASSERT(sameExceptHashes);
} }
#endif #endif
const nsCOMPtr<nsILoadInfo> loadInfo =
doc->GetChannel() ? doc->GetChannel()->LoadInfo() : nullptr;
if (loadInfo) {
loadInfo->SetIsSameDocumentNavigation(true);
}
// Save the position of the scrollers. // Save the position of the scrollers.
nsPoint scrollPos = GetCurScrollPos(); nsPoint scrollPos = GetCurScrollPos();

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

@ -879,6 +879,9 @@ nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& loadInfoArgs,
loadInfoArgs.skipContentSniffing(), loadInfoArgs.httpsOnlyStatus(), loadInfoArgs.skipContentSniffing(), loadInfoArgs.httpsOnlyStatus(),
loadInfoArgs.hstsStatus(), loadInfoArgs.hasValidUserGestureActivation(), loadInfoArgs.hstsStatus(), loadInfoArgs.hasValidUserGestureActivation(),
loadInfoArgs.textDirectiveUserActivation(), 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.allowDeprecatedSystemRequests(),
loadInfoArgs.isInDevToolsContext(), loadInfoArgs.parserCreatedScript(), loadInfoArgs.isInDevToolsContext(), loadInfoArgs.parserCreatedScript(),
loadInfoArgs.storagePermission(), overriddenFingerprintingSettings, loadInfoArgs.storagePermission(), overriddenFingerprintingSettings,

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

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

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

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

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

@ -776,6 +776,16 @@ TRRLoadInfo::SetTextDirectiveUserActivation(bool aTextDirectiveUserActivation) {
return NS_ERROR_NOT_IMPLEMENTED; 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 NS_IMETHODIMP
TRRLoadInfo::GetInternalContentPolicyType(nsContentPolicyType* aResult) { TRRLoadInfo::GetInternalContentPolicyType(nsContentPolicyType* aResult) {
*aResult = mInternalContentPolicyType; *aResult = mInternalContentPolicyType;

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

@ -554,6 +554,21 @@ interface nsILoadInfo : nsISupports
*/ */
[infallible] attribute boolean textDirectiveUserActivation; [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 * We disallow the SystemPrincipal to initiate requests to
* the public web. This flag is to allow exceptions. * the public web. This flag is to allow exceptions.