summaryrefslogtreecommitdiffstats
path: root/uriloader/preload
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /uriloader/preload
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 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,