Bug 1865610: part 1) Add partial support for the "fetchpriority" attribute for loading style sheets from <link> elements or Link header fields. r=smaug,emilio,valentin
Includes only support for dynamically loading style sheets from `<link>` elements and `Link` header fields. The remaining support, including preloading, is completed in part 3. Differential Revision: https://phabricator.services.mozilla.com/D191745
This commit is contained in:
@@ -682,26 +682,28 @@ static void AdjustPriorityForNonLinkPreloadScripts(
|
||||
// For web-compatibility, the fetch priority mapping from
|
||||
// <https://web.dev/fetch-priority/#browser-priority-and-fetchpriority> is
|
||||
// taken.
|
||||
switch (fetchPriority) {
|
||||
case RequestPriority::Auto:
|
||||
LOG(("ScriptLoader::%s:, fetchpriority=auto", __FUNCTION__));
|
||||
break;
|
||||
case RequestPriority::Low: {
|
||||
LOG(("ScriptLoader::%s:, fetchpriority=low, setting priority",
|
||||
__FUNCTION__));
|
||||
supportsPriority->SetPriority(nsISupportsPriority::PRIORITY_LOW);
|
||||
break;
|
||||
}
|
||||
case RequestPriority::High: {
|
||||
LOG(("ScriptLoader::%s:, fetchpriority=high, setting priority",
|
||||
__FUNCTION__));
|
||||
supportsPriority->SetPriority(nsISupportsPriority::PRIORITY_HIGH);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
MOZ_ASSERT_UNREACHABLE();
|
||||
break;
|
||||
const Maybe<int32_t> supportsPriorityValue = [&]() -> Maybe<int32_t> {
|
||||
switch (fetchPriority) {
|
||||
case RequestPriority::Auto:
|
||||
return Nothing{};
|
||||
case RequestPriority::Low: {
|
||||
return Some(nsISupportsPriority::PRIORITY_LOW);
|
||||
}
|
||||
case RequestPriority::High: {
|
||||
return Some(nsISupportsPriority::PRIORITY_HIGH);
|
||||
}
|
||||
default: {
|
||||
MOZ_ASSERT_UNREACHABLE();
|
||||
return Nothing{};
|
||||
}
|
||||
}
|
||||
}();
|
||||
|
||||
if (supportsPriorityValue) {
|
||||
LogPriorityMapping(ScriptLoader::gScriptLoaderLog,
|
||||
ToFetchPriority(fetchPriority),
|
||||
*supportsPriorityValue);
|
||||
supportsPriority->SetPriority(*supportsPriorityValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user