Bug 577974 - Part 1: Rename CSSGroupRuleListImpl. r=bzbarsky
authorCraig Topper <craig.topper@gmail.com>
Sat, 07 Aug 2010 22:23:17 -0700
changeset 64676 45d658bb4be18c836dc93fa6ff532731f3a55530
parent 64675 a8a0a7b518925d3256723cf17907124e0311ae07
child 64677 f100d70f483a75430129d12a2b46b171687978a2
push idunknown
push userunknown
push dateunknown
reviewersbzbarsky
bugs577974
milestone2.2a1pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 577974 - Part 1: Rename CSSGroupRuleListImpl. r=bzbarsky
layout/style/nsCSSRules.cpp
layout/style/nsCSSRules.h
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -80,77 +80,79 @@ nsIDOMCSSRule* _class::GetDOMRuleWeak(ns
 #define IMPL_STYLE_RULE_INHERIT2(_class, super) \
 /* virtual */ already_AddRefed<nsIStyleSheet> _class::GetStyleSheet() const { return super::GetStyleSheet(); }  \
 /* virtual */ void  _class::SetParentRule(nsICSSGroupRule* aRule) { super::SetParentRule(aRule); }  \
 /* virtual */ void _class::MapRuleInfoInto(nsRuleData* aRuleData) { }
 
 // -------------------------------
 // Style Rule List for group rules
 //
-class CSSGroupRuleRuleListImpl : public nsICSSRuleList
+
+namespace mozilla {
+namespace css {
+
+class NS_FINAL_CLASS GroupRuleRuleList : public nsICSSRuleList
 {
 public:
-  CSSGroupRuleRuleListImpl(nsICSSGroupRule *aGroupRule);
+  GroupRuleRuleList(nsICSSGroupRule *aGroupRule);
 
   NS_DECL_ISUPPORTS
 
   NS_DECL_NSIDOMCSSRULELIST
 
   virtual nsIDOMCSSRule* GetItemAt(PRUint32 aIndex, nsresult* aResult);
 
   void DropReference() { mGroupRule = nsnull; }
 
-protected:
-  virtual ~CSSGroupRuleRuleListImpl(void);
+private:
+  ~GroupRuleRuleList();
 
 private:
   nsICSSGroupRule* mGroupRule;
 };
 
-CSSGroupRuleRuleListImpl::CSSGroupRuleRuleListImpl(nsICSSGroupRule *aGroupRule)
+GroupRuleRuleList::GroupRuleRuleList(nsICSSGroupRule *aGroupRule)
 {
   // Not reference counted to avoid circular references.
   // The rule will tell us when its going away.
   mGroupRule = aGroupRule;
 }
 
-CSSGroupRuleRuleListImpl::~CSSGroupRuleRuleListImpl()
+GroupRuleRuleList::~GroupRuleRuleList()
 {
 }
 
-DOMCI_DATA(CSSGroupRuleRuleList, CSSGroupRuleRuleListImpl)
-
 // QueryInterface implementation for CSSGroupRuleRuleList
-NS_INTERFACE_MAP_BEGIN(CSSGroupRuleRuleListImpl)
+NS_INTERFACE_MAP_BEGIN(GroupRuleRuleList)
   NS_INTERFACE_MAP_ENTRY(nsICSSRuleList)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRuleList)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSGroupRuleRuleList)
 NS_INTERFACE_MAP_END
 
 
-NS_IMPL_ADDREF(CSSGroupRuleRuleListImpl)
-NS_IMPL_RELEASE(CSSGroupRuleRuleListImpl)
+NS_IMPL_ADDREF(GroupRuleRuleList)
+NS_IMPL_RELEASE(GroupRuleRuleList)
 
-NS_IMETHODIMP    
-CSSGroupRuleRuleListImpl::GetLength(PRUint32* aLength)
+NS_IMETHODIMP
+GroupRuleRuleList::GetLength(PRUint32* aLength)
 {
   if (mGroupRule) {
     PRInt32 count;
     mGroupRule->StyleRuleCount(count);
     *aLength = (PRUint32)count;
   } else {
     *aLength = 0;
   }
 
   return NS_OK;
 }
 
-nsIDOMCSSRule*    
-CSSGroupRuleRuleListImpl::GetItemAt(PRUint32 aIndex, nsresult* aResult)
+nsIDOMCSSRule*
+GroupRuleRuleList::GetItemAt(PRUint32 aIndex, nsresult* aResult)
 {
   nsresult result = NS_OK;
 
   if (mGroupRule) {
     nsCOMPtr<nsICSSRule> rule;
 
     result = mGroupRule->GetStyleRuleAt(aIndex, *getter_AddRefs(rule));
     if (rule) {
@@ -161,30 +163,36 @@ CSSGroupRuleRuleListImpl::GetItemAt(PRUi
     }
   }
 
   *aResult = result;
 
   return nsnull;
 }
 
-NS_IMETHODIMP    
-CSSGroupRuleRuleListImpl::Item(PRUint32 aIndex, nsIDOMCSSRule** aReturn)
+NS_IMETHODIMP
+GroupRuleRuleList::Item(PRUint32 aIndex, nsIDOMCSSRule** aReturn)
 {
   nsresult rv;
   nsIDOMCSSRule* rule = GetItemAt(aIndex, &rv);
   if (!rule) {
     *aReturn = nsnull;
     return rv;
   }
 
   NS_ADDREF(*aReturn = rule);
   return NS_OK;
 }
 
+} // namespace css
+} // namespace mozilla
+
+// Must be outside the namespace
+DOMCI_DATA(CSSGroupRuleRuleList, css::GroupRuleRuleList)
+
 // -------------------------------------------
 // CharsetRule
 //
 class NS_FINAL_CLASS CSSCharsetRuleImpl : public nsCSSRule,
                                           public nsICSSRule,
                                           public nsIDOMCSSCharsetRule
 {
 public:
@@ -565,17 +573,16 @@ NS_NewCSSImportRule(css::ImportRule** aI
 
   it->SetURLSpec(aURLSpec);
   NS_ADDREF(*aInstancePtrResult = it);
   return NS_OK;
 }
 
 nsCSSGroupRule::nsCSSGroupRule()
   : nsCSSRule()
-  , mRuleCollection(nsnull)
 {
 }
 
 static PRBool
 CloneRuleInto(nsICSSRule* aRule, void* aArray)
 {
   nsCOMPtr<nsICSSRule> clone = aRule->Clone();
   static_cast<nsCOMArray<nsICSSRule>*>(aArray)->AppendObject(clone);
@@ -587,28 +594,26 @@ SetParentRuleReference(nsICSSRule* aRule
 {
   nsCSSGroupRule* parentRule = static_cast<nsCSSGroupRule*>(aParentRule);
   aRule->SetParentRule(parentRule);
   return PR_TRUE;
 }
 
 nsCSSGroupRule::nsCSSGroupRule(const nsCSSGroupRule& aCopy)
   : nsCSSRule(aCopy)
-  , mRuleCollection(nsnull) // lazily constructed
 {
   const_cast<nsCSSGroupRule&>(aCopy).mRules.EnumerateForwards(CloneRuleInto, &mRules);
   mRules.EnumerateForwards(SetParentRuleReference, this);
 }
 
 nsCSSGroupRule::~nsCSSGroupRule()
 {
   mRules.EnumerateForwards(SetParentRuleReference, nsnull);
   if (mRuleCollection) {
     mRuleCollection->DropReference();
-    NS_RELEASE(mRuleCollection);
   }
 }
 
 NS_IMPL_ADDREF(nsCSSGroupRule)
 NS_IMPL_RELEASE(nsCSSGroupRule)
 
 IMPL_STYLE_RULE_INHERIT2(nsCSSGroupRule, nsCSSRule)
 
@@ -763,21 +768,17 @@ nsCSSGroupRule::GetParentRule(nsIDOMCSSR
   return NS_OK;
 }
 
 // nsIDOMCSSMediaRule or nsIDOMCSSMozDocumentRule methods
 nsresult
 nsCSSGroupRule::GetCssRules(nsIDOMCSSRuleList* *aRuleList)
 {
   if (!mRuleCollection) {
-    mRuleCollection = new CSSGroupRuleRuleListImpl(this);
-    if (!mRuleCollection) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-    NS_ADDREF(mRuleCollection);
+    mRuleCollection = new css::GroupRuleRuleList(this);
   }
 
   NS_ADDREF(*aRuleList = mRuleCollection);
   return NS_OK;
 }
 
 nsresult
 nsCSSGroupRule::InsertRule(const nsAString & aRule, PRUint32 aIndex, PRUint32* _retval)
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -48,20 +48,25 @@
 #include "nsIDOMCSSMediaRule.h"
 #include "nsIDOMCSSMozDocumentRule.h"
 #include "nsIDOMCSSFontFaceRule.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsAutoPtr.h"
 #include "nsCSSProperty.h"
 #include "nsCSSValue.h"
 
-class CSSGroupRuleRuleListImpl;
 class nsMediaList;
 template<class T> struct already_AddRefed;
 
+namespace mozilla {
+namespace css {
+class GroupRuleRuleList;
+}
+}
+
 #define DECL_STYLE_RULE_INHERIT_NO_DOMRULE  \
 virtual already_AddRefed<nsIStyleSheet> GetStyleSheet() const; \
 virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); \
 virtual void SetParentRule(nsICSSGroupRule* aRule); \
 virtual void MapRuleInfoInto(nsRuleData* aRuleData);
 
 #define DECL_STYLE_RULE_INHERIT  \
 DECL_STYLE_RULE_INHERIT_NO_DOMRULE \
@@ -113,17 +118,17 @@ protected:
   // to implement common methods on nsIDOMCSSMediaRule and
   // nsIDOMCSSMozDocumentRule
   nsresult GetCssRules(nsIDOMCSSRuleList* *aRuleList);
   nsresult InsertRule(const nsAString & aRule, PRUint32 aIndex,
                       PRUint32* _retval);
   nsresult DeleteRule(PRUint32 aIndex);
 
   nsCOMArray<nsICSSRule> mRules;
-  CSSGroupRuleRuleListImpl* mRuleCollection;
+  nsRefPtr<mozilla::css::GroupRuleRuleList> mRuleCollection; // lazily constructed
 };
 
 class NS_FINAL_CLASS nsCSSMediaRule : public nsCSSGroupRule,
                                       public nsIDOMCSSMediaRule
 {
 public:
   nsCSSMediaRule();
   nsCSSMediaRule(const nsCSSMediaRule& aCopy);