Bug 1776056 - Switch to the tab an animation is running and make sure the animation...
[gecko.git] / layout / base / nsStyleSheetService.h
blob83e1f160266531b1d42738aa97b826e6622a37d4
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"
13 #include "nsCOMPtr.h"
14 #include "nsIMemoryReporter.h"
15 #include "nsIStyleSheetService.h"
16 #include "mozilla/Array.h"
17 #include "mozilla/Attributes.h"
18 #include "mozilla/MemoryReporting.h"
19 #include "mozilla/StyleSheet.h"
21 class nsICategoryManager;
22 class nsIMemoryReporter;
23 class nsISimpleEnumerator;
25 namespace mozilla {
26 class PresShell;
27 } // namespace mozilla
29 #define NS_STYLESHEETSERVICE_CID \
30 { \
31 0x3b55e72e, 0xab7e, 0x431b, { \
32 0x89, 0xc0, 0x3b, 0x06, 0xa8, 0xb1, 0x40, 0x16 \
33 } \
36 #define NS_STYLESHEETSERVICE_CONTRACTID \
37 "@mozilla.org/content/style-sheet-service;1"
39 class nsStyleSheetService final : public nsIStyleSheetService,
40 public nsIMemoryReporter {
41 public:
42 typedef nsTArray<RefPtr<mozilla::StyleSheet>> SheetArray;
44 nsStyleSheetService();
46 NS_DECL_ISUPPORTS
47 NS_DECL_NSISTYLESHEETSERVICE
48 NS_DECL_NSIMEMORYREPORTER
50 nsresult Init();
52 SheetArray* AgentStyleSheets() { return &mSheets[AGENT_SHEET]; }
53 SheetArray* UserStyleSheets() { return &mSheets[USER_SHEET]; }
54 SheetArray* AuthorStyleSheets() { return &mSheets[AUTHOR_SHEET]; }
56 void RegisterPresShell(mozilla::PresShell* aPresShell);
57 void UnregisterPresShell(mozilla::PresShell* aPresShell);
59 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
61 static nsStyleSheetService* GetInstance();
62 static nsStyleSheetService* gInstance;
64 private:
65 ~nsStyleSheetService();
67 void RegisterFromEnumerator(nsICategoryManager* aManager,
68 const char* aCategory,
69 nsISimpleEnumerator* aEnumerator,
70 uint32_t aSheetType);
72 int32_t FindSheetByURI(uint32_t aSheetType, nsIURI* aSheetURI);
74 // Like LoadAndRegisterSheet, but doesn't notify. If successful, the
75 // new sheet will be the last sheet in mSheets[aSheetType].
76 nsresult LoadAndRegisterSheetInternal(nsIURI* aSheetURI, uint32_t aSheetType);
78 mozilla::Array<SheetArray, 3> mSheets;
80 // Registered PresShells that will be notified when sheets are added and
81 // removed from the style sheet service.
82 nsTArray<RefPtr<mozilla::PresShell>> mPresShells;
85 #endif