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 #ifndef nsLayoutStylesheetCache_h__
8 #define nsLayoutStylesheetCache_h__
10 #include "nsIMemoryReporter.h"
11 #include "nsIObserver.h"
12 #include "nsAutoPtr.h"
13 #include "mozilla/Attributes.h"
14 #include "mozilla/MemoryReporting.h"
15 #include "mozilla/StaticPtr.h"
27 class nsLayoutStylesheetCache MOZ_FINAL
29 , public nsIMemoryReporter
33 NS_DECL_NSIMEMORYREPORTER
35 static mozilla::CSSStyleSheet
* ScrollbarsSheet();
36 static mozilla::CSSStyleSheet
* FormsSheet();
37 // This function is expected to return nullptr when the dom.forms.number
39 static mozilla::CSSStyleSheet
* NumberControlSheet();
40 static mozilla::CSSStyleSheet
* UserContentSheet();
41 static mozilla::CSSStyleSheet
* UserChromeSheet();
42 static mozilla::CSSStyleSheet
* UASheet();
43 static mozilla::CSSStyleSheet
* HTMLSheet();
44 static mozilla::CSSStyleSheet
* MinimalXULSheet();
45 static mozilla::CSSStyleSheet
* XULSheet();
46 static mozilla::CSSStyleSheet
* QuirkSheet();
47 static mozilla::CSSStyleSheet
* FullScreenOverrideSheet();
48 static mozilla::CSSStyleSheet
* SVGSheet();
49 static mozilla::CSSStyleSheet
* MathMLSheet();
50 static mozilla::CSSStyleSheet
* CounterStylesSheet();
52 static void Shutdown();
54 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf
) const;
57 nsLayoutStylesheetCache();
58 ~nsLayoutStylesheetCache();
60 static void EnsureGlobal();
61 void InitFromProfile();
62 void InitMemoryReporter();
63 static void LoadSheetURL(const char* aURL
,
64 nsRefPtr
<mozilla::CSSStyleSheet
>& aSheet
,
65 bool aEnableUnsafeRules
);
66 static void LoadSheetFile(nsIFile
* aFile
,
67 nsRefPtr
<mozilla::CSSStyleSheet
>& aSheet
);
68 static void LoadSheet(nsIURI
* aURI
, nsRefPtr
<mozilla::CSSStyleSheet
>& aSheet
,
69 bool aEnableUnsafeRules
);
70 static void InvalidateSheet(nsRefPtr
<mozilla::CSSStyleSheet
>& aSheet
);
71 static void DependentPrefChanged(const char* aPref
, void* aData
);
73 static mozilla::StaticRefPtr
<nsLayoutStylesheetCache
> gStyleCache
;
74 static mozilla::css::Loader
* gCSSLoader
;
75 nsRefPtr
<mozilla::CSSStyleSheet
> mCounterStylesSheet
;
76 nsRefPtr
<mozilla::CSSStyleSheet
> mFormsSheet
;
77 nsRefPtr
<mozilla::CSSStyleSheet
> mFullScreenOverrideSheet
;
78 nsRefPtr
<mozilla::CSSStyleSheet
> mHTMLSheet
;
79 nsRefPtr
<mozilla::CSSStyleSheet
> mMathMLSheet
;
80 nsRefPtr
<mozilla::CSSStyleSheet
> mMinimalXULSheet
;
81 nsRefPtr
<mozilla::CSSStyleSheet
> mNumberControlSheet
;
82 nsRefPtr
<mozilla::CSSStyleSheet
> mQuirkSheet
;
83 nsRefPtr
<mozilla::CSSStyleSheet
> mSVGSheet
;
84 nsRefPtr
<mozilla::CSSStyleSheet
> mScrollbarsSheet
;
85 nsRefPtr
<mozilla::CSSStyleSheet
> mUASheet
;
86 nsRefPtr
<mozilla::CSSStyleSheet
> mUserChromeSheet
;
87 nsRefPtr
<mozilla::CSSStyleSheet
> mUserContentSheet
;
88 nsRefPtr
<mozilla::CSSStyleSheet
> mXULSheet
;