Bug 1571530 - Remove various bool arguments in sheet loader APIs. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 16 Aug 2019 10:56:05 +0000
changeset 488484 589addc490dc23dfc16eedc50ac90e3dad3a4d1b
parent 488483 db8dfad2e3b380ed6d9d63d5ef067400b51197ee
child 488485 1f4c64e73cfc266d25c595a1e943737f577c5e0a
push id36444
push userccoroiu@mozilla.com
push dateFri, 16 Aug 2019 16:24:18 +0000
treeherdermozilla-central@8a9e9189cd98 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1571530
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1571530 - Remove various bool arguments in sheet loader APIs. r=heycam They're bad, specially if they do vastly different thing in overloaded functions, like aUseSystemPrincipal and aIsPreload. :) Differential Revision: https://phabricator.services.mozilla.com/D40851
dom/base/Document.cpp
editor/libeditor/HTMLEditor.cpp
layout/base/nsStyleSheetService.cpp
layout/style/Loader.cpp
layout/style/Loader.h
layout/style/PreloadedStyleSheet.cpp
layout/style/nsLayoutStylesheetCache.cpp
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -6480,17 +6480,18 @@ nsresult Document::LoadAdditionalStyleSh
     case Document::eAuthorSheet:
       parsingMode = css::eAuthorSheetFeatures;
       break;
 
     default:
       MOZ_CRASH("impossible value for aType");
   }
 
-  auto result = loader->LoadSheetSync(aSheetURI, parsingMode, true);
+  auto result = loader->LoadSheetSync(aSheetURI, parsingMode,
+                                      css::Loader::UseSystemPrincipal::Yes);
   if (result.isErr()) {
     return result.unwrapErr();
   }
 
   RefPtr<StyleSheet> sheet = result.unwrap();
 
   sheet->SetAssociatedDocumentOrShadowRoot(
       this, StyleSheet::OwnedByDocumentOrShadowRoot);
@@ -11441,23 +11442,24 @@ void Document::PreloadStyle(
   // The CSSLoader will retain this object after we return.
   nsCOMPtr<nsICSSLoaderObserver> obs = new StubCSSLoaderObserver();
 
   nsCOMPtr<nsIReferrerInfo> referrerInfo =
       ReferrerInfo::CreateFromDocumentAndPolicyOverride(this, aReferrerPolicy);
 
   // Charset names are always ASCII.
   Unused << CSSLoader()->LoadSheet(
-      uri, true, NodePrincipal(), aEncoding, referrerInfo, obs,
-      Element::StringToCORSMode(aCrossOriginAttr), aIntegrity);
+      uri, css::Loader::IsPreload::Yes, NodePrincipal(), aEncoding,
+      referrerInfo, obs, Element::StringToCORSMode(aCrossOriginAttr),
+      aIntegrity);
 }
 
 RefPtr<StyleSheet> Document::LoadChromeSheetSync(nsIURI* uri) {
   return CSSLoader()
-      ->LoadSheetSync(uri, css::eAuthorSheetFeatures, false)
+      ->LoadSheetSync(uri, css::eAuthorSheetFeatures)
       .unwrapOr(nullptr);
 }
 
 void Document::ResetDocumentDirection() {
   if (!nsContentUtils::IsChromeDoc(this)) {
     return;
   }
   UpdateDocumentStates(NS_DOCUMENT_STATE_RTL_LOCALE, true);
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3104,17 +3104,17 @@ nsresult HTMLEditor::AddOverrideStyleShe
     return rv;
   }
 
   // We MUST ONLY load synchronous local files (no @import)
   // XXXbz Except this will actually try to load remote files
   // synchronously, of course..
   // Editor override style sheets may want to style Gecko anonymous boxes
   auto result = presShell->GetDocument()->CSSLoader()->LoadSheetSync(
-      uaURI, css::eAgentSheetFeatures, true);
+      uaURI, css::eAgentSheetFeatures, css::Loader::UseSystemPrincipal::Yes);
   // Synchronous loads should ALWAYS return completed
   if (NS_WARN_IF(result.isErr())) {
     return result.unwrapErr();
   }
 
   RefPtr<StyleSheet> sheet = result.unwrap();
 
   // Add the override style sheet
