layout/base/nsStyleSheetService.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:31b371055253
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 /* implementation of interface for managing user and user-agent style sheets */
8
9 #ifndef nsStyleSheetService_h_
10 #define nsStyleSheetService_h_
11
12 #include "nsCOMArray.h"
13 #include "nsCOMPtr.h"
14 #include "nsIMemoryReporter.h"
15 #include "nsIStyleSheetService.h"
16 #include "mozilla/Attributes.h"
17 #include "mozilla/MemoryReporting.h"
18
19 class nsICategoryManager;
20 class nsIMemoryReporter;
21 class nsISimpleEnumerator;
22 class nsIStyleSheet;
23
24 #define NS_STYLESHEETSERVICE_CID \
25 {0xfcca6f83, 0x9f7d, 0x44e4, {0xa7, 0x4b, 0xb5, 0x94, 0x33, 0xe6, 0xc8, 0xc3}}
26
27 #define NS_STYLESHEETSERVICE_CONTRACTID \
28 "@mozilla.org/content/style-sheet-service;1"
29
30 class nsStyleSheetService MOZ_FINAL
31 : public nsIStyleSheetService
32 , public nsIMemoryReporter
33 {
34 public:
35 nsStyleSheetService() NS_HIDDEN;
36 ~nsStyleSheetService() NS_HIDDEN;
37
38 NS_DECL_ISUPPORTS
39 NS_DECL_NSISTYLESHEETSERVICE
40 NS_DECL_NSIMEMORYREPORTER
41
42 NS_HIDDEN_(nsresult) Init();
43
44 nsCOMArray<nsIStyleSheet>* AgentStyleSheets() { return &mSheets[AGENT_SHEET]; }
45 nsCOMArray<nsIStyleSheet>* UserStyleSheets() { return &mSheets[USER_SHEET]; }
46 nsCOMArray<nsIStyleSheet>* AuthorStyleSheets() { return &mSheets[AUTHOR_SHEET]; }
47
48 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
49
50 static nsStyleSheetService *GetInstance();
51 static nsStyleSheetService *gInstance;
52
53 private:
54
55 NS_HIDDEN_(void) RegisterFromEnumerator(nsICategoryManager *aManager,
56 const char *aCategory,
57 nsISimpleEnumerator *aEnumerator,
58 uint32_t aSheetType);
59
60 NS_HIDDEN_(int32_t) FindSheetByURI(const nsCOMArray<nsIStyleSheet> &sheets,
61 nsIURI *sheetURI);
62
63 // Like LoadAndRegisterSheet, but doesn't notify. If successful, the
64 // new sheet will be the last sheet in mSheets[aSheetType].
65 NS_HIDDEN_(nsresult) LoadAndRegisterSheetInternal(nsIURI *aSheetURI,
66 uint32_t aSheetType);
67
68 nsCOMArray<nsIStyleSheet> mSheets[3];
69 };
70
71 #endif

mercurial