Bug 577976 - Part 4: Move AddRef/Release back to nsCSSRule, r=bzbarsky
authorCraig Topper <craig.topper@gmail.com>
Thu, 17 Mar 2011 22:18:08 -0700
changeset 64683 5d537abf700580e70406c631d461ab60bb956e09
parent 64682 7e119e22b856b359b201601934bd194194d8cd98
child 64684 5235a5391635a57d75ac52e6bf7aa2dce73e5cd6
push idunknown
push userunknown
push dateunknown
reviewersbzbarsky
bugs577976
milestone2.2a1pre
Bug 577976 - Part 4: Move AddRef/Release back to nsCSSRule, r=bzbarsky
layout/style/GroupRule.h
layout/style/ImportRule.h
layout/style/NameSpaceRule.h
layout/style/Rule.h
layout/style/StyleRule.cpp
layout/style/StyleRule.h
layout/style/nsCSSRules.cpp
layout/style/nsCSSRules.h
--- a/layout/style/GroupRule.h
+++ b/layout/style/GroupRule.h
@@ -58,26 +58,18 @@ class GroupRuleRuleList;
 // inherits from Rule so it can be shared between
 // MediaRule and DocumentRule
 class GroupRule : public Rule
 {
 protected:
   GroupRule();
   GroupRule(const GroupRule& aCopy);
   virtual ~GroupRule();
-
-protected:
-  nsAutoRefCnt mRefCnt;
-  NS_DECL_OWNINGTHREAD
 public:
 
-  // Implement part of nsISupports.
-  NS_IMETHOD_(nsrefcnt) AddRef();
-  NS_IMETHOD_(nsrefcnt) Release();
-
   // implement part of nsIStyleRule and nsICSSRule
   DECL_STYLE_RULE_INHERIT_NO_DOMRULE
   virtual void SetStyleSheet(nsCSSStyleSheet* aSheet);
 
   // to help implement nsIStyleRule
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
 #endif
--- a/layout/style/ImportRule.h
+++ b/layout/style/ImportRule.h
@@ -55,17 +55,17 @@ class NS_FINAL_CLASS ImportRule : public
 {
 public:
   ImportRule(nsMediaList* aMedia);
 private:
   // for |Clone|
   ImportRule(const ImportRule& aCopy);
   ~ImportRule();
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_ISUPPORTS_INHERITED
 
   DECL_STYLE_RULE_INHERIT
 
 #ifdef HAVE_CPP_AMBIGUITY_RESOLVING_USING
   using Rule::GetStyleSheet; // unhide since nsIDOMCSSImportRule has its own GetStyleSheet
 #endif
 
   // nsIStyleRule methods
--- a/layout/style/NameSpaceRule.h
+++ b/layout/style/NameSpaceRule.h
@@ -60,17 +60,17 @@ public:
   NameSpaceRule();
 private:
   // for |Clone|
   NameSpaceRule(const NameSpaceRule& aCopy);
   ~NameSpaceRule();
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_CSS_NAMESPACE_RULE_IMPL_CID)
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_ISUPPORTS_INHERITED
 
   DECL_STYLE_RULE_INHERIT
 
   // nsIStyleRule methods
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
 #endif
 
--- a/layout/style/Rule.h
+++ b/layout/style/Rule.h
@@ -67,16 +67,25 @@ protected:
   }
 
   Rule(const Rule& aCopy)
     : mSheet(aCopy.mSheet),
       mParentRule(aCopy.mParentRule)
   {
   }
 
+  virtual ~Rule() {}
+
+public:
+  // for implementing nsISupports
+  NS_IMETHOD_(nsrefcnt) AddRef();
+  NS_IMETHOD_(nsrefcnt) Release();
+protected:
+  nsAutoRefCnt mRefCnt;
+  NS_DECL_OWNINGTHREAD
 public:
 
   virtual already_AddRefed<nsIStyleSheet> GetStyleSheet() const;
   virtual void SetStyleSheet(nsCSSStyleSheet* aSheet);
 
   virtual void SetParentRule(GroupRule* aRule);
 
 protected:
--- a/layout/style/StyleRule.cpp
+++ b/layout/style/StyleRule.cpp
@@ -1349,18 +1349,18 @@ NS_INTERFACE_MAP_BEGIN(StyleRule)
     return NS_OK;
   }
   else
   NS_INTERFACE_MAP_ENTRY(nsICSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule)
 NS_INTERFACE_MAP_END
 
