/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* loading of CSS style sheets using the network APIs */ #include "mozilla/css/Loader.h" #include "mozilla/ArrayUtils.h" #include "mozilla/dom/DocGroup.h" #include "mozilla/dom/SRILogHelper.h" #include "mozilla/IntegerPrintfMacros.h" #include "mozilla/AutoRestore.h" #include "mozilla/LoadInfo.h" #include "mozilla/Logging.h" #include "mozilla/MemoryReporting.h" #include "mozilla/PreloadHashKey.h" #include "mozilla/ResultExtensions.h" #include "mozilla/SchedulerGroup.h" #include "mozilla/URLPreloader.h" #include "nsIRunnable.h" #include "nsISupportsPriority.h" #include "nsITimedChannel.h" #include "nsICachingChannel.h" #include "nsSyncLoadService.h" #include "nsCOMPtr.h" #include "nsString.h" #include "nsIContent.h" #include "nsIContentInlines.h" #include "nsICookieJarSettings.h" #include "mozilla/dom/Document.h" #include "nsIURI.h" #include "nsNetUtil.h" #include "nsContentUtils.h" #include "nsIScriptSecurityManager.h" #include "nsContentPolicyUtils.h" #include "nsIHttpChannel.h" #include "nsIHttpChannelInternal.h" #include "nsIClassOfService.h" #include "nsIScriptError.h" #include "nsMimeTypes.h" #include "nsICSSLoaderObserver.h" #include "nsThreadUtils.h" #include "nsGkAtoms.h" #include "nsIThreadInternal.h" #include "nsINetworkPredictor.h" #include "nsStringStream.h" #include "mozilla/dom/MediaList.h" #include "mozilla/dom/ShadowRoot.h" #include "mozilla/dom/URL.h" #include "mozilla/net/UrlClassifierFeatureFactory.h" #include "mozilla/AsyncEventDispatcher.h" #include "mozilla/ProfilerLabels.h" #include "mozilla/ServoBindings.h" #include "mozilla/StyleSheet.h" #include "mozilla/StyleSheetInlines.h" #include "mozilla/ConsoleReportCollector.h" #include "mozilla/ServoUtils.h" #include "mozilla/css/StreamLoader.h" #include "mozilla/SharedStyleSheetCache.h" #include "mozilla/StaticPrefs_dom.h" #include "ReferrerInfo.h" #ifdef MOZ_XUL # include "nsXULPrototypeCache.h" #endif #include "nsError.h" #include "mozilla/dom/SRICheck.h" #include "mozilla/Encoding.h" using namespace mozilla::dom; // 1024 bytes is specified in https://drafts.csswg.org/css-syntax/ #define SNIFFING_BUFFER_SIZE 1024 /** * OVERALL ARCHITECTURE * * The CSS Loader gets requests to load various sorts of style sheets: * inline style from