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/. */
8 * internal interface representing CSS style rules that contain other
9 * rules, such as @media rules
12 #ifndef mozilla_css_GroupRule_h__
13 #define mozilla_css_GroupRule_h__
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"
32 // inherits from Rule so it can be shared between
33 // MediaRule and DocumentRule
34 class GroupRule
: public Rule
{
36 GroupRule(already_AddRefed
<ServoCssRules
> aRules
, StyleSheet
* aSheet
,
37 Rule
* aParentRule
, uint32_t aLineNumber
, uint32_t aColumnNumber
);
38 GroupRule(const GroupRule
& aCopy
) = delete;
42 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(GroupRule
, Rule
)
43 NS_DECL_ISUPPORTS_INHERITED
44 virtual bool IsCCLeaf() const override
;
47 void List(FILE* out
= stdout
, int32_t aIndent
= 0) const override
;
49 void DropSheetReference() override
;
52 int32_t StyleRuleCount() const { return mRuleList
->Length(); }
54 Rule
* GetStyleRuleAt(int32_t aIndex
) const {
55 return mRuleList
->GetRule(aIndex
);
59 * The next method should never be called unless you have first called
60 * WillDirty() on the parent stylesheet.
62 nsresult
DeleteStyleRuleAt(uint32_t aIndex
) {
63 return mRuleList
->DeleteRule(aIndex
);
66 // non-virtual -- it is only called by subclasses
67 size_t SizeOfExcludingThis(MallocSizeOf
) const;
68 size_t SizeOfIncludingThis(MallocSizeOf
) const override
= 0;
71 dom::CSSRuleList
* CssRules() { return mRuleList
; }
72 uint32_t InsertRule(const nsAString
& aRule
, uint32_t aIndex
,
74 void DeleteRule(uint32_t aIndex
, ErrorResult
& aRv
);
77 RefPtr
<ServoCSSRuleList
> mRuleList
;
80 // Implementation of WebIDL CSSConditionRule.
81 class ConditionRule
: public GroupRule
{
83 using GroupRule::GroupRule
;
86 virtual void GetConditionText(nsAString
& aConditionText
) = 0;
87 virtual void SetConditionText(const nsAString
& aConditionText
,
88 ErrorResult
& aRv
) = 0;
92 } // namespace mozilla
94 #endif /* mozilla_css_GroupRule_h__ */