Bug 1877662 - expose mozconfig as an artifact from build-fat-aar. r=glandium,geckovie...
[gecko.git] / layout / base / nsStyleSheetService.h
blob79a2f867d96e74040045754f4273418c49d05a2f
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 "nsIMemoryReporter.h"
13 #include "nsIStyleSheetService.h"
14 #include "mozilla/Array.h"
15 #include "mozilla/Attributes.h"
16 #include "mozilla/MemoryReporting.h"
17 #include "mozilla/StyleSheet.h"
19 class nsISimpleEnumerator;
21 namespace mozilla {
22 class PresShell;
23 } // namespace mozilla
25 #define NS_STYLESHEETSERVICE_CID \
26 { \
27 0x3b55e72e, 0xab7e, 0x431b, { \
28 0x89, 0xc0, 0x3b, 0x06, 0xa8, 0xb1, 0x40, 0x16 \
29 } \
32 #define NS_STYLESHEETSERVICE_CONTRACTID \
33 "@mozilla.org/content/style-sheet-service;1"
35 class nsStyleSheetService final : public nsIStyleSheetService,
36 public nsIMemoryReporter {
37 public:
38 typedef nsTArray<RefPtr<mozilla::StyleSheet>> SheetArray;
40 nsStyleSheetService();
42 NS_DECL_ISUPPORTS
43 NS_DECL_NSISTYLESHEETSERVICE
44 NS_DECL_NSIMEMORYREPORTER
46 nsresult Init();
48 SheetArray* AgentStyleSheets() { return &mSheets[AGENT_SHEET]; }
49 SheetArray* UserStyleSheets() { return &mSheets[USER_SHEET]; }
50 SheetArray* AuthorStyleSheets() { return &mSheets[AUTHOR_SHEET]; }
52 void RegisterPresShell(mozilla::PresShell* aPresShell);
53 void UnregisterPresShell(mozilla::PresShell* aPresShell);
55 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
57 static nsStyleSheetService* GetInstance();
58 static nsStyleSheetService* gInstance;
60 private:
61 ~nsStyleSheetService();
63 int32_t FindSheetByURI(uint32_t aSheetType, nsIURI* aSheetURI);
65 // Like LoadAndRegisterSheet, but doesn't notify. If successful, the
66 // new sheet will be the last sheet in mSheets[aSheetType].
67 nsresult LoadAndRegisterSheetInternal(nsIURI* aSheetURI, uint32_t aSheetType);
69 mozilla::Array<SheetArray, 3> mSheets;
71 // Registered PresShells that will be notified when sheets are added and
72 // removed from the style sheet service.
73 nsTArray<RefPtr<mozilla::PresShell>> mPresShells;
76 #endif