no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / layout / style / GroupRule.h
blob1584efd9b1ea646a83d42ea031dc227da4cb84af
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/MemoryReporting.h"
17 #include "mozilla/ServoCSSRuleList.h"
18 #include "mozilla/css/Rule.h"
19 #include "nsCycleCollectionParticipant.h"
21 namespace mozilla {
23 class ErrorResult;
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 MediaRule and DocumentRule
33 class GroupRule : public Rule {
34 protected:
35 GroupRule(StyleSheet* aSheet, Rule* aParentRule, uint32_t aLineNumber,
36 uint32_t aColumnNumber);
37 virtual ~GroupRule();
38 virtual already_AddRefed<StyleLockedCssRules> GetOrCreateRawRules() = 0;
40 public:
41 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(GroupRule, Rule)
42 NS_DECL_ISUPPORTS_INHERITED
44 GroupRule(const GroupRule&) = delete;
45 bool IsCCLeaf() const override;
47 bool IsGroupRule() const final { return true; }
49 #ifdef DEBUG
50 void List(FILE* out = stdout, int32_t aIndent = 0) const override;
51 #endif
52 void DropSheetReference() override;
53 uint32_t StyleRuleCount() { return CssRules()->Length(); }
54 Rule* GetStyleRuleAt(int32_t aIndex) { return CssRules()->GetRule(aIndex); }
56 void DidSetRawAfterClone() {
57 if (mRuleList) {
58 mRuleList->SetRawAfterClone(GetOrCreateRawRules());
63 * The next method should never be called unless you have first called
64 * WillDirty() on the parent stylesheet.
66 nsresult DeleteStyleRuleAt(uint32_t aIndex) {
67 return CssRules()->DeleteRule(aIndex);
70 // non-virtual -- it is only called by subclasses
71 size_t SizeOfExcludingThis(MallocSizeOf) const;
72 size_t SizeOfIncludingThis(MallocSizeOf) const override = 0;
74 // WebIDL API
75 ServoCSSRuleList* CssRules();
76 uint32_t InsertRule(const nsACString& aRule, uint32_t aIndex,
77 ErrorResult& aRv);
78 void DeleteRule(uint32_t aIndex, ErrorResult& aRv);
80 private:
81 RefPtr<ServoCSSRuleList> mRuleList;
84 // Implementation of WebIDL CSSConditionRule.
85 class ConditionRule : public GroupRule {
86 protected:
87 using GroupRule::GroupRule;
89 public:
90 virtual void GetConditionText(nsACString& aConditionText) = 0;
93 } // namespace css
94 } // namespace mozilla
96 #endif /* mozilla_css_GroupRule_h__ */