layout/style/GroupRule.h

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

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

mercurial