/work/obj-fuzz/dist/include/mozilla/ServoStyleRuleMap.h
Line | Count | Source (jump to first uncovered line) |
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 mozilla_ServoStyleRuleMap_h |
8 | | #define mozilla_ServoStyleRuleMap_h |
9 | | |
10 | | #include "mozilla/dom/CSSStyleRule.h" |
11 | | #include "mozilla/StyleSheet.h" |
12 | | |
13 | | #include "nsDataHashtable.h" |
14 | | |
15 | | struct RawServoStyleRule; |
16 | | class nsXBLPrototypeResources; |
17 | | |
18 | | namespace mozilla { |
19 | | class ServoCSSRuleList; |
20 | | class ServoStyleSet; |
21 | | namespace css { |
22 | | class Rule; |
23 | | } // namespace css |
24 | | namespace dom { |
25 | | class ShadowRoot; |
26 | | } |
27 | | class ServoStyleRuleMap |
28 | | { |
29 | | public: |
30 | 0 | ServoStyleRuleMap() = default; |
31 | | |
32 | | void EnsureTable(ServoStyleSet&); |
33 | | void EnsureTable(nsXBLPrototypeResources&); |
34 | | void EnsureTable(dom::ShadowRoot&); |
35 | | |
36 | | dom::CSSStyleRule* Lookup(const RawServoStyleRule* aRawRule) const |
37 | 0 | { |
38 | 0 | return mTable.Get(aRawRule); |
39 | 0 | } |
40 | | |
41 | | void SheetAdded(StyleSheet&); |
42 | | void SheetRemoved(StyleSheet&); |
43 | | |
44 | | void RuleAdded(StyleSheet& aStyleSheet, css::Rule&); |
45 | | void RuleRemoved(StyleSheet& aStyleSheet, css::Rule&); |
46 | | |
47 | | size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const; |
48 | | |
49 | 0 | ~ServoStyleRuleMap() = default; |
50 | | |
51 | | private: |
52 | | // Since we would never have a document which contains no style rule, |
53 | | // we use IsEmpty as an indication whether we need to walk through |
54 | | // all stylesheets to fill the table. |
55 | 0 | bool IsEmpty() const { return mTable.Count() == 0; } |
56 | | |
57 | | void FillTableFromRule(css::Rule&); |
58 | | void FillTableFromRuleList(ServoCSSRuleList&); |
59 | | void FillTableFromStyleSheet(StyleSheet&); |
60 | | |
61 | | typedef nsDataHashtable<nsPtrHashKey<const RawServoStyleRule>, |
62 | | WeakPtr<dom::CSSStyleRule>> Hashtable; |
63 | | Hashtable mTable; |
64 | | }; |
65 | | |
66 | | } // namespace mozilla |
67 | | |
68 | | #endif // mozilla_ServoStyleRuleMap_h |