/work/obj-fuzz/dist/include/mozilla/css/GroupRule.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 | | /* |
8 | | * internal interface representing CSS style rules that contain other |
9 | | * rules, such as @media rules |
10 | | */ |
11 | | |
12 | | #ifndef mozilla_css_GroupRule_h__ |
13 | | #define mozilla_css_GroupRule_h__ |
14 | | |
15 | | #include "mozilla/Attributes.h" |
16 | | #include "mozilla/ErrorResult.h" |
17 | | #include "mozilla/MemoryReporting.h" |
18 | | #include "mozilla/ServoCSSRuleList.h" |
19 | | #include "mozilla/css/Rule.h" |
20 | | #include "nsCycleCollectionParticipant.h" |
21 | | |
22 | | namespace mozilla { |
23 | | |
24 | | class StyleSheet; |
25 | | |
26 | | namespace dom { |
27 | | class CSSRuleList; |
28 | | } // namespace dom |
29 | | |
30 | | namespace css { |
31 | | |
32 | | // inherits from Rule so it can be shared between |
33 | | // MediaRule and DocumentRule |
34 | | class GroupRule : public Rule |
35 | | { |
36 | | protected: |
37 | | GroupRule(already_AddRefed<ServoCssRules> aRules, |
38 | | StyleSheet* aSheet, |
39 | | Rule* aParentRule, |
40 | | uint32_t aLineNumber, |
41 | | uint32_t aColumnNumber); |
42 | | GroupRule(const GroupRule& aCopy) = delete; |
43 | | virtual ~GroupRule(); |
44 | | public: |
45 | | |
46 | | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(GroupRule, Rule) |
47 | | NS_DECL_ISUPPORTS_INHERITED |
48 | | virtual bool IsCCLeaf() const override; |
49 | | |
50 | | #ifdef DEBUG |
51 | | void List(FILE* out = stdout, int32_t aIndent = 0) const override; |
52 | | #endif |
53 | | void DropSheetReference() override; |
54 | | |
55 | | public: |
56 | | |
57 | 0 | int32_t StyleRuleCount() const { return mRuleList->Length(); } |
58 | | |
59 | 0 | Rule* GetStyleRuleAt(int32_t aIndex) const { |
60 | 0 | return mRuleList->GetRule(aIndex); |
61 | 0 | } |
62 | | |
63 | | /* |
64 | | * The next method should never be called unless you have first called |
65 | | * WillDirty() on the parent stylesheet. |
66 | | */ |
67 | 0 | nsresult DeleteStyleRuleAt(uint32_t aIndex) { |
68 | 0 | return mRuleList->DeleteRule(aIndex); |
69 | 0 | } |
70 | | |
71 | | // non-virtual -- it is only called by subclasses |
72 | | size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
73 | | virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override = 0; |
74 | | |
75 | | // WebIDL API |
76 | 0 | dom::CSSRuleList* CssRules() { return mRuleList; } |
77 | | uint32_t InsertRule(const nsAString& aRule, uint32_t aIndex, |
78 | | ErrorResult& aRv); |
79 | | void DeleteRule(uint32_t aIndex, ErrorResult& aRv); |
80 | | |
81 | | private: |
82 | | RefPtr<ServoCSSRuleList> mRuleList; |
83 | | }; |
84 | | |
85 | | // Implementation of WebIDL CSSConditionRule. |
86 | | class ConditionRule : public GroupRule |
87 | | { |
88 | | protected: |
89 | | using GroupRule::GroupRule; |
90 | | |
91 | | public: |
92 | | virtual void GetConditionText(nsAString& aConditionText) = 0; |
93 | | virtual void SetConditionText(const nsAString& aConditionText, |
94 | | ErrorResult& aRv) = 0; |
95 | | }; |
96 | | |
97 | | } // namespace css |
98 | | } // namespace mozilla |
99 | | |
100 | | #endif /* mozilla_css_GroupRule_h__ */ |