-NS_IMPL_ADDREF(StyleRule)
-NS_IMPL_RELEASE(StyleRule)
+NS_IMPL_ADDREF_INHERITED(StyleRule, Rule)
+NS_IMPL_RELEASE_INHERITED(StyleRule, Rule)
 
 nsIStyleRule* StyleRule::GetImportantRule()
 {
   return mImportantRule;
 }
 
 void
 StyleRule::RuleMatched()
--- a/layout/style/StyleRule.h
+++ b/layout/style/StyleRule.h
@@ -303,17 +303,17 @@ private:
   // for |Clone|
   StyleRule(const StyleRule& aCopy);
   // for |DeclarationChanged|
   StyleRule(StyleRule& aCopy,
             Declaration *aDeclaration);
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_CSS_STYLE_RULE_IMPL_CID)
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_ISUPPORTS_INHERITED
 
   // null for style attribute
   nsCSSSelectorList* Selector() { return mSelector; }
 
   PRUint32 GetLineNumber() const { return mLineNumber; }
   void SetLineNumber(PRUint32 aLineNumber) { mLineNumber = aLineNumber; }
 
   Declaration* GetDeclaration() const { return mDeclaration; }
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -78,16 +78,19 @@ nsIDOMCSSRule* _class::GetDOMRuleWeak(ns
 /* virtual */ void _class::MapRuleInfoInto(nsRuleData* aRuleData) { }
 
 
 // base class for all rule types in a CSS style sheet
 
 namespace mozilla {
 namespace css {
 
+NS_IMPL_ADDREF(Rule)
+NS_IMPL_RELEASE(Rule)
+
 /* virtual */ already_AddRefed<nsIStyleSheet>
 Rule::GetStyleSheet() const
 {
   NS_IF_ADDREF(mSheet);
   return mSheet;
 }
 
 /* virtual */ void
@@ -216,17 +219,17 @@ class NS_FINAL_CLASS CSSCharsetRuleImpl 
                                           public nsIDOMCSSCharsetRule
 {
 public:
   CSSCharsetRuleImpl(const nsAString& aEncoding);
   CSSCharsetRuleImpl(const CSSCharsetRuleImpl& aCopy);
 private:
   ~CSSCharsetRuleImpl() {}
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_ISUPPORTS_INHERITED
 
   DECL_STYLE_RULE_INHERIT
 
   // nsIStyleRule methods
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
 #endif
 
@@ -252,18 +255,18 @@ CSSCharsetRuleImpl::CSSCharsetRuleImpl(c
 }
 
 CSSCharsetRuleImpl::CSSCharsetRuleImpl(const CSSCharsetRuleImpl& aCopy)
   : css::Rule(aCopy),
     mEncoding(aCopy.mEncoding)
 {
 }
 
-NS_IMPL_ADDREF(CSSCharsetRuleImpl)
-NS_IMPL_RELEASE(CSSCharsetRuleImpl)
+NS_IMPL_ADDREF_INHERITED(CSSCharsetRuleImpl, css::Rule)
+NS_IMPL_RELEASE_INHERITED(CSSCharsetRuleImpl, css::Rule)
 
 DOMCI_DATA(CSSCharsetRule, CSSCharsetRuleImpl)
 
 // QueryInterface implementation for CSSCharsetRuleImpl
 NS_INTERFACE_MAP_BEGIN(CSSCharsetRuleImpl)
   NS_INTERFACE_MAP_ENTRY(nsICSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
@@ -409,18 +412,18 @@ ImportRule::ImportRule(const ImportRule&
 
 ImportRule::~ImportRule()
 {
   if (mChildSheet) {
     mChildSheet->SetOwnerRule(nsnull);
   }
 }
 
-NS_IMPL_ADDREF(ImportRule)
-NS_IMPL_RELEASE(ImportRule)
+NS_IMPL_ADDREF_INHERITED(ImportRule, Rule)
+NS_IMPL_RELEASE_INHERITED(ImportRule, Rule)
 
 // QueryInterface implementation for ImportRule
 NS_INTERFACE_MAP_BEGIN(ImportRule)
   NS_INTERFACE_MAP_ENTRY(nsICSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSImportRule)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule)
@@ -630,19 +633,16 @@ GroupRule::GroupRule(const GroupRule& aC
 GroupRule::~GroupRule()
 {
   mRules.EnumerateForwards(SetParentRuleReference, nsnull);
   if (mRuleCollection) {
     mRuleCollection->DropReference();
   }
 }
 
-NS_IMPL_ADDREF(GroupRule)
-NS_IMPL_RELEASE(GroupRule)
-
 IMPL_STYLE_RULE_INHERIT2(GroupRule, Rule)
 
 static PRBool
 SetStyleSheetReference(nsICSSRule* aRule, void* aSheet)
 {
   nsCSSStyleSheet* sheet = (nsCSSStyleSheet*)aSheet;
   aRule->SetStyleSheet(sheet);
   return PR_TRUE;
@@ -831,18 +831,18 @@ MediaRule::MediaRule(const MediaRule& aC
 
 MediaRule::~MediaRule()
 {
   if (mMedia) {
     mMedia->SetStyleSheet(nsnull);
   }
 }
 
-NS_IMPL_ADDREF_INHERITED(MediaRule, GroupRule)
-NS_IMPL_RELEASE_INHERITED(MediaRule, GroupRule)
+NS_IMPL_ADDREF_INHERITED(MediaRule, Rule)
+NS_IMPL_RELEASE_INHERITED(MediaRule, Rule)
 
 // QueryInterface implementation for MediaRule
 NS_INTERFACE_MAP_BEGIN(MediaRule)
   NS_INTERFACE_MAP_ENTRY(nsICSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSMediaRule)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule)
@@ -1001,18 +1001,18 @@ DocumentRule::DocumentRule(const Documen
   , mURLs(new URL(*aCopy.mURLs))
 {
 }
 
 DocumentRule::~DocumentRule()
 {
 }
 
-NS_IMPL_ADDREF_INHERITED(DocumentRule, GroupRule)
-NS_IMPL_RELEASE_INHERITED(DocumentRule, GroupRule)
+NS_IMPL_ADDREF_INHERITED(DocumentRule, Rule)
+NS_IMPL_RELEASE_INHERITED(DocumentRule, Rule)
 
 // QueryInterface implementation for DocumentRule
 NS_INTERFACE_MAP_BEGIN(DocumentRule)
   NS_INTERFACE_MAP_ENTRY(nsICSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSMozDocumentRule)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule)
@@ -1207,18 +1207,18 @@ NameSpaceRule::NameSpaceRule(const NameS
     mURLSpec(aCopy.mURLSpec)
 {
 }
 
 NameSpaceRule::~NameSpaceRule()
 {
 }
 
-NS_IMPL_ADDREF(NameSpaceRule)
-NS_IMPL_RELEASE(NameSpaceRule)
+NS_IMPL_ADDREF_INHERITED(NameSpaceRule, Rule)
+NS_IMPL_RELEASE_INHERITED(NameSpaceRule, Rule)
 
 // QueryInterface implementation for NameSpaceRule
 NS_INTERFACE_MAP_BEGIN(NameSpaceRule)
   if (aIID.Equals(NS_GET_IID(css::NameSpaceRule))) {
     *aInstancePtr = this;
     NS_ADDREF_THIS();
     return NS_OK;
   }
@@ -1672,18 +1672,18 @@ nsCSSFontFaceStyleDecl::GetParentRule(ns
 
 /* virtual */ already_AddRefed<nsICSSRule>
 nsCSSFontFaceRule::Clone() const
 {
   nsCOMPtr<nsICSSRule> clone = new nsCSSFontFaceRule(*this);
   return clone.forget();
 }
 
-NS_IMPL_ADDREF(nsCSSFontFaceRule)
-NS_IMPL_RELEASE(nsCSSFontFaceRule)
+NS_IMPL_ADDREF_INHERITED(nsCSSFontFaceRule, css::Rule)
+NS_IMPL_RELEASE_INHERITED(nsCSSFontFaceRule, css::Rule)
 
 DOMCI_DATA(CSSFontFaceRule, nsCSSFontFaceRule)
 
 // QueryInterface implementation for nsCSSFontFaceRule
 NS_INTERFACE_MAP_BEGIN(nsCSSFontFaceRule)
   NS_INTERFACE_MAP_ENTRY(nsICSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSFontFaceRule)
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -206,17 +206,17 @@ class NS_FINAL_CLASS nsCSSFontFaceRule :
 {
 public:
   nsCSSFontFaceRule() {}
 
   nsCSSFontFaceRule(const nsCSSFontFaceRule& aCopy)
     // copy everything except our reference count
     : mozilla::css::Rule(aCopy), mDecl(aCopy.mDecl) {}
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_ISUPPORTS_INHERITED
 
   // nsIStyleRule methods
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
 #endif
 
   // nsICSSRule methods
   DECL_STYLE_RULE_INHERIT