/work/obj-fuzz/dist/include/mozilla/dom/CSSStyleRule.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_CSSStyleRule_h |
8 | | #define mozilla_CSSStyleRule_h |
9 | | |
10 | | #include "mozilla/BindingStyleRule.h" |
11 | | #include "mozilla/ServoBindingTypes.h" |
12 | | #include "mozilla/WeakPtr.h" |
13 | | |
14 | | #include "nsDOMCSSDeclaration.h" |
15 | | |
16 | | namespace mozilla { |
17 | | |
18 | | class DeclarationBlock; |
19 | | |
20 | | namespace dom { |
21 | | class DocGroup; |
22 | | class CSSStyleRule; |
23 | | |
24 | | class CSSStyleRuleDeclaration final : public nsDOMCSSDeclaration |
25 | | { |
26 | | public: |
27 | | NS_DECL_ISUPPORTS_INHERITED |
28 | | |
29 | | css::Rule* GetParentRule() final; |
30 | | nsINode* GetParentObject() final; |
31 | | |
32 | | protected: |
33 | | mozilla::DeclarationBlock* GetOrCreateCSSDeclaration( |
34 | | Operation aOperation, mozilla::DeclarationBlock** aCreated) final; |
35 | | nsresult SetCSSDeclaration(DeclarationBlock* aDecl, |
36 | | MutationClosureData* aClosureData) final; |
37 | | nsIDocument* DocToUpdate() final; |
38 | | ParsingEnvironment |
39 | | GetParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final; |
40 | | |
41 | | private: |
42 | | // For accessing the constructor. |
43 | | friend class CSSStyleRule; |
44 | | |
45 | | explicit CSSStyleRuleDeclaration( |
46 | | already_AddRefed<RawServoDeclarationBlock> aDecls); |
47 | | ~CSSStyleRuleDeclaration(); |
48 | | |
49 | | inline CSSStyleRule* Rule(); |
50 | | inline const CSSStyleRule* Rule() const; |
51 | | |
52 | | RefPtr<DeclarationBlock> mDecls; |
53 | | }; |
54 | | |
55 | | class CSSStyleRule final : public BindingStyleRule |
56 | | , public SupportsWeakPtr<CSSStyleRule> |
57 | | { |
58 | | public: |
59 | | CSSStyleRule(already_AddRefed<RawServoStyleRule> aRawRule, |
60 | | StyleSheet* aSheet, |
61 | | css::Rule* aParentRule, |
62 | | uint32_t aLine, |
63 | | uint32_t aColumn); |
64 | | |
65 | | NS_DECL_ISUPPORTS_INHERITED |
66 | | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(CSSStyleRule, |
67 | | css::Rule) |
68 | | bool IsCCLeaf() const final MOZ_MUST_OVERRIDE; |
69 | | |
70 | | MOZ_DECLARE_WEAKREFERENCE_TYPENAME(CSSStyleRule) |
71 | | |
72 | | uint32_t GetSelectorCount() override; |
73 | | nsresult GetSelectorText(uint32_t aSelectorIndex, |
74 | | nsAString& aText) override; |
75 | | nsresult GetSpecificity(uint32_t aSelectorIndex, |
76 | | uint64_t* aSpecificity) override; |
77 | | nsresult SelectorMatchesElement(dom::Element* aElement, |
78 | | uint32_t aSelectorIndex, |
79 | | const nsAString& aPseudo, |
80 | | bool* aMatches) override; |
81 | | NotNull<DeclarationBlock*> GetDeclarationBlock() const override; |
82 | | |
83 | | // WebIDL interface |
84 | 0 | uint16_t Type() const final { return dom::CSSRule_Binding::STYLE_RULE; } |
85 | | void GetCssText(nsAString& aCssText) const final; |
86 | | void GetSelectorText(nsAString& aSelectorText) final; |
87 | | void SetSelectorText(const nsAString& aSelectorText) final; |
88 | | nsICSSDeclaration* Style() final; |
89 | | |
90 | 0 | RawServoStyleRule* Raw() const { return mRawRule; } |
91 | | |
92 | | // Methods of mozilla::css::Rule |
93 | | size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final; |
94 | | #ifdef DEBUG |
95 | | void List(FILE* out = stdout, int32_t aIndent = 0) const final; |
96 | | #endif |
97 | | |
98 | | private: |
99 | 0 | ~CSSStyleRule() {} |
100 | | |
101 | | // For computing the offset of mDecls. |
102 | | friend class CSSStyleRuleDeclaration; |
103 | | |
104 | | RefPtr<RawServoStyleRule> mRawRule; |
105 | | CSSStyleRuleDeclaration mDecls; |
106 | | }; |
107 | | |
108 | | CSSStyleRule* |
109 | | CSSStyleRuleDeclaration::Rule() |
110 | 0 | { |
111 | 0 | return reinterpret_cast<CSSStyleRule*>( |
112 | 0 | reinterpret_cast<uint8_t*>(this) - offsetof(CSSStyleRule, mDecls)); |
113 | 0 | } |
114 | | |
115 | | const CSSStyleRule* |
116 | | CSSStyleRuleDeclaration::Rule() const |
117 | 0 | { |
118 | 0 | return reinterpret_cast<const CSSStyleRule*>( |
119 | 0 | reinterpret_cast<const uint8_t*>(this) - offsetof(CSSStyleRule, mDecls)); |
120 | 0 | } |
121 | | |
122 | | } // namespace dom |
123 | | } // namespace mozilla |
124 | | |
125 | | #endif // mozilla_CSSStyleRule_h |