no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / layout / style / Loader.h
blob73d7b806a18e4c6a4f41d7fb33632e05f25571a0
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* loading of CSS style sheets using the network APIs */
9 #ifndef mozilla_css_Loader_h
10 #define mozilla_css_Loader_h
12 #include <tuple>
13 #include <utility>
15 #include "mozilla/Attributes.h"
16 #include "mozilla/CORSMode.h"
17 #include "mozilla/css/StylePreloadKind.h"
18 #include "mozilla/dom/LinkStyle.h"
19 #include "mozilla/MemoryReporting.h"
20 #include "mozilla/UniquePtr.h"
21 #include "nsCompatibility.h"
22 #include "nsCycleCollectionParticipant.h"
23 #include "nsStringFwd.h"
24 #include "nsTArray.h"
25 #include "nsTObserverArray.h"
26 #include "nsURIHashKey.h"
27 #include "nsRefPtrHashtable.h"
29 class nsICSSLoaderObserver;
30 class nsIConsoleReportCollector;
31 class nsIContent;
32 class nsIPrincipal;
34 namespace mozilla {
36 class PreloadHashKey;
37 class SharedStyleSheetCache;
38 class SheetLoadDataHashKey;
39 class StyleSheet;
41 namespace dom {
42 class DocGroup;
43 class Element;
44 } // namespace dom
46 // The load data for a <link> or @import style-sheet.
48 // This must contain all the state that affects CSS parsing.
49 class SheetLoadDataHashKey : public PLDHashEntryHdr {
50 public:
51 using KeyType = const SheetLoadDataHashKey&;
52 using KeyTypePointer = const SheetLoadDataHashKey*;
54 explicit SheetLoadDataHashKey(const SheetLoadDataHashKey* aKey)
55 : mURI(aKey->mURI),
56 mPrincipal(aKey->mPrincipal),
57 mLoaderPrincipal(aKey->mLoaderPrincipal),
58 mPartitionPrincipal(aKey->mPartitionPrincipal),
59 mEncodingGuess(aKey->mEncodingGuess),
60 mCORSMode(aKey->mCORSMode),
61 mParsingMode(aKey->mParsingMode),
62 mCompatMode(aKey->mCompatMode),
63 mSRIMetadata(aKey->mSRIMetadata),
64 mIsLinkRelPreload(aKey->mIsLinkRelPreload) {
65 MOZ_COUNT_CTOR(SheetLoadDataHashKey);
68 SheetLoadDataHashKey(nsIURI* aURI, nsIPrincipal* aPrincipal,
69 nsIPrincipal* aLoaderPrincipal,
70 nsIPrincipal* aPartitionPrincipal,
71 NotNull<const Encoding*> aEncodingGuess,
72 CORSMode aCORSMode, css::SheetParsingMode aParsingMode,
73 nsCompatibility aCompatMode,
74 const dom::SRIMetadata& aSRIMetadata,
75 css::StylePreloadKind aPreloadKind)
76 : mURI(aURI),
77 mPrincipal(aPrincipal),
78 mLoaderPrincipal(aLoaderPrincipal),
79 mPartitionPrincipal(aPartitionPrincipal),
80 mEncodingGuess(aEncodingGuess),
81 mCORSMode(aCORSMode),
82 mParsingMode(aParsingMode),
83 mCompatMode(aCompatMode),
84 mSRIMetadata(aSRIMetadata),
85 mIsLinkRelPreload(IsLinkRelPreload(aPreloadKind)) {
86 MOZ_ASSERT(aURI);
87 MOZ_ASSERT(aPrincipal);
88 MOZ_ASSERT(aLoaderPrincipal);
89 MOZ_COUNT_CTOR(SheetLoadDataHashKey);
92 SheetLoadDataHashKey(SheetLoadDataHashKey&& toMove)
93 : mURI(std::move(toMove.mURI)),
94 mPrincipal(std::move(toMove.mPrincipal)),
95 mLoaderPrincipal(std::move(toMove.mLoaderPrincipal)),
96 mPartitionPrincipal(std::move(toMove.mPartitionPrincipal)),
97 mEncodingGuess(std::move(toMove.mEncodingGuess)),
98 mCORSMode(std::move(toMove.mCORSMode)),
99 mParsingMode(std::move(toMove.mParsingMode)),
100 mCompatMode(std::move(toMove.mCompatMode)),
101 mSRIMetadata(std::move(toMove.mSRIMetadata)),
102 mIsLinkRelPreload(std::move(toMove.mIsLinkRelPreload)) {
103 MOZ_COUNT_CTOR(SheetLoadDataHashKey);
106 explicit SheetLoadDataHashKey(const css::SheetLoadData&);
108 MOZ_COUNTED_DTOR(SheetLoadDataHashKey)
110 const SheetLoadDataHashKey& GetKey() const { return *this; }
111 const SheetLoadDataHashKey* GetKeyPointer() const { return this; }
113 bool KeyEquals(const SheetLoadDataHashKey* aKey) const {
114 return KeyEquals(*aKey);
117 bool KeyEquals(const SheetLoadDataHashKey&) const;
119 static const SheetLoadDataHashKey* KeyToPointer(
120 const SheetLoadDataHashKey& aKey) {
121 return &aKey;
123 static PLDHashNumber HashKey(const SheetLoadDataHashKey* aKey) {
124 return nsURIHashKey::HashKey(aKey->mURI);
127 nsIURI* URI() const { return mURI; }
129 nsIPrincipal* Principal() const { return mPrincipal; }
131 nsIPrincipal* LoaderPrincipal() const { return mLoaderPrincipal; }
133 nsIPrincipal* PartitionPrincipal() const { return mPartitionPrincipal; }
135 css::SheetParsingMode ParsingMode() const { return mParsingMode; }
137 enum { ALLOW_MEMMOVE = true };
139 protected:
140 const nsCOMPtr<nsIURI> mURI;
141 const nsCOMPtr<nsIPrincipal> mPrincipal;
142 const nsCOMPtr<nsIPrincipal> mLoaderPrincipal;
143 const nsCOMPtr<nsIPrincipal> mPartitionPrincipal;
144 // The encoding guess is the encoding the sheet would get if the request
145 // didn't have any encoding information like @charset or a Content-Encoding
146 // header.
147 const NotNull<const Encoding*> mEncodingGuess;
148 const CORSMode mCORSMode;
149 const css::SheetParsingMode mParsingMode;
150 const nsCompatibility mCompatMode;
151 dom::SRIMetadata mSRIMetadata;
152 const bool mIsLinkRelPreload;
155 namespace css {
157 class SheetLoadData;
158 class ImportRule;
160 /*********************
161 * Style sheet reuse *
162 *********************/
164 class MOZ_RAII LoaderReusableStyleSheets {
165 public:
166 LoaderReusableStyleSheets() = default;
169 * Look for a reusable sheet (see AddReusableSheet) matching the
170 * given URL. If found, set aResult, remove the reused sheet from
171 * the internal list, and return true. If not found, return false;
172 * in this case, aResult is not modified.
174 * @param aURL the url to match
175 * @param aResult [out] the style sheet which can be reused
177 bool FindReusableStyleSheet(nsIURI* aURL, RefPtr<StyleSheet>& aResult);
180 * Indicate that a certain style sheet is available for reuse if its
181 * URI matches the URI of an @import. Sheets should be added in the
182 * opposite order in which they are intended to be reused.
184 * @param aSheet the sheet which can be reused
186 void AddReusableSheet(StyleSheet* aSheet) {
187 mReusableSheets.AppendElement(aSheet);
190 private:
191 LoaderReusableStyleSheets(const LoaderReusableStyleSheets&) = delete;
192 LoaderReusableStyleSheets& operator=(const LoaderReusableStyleSheets&) =
193 delete;
195 // The sheets that can be reused.
196 nsTArray<RefPtr<StyleSheet>> mReusableSheets;
199 class Loader final {
200 using ReferrerPolicy = dom::ReferrerPolicy;
202 public:
203 using Completed = dom::LinkStyle::Completed;
204 using HasAlternateRel = dom::LinkStyle::HasAlternateRel;
205 using IsAlternate = dom::LinkStyle::IsAlternate;
206 using IsInline = dom::LinkStyle::IsInline;
207 using IsExplicitlyEnabled = dom::LinkStyle::IsExplicitlyEnabled;
208 using MediaMatched = dom::LinkStyle::MediaMatched;
209 using LoadSheetResult = dom::LinkStyle::Update;
210 using SheetInfo = dom::LinkStyle::SheetInfo;
212 Loader();
213 // aDocGroup is used for dispatching SheetLoadData in PostLoadEvent(). It
214 // can be null if you want to use this constructor, and there's no
215 // document when the Loader is constructed.
216 explicit Loader(dom::DocGroup*);
217 explicit Loader(dom::Document*);
219 private:
220 // Private destructor, to discourage deletion outside of Release():
221 ~Loader();
223 public:
224 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(Loader)
225 NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(Loader)
227 void DropDocumentReference(); // notification that doc is going away
229 void DeregisterFromSheetCache();
230 void RegisterInSheetCache();
232 void SetCompatibilityMode(nsCompatibility aCompatMode) {
233 mDocumentCompatMode = aCompatMode;
236 using StylePreloadKind = css::StylePreloadKind;
238 bool HasLoaded(const SheetLoadDataHashKey& aKey) const {
239 return mLoadsPerformed.Contains(aKey);
242 void WillStartPendingLoad() {
243 MOZ_DIAGNOSTIC_ASSERT(mPendingLoadCount, "Where did this load come from?");
244 mPendingLoadCount--;
247 nsCompatibility CompatMode(StylePreloadKind aPreloadKind) const {
248 // For Link header preload, we guess non-quirks, because otherwise it is
249 // useless for modern pages.
251 // Link element preload is generally good because the speculative html
252 // parser deals with quirks mode properly.
253 if (aPreloadKind == StylePreloadKind::FromLinkRelPreloadHeader) {
254 return eCompatibility_FullStandards;
256 return mDocumentCompatMode;
259 // TODO(emilio): Is the complexity of this method and carrying the titles
260 // around worth it? The alternate sheets will load anyhow eventually...
261 void DocumentStyleSheetSetChanged();
263 // XXXbz sort out what the deal is with events! When should they fire?
266 * Load an inline style sheet. If a successful result is returned and
267 * result.WillNotify() is true, then aObserver is guaranteed to be notified
268 * asynchronously once the sheet is marked complete. If an error is
269 * returned, or if result.WillNotify() is false, aObserver will not be
270 * notified. In addition to parsing the sheet, this method will insert it
271 * into the stylesheet list of this CSSLoader's document.
272 * @param aObserver the observer to notify when the load completes.
273 * May be null.
274 * @param aBuffer the stylesheet data
275 * @param aLineNumber the line number at which the stylesheet data started.
277 Result<LoadSheetResult, nsresult> LoadInlineStyle(
278 const SheetInfo&, const nsAString& aBuffer, uint32_t aLineNumber,
279 nsICSSLoaderObserver* aObserver);
282 * Load a linked (document) stylesheet. If a successful result is returned,
283 * aObserver is guaranteed to be notified asynchronously once the sheet is
284 * loaded and marked complete, i.e., result.WillNotify() will always return
285 * true. If an error is returned, aObserver will not be notified. In
286 * addition to loading the sheet, this method will insert it into the
287 * stylesheet list of this CSSLoader's document.
288 * @param aObserver the observer to notify when the load completes.
289 * May be null.
291 Result<LoadSheetResult, nsresult> LoadStyleLink(
292 const SheetInfo&, nsICSSLoaderObserver* aObserver);
295 * Load a child (@import-ed) style sheet. In addition to loading the sheet,
296 * this method will insert it into the child sheet list of aParentSheet. If
297 * there is no sheet currently being parsed and the child sheet is not
298 * complete when this method returns, then when the child sheet becomes
299 * complete aParentSheet will be QIed to nsICSSLoaderObserver and
300 * asynchronously notified, just like for LoadStyleLink. Note that if the
301 * child sheet is already complete when this method returns, no
302 * nsICSSLoaderObserver notification will be sent.
304 * @param aParentSheet the parent of this child sheet
305 * @param aParentData the SheetLoadData corresponding to the load of the
306 * parent sheet. May be null for @import rules inserted via
307 * CSSOM.
308 * @param aURL the URL of the child sheet
309 * @param aMedia the already-parsed media list for the child sheet
310 * @param aSavedSheets any saved style sheets which could be reused
311 * for this load
313 nsresult LoadChildSheet(StyleSheet& aParentSheet, SheetLoadData* aParentData,
314 nsIURI* aURL, dom::MediaList* aMedia,
315 LoaderReusableStyleSheets* aSavedSheets);
318 * Called when we hit the internal memory cache with a complete stylesheet.
320 void DidHitCompleteSheetCache(const SheetLoadDataHashKey&,
321 const StyleUseCounters* aCounters);
323 enum class UseSystemPrincipal { No, Yes };
326 * Synchronously load and return the stylesheet at aURL. Any child sheets
327 * will also be loaded synchronously. Note that synchronous loads over some
328 * protocols may involve spinning up a new event loop, so use of this method
329 * does NOT guarantee not receiving any events before the sheet loads. This
330 * method can be used to load sheets not associated with a document.
332 * @param aURL the URL of the sheet to load
333 * @param aParsingMode the mode in which to parse the sheet
334 * (see comments at enum SheetParsingMode, above).
335 * @param aUseSystemPrincipal if true, give the resulting sheet the system
336 * principal no matter where it's being loaded from.
338 * NOTE: At the moment, this method assumes the sheet will be UTF-8, but
339 * ideally it would allow arbitrary encodings. Callers should NOT depend on
340 * non-UTF8 sheets being treated as UTF-8 by this method.
342 * NOTE: A successful return from this method doesn't indicate anything about
343 * whether the data could be parsed as CSS and doesn't indicate anything
344 * about the status of child sheets of the returned sheet.
346 Result<RefPtr<StyleSheet>, nsresult> LoadSheetSync(
347 nsIURI*, SheetParsingMode = eAuthorSheetFeatures,
348 UseSystemPrincipal = UseSystemPrincipal::No);
351 * Asynchronously load the stylesheet at aURL. If a successful result is
352 * returned, aObserver is guaranteed to be notified asynchronously once the
353 * sheet is loaded and marked complete. This method can be used to load
354 * sheets not associated with a document.
356 * @param aURL the URL of the sheet to load
357 * @param aParsingMode the mode in which to parse the sheet
358 * (see comments at enum SheetParsingMode, above).
359 * @param aUseSystemPrincipal if true, give the resulting sheet the system
360 * principal no matter where it's being loaded from.
361 * @param aReferrerInfo referrer information of the sheet.
362 * @param aObserver the observer to notify when the load completes.
363 * Must not be null.
364 * @param aEarlyHintPreloaderId to connect back to the early hint preload
365 * channel. Null means no connect back should happen
366 * @return the sheet to load. Note that the sheet may well not be loaded by
367 * the time this method returns.
369 * NOTE: At the moment, this method assumes the sheet will be UTF-8, but
370 * ideally it would allow arbitrary encodings. Callers should NOT depend on
371 * non-UTF8 sheets being treated as UTF-8 by this method.
373 Result<RefPtr<StyleSheet>, nsresult> LoadSheet(
374 nsIURI* aURI, StylePreloadKind, const Encoding* aPreloadEncoding,
375 nsIReferrerInfo* aReferrerInfo, nsICSSLoaderObserver* aObserver,
376 uint64_t aEarlyHintPreloaderId, CORSMode aCORSMode,
377 const nsAString& aNonce, const nsAString& aIntegrity);
380 * As above, but without caring for a couple things.
382 Result<RefPtr<StyleSheet>, nsresult> LoadSheet(nsIURI*, SheetParsingMode,
383 UseSystemPrincipal,
384 nsICSSLoaderObserver*);
387 * Stop loading all sheets. All nsICSSLoaderObservers involved will be
388 * notified with NS_BINDING_ABORTED as the status, possibly synchronously.
390 void Stop();
393 * nsresult Loader::StopLoadingSheet(nsIURI* aURL), which notifies the
394 * nsICSSLoaderObserver with NS_BINDING_ABORTED, was removed in Bug 556446.
395 * It can be found in revision 2c44a32052ad.
399 * Whether the loader is enabled or not.
400 * When disabled, processing of new styles is disabled and an attempt
401 * to do so will fail with a return code of
402 * NS_ERROR_NOT_AVAILABLE. Note that this DOES NOT disable
403 * currently loading styles or already processed styles.
405 bool GetEnabled() { return mEnabled; }
406 void SetEnabled(bool aEnabled) { mEnabled = aEnabled; }
408 uint32_t ParsedSheetCount() const { return mParsedSheetCount; }
411 * Get the document we live for. May return null.
413 dom::Document* GetDocument() const { return mDocument; }
415 bool IsDocumentAssociated() const { return mIsDocumentAssociated; }
418 * Return true if this loader has pending loads (ones that would send
419 * notifications to an nsICSSLoaderObserver attached to this loader).
420 * If called from inside nsICSSLoaderObserver::StyleSheetLoaded, this will
421 * return false if and only if that is the last StyleSheetLoaded
422 * notification the CSSLoader knows it's going to send. In other words, if
423 * two sheets load at once (via load coalescing, e.g.), HasPendingLoads()
424 * will return true during notification for the first one, and false
425 * during notification for the second one.
427 bool HasPendingLoads();
430 * Add an observer to this loader. The observer will be notified
431 * for all loads that would have notified their own observers (even
432 * if those loads don't have observers attached to them).
433 * Load-specific observers will be notified before generic
434 * observers. The loader holds a reference to the observer.
436 * aObserver must not be null.
438 void AddObserver(nsICSSLoaderObserver* aObserver);
441 * Remove an observer added via AddObserver.
443 void RemoveObserver(nsICSSLoaderObserver* aObserver);
445 // These interfaces are public only for the benefit of static functions
446 // within nsCSSLoader.cpp.
448 // IsAlternateSheet can change our currently selected style set if none is
449 // selected and aHasAlternateRel is false.
450 IsAlternate IsAlternateSheet(const nsAString& aTitle, bool aHasAlternateRel);
452 // Measure our size.
453 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
455 enum class SheetState : uint8_t {
456 NeedsParser = 0,
457 Pending,
458 Loading,
459 Complete
462 // The loader principal is the document's node principal, if this loader is
463 // owned by a document, or the system principal otherwise.
464 nsIPrincipal* LoaderPrincipal() const;
466 // The partitioned principal is the document's partitioned principal, if this
467 // loader is owned by a document, or the system principal otherwise.
468 nsIPrincipal* PartitionedPrincipal() const;
470 bool ShouldBypassCache() const;
472 private:
473 friend class mozilla::SharedStyleSheetCache;
474 friend class SheetLoadData;
475 friend class StreamLoader;
477 // Helpers to conditionally block onload if mDocument is non-null.
478 void IncrementOngoingLoadCount() {
479 if (!mOngoingLoadCount++) {
480 BlockOnload();
484 void DecrementOngoingLoadCount() {
485 MOZ_DIAGNOSTIC_ASSERT(mOngoingLoadCount);
486 MOZ_DIAGNOSTIC_ASSERT(mOngoingLoadCount > mPendingLoadCount);
487 if (!--mOngoingLoadCount) {
488 UnblockOnload(false);
492 void BlockOnload();
493 void UnblockOnload(bool aFireSync);
495 // Helper to select the correct dispatch target for asynchronous events for
496 // this loader.
497 already_AddRefed<nsISerialEventTarget> DispatchTarget();
499 nsresult CheckContentPolicy(nsIPrincipal* aLoadingPrincipal,
500 nsIPrincipal* aTriggeringPrincipal,
501 nsIURI* aTargetURI, nsINode* aRequestingNode,
502 const nsAString& aNonce, StylePreloadKind);
504 std::tuple<RefPtr<StyleSheet>, SheetState> CreateSheet(
505 const SheetInfo& aInfo, css::SheetParsingMode aParsingMode,
506 bool aSyncLoad, css::StylePreloadKind aPreloadKind) {
507 nsIPrincipal* triggeringPrincipal = aInfo.mTriggeringPrincipal
508 ? aInfo.mTriggeringPrincipal.get()
509 : LoaderPrincipal();
510 return CreateSheet(aInfo.mURI, aInfo.mContent, triggeringPrincipal,
511 aParsingMode, aInfo.mCORSMode,
512 /* aPreloadOrParentDataEncoding = */ nullptr,
513 aInfo.mIntegrity, aSyncLoad, aPreloadKind);
516 // For inline style, the aURI param is null, but the aLinkingContent
517 // must be non-null then. The loader principal must never be null
518 // if aURI is not null.
519 std::tuple<RefPtr<StyleSheet>, SheetState> CreateSheet(
520 nsIURI* aURI, nsIContent* aLinkingContent,
521 nsIPrincipal* aTriggeringPrincipal, css::SheetParsingMode, CORSMode,
522 const Encoding* aPreloadOrParentDataEncoding, const nsAString& aIntegrity,
523 bool aSyncLoad, StylePreloadKind);
525 // Pass in either a media string or the MediaList from the CSSParser. Don't
526 // pass both.
528 // This method will set the sheet's enabled state based on IsAlternate and co.
529 MediaMatched PrepareSheet(StyleSheet&, const nsAString& aTitle,
530 const nsAString& aMediaString, dom::MediaList*,
531 IsAlternate, IsExplicitlyEnabled);
533 // Inserts a style sheet in a document or a ShadowRoot.
534 void InsertSheetInTree(StyleSheet& aSheet);
535 // Inserts a style sheet into a parent style sheet.
536 void InsertChildSheet(StyleSheet& aSheet, StyleSheet& aParentSheet);
538 Result<RefPtr<StyleSheet>, nsresult> InternalLoadNonDocumentSheet(
539 nsIURI* aURL, StylePreloadKind, SheetParsingMode aParsingMode,
540 UseSystemPrincipal, const Encoding* aPreloadEncoding,
541 nsIReferrerInfo* aReferrerInfo, nsICSSLoaderObserver* aObserver,
542 CORSMode aCORSMode, const nsAString& aNonce, const nsAString& aIntegrity,
543 uint64_t aEarlyHintPreloaderId);
545 RefPtr<StyleSheet> LookupInlineSheetInCache(const nsAString&, nsIPrincipal*);
547 // Synchronously notify of a cached load data.
548 void NotifyOfCachedLoad(RefPtr<SheetLoadData>);
550 // Start the loads of all the sheets in mPendingDatas
551 void StartDeferredLoads();
553 // Note: LoadSheet is responsible for setting the sheet to complete on
554 // failure.
555 enum class PendingLoad { No, Yes };
556 nsresult LoadSheet(SheetLoadData&, SheetState, uint64_t aEarlyHintPreloaderId,
557 PendingLoad = PendingLoad::No);
559 enum class AllowAsyncParse {
560 Yes,
564 // Parse the stylesheet in the load data.
566 // Returns whether the parse finished. It may not finish e.g. if the sheet had
567 // an @import.
569 // If this function returns Completed::Yes, then ParseSheet also called
570 // SheetComplete on aLoadData.
571 Completed ParseSheet(const nsACString&, SheetLoadData&, AllowAsyncParse);
573 // The load of the sheet in the load data is done, one way or another.
574 // Do final cleanup.
575 void SheetComplete(SheetLoadData&, nsresult);
577 // Notify observers on an individual data. This is different from
578 // SheetComplete for loads that are shared.
579 void NotifyObservers(SheetLoadData&, nsresult);
581 // Mark the given SheetLoadData, as well as any of its siblings, parents, etc
582 // transitively, as failed. The idea is to mark as failed any load that was
583 // directly or indirectly @importing the sheet this SheetLoadData represents.
585 // if aOnlyForLoader is non-null, then only loads for a given loader will be
586 // marked as failing. This is useful to only cancel loads associated to a
587 // given loader, in case they were marked as canceled.
588 static void MarkLoadTreeFailed(SheetLoadData&,
589 Loader* aOnlyForLoader = nullptr);
591 // A shorthand to mark a possible link preload as used to supress "unused"
592 // warning in the console.
593 void MaybeNotifyPreloadUsed(SheetLoadData&);
595 nsRefPtrHashtable<nsStringHashKey, StyleSheet> mInlineSheets;
597 // A set with all the different loads we've done in a given document, for the
598 // purpose of not posting duplicate performance entries for them.
599 nsTHashtable<const SheetLoadDataHashKey> mLoadsPerformed;
601 RefPtr<SharedStyleSheetCache> mSheets;
603 // Our array of "global" observers
604 nsTObserverArray<nsCOMPtr<nsICSSLoaderObserver>> mObservers;
606 // This reference is nulled by the Document in it's destructor through
607 // DropDocumentReference().
608 dom::Document* MOZ_NON_OWNING_REF mDocument; // the document we live for
610 // For dispatching events via DocGroup::Dispatch() when mDocument is nullptr.
611 RefPtr<dom::DocGroup> mDocGroup;
613 nsCompatibility mDocumentCompatMode;
615 nsCOMPtr<nsIConsoleReportCollector> mReporter;
617 // Number of datas for asynchronous sheet loads still waiting to be notified.
618 // This includes pending stylesheets whose load hasn't started yet but which
619 // we need to, but not inline or constructable stylesheets, though the
620 // constructable stylesheets bit may change, see bug 1642227.
621 uint32_t mOngoingLoadCount = 0;
623 // The number of sheets that have been deferred / are in a pending state.
624 uint32_t mPendingLoadCount = 0;
626 // The number of stylesheets that we have parsed, for testing purposes.
627 uint32_t mParsedSheetCount = 0;
629 bool mEnabled = true;
631 // Whether we had a document at the point of creation.
632 bool mIsDocumentAssociated = false;
634 #ifdef DEBUG
635 // Whether we're in a necko callback atm.
636 bool mSyncCallback = false;
637 #endif
640 } // namespace css
641 } // namespace mozilla
643 #endif /* mozilla_css_Loader_h */