Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / layout / style / GroupRule.h
blob412990ccdab4a44504f1eeec255bd969ccdc1780
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /*
7 * internal interface representing CSS style rules that contain other
8 * rules, such as @media rules
9 */
11 #ifndef mozilla_css_GroupRule_h__
12 #define mozilla_css_GroupRule_h__
14 #include "mozilla/Attributes.h"
15 #include "mozilla/MemoryReporting.h"
16 #include "mozilla/css/Rule.h"
17 #include "nsCOMArray.h"
18 #include "nsAutoPtr.h"
19 #include "nsCycleCollectionParticipant.h"
21 class nsPresContext;
22 class nsMediaQueryResultCacheKey;
24 namespace mozilla {
26 class CSSStyleSheet;
28 namespace css {
30 class GroupRuleRuleList;
32 // inherits from Rule so it can be shared between
33 // MediaRule and DocumentRule
34 class GroupRule : public Rule
36 protected:
37 GroupRule(uint32_t aLineNumber, uint32_t aColumnNumber);
38 GroupRule(const GroupRule& aCopy);
39 virtual ~GroupRule();
40 public:
42 NS_DECL_CYCLE_COLLECTION_CLASS(GroupRule)
43 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
45 // implement part of nsIStyleRule and Rule
46 DECL_STYLE_RULE_INHERIT_NO_DOMRULE
47 virtual void SetStyleSheet(CSSStyleSheet* aSheet) MOZ_OVERRIDE;
49 // to help implement nsIStyleRule
50 #ifdef DEBUG
51 virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
52 #endif
54 public:
55 void AppendStyleRule(Rule* aRule);
57 int32_t StyleRuleCount() const { return mRules.Count(); }
58 Rule* GetStyleRuleAt(int32_t aIndex) const;
60 typedef nsCOMArray<Rule>::nsCOMArrayEnumFunc RuleEnumFunc;
61 bool EnumerateRulesForwards(RuleEnumFunc aFunc, void * aData) const;
64 * The next three methods should never be called unless you have first
65 * called WillDirty() on the parent stylesheet. After they are
66 * called, DidDirty() needs to be called on the sheet.
68 nsresult DeleteStyleRuleAt(uint32_t aIndex);
69 nsresult InsertStyleRuleAt(uint32_t aIndex, Rule* aRule);
70 nsresult ReplaceStyleRule(Rule *aOld, Rule *aNew);
72 virtual bool UseForPresentation(nsPresContext* aPresContext,
73 nsMediaQueryResultCacheKey& aKey) = 0;
75 // non-virtual -- it is only called by subclasses
76 size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
77 virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE = 0;
79 static bool
80 CloneRuleInto(Rule* aRule, void* aArray)
82 nsRefPtr<Rule> clone = aRule->Clone();
83 static_cast<nsCOMArray<Rule>*>(aArray)->AppendObject(clone);
84 return true;
87 protected:
88 // to help implement nsIDOMCSSRule
89 void AppendRulesToCssText(nsAString& aCssText);
91 // to implement common methods on nsIDOMCSSMediaRule and
92 // nsIDOMCSSMozDocumentRule
93 nsresult GetCssRules(nsIDOMCSSRuleList* *aRuleList);
94 nsresult InsertRule(const nsAString & aRule, uint32_t aIndex,
95 uint32_t* _retval);
96 nsresult DeleteRule(uint32_t aIndex);
98 nsCOMArray<Rule> mRules;
99 nsRefPtr<GroupRuleRuleList> mRuleCollection; // lazily constructed
102 } // namespace css
103 } // namespace mozilla
105 #endif /* mozilla_css_GroupRule_h__ */