Bug 1637593 [wpt PR 23564] - Fix superclass calls in MarionetteRefTestExecutor, a...
[gecko.git] / layout / style / GroupRule.h
blobdf357f446654074d3b27ee9d3692f4e578230213
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 /*
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"
22 namespace mozilla {
24 class StyleSheet;
26 namespace dom {
27 class CSSRuleList;
28 } // namespace dom
30 namespace css {
32 // inherits from Rule so it can be shared between
33 // MediaRule and DocumentRule
34 class GroupRule : public Rule {
35 protected:
36 GroupRule(already_AddRefed<ServoCssRules> aRules, StyleSheet* aSheet,
37 Rule* aParentRule, uint32_t aLineNumber, uint32_t aColumnNumber);
38 GroupRule(const GroupRule& aCopy) = delete;
39 virtual ~GroupRule();
41 public:
42 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(GroupRule, Rule)
43 NS_DECL_ISUPPORTS_INHERITED
44 virtual bool IsCCLeaf() const override;
46 #ifdef DEBUG
47 void List(FILE* out = stdout, int32_t aIndent = 0) const override;
48 #endif
49 void DropSheetReference() override;
51 public:
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;
70 // WebIDL API
71 dom::CSSRuleList* CssRules() { return mRuleList; }
72 uint32_t InsertRule(const nsAString& aRule, uint32_t aIndex,
73 ErrorResult& aRv);
74 void DeleteRule(uint32_t aIndex, ErrorResult& aRv);
76 private:
77 RefPtr<ServoCSSRuleList> mRuleList;
80 // Implementation of WebIDL CSSConditionRule.
81 class ConditionRule : public GroupRule {
82 protected:
83 using GroupRule::GroupRule;
85 public:
86 virtual void GetConditionText(nsAString& aConditionText) = 0;
87 virtual void SetConditionText(const nsAString& aConditionText,
88 ErrorResult& aRv) = 0;
91 } // namespace css
92 } // namespace mozilla
94 #endif /* mozilla_css_GroupRule_h__ */