--- a/layout/base/nsStyleSheetService.cpp
+++ b/layout/base/nsStyleSheetService.cpp
@@ -200,17 +200,18 @@ nsresult nsStyleSheetService::LoadAndReg
       break;
 
     default:
       NS_WARNING("invalid sheet type argument");
       return NS_ERROR_INVALID_ARG;
   }
 
   RefPtr<css::Loader> loader = new css::Loader;
-  auto result = loader->LoadSheetSync(aSheetURI, parsingMode, true);
+  auto result = loader->LoadSheetSync(aSheetURI, parsingMode,
+                                      css::Loader::UseSystemPrincipal::Yes);
   if (result.isErr()) {
     return result.unwrapErr();
   }
   mSheets[aSheetType].AppendElement(result.unwrap());
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -610,17 +610,17 @@ void Loader::DocumentStyleSheetSetChange
       arr.AppendElement(data);
       iter.Remove();
     }
   }
 
   mDatasToNotifyOn += arr.Length();
   for (uint32_t i = 0; i < arr.Length(); ++i) {
     --mDatasToNotifyOn;
-    LoadSheet(arr[i], SheetState::NeedsParser, false);
+    LoadSheet(arr[i], SheetState::NeedsParser, IsPreload::No);
   }
 }
 
 static const char kCharsetSym[] = "@charset \"";
 
 static bool GetCharsetFromData(const char* aStyleSheetData,
                                uint32_t aDataLength, nsACString& aCharset) {
   aCharset.Truncate();
@@ -981,26 +981,28 @@ Loader::IsAlternate Loader::IsAlternateS
   }
 
   return IsAlternate::Yes;
 }
 
 nsresult Loader::CheckContentPolicy(nsIPrincipal* aLoadingPrincipal,
                                     nsIPrincipal* aTriggeringPrincipal,
                                     nsIURI* aTargetURI,
-                                    nsINode* aRequestingNode, bool aIsPreload) {
+                                    nsINode* aRequestingNode,
+                                    IsPreload aIsPreload) {
   // When performing a system load (e.g. aUseSystemPrincipal = true)
   // then aLoadingPrincipal == null; don't consult content policies.
   if (!aLoadingPrincipal) {
     return NS_OK;
   }
 
   nsContentPolicyType contentPolicyType =
-      aIsPreload ? nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD
-                 : nsIContentPolicy::TYPE_INTERNAL_STYLESHEET;
+      aIsPreload == IsPreload::Yes
+          ? nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD
+          : nsIContentPolicy::TYPE_INTERNAL_STYLESHEET;
 
   nsCOMPtr<nsILoadInfo> secCheckLoadInfo = new net::LoadInfo(
       aLoadingPrincipal, aTriggeringPrincipal, aRequestingNode,
       nsILoadInfo::SEC_ONLY_FOR_EXPLICIT_CONTENTSEC_CHECK, contentPolicyType);
 
   // snapshot the nonce at load start time for performing CSP checks
   if (contentPolicyType == nsIContentPolicy::TYPE_INTERNAL_STYLESHEET) {
     nsCOMPtr<Element> element = do_QueryInterface(aRequestingNode);
@@ -1227,17 +1229,17 @@ void Loader::InsertChildSheet(StyleSheet
  * LoadSheet handles the actual load of a sheet.  If the load is
  * supposed to be synchronous it just opens a channel synchronously
  * using the given uri, wraps the resulting stream in a converter
  * stream and calls ParseSheet.  Otherwise it tries to look for an
  * existing load for this URI and piggyback on it.  Failing all that,
  * a new load is kicked off asynchronously.
  */
 nsresult Loader::LoadSheet(SheetLoadData* aLoadData, SheetState aSheetState,
-                           bool aIsPreload) {
+                           IsPreload aIsPreload) {
   LOG(("css::Loader::LoadSheet"));
   MOZ_ASSERT(aLoadData, "Need a load data");
   MOZ_ASSERT(aLoadData->mURI, "Need a URI to load");
   MOZ_ASSERT(aLoadData->mSheet, "Need a sheet to load into");
   MOZ_ASSERT(aSheetState != SheetState::Complete, "Why bother?");
   MOZ_ASSERT(!aLoadData->mUseSystemPrincipal || aLoadData->mSyncLoad,
              "Shouldn't use system principal for async loads");
   NS_ASSERTION(mSheets, "mLoadingDatas should be initialized by now.");
@@ -1273,18 +1275,19 @@ nsresult Loader::LoadSheet(SheetLoadData
                                    mDocument);
     }
 
     nsSecurityFlags securityFlags =
         nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS |
         nsILoadInfo::SEC_ALLOW_CHROME;
 
     nsContentPolicyType contentPolicyType =
-        aIsPreload ? nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD
-                   : nsIContentPolicy::TYPE_INTERNAL_STYLESHEET;
+        aIsPreload == IsPreload::Yes
+            ? nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD
+            : nsIContentPolicy::TYPE_INTERNAL_STYLESHEET;
 
     // Just load it
     nsCOMPtr<nsIChannel> channel;
     // Note that we are calling NS_NewChannelWithTriggeringPrincipal() with both
     // a node and a principal.
     // This is because of a case where the node is the document being styled and
     // the principal is the stylesheet (perhaps from a different origin) that is
     // applying the styles.
@@ -1419,18 +1422,19 @@ nsresult Loader::LoadSheet(SheetLoadData
   if (ourCORSMode == CORS_ANONYMOUS) {
     securityFlags |= nsILoadInfo::SEC_COOKIES_SAME_ORIGIN;
   } else if (ourCORSMode == CORS_USE_CREDENTIALS) {
     securityFlags |= nsILoadInfo::SEC_COOKIES_INCLUDE;
   }
   securityFlags |= nsILoadInfo::SEC_ALLOW_CHROME;
 
   nsContentPolicyType contentPolicyType =
-      aIsPreload ? nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD
-                 : nsIContentPolicy::TYPE_INTERNAL_STYLESHEET;
+      aIsPreload == IsPreload::Yes
+          ? nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD
+          : nsIContentPolicy::TYPE_INTERNAL_STYLESHEET;
 
   nsCOMPtr<nsIChannel> channel;
   // Note we are calling NS_NewChannelWithTriggeringPrincipal here with a node
   // and a principal. This is because of a case where the node is the document
   // being styled and the principal is the stylesheet (perhaps from a different
   // origin)  that is applying the styles.
   if (aLoadData->mRequestingNode && aLoadData->mLoaderPrincipal) {
     rv = NS_NewChannelWithTriggeringPrincipal(
@@ -1919,17 +1923,17 @@ Result<Loader::LoadSheetResult, nsresult
   }
 
   bool syncLoad = aInfo.mContent && aInfo.mContent->IsInUAWidget() &&
                   IsChromeURI(aInfo.mURI);
   LOG(("  Link sync load: '%s'", syncLoad ? "true" : "false"));
   MOZ_ASSERT_IF(syncLoad, !aObserver);
 
   nsresult rv = CheckContentPolicy(loadingPrincipal, principal, aInfo.mURI,
-                                   context, false);
+                                   context, IsPreload::No);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     // Don't fire the error event if our document is loaded as data.  We're
     // supposed to not even try to do loads in that case... Unfortunately, we
     // implement that via nsDataDocumentContentPolicy, which doesn't have a good
     // way to communicate back to us that _it_ is the thing that blocked the
     // load.
     if (aInfo.mContent && !mDocument->IsLoadedAsData()) {
       // Fire an async error event on it.
@@ -1992,17 +1996,17 @@ Result<Loader::LoadSheetResult, nsresult
     LOG(("  Deferring sheet load"));
     SheetLoadDataHashKey key(data);
     mSheets->mPendingDatas.Put(&key, data);
     data->mMustNotify = true;
     return result;
   }
 
   // Load completion will free the data
-  rv = LoadSheet(data, state, false);
+  rv = LoadSheet(data, state, IsPreload::No);
   if (NS_FAILED(rv)) {
     return Err(rv);
   }
 
   if (!syncLoad) {
     data->mMustNotify = true;
   }
   return result;
@@ -2068,18 +2072,18 @@ nsresult Loader::LoadChildSheet(StyleShe
     context = owningNode;
     loadingPrincipal = owningNode->NodePrincipal();
   } else if (mDocument) {
     context = mDocument;
     loadingPrincipal = mDocument->NodePrincipal();
   }
 
   nsIPrincipal* principal = aParentSheet->Principal();
-  nsresult rv =
-      CheckContentPolicy(loadingPrincipal, principal, aURL, context, false);
+  nsresult rv = CheckContentPolicy(loadingPrincipal, principal, aURL, context,
+                                   IsPreload::No);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     if (aParentData) {
       MarkLoadTreeFailed(aParentData);
     }
     return rv;
   }
 
   nsCOMPtr<nsICSSLoaderObserver> observer;
@@ -2134,63 +2138,65 @@ nsresult Loader::LoadChildSheet(StyleShe
   SheetLoadData* data =
       new SheetLoadData(this, aURL, sheet, aParentData, observer, principal,
                         aParentSheet->GetReferrerInfo(), context);
 
   NS_ADDREF(data);
   bool syncLoad = data->mSyncLoad;
 
   // Load completion will release the data
-  rv = LoadSheet(data, state, false);
+  rv = LoadSheet(data, state, IsPreload::No);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // If syncLoad is true, |data| will be deleted by now.
   if (!syncLoad) {
     data->mMustNotify = true;
   }
   return rv;
 }
 
 Result<RefPtr<StyleSheet>, nsresult> Loader::LoadSheetSync(
-    nsIURI* aURL, SheetParsingMode aParsingMode, bool aUseSystemPrincipal) {
+    nsIURI* aURL, SheetParsingMode aParsingMode,
+    UseSystemPrincipal aUseSystemPrincipal) {
   LOG(("css::Loader::LoadSheetSync"));
   nsCOMPtr<nsIReferrerInfo> referrerInfo = new ReferrerInfo(nullptr);
   return InternalLoadNonDocumentSheet(
-      aURL, false, aParsingMode, aUseSystemPrincipal, nullptr, nullptr,
+      aURL, IsPreload::No, aParsingMode, aUseSystemPrincipal, nullptr, nullptr,
       referrerInfo, nullptr, CORS_NONE, EmptyString());
 }
 
 Result<RefPtr<StyleSheet>, nsresult> Loader::LoadSheet(
-    nsIURI* aURI, SheetParsingMode aParsingMode, bool aUseSystemPrincipal,
-    nsICSSLoaderObserver* aObserver) {
+    nsIURI* aURI, SheetParsingMode aParsingMode,
+    UseSystemPrincipal aUseSystemPrincipal, nsICSSLoaderObserver* aObserver) {
   nsCOMPtr<nsIReferrerInfo> referrerInfo = new ReferrerInfo(nullptr);
   return InternalLoadNonDocumentSheet(
-      aURI, false, aParsingMode, aUseSystemPrincipal, nullptr, nullptr,
+      aURI, IsPreload::No, aParsingMode, aUseSystemPrincipal, nullptr, nullptr,
       referrerInfo, aObserver, CORS_NONE, EmptyString());
 }
 
 Result<RefPtr<StyleSheet>, nsresult> Loader::LoadSheet(
-    nsIURI* aURL, bool aIsPreload, nsIPrincipal* aOriginPrincipal,
+    nsIURI* aURL, IsPreload aIsPreload, nsIPrincipal* aOriginPrincipal,
     const Encoding* aPreloadEncoding, nsIReferrerInfo* aReferrerInfo,
     nsICSSLoaderObserver* aObserver, CORSMode aCORSMode,
     const nsAString& aIntegrity) {
   LOG(("css::Loader::LoadSheet(aURL, aObserver) api call"));
-  return InternalLoadNonDocumentSheet(
-      aURL, aIsPreload, eAuthorSheetFeatures, false, aOriginPrincipal,
-      aPreloadEncoding, aReferrerInfo, aObserver, aCORSMode, aIntegrity);
+  return InternalLoadNonDocumentSheet(aURL, aIsPreload, eAuthorSheetFeatures,
+                                      UseSystemPrincipal::No, aOriginPrincipal,
+                                      aPreloadEncoding, aReferrerInfo,
+                                      aObserver, aCORSMode, aIntegrity);
 }
 
 Result<RefPtr<StyleSheet>, nsresult> Loader::InternalLoadNonDocumentSheet(
-    nsIURI* aURL, bool aIsPreload, SheetParsingMode aParsingMode,
-    bool aUseSystemPrincipal, nsIPrincipal* aOriginPrincipal,
+    nsIURI* aURL, IsPreload aIsPreload, SheetParsingMode aParsingMode,
+    UseSystemPrincipal aUseSystemPrincipal, nsIPrincipal* aOriginPrincipal,
     const Encoding* aPreloadEncoding, nsIReferrerInfo* aReferrerInfo,
     nsICSSLoaderObserver* aObserver, CORSMode aCORSMode,
     const nsAString& aIntegrity) {
   MOZ_ASSERT(aURL, "Must have a URI to load");
-  MOZ_ASSERT(!aUseSystemPrincipal || !aObserver,
+  MOZ_ASSERT(aUseSystemPrincipal == UseSystemPrincipal::No || !aObserver,
              "Shouldn't load system-principal sheets async");
   MOZ_ASSERT(aReferrerInfo, "Must have referrerInfo");
 
   LOG_URI("  Non-document sheet uri: '%s'", aURL);
 
   if (!mEnabled) {
     LOG_WARN(("  Not enabled"));
     return Err(NS_ERROR_NOT_AVAILABLE);
@@ -2223,17 +2229,18 @@ Result<RefPtr<StyleSheet>, nsresult> Loa
       if (NS_FAILED(rv)) {
         return Err(rv);
       }
     }
     return sheet;
   }
 
   SheetLoadData* data = new SheetLoadData(
-      this, aURL, sheet, syncLoad, aUseSystemPrincipal, aPreloadEncoding,
+      this, aURL, sheet, syncLoad,
+      aUseSystemPrincipal == UseSystemPrincipal::Yes, aPreloadEncoding,
       aObserver, aOriginPrincipal, aReferrerInfo, mDocument);
 
   NS_ADDREF(data);
   rv = LoadSheet(data, state, aIsPreload);
   if (NS_FAILED(rv)) {
     return Err(rv);
   }
   if (aObserver) {
@@ -2380,17 +2387,17 @@ void Loader::StartDeferredLoads() {
   for (auto iter = mSheets->mPendingDatas.Iter(); !iter.Done(); iter.Next()) {
     arr.AppendElement(iter.Data());
     iter.Remove();
   }
 
   mDatasToNotifyOn += arr.Length();
   for (uint32_t i = 0; i < arr.Length(); ++i) {
     --mDatasToNotifyOn;
-    LoadSheet(arr[i], SheetState::NeedsParser, false);
+    LoadSheet(arr[i], SheetState::NeedsParser, IsPreload::No);
   }
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(Loader)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Loader)
   if (tmp->mSheets) {
     for (auto iter = tmp->mSheets->mCompleteSheets.Iter(); !iter.Done();
--- a/layout/style/Loader.h
+++ b/layout/style/Loader.h
@@ -173,16 +173,18 @@ class Loader final {
    * @param aMedia the already-parsed media list for the child sheet
    * @param aSavedSheets any saved style sheets which could be reused
    *              for this load
    */
   nsresult LoadChildSheet(StyleSheet* aParentSheet, SheetLoadData* aParentData,
                           nsIURI* aURL, dom::MediaList* aMedia,
                           LoaderReusableStyleSheets* aSavedSheets);
 
+  enum class UseSystemPrincipal { No, Yes };
+
   /**
    * Synchronously load and return the stylesheet at aURL.  Any child sheets
    * will also be loaded synchronously.  Note that synchronous loads over some
    * protocols may involve spinning up a new event loop, so use of this method
    * does NOT guarantee not receiving any events before the sheet loads.  This
    * method can be used to load sheets not associated with a document.
    *
    * @param aURL the URL of the sheet to load
@@ -196,17 +198,19 @@ class Loader final {
    * non-UTF8 sheets being treated as UTF-8 by this method.
    *
    * NOTE: A successful return from this method doesn't indicate anything about
    * whether the data could be parsed as CSS and doesn't indicate anything
    * about the status of child sheets of the returned sheet.
    */
   Result<RefPtr<StyleSheet>, nsresult> LoadSheetSync(
       nsIURI*, SheetParsingMode = eAuthorSheetFeatures,
-      bool aUseSystemPrincipal = false);
+      UseSystemPrincipal = UseSystemPrincipal::No);
+
+  enum class IsPreload { No, Yes };
 
   /**
    * Asynchronously load the stylesheet at aURL.  If a successful result is
    * returned, aObserver is guaranteed to be notified asynchronously once the
    * sheet is loaded and marked complete.  This method can be used to load
    * sheets not associated with a document.
    *
    * @param aURL the URL of the sheet to load
@@ -220,26 +224,26 @@ class Loader final {
    * @return the sheet to load. Note that the sheet may well not be loaded by
    * the time this method returns.
    *
    * NOTE: At the moment, this method assumes the sheet will be UTF-8, but
    * ideally it would allow arbitrary encodings.  Callers should NOT depend on
    * non-UTF8 sheets being treated as UTF-8 by this method.
    */
   Result<RefPtr<StyleSheet>, nsresult> LoadSheet(
-      nsIURI* aURI, bool aIsPreLoad, nsIPrincipal* aOriginPrincipal,
+      nsIURI* aURI, IsPreload, nsIPrincipal* aOriginPrincipal,
       const Encoding* aPreloadEncoding, nsIReferrerInfo* aReferrerInfo,
       nsICSSLoaderObserver* aObserver, CORSMode aCORSMode = CORS_NONE,
       const nsAString& aIntegrity = EmptyString());
 
   /**
    * As above, but without caring for a couple things.
    */
   Result<RefPtr<StyleSheet>, nsresult> LoadSheet(nsIURI*, SheetParsingMode,
-                                                 bool aUseSystemPrincipal,
+                                                 UseSystemPrincipal,
                                                  nsICSSLoaderObserver*);
 
   /**
    * Stop loading all sheets.  All nsICSSLoaderObservers involved will be
    * notified with NS_BINDING_ABORTED as the status, possibly synchronously.
    */
   void Stop();
 
@@ -314,17 +318,17 @@ class Loader final {
 
   // Helper to select the correct dispatch target for asynchronous events for
   // this loader.
   already_AddRefed<nsISerialEventTarget> DispatchTarget();
 
   nsresult CheckContentPolicy(nsIPrincipal* aLoadingPrincipal,
                               nsIPrincipal* aTriggeringPrincipal,
                               nsIURI* aTargetURI, nsINode* aRequestingNode,
-                              bool aIsPreload);
+                              IsPreload);
 
   enum class SheetState : uint8_t {
     Unknown = 0,
     NeedsParser,
     Pending,
     Loading,
     Complete
   };
@@ -354,18 +358,18 @@ class Loader final {
                             IsAlternate, IsExplicitlyEnabled);
 
   // Inserts a style sheet in a document or a ShadowRoot.
   void InsertSheetInTree(StyleSheet& aSheet, nsIContent* aLinkingContent);
   // Inserts a style sheet into a parent style sheet.
   void InsertChildSheet(StyleSheet& aSheet, StyleSheet& aParentSheet);
 
   Result<RefPtr<StyleSheet>, nsresult> InternalLoadNonDocumentSheet(
-      nsIURI* aURL, bool aIsPreload, SheetParsingMode aParsingMode,
-      bool aUseSystemPrincipal, nsIPrincipal* aOriginPrincipal,
+      nsIURI* aURL, IsPreload, SheetParsingMode aParsingMode,
+      UseSystemPrincipal, nsIPrincipal* aOriginPrincipal,
       const Encoding* aPreloadEncoding, nsIReferrerInfo* aReferrerInfo,
       nsICSSLoaderObserver* aObserver, CORSMode aCORSMode,
       const nsAString& aIntegrity);
 
   // Post a load event for aObserver to be notified about aSheet.  The
   // notification will be sent with status NS_OK unless the load event is
   // canceled at some point (in which case it will be sent with
   // NS_BINDING_ABORTED).  aWasAlternate indicates the state when the load was
@@ -381,17 +385,17 @@ class Loader final {
   // Start the loads of all the sheets in mPendingDatas
   void StartDeferredLoads();
 
   // Handle an event posted by PostLoadEvent
   void HandleLoadEvent(SheetLoadData* aEvent);
 
   // Note: LoadSheet is responsible for releasing the load data and setting the
   // sheet to complete on failure.
-  nsresult LoadSheet(SheetLoadData*, SheetState, bool aIsPreLoad);
+  nsresult LoadSheet(SheetLoadData*, SheetState, IsPreload);
 
   enum class AllowAsyncParse {
     Yes,
     No,
   };
 
   // Parse the stylesheet in the load data.
   //
--- a/layout/style/PreloadedStyleSheet.cpp
+++ b/layout/style/PreloadedStyleSheet.cpp
@@ -31,17 +31,18 @@ NS_IMPL_CYCLE_COLLECTION(PreloadedStyleS
 
 nsresult PreloadedStyleSheet::GetSheet(StyleSheet** aResult) {
   *aResult = nullptr;
 
   MOZ_DIAGNOSTIC_ASSERT(mLoaded);
 
   if (!mSheet) {
     RefPtr<css::Loader> loader = new css::Loader;
-    auto result = loader->LoadSheetSync(mURI, mParsingMode, true);
+    auto result = loader->LoadSheetSync(mURI, mParsingMode,
+                                        css::Loader::UseSystemPrincipal::Yes);
     if (result.isErr()) {
       return result.unwrapErr();
     }
     mSheet = result.unwrap();
   }
 
   *aResult = mSheet;
   return NS_OK;
@@ -75,17 +76,18 @@ PreloadedStyleSheet::StylesheetPreloadOb
 // Note: After calling this method, the preloaded sheet *must not* be used
 // until the observer is notified that the sheet has finished loading.
 nsresult PreloadedStyleSheet::PreloadAsync(NotNull<dom::Promise*> aPromise) {
   MOZ_DIAGNOSTIC_ASSERT(!mLoaded);
 
   RefPtr<css::Loader> loader = new css::Loader;
   RefPtr<StylesheetPreloadObserver> obs =
       new StylesheetPreloadObserver(aPromise, this);
-  auto result = loader->LoadSheet(mURI, mParsingMode, false, obs);
+  auto result = loader->LoadSheet(mURI, mParsingMode,
+                                  css::Loader::UseSystemPrincipal::No, obs);
   if (result.isErr()) {
     return result.unwrapErr();
   }
   mSheet = result.unwrap();
   return NS_OK;
 }
 
 }  // namespace mozilla
--- a/layout/style/nsLayoutStylesheetCache.cpp
+++ b/layout/style/nsLayoutStylesheetCache.cpp
@@ -502,17 +502,18 @@ RefPtr<StyleSheet> nsLayoutStylesheetCac
     }
   }
 
   // Note: The parallel parsing code assume that UA sheets are always loaded
   // synchronously like they are here, and thus that we'll never attempt
   // parallel parsing on them. If that ever changes, we'll either need to find a
   // different way to prohibit parallel parsing for UA sheets, or handle
   // -moz-bool-pref and various other things in the parallel parsing code.
-  auto result = gCSSLoader->LoadSheetSync(aURI, aParsingMode, true);
+  auto result = gCSSLoader->LoadSheetSync(aURI, aParsingMode,
+                                          css::Loader::UseSystemPrincipal::Yes);
   if (MOZ_UNLIKELY(result.isErr())) {
     ErrorLoadingSheet(
         aURI,
         nsPrintfCString("LoadSheetSync failed with error %" PRIx32,
                         static_cast<uint32_t>(result.unwrapErr()))
             .get(),
         aFailureAction);
   }