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 /* implementation of interface for managing user and user-agent style sheets */
9 #ifndef nsStyleSheetService_h_
10 #define nsStyleSheetService_h_
12 #include "nsCOMArray.h"
14 #include "nsIMemoryReporter.h"
15 #include "nsIStyleSheetService.h"
16 #include "mozilla/Attributes.h"
17 #include "mozilla/MemoryReporting.h"
19 class nsICategoryManager
;
20 class nsIMemoryReporter
;
21 class nsISimpleEnumerator
;
24 #define NS_STYLESHEETSERVICE_CID \
25 {0xfcca6f83, 0x9f7d, 0x44e4, {0xa7, 0x4b, 0xb5, 0x94, 0x33, 0xe6, 0xc8, 0xc3}}
27 #define NS_STYLESHEETSERVICE_CONTRACTID \
28 "@mozilla.org/content/style-sheet-service;1"
30 class nsStyleSheetService MOZ_FINAL
31 : public nsIStyleSheetService
32 , public nsIMemoryReporter
35 nsStyleSheetService();
38 NS_DECL_NSISTYLESHEETSERVICE
39 NS_DECL_NSIMEMORYREPORTER
43 nsCOMArray
<nsIStyleSheet
>* AgentStyleSheets() { return &mSheets
[AGENT_SHEET
]; }
44 nsCOMArray
<nsIStyleSheet
>* UserStyleSheets() { return &mSheets
[USER_SHEET
]; }
45 nsCOMArray
<nsIStyleSheet
>* AuthorStyleSheets() { return &mSheets
[AUTHOR_SHEET
]; }
47 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf
) const;
49 static nsStyleSheetService
*GetInstance();
50 static nsStyleSheetService
*gInstance
;
53 ~nsStyleSheetService();
55 void RegisterFromEnumerator(nsICategoryManager
*aManager
,
56 const char *aCategory
,
57 nsISimpleEnumerator
*aEnumerator
,
60 int32_t FindSheetByURI(const nsCOMArray
<nsIStyleSheet
> &sheets
,
63 // Like LoadAndRegisterSheet, but doesn't notify. If successful, the
64 // new sheet will be the last sheet in mSheets[aSheetType].
65 nsresult
LoadAndRegisterSheetInternal(nsIURI
*aSheetURI
,
68 nsCOMArray
<nsIStyleSheet
> mSheets
[3];