|
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/. */ |
|
6 |
|
7 #ifndef nsLayoutStylesheetCache_h__ |
|
8 #define nsLayoutStylesheetCache_h__ |
|
9 |
|
10 #include "nsIMemoryReporter.h" |
|
11 #include "nsIObserver.h" |
|
12 #include "nsAutoPtr.h" |
|
13 #include "mozilla/Attributes.h" |
|
14 #include "mozilla/MemoryReporting.h" |
|
15 |
|
16 class nsCSSStyleSheet; |
|
17 class nsIFile; |
|
18 class nsIURI; |
|
19 |
|
20 namespace mozilla { |
|
21 namespace css { |
|
22 class Loader; |
|
23 } |
|
24 } |
|
25 |
|
26 class nsLayoutStylesheetCache MOZ_FINAL |
|
27 : public nsIObserver |
|
28 , public nsIMemoryReporter |
|
29 { |
|
30 NS_DECL_ISUPPORTS |
|
31 NS_DECL_NSIOBSERVER |
|
32 NS_DECL_NSIMEMORYREPORTER |
|
33 |
|
34 static nsCSSStyleSheet* ScrollbarsSheet(); |
|
35 static nsCSSStyleSheet* FormsSheet(); |
|
36 // This function is expected to return nullptr when the dom.forms.number |
|
37 // pref is disabled. |
|
38 static nsCSSStyleSheet* NumberControlSheet(); |
|
39 static nsCSSStyleSheet* UserContentSheet(); |
|
40 static nsCSSStyleSheet* UserChromeSheet(); |
|
41 static nsCSSStyleSheet* UASheet(); |
|
42 static nsCSSStyleSheet* QuirkSheet(); |
|
43 static nsCSSStyleSheet* FullScreenOverrideSheet(); |
|
44 |
|
45 static void Shutdown(); |
|
46 |
|
47 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
|
48 |
|
49 private: |
|
50 nsLayoutStylesheetCache(); |
|
51 ~nsLayoutStylesheetCache(); |
|
52 |
|
53 static void EnsureGlobal(); |
|
54 void InitFromProfile(); |
|
55 void InitMemoryReporter(); |
|
56 static void LoadSheetFile(nsIFile* aFile, nsRefPtr<nsCSSStyleSheet> &aSheet); |
|
57 static void LoadSheet(nsIURI* aURI, nsRefPtr<nsCSSStyleSheet> &aSheet, |
|
58 bool aEnableUnsafeRules); |
|
59 |
|
60 static nsLayoutStylesheetCache* gStyleCache; |
|
61 static mozilla::css::Loader* gCSSLoader; |
|
62 nsRefPtr<nsCSSStyleSheet> mScrollbarsSheet; |
|
63 nsRefPtr<nsCSSStyleSheet> mFormsSheet; |
|
64 nsRefPtr<nsCSSStyleSheet> mNumberControlSheet; |
|
65 nsRefPtr<nsCSSStyleSheet> mUserContentSheet; |
|
66 nsRefPtr<nsCSSStyleSheet> mUserChromeSheet; |
|
67 nsRefPtr<nsCSSStyleSheet> mUASheet; |
|
68 nsRefPtr<nsCSSStyleSheet> mQuirkSheet; |
|
69 nsRefPtr<nsCSSStyleSheet> mFullScreenOverrideSheet; |
|
70 }; |
|
71 |
|
72 #endif |