зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1888756, part 1 - Text Fragments: Introduce `textDirectiveUserActivation` flag. r=edgar,dom-core
This commit is a prerequisite for part 5 of this patch set and introduces the `text directive user activation` flag as well as the necessary boilerplate to transport the value through process boundaries in `nsDocShellLoadState` and `LoadInfo`. There is no changed behavior in this commit. Differential Revision: https://phabricator.services.mozilla.com/D212816
This commit is contained in:
Родитель
863cd557f4
Коммит
0221e167ca
|
@ -73,6 +73,7 @@ nsDocShellLoadState::nsDocShellLoadState(
|
|||
mInternalLoadFlags = aLoadState.InternalLoadFlags();
|
||||
mFirstParty = aLoadState.FirstParty();
|
||||
mHasValidUserGestureActivation = aLoadState.HasValidUserGestureActivation();
|
||||
mTextDirectiveUserActivation = aLoadState.TextDirectiveUserActivation();
|
||||
mAllowFocusMove = aLoadState.AllowFocusMove();
|
||||
mTypeHint = aLoadState.TypeHint();
|
||||
mFileName = aLoadState.FileName();
|
||||
|
@ -183,6 +184,7 @@ nsDocShellLoadState::nsDocShellLoadState(const nsDocShellLoadState& aOther)
|
|||
mInternalLoadFlags(aOther.mInternalLoadFlags),
|
||||
mFirstParty(aOther.mFirstParty),
|
||||
mHasValidUserGestureActivation(aOther.mHasValidUserGestureActivation),
|
||||
mTextDirectiveUserActivation(aOther.mTextDirectiveUserActivation),
|
||||
mAllowFocusMove(aOther.mAllowFocusMove),
|
||||
mTypeHint(aOther.mTypeHint),
|
||||
mFileName(aOther.mFileName),
|
||||
|
@ -460,6 +462,8 @@ nsresult nsDocShellLoadState::CreateFromLoadURIOptions(
|
|||
loadState->SetFirstParty(true);
|
||||
loadState->SetHasValidUserGestureActivation(
|
||||
aLoadURIOptions.mHasValidUserGestureActivation);
|
||||
loadState->SetTextDirectiveUserActivation(
|
||||
aLoadURIOptions.mHasValidUserGestureActivation);
|
||||
loadState->SetTriggeringSandboxFlags(aLoadURIOptions.mTriggeringSandboxFlags);
|
||||
loadState->SetTriggeringWindowId(aLoadURIOptions.mTriggeringWindowId);
|
||||
loadState->SetTriggeringStorageAccess(
|
||||
|
@ -907,6 +911,15 @@ void nsDocShellLoadState::SetHasValidUserGestureActivation(
|
|||
mHasValidUserGestureActivation = aHasValidUserGestureActivation;
|
||||
}
|
||||
|
||||
void nsDocShellLoadState::SetTextDirectiveUserActivation(
|
||||
bool aTextDirectiveUserActivation) {
|
||||
mTextDirectiveUserActivation = aTextDirectiveUserActivation;
|
||||
}
|
||||
|
||||
bool nsDocShellLoadState::GetTextDirectiveUserActivation() {
|
||||
return mTextDirectiveUserActivation;
|
||||
}
|
||||
|
||||
const nsCString& nsDocShellLoadState::TypeHint() const { return mTypeHint; }
|
||||
|
||||
void nsDocShellLoadState::SetTypeHint(const nsCString& aTypeHint) {
|
||||
|
@ -1298,6 +1311,7 @@ DocShellLoadStateInit nsDocShellLoadState::Serialize(
|
|||
loadState.InternalLoadFlags() = mInternalLoadFlags;
|
||||
loadState.FirstParty() = mFirstParty;
|
||||
loadState.HasValidUserGestureActivation() = mHasValidUserGestureActivation;
|
||||
loadState.TextDirectiveUserActivation() = mTextDirectiveUserActivation;
|
||||
loadState.AllowFocusMove() = mAllowFocusMove;
|
||||
loadState.TypeHint() = mTypeHint;
|
||||
loadState.FileName() = mFileName;
|
||||
|
|
|
@ -258,6 +258,10 @@ class nsDocShellLoadState final {
|
|||
|
||||
void SetHasValidUserGestureActivation(bool HasValidUserGestureActivation);
|
||||
|
||||
void SetTextDirectiveUserActivation(bool aTextDirectiveUserActivation);
|
||||
|
||||
bool GetTextDirectiveUserActivation();
|
||||
|
||||
const nsCString& TypeHint() const;
|
||||
|
||||
void SetTypeHint(const nsCString& aTypeHint);
|
||||
|
@ -559,6 +563,11 @@ class nsDocShellLoadState final {
|
|||
// Is this load triggered by a user gesture?
|
||||
bool mHasValidUserGestureActivation;
|
||||
|
||||
// True if a text directive can be scrolled to. This is true either if the
|
||||
// load is triggered by a user, or the document has an unconsumed activation
|
||||
// (eg. client redirect).
|
||||
bool mTextDirectiveUserActivation = false;
|
||||
|
||||
// Whether this load can steal the focus from the source browsing context.
|
||||
bool mAllowFocusMove;
|
||||
|
||||
|
|
|
@ -209,6 +209,7 @@ struct DocShellLoadStateInit
|
|||
bool IsFormSubmission;
|
||||
bool FirstParty;
|
||||
bool HasValidUserGestureActivation;
|
||||
bool TextDirectiveUserActivation;
|
||||
bool AllowFocusMove;
|
||||
bool IsFromProcessingFrameAttributes;
|
||||
bool WasSchemelessInput;
|
||||
|
|
|
@ -587,6 +587,7 @@ nsresult LoadInfoToLoadInfoArgs(nsILoadInfo* aLoadInfo,
|
|||
integrityMetadata, aLoadInfo->GetSkipContentSniffing(),
|
||||
aLoadInfo->GetHttpsOnlyStatus(), aLoadInfo->GetHstsStatus(),
|
||||
aLoadInfo->GetHasValidUserGestureActivation(),
|
||||
aLoadInfo->GetTextDirectiveUserActivation(),
|
||||
aLoadInfo->GetAllowDeprecatedSystemRequests(),
|
||||
aLoadInfo->GetIsInDevToolsContext(), aLoadInfo->GetParserCreatedScript(),
|
||||
aLoadInfo->GetIsFromProcessingFrameAttributes(),
|
||||
|
@ -877,6 +878,7 @@ nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& loadInfoArgs,
|
|||
loadInfoArgs.cspNonce(), loadInfoArgs.integrityMetadata(),
|
||||
loadInfoArgs.skipContentSniffing(), loadInfoArgs.httpsOnlyStatus(),
|
||||
loadInfoArgs.hstsStatus(), loadInfoArgs.hasValidUserGestureActivation(),
|
||||
loadInfoArgs.textDirectiveUserActivation(),
|
||||
loadInfoArgs.allowDeprecatedSystemRequests(),
|
||||
loadInfoArgs.isInDevToolsContext(), loadInfoArgs.parserCreatedScript(),
|
||||
loadInfoArgs.storagePermission(), overriddenFingerprintingSettings,
|
||||
|
@ -955,6 +957,7 @@ void LoadInfoToParentLoadInfoForwarder(
|
|||
aLoadInfo->GetSkipContentSniffing(), aLoadInfo->GetHttpsOnlyStatus(),
|
||||
aLoadInfo->GetWasSchemelessInput(), aLoadInfo->GetHttpsUpgradeTelemetry(),
|
||||
aLoadInfo->GetHstsStatus(), aLoadInfo->GetHasValidUserGestureActivation(),
|
||||
aLoadInfo->GetTextDirectiveUserActivation(),
|
||||
aLoadInfo->GetAllowDeprecatedSystemRequests(),
|
||||
aLoadInfo->GetIsInDevToolsContext(), aLoadInfo->GetParserCreatedScript(),
|
||||
aLoadInfo->GetTriggeringSandboxFlags(),
|
||||
|
@ -990,6 +993,9 @@ nsresult MergeParentLoadInfoForwarder(
|
|||
} else {
|
||||
aLoadInfo->MaybeIncreaseTainting(aForwarderArgs.tainting());
|
||||
}
|
||||
rv = aLoadInfo->SetTextDirectiveUserActivation(
|
||||
aForwarderArgs.textDirectiveUserActivation());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = aLoadInfo->SetSkipContentSniffing(aForwarderArgs.skipContentSniffing());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -670,6 +670,7 @@ LoadInfo::LoadInfo(const LoadInfo& rhs)
|
|||
mHttpsOnlyStatus(rhs.mHttpsOnlyStatus),
|
||||
mHstsStatus(rhs.mHstsStatus),
|
||||
mHasValidUserGestureActivation(rhs.mHasValidUserGestureActivation),
|
||||
mTextDirectiveUserActivation(rhs.mTextDirectiveUserActivation),
|
||||
mAllowDeprecatedSystemRequests(rhs.mAllowDeprecatedSystemRequests),
|
||||
mIsInDevToolsContext(rhs.mIsInDevToolsContext),
|
||||
mParserCreatedScript(rhs.mParserCreatedScript),
|
||||
|
@ -730,8 +731,9 @@ LoadInfo::LoadInfo(
|
|||
bool aNeedForCheckingAntiTrackingHeuristic, const nsAString& aCspNonce,
|
||||
const nsAString& aIntegrityMetadata, bool aSkipContentSniffing,
|
||||
uint32_t aHttpsOnlyStatus, bool aHstsStatus,
|
||||
bool aHasValidUserGestureActivation, bool aAllowDeprecatedSystemRequests,
|
||||
bool aIsInDevToolsContext, bool aParserCreatedScript,
|
||||
bool aHasValidUserGestureActivation, bool aTextDirectiveUserActivation,
|
||||
bool aAllowDeprecatedSystemRequests, bool aIsInDevToolsContext,
|
||||
bool aParserCreatedScript,
|
||||
nsILoadInfo::StoragePermissionState aStoragePermission,
|
||||
const Maybe<RFPTarget>& aOverriddenFingerprintingSettings,
|
||||
bool aIsMetaRefresh, uint32_t aRequestBlockingReason,
|
||||
|
@ -805,6 +807,7 @@ LoadInfo::LoadInfo(
|
|||
mHttpsOnlyStatus(aHttpsOnlyStatus),
|
||||
mHstsStatus(aHstsStatus),
|
||||
mHasValidUserGestureActivation(aHasValidUserGestureActivation),
|
||||
mTextDirectiveUserActivation(aTextDirectiveUserActivation),
|
||||
mAllowDeprecatedSystemRequests(aAllowDeprecatedSystemRequests),
|
||||
mIsInDevToolsContext(aIsInDevToolsContext),
|
||||
mParserCreatedScript(aParserCreatedScript),
|
||||
|
@ -1985,6 +1988,18 @@ LoadInfo::SetHasValidUserGestureActivation(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetTextDirectiveUserActivation(bool* aTextDirectiveUserActivation) {
|
||||
*aTextDirectiveUserActivation = mTextDirectiveUserActivation;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::SetTextDirectiveUserActivation(bool aTextDirectiveUserActivation) {
|
||||
mTextDirectiveUserActivation = aTextDirectiveUserActivation;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetAllowDeprecatedSystemRequests(
|
||||
bool* aAllowDeprecatedSystemRequests) {
|
||||
|
|
|
@ -249,8 +249,9 @@ class LoadInfo final : public nsILoadInfo {
|
|||
bool aNeedForCheckingAntiTrackingHeuristic, const nsAString& aCspNonce,
|
||||
const nsAString& aIntegrityMetadata, bool aSkipContentSniffing,
|
||||
uint32_t aHttpsOnlyStatus, bool aHstsStatus,
|
||||
bool aHasValidUserGestureActivation, bool aAllowDeprecatedSystemRequests,
|
||||
bool aIsInDevToolsContext, bool aParserCreatedScript,
|
||||
bool aHasValidUserGestureActivation, bool aTextDirectiveUserActivation,
|
||||
bool aAllowDeprecatedSystemRequests, bool aIsInDevToolsContext,
|
||||
bool aParserCreatedScript,
|
||||
nsILoadInfo::StoragePermissionState aStoragePermission,
|
||||
const Maybe<RFPTarget>& aOverriddenFingerprintingSettings,
|
||||
bool aIsMetaRefresh, uint32_t aRequestBlockingReason,
|
||||
|
@ -367,6 +368,7 @@ class LoadInfo final : public nsILoadInfo {
|
|||
uint32_t mHttpsOnlyStatus = nsILoadInfo::HTTPS_ONLY_UNINITIALIZED;
|
||||
bool mHstsStatus = false;
|
||||
bool mHasValidUserGestureActivation = false;
|
||||
bool mTextDirectiveUserActivation = false;
|
||||
bool mAllowDeprecatedSystemRequests = false;
|
||||
bool mIsUserTriggeredSave = false;
|
||||
bool mIsInDevToolsContext = false;
|
||||
|
|
|
@ -765,6 +765,17 @@ TRRLoadInfo::SetHasValidUserGestureActivation(
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TRRLoadInfo::GetTextDirectiveUserActivation(
|
||||
bool* aTextDirectiveUserActivation) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TRRLoadInfo::SetTextDirectiveUserActivation(bool aTextDirectiveUserActivation) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TRRLoadInfo::GetInternalContentPolicyType(nsContentPolicyType* aResult) {
|
||||
*aResult = mInternalContentPolicyType;
|
||||
|
|
|
@ -546,6 +546,14 @@ interface nsILoadInfo : nsISupports
|
|||
*/
|
||||
[infallible] attribute boolean hasValidUserGestureActivation;
|
||||
|
||||
/**
|
||||
* Returns true if at the time of the loadinfo construction the document that
|
||||
* triggered this load was user activated. This flag is being used to indicate
|
||||
* whether a document load with a text fragment is allowed to scroll to the
|
||||
* first text directive.
|
||||
*/
|
||||
[infallible] attribute boolean textDirectiveUserActivation;
|
||||
|
||||
/**
|
||||
* We disallow the SystemPrincipal to initiate requests to
|
||||
* the public web. This flag is to allow exceptions.
|
||||
|
|
|
@ -178,6 +178,7 @@ struct LoadInfoArgs
|
|||
uint32_t httpsOnlyStatus;
|
||||
bool hstsStatus;
|
||||
bool hasValidUserGestureActivation;
|
||||
bool textDirectiveUserActivation;
|
||||
bool allowDeprecatedSystemRequests;
|
||||
bool isInDevToolsContext;
|
||||
bool parserCreatedScript;
|
||||
|
@ -238,6 +239,11 @@ struct ParentLoadInfoForwarderArgs
|
|||
// in the context of Sec-Fetch-User.)
|
||||
bool hasValidUserGestureActivation;
|
||||
|
||||
// Returns true if at the time of the loadinfo construction the document
|
||||
// that triggered this load has an user activation, so that if the new
|
||||
// document has a text fragment, its first text directive can be scrolled to.
|
||||
bool textDirectiveUserActivation;
|
||||
|
||||
// The SystemPrincipal is disallowed to make requests to the public web
|
||||
// and all requests will be cancelled. Setting this flag to true prevents
|
||||
// the request from being cancelled.
|
||||
|
|
Загрузка…
Ссылка в новой задаче