commit 252144864c8df5da8e5b9b7c1c6dc817c2fa8df8
parent b0c596352f76e501680fc2fbe4419e701e488ece
Author: Tooru Fujisawa <arai_a@mac.com>
Date: Thu, 27 Nov 2025 14:05:46 +0000
Bug 2002770 - Part 1: Reorder the ScriptFetchOptions fields by size. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D274286
Diffstat:
2 files changed, 32 insertions(+), 29 deletions(-)
diff --git a/js/loader/ScriptFetchOptions.h b/js/loader/ScriptFetchOptions.h
@@ -62,6 +62,31 @@ class ScriptFetchOptions {
void SetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal);
+ // Returns true if given fetch option is compatible with this fetch option
+ // in term of sharing the server response.
+ inline bool IsCompatible(ScriptFetchOptions* other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (mTriggeringPrincipal && other->mTriggeringPrincipal) {
+ bool equals;
+ (void)mTriggeringPrincipal->Equals(other->mTriggeringPrincipal, &equals);
+ if (!equals) {
+ return false;
+ }
+ } else if (mTriggeringPrincipal || other->mTriggeringPrincipal) {
+ return false;
+ }
+
+ // NOTE: mParserMetadata can be ignored.
+ return mCORSMode == other->mCORSMode && mNonce == other->mNonce &&
+ mFetchPriority == other->mFetchPriority;
+ }
+
+ public:
+ /* Fields */
+
/*
* The credentials mode used for the initial fetch (for module scripts)
* and for fetching any imported modules (for both module scripts and
@@ -70,12 +95,6 @@ class ScriptFetchOptions {
const mozilla::CORSMode mCORSMode;
/*
- * The cryptographic nonce metadata used for the initial fetch and for
- * fetching any imported modules.
- */
- const nsString mNonce;
-
- /*
* <https://html.spec.whatwg.org/multipage/webappapis.html#script-fetch-options>.
*/
const mozilla::dom::RequestPriority mFetchPriority;
@@ -93,27 +112,11 @@ class ScriptFetchOptions {
*/
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
- // Returns true if given fetch option is compatible with this fetch option
- // in term of sharing the server response.
- inline bool IsCompatible(ScriptFetchOptions* other) {
- if (this == other) {
- return true;
- }
-
- if (mTriggeringPrincipal && other->mTriggeringPrincipal) {
- bool equals;
- (void)mTriggeringPrincipal->Equals(other->mTriggeringPrincipal, &equals);
- if (!equals) {
- return false;
- }
- } else if (mTriggeringPrincipal || other->mTriggeringPrincipal) {
- return false;
- }
-
- // NOTE: mParserMetadata can be ignored.
- return mCORSMode == other->mCORSMode && mNonce == other->mNonce &&
- mFetchPriority == other->mFetchPriority;
- }
+ /*
+ * The cryptographic nonce metadata used for the initial fetch and for
+ * fetching any imported modules.
+ */
+ const nsString mNonce;
};
} // namespace JS::loader
diff --git a/js/loader/ScriptLoadRequest.cpp b/js/loader/ScriptLoadRequest.cpp
@@ -36,10 +36,10 @@ ScriptFetchOptions::ScriptFetchOptions(
mozilla::dom::RequestPriority aFetchPriority,
const ParserMetadata aParserMetadata, nsIPrincipal* aTriggeringPrincipal)
: mCORSMode(aCORSMode),
- mNonce(aNonce),
mFetchPriority(aFetchPriority),
mParserMetadata(aParserMetadata),
- mTriggeringPrincipal(aTriggeringPrincipal) {}
+ mTriggeringPrincipal(aTriggeringPrincipal),
+ mNonce(aNonce) {}
void ScriptFetchOptions::SetTriggeringPrincipal(
nsIPrincipal* aTriggeringPrincipal) {