Bug 1878895 - Remove network.fetchpriority.enabled check from nsContentSink::ProcessStyleLinkFromHeader. r=smaug

Follow-up of https://phabricator.services.mozilla.com/D191745#6355404
This check can actually be removed without observable behavior change,
as detailed below:

1. In `nsContentSink::ProcessLinkFromHeader`, the
   `aHeader.mFetchPriority` string is passed to
   `nsContentSink::ProcessStyleLinkFromHeader`:
   https://searchfox.org/mozilla-central/rev/6b8a3f804789fb865f42af54e9d2fef9dd3ec74d/dom/base/nsContentSink.cpp#338

2. In `nsContentSink::ProcessStyleLinkFromHeader`, `aFetchPriority`
   is only parsed into a `fetchPriority` value by
   `nsGenericHTMLElement::ToFetchPriority`. That value is only wrapped
   into a `Loader::SheetInfo` info. And that info is only passed to
   `Loader::LoadStyleLink`:
   https://searchfox.org/mozilla-central/rev/6b8a3f804789fb865f42af54e9d2fef9dd3ec74d/dom/base/nsContentSink.cpp#381

3. In `Loader::LoadStyleLink`, `aInfo` is only used to access some specific
   members and `aInfo.mFetchPriority` only passed to the `SheetLoadData`
   constructor where it is stored as a member:
   https://searchfox.org/mozilla-central/rev/6b8a3f804789fb865f42af54e9d2fef9dd3ec74d/layout/style/Loader.cpp#309

4. Finally, the only place where `SheetLoadData.mFetchPriority` is actually
   used is in `Loader::AdjustPriority`. But if `network.fetchpriority` is
   disabled, we actually return early  without using it:
   https://searchfox.org/mozilla-central/rev/6b8a3f804789fb865f42af54e9d2fef9dd3ec74d/layout/style/Loader.cpp#1354

Differential Revision: https://phabricator.services.mozilla.com/D200909
This commit is contained in:
Frédéric Wang 2024-02-07 21:34:21 +00:00
parent 3f6f4db1d8
commit f4030d1754

View File

@ -335,11 +335,10 @@ nsresult nsContentSink::ProcessLinkFromHeader(const net::LinkHeader& aHeader,
}
bool isAlternate = linkTypes & LinkStyle::eALTERNATE;
return ProcessStyleLinkFromHeader(
aHeader.mHref, isAlternate, aHeader.mTitle, aHeader.mIntegrity,
aHeader.mType, aHeader.mMedia, aHeader.mReferrerPolicy,
StaticPrefs::network_fetchpriority_enabled() ? aHeader.mFetchPriority
: EmptyString());
return ProcessStyleLinkFromHeader(aHeader.mHref, isAlternate, aHeader.mTitle,
aHeader.mIntegrity, aHeader.mType,
aHeader.mMedia, aHeader.mReferrerPolicy,
aHeader.mFetchPriority);
}
nsresult nsContentSink::ProcessStyleLinkFromHeader(