summaryrefslogtreecommitdiffstats
path: root/uriloader/preload
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /uriloader/preload
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz
firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'uriloader/preload')
-rw-r--r--uriloader/preload/PreloadService.cpp50
-rw-r--r--uriloader/preload/PreloadService.h3
2 files changed, 19 insertions, 34 deletions
diff --git a/uriloader/preload/PreloadService.cpp b/uriloader/preload/PreloadService.cpp
index 5fc59760f0..48cf9a364c 100644
--- a/uriloader/preload/PreloadService.cpp
+++ b/uriloader/preload/PreloadService.cpp
@@ -137,46 +137,28 @@ void PreloadService::PreloadLinkHeader(
}
// The mapping is specified as implementation-defined, see step 15 of
-// <https://fetch.spec.whatwg.org/#concept-fetch>. For web-compatibility,
-// Chromium's mapping described at
-// <https://web.dev/articles/fetch-priority#browser_priority_and_fetchpriority>
-// is chosen.
+// <https://fetch.spec.whatwg.org/#concept-fetch>.
+// See corresponding preferences in StaticPrefList.yaml for more context.
class SupportsPriorityValueFor {
public:
static int32_t LinkRelPreloadFont(const FetchPriority aFetchPriority) {
+ int32_t priorityValue = nsISupportsPriority::PRIORITY_HIGH;
if (!StaticPrefs::network_fetchpriority_enabled()) {
- return nsISupportsPriority::PRIORITY_HIGH;
+ return priorityValue;
}
- switch (aFetchPriority) {
- case FetchPriority::Auto:
- return nsISupportsPriority::PRIORITY_HIGH;
- case FetchPriority::High:
- return nsISupportsPriority::PRIORITY_HIGH;
- case FetchPriority::Low:
- return nsISupportsPriority::PRIORITY_LOW;
- }
-
- MOZ_ASSERT_UNREACHABLE();
- return nsISupportsPriority::PRIORITY_HIGH;
+ return priorityValue +
+ FETCH_PRIORITY_ADJUSTMENT_FOR(link_preload_font, aFetchPriority);
}
static int32_t LinkRelPreloadFetch(const FetchPriority aFetchPriority) {
+ int32_t priorityValue = nsISupportsPriority::PRIORITY_NORMAL;
if (!StaticPrefs::network_fetchpriority_enabled()) {
- return nsISupportsPriority::PRIORITY_NORMAL;
- }
-
- switch (aFetchPriority) {
- case FetchPriority::Auto:
- return nsISupportsPriority::PRIORITY_NORMAL;
- case FetchPriority::High:
- return nsISupportsPriority::PRIORITY_HIGH;
- case FetchPriority::Low:
- return nsISupportsPriority::PRIORITY_LOW;
+ return priorityValue;
}
- MOZ_ASSERT_UNREACHABLE();
- return nsISupportsPriority::PRIORITY_NORMAL;
+ return priorityValue +
+ FETCH_PRIORITY_ADJUSTMENT_FOR(link_preload_fetch, aFetchPriority);
}
};
@@ -244,7 +226,8 @@ PreloadService::PreloadOrCoalesceResult PreloadService::PreloadOrCoalesce(
break;
}
} else if (aAs.LowerCaseEqualsASCII("image")) {
- PreloadImage(uri, aCORS, aReferrerPolicy, isImgSet, aEarlyHintPreloaderId);
+ PreloadImage(uri, aCORS, aReferrerPolicy, isImgSet, aEarlyHintPreloaderId,
+ aFetchPriority);
} else if (aAs.LowerCaseEqualsASCII("font")) {
PreloadFont(uri, aCORS, aReferrerPolicy, aEarlyHintPreloaderId,
aFetchPriority);
@@ -276,10 +259,11 @@ void PreloadService::PreloadScript(
void PreloadService::PreloadImage(nsIURI* aURI, const nsAString& aCrossOrigin,
const nsAString& aImageReferrerPolicy,
bool aIsImgSet,
- uint64_t aEarlyHintPreloaderId) {
- mDocument->PreLoadImage(aURI, aCrossOrigin,
- PreloadReferrerPolicy(aImageReferrerPolicy),
- aIsImgSet, true, aEarlyHintPreloaderId);
+ uint64_t aEarlyHintPreloaderId,
+ const nsAString& aFetchPriority) {
+ mDocument->PreLoadImage(
+ aURI, aCrossOrigin, PreloadReferrerPolicy(aImageReferrerPolicy),
+ aIsImgSet, true, aEarlyHintPreloaderId, aFetchPriority);
}
void PreloadService::PreloadFont(nsIURI* aURI, const nsAString& aCrossOrigin,
diff --git a/uriloader/preload/PreloadService.h b/uriloader/preload/PreloadService.h
index 5f6566ea34..79f5e7b6d1 100644
--- a/uriloader/preload/PreloadService.h
+++ b/uriloader/preload/PreloadService.h
@@ -90,7 +90,8 @@ class PreloadService {
void PreloadImage(nsIURI* aURI, const nsAString& aCrossOrigin,
const nsAString& aImageReferrerPolicy, bool aIsImgSet,
- uint64_t aEarlyHintPreloaderId);
+ uint64_t aEarlyHintPreloaderId,
+ const nsAString& aFetchPriority);
void PreloadFont(nsIURI* aURI, const nsAString& aCrossOrigin,
const nsAString& aReferrerPolicy,