Bug 577976 - Part 3: Rename nsCSSRule and put in css namespace, r=bzbarsky
authorCraig Topper <craig.topper@gmail.com>
Sun, 06 Mar 2011 19:59:03 -0800
changeset 64682 7e119e22b856b359b201601934bd194194d8cd98
parent 64681 f2685fc02b6bea19c3406875f6dd5d7b2fcf078a
child 64683 5d537abf700580e70406c631d461ab60bb956e09
push idunknown
push userunknown
push dateunknown
reviewersbzbarsky
bugs577976
milestone2.2a1pre
Bug 577976 - Part 3: Rename nsCSSRule and put in css namespace, 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/nsCSSRule.h
layout/style/nsCSSRules.cpp
layout/style/nsCSSRules.h
--- a/layout/style/GroupRule.h
+++ b/layout/style/GroupRule.h
@@ -38,31 +38,31 @@
 /*
  * internal interface representing CSS style rules that contain other
  * rules, such as @media rules
  */
 
 #ifndef mozilla_css_GroupRule_h__
 #define mozilla_css_GroupRule_h__
 
-#include "nsCSSRule.h"
+#include "Rule.h"
 #include "nsCOMArray.h"
 #include "nsAutoPtr.h"
 
 class nsPresContext;
 class nsMediaQueryResultCacheKey;
 
 namespace mozilla {
 namespace css {
 
 class GroupRuleRuleList;
 
-// inherits from nsCSSRule so it can be shared between
+// inherits from Rule so it can be shared between
 // MediaRule and DocumentRule
-class GroupRule : public nsCSSRule
+class GroupRule : public Rule
 {
 protected:
   GroupRule();
   GroupRule(const GroupRule& aCopy);
   virtual ~GroupRule();
 
 protected:
   nsAutoRefCnt mRefCnt;
--- a/layout/style/ImportRule.h
+++ b/layout/style/ImportRule.h
@@ -35,42 +35,42 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* class for CSS @import rules */
 
 #ifndef mozilla_css_ImportRule_h__
 #define mozilla_css_ImportRule_h__
 
-#include "nsCSSRule.h"
+#include "Rule.h"
 #include "nsIDOMCSSImportRule.h"
 #include "nsCSSRules.h"
 
 class nsMediaList;
 class nsString;
 
 namespace mozilla {
 namespace css {
 
-class NS_FINAL_CLASS ImportRule : public nsCSSRule,
+class NS_FINAL_CLASS ImportRule : public Rule,
                                   public nsIDOMCSSImportRule
 {
 public:
   ImportRule(nsMediaList* aMedia);
 private:
   // for |Clone|
   ImportRule(const ImportRule& aCopy);
   ~ImportRule();
 public:
   NS_DECL_ISUPPORTS
 
   DECL_STYLE_RULE_INHERIT
 
 #ifdef HAVE_CPP_AMBIGUITY_RESOLVING_USING
-  using nsCSSRule::GetStyleSheet; // unhide since nsIDOMCSSImportRule has its own GetStyleSheet
+  using Rule::GetStyleSheet; // unhide since nsIDOMCSSImportRule has its own GetStyleSheet
 #endif
 
   // nsIStyleRule methods
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
 #endif
 
   // nsICSSRule methods
--- a/layout/style/NameSpaceRule.h
+++ b/layout/style/NameSpaceRule.h
@@ -35,30 +35,30 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* class for CSS @namespace rules */
 
 #ifndef mozilla_css_NameSpaceRule_h__
 #define mozilla_css_NameSpaceRule_h__
 
-#include "nsCSSRule.h"
+#include "Rule.h"
 #include "nsIDOMCSSRule.h"
 
 class nsIAtom;
 
 // IID for the nsCSSNameSpaceRule class {f0b0dbe1-5031-4a21-b06a-dc141ef2af98}
 #define NS_CSS_NAMESPACE_RULE_IMPL_CID     \
 {0xf0b0dbe1, 0x5031, 0x4a21, {0xb0, 0x6a, 0xdc, 0x14, 0x1e, 0xf2, 0xaf, 0x98}}
 
 
 namespace mozilla {
 namespace css {
 
-class NS_FINAL_CLASS NameSpaceRule : public nsCSSRule,
+class NS_FINAL_CLASS NameSpaceRule : public Rule,
                                      public nsIDOMCSSRule
 {
 public:
   NameSpaceRule();
 private:
   // for |Clone|
   NameSpaceRule(const NameSpaceRule& aCopy);
   ~NameSpaceRule();
rename from layout/style/nsCSSRule.h
rename to layout/style/Rule.h
--- a/layout/style/nsCSSRule.h
+++ b/layout/style/Rule.h
@@ -32,58 +32,59 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* base class for all rule types in a CSS style sheet */
 
-#ifndef nsCSSRule_h___
-#define nsCSSRule_h___
+#ifndef mozilla_css_Rule_h___
+#define mozilla_css_Rule_h___
 
 #include "nsICSSRule.h"
 
 class nsIStyleSheet;
 class nsCSSStyleSheet;
 struct nsRuleData;
 template<class T> struct already_AddRefed;
 
 namespace mozilla {
 namespace css {
 class GroupRule;
-}
-}
 
 #define DECL_STYLE_RULE_INHERIT_NO_DOMRULE  \
 virtual void MapRuleInfoInto(nsRuleData* aRuleData);
 
 #define DECL_STYLE_RULE_INHERIT  \
 DECL_STYLE_RULE_INHERIT_NO_DOMRULE \
 virtual nsIDOMCSSRule* GetDOMRuleWeak(nsresult* aResult);
 
-class nsCSSRule : public nsICSSRule {
+class Rule : public nsICSSRule {
 protected:
-  nsCSSRule()
+  Rule()
     : mSheet(nsnull),
       mParentRule(nsnull)
   {
   }
 
-  nsCSSRule(const nsCSSRule& aCopy)
+  Rule(const Rule& aCopy)
     : mSheet(aCopy.mSheet),
       mParentRule(aCopy.mParentRule)
   {
   }
 
 public:
 
   virtual already_AddRefed<nsIStyleSheet> GetStyleSheet() const;
   virtual void SetStyleSheet(nsCSSStyleSheet* aSheet);
 
-  virtual void SetParentRule(mozilla::css::GroupRule* aRule);
+  virtual void SetParentRule(GroupRule* aRule);
 
 protected:
-  nsCSSStyleSheet*         mSheet;
-  mozilla::css::GroupRule* mParentRule;
+  nsCSSStyleSheet*  mSheet;
+  GroupRule*        mParentRule;
 };
 
-#endif /* nsCSSRule_h___ */
+} // namespace css
+} // namespace mozilla
+
+#endif /* mozilla_css_Rule_h___ */
--- a/layout/style/StyleRule.cpp
+++ b/layout/style/StyleRule.cpp
@@ -1274,43 +1274,43 @@ DOMCSSStyleRule::GetCSSStyleRule(StyleRu
 
 // -- StyleRule ------------------------------------
 
 namespace mozilla {
 namespace css {
 
 StyleRule::StyleRule(nsCSSSelectorList* aSelector,
                      Declaration* aDeclaration)
-  : nsCSSRule(),
+  : Rule(),
     mSelector(aSelector),
     mDeclaration(aDeclaration),
     mImportantRule(nsnull),
     mDOMRule(nsnull),
     mLineNumber(0),
     mWasMatched(PR_FALSE)
 {
 }
 
 // for |Clone|
 StyleRule::StyleRule(const StyleRule& aCopy)
-  : nsCSSRule(aCopy),
+  : Rule(aCopy),
     mSelector(aCopy.mSelector ? aCopy.mSelector->Clone() : nsnull),
     mDeclaration(new Declaration(*aCopy.mDeclaration)),
     mImportantRule(nsnull),
     mDOMRule(nsnull),
     mLineNumber(aCopy.mLineNumber),
     mWasMatched(PR_FALSE)
 {
   // rest is constructed lazily on existing data
 }
 
 // for |SetCSSDeclaration|
 StyleRule::StyleRule(StyleRule& aCopy,
                      Declaration* aDeclaration)
-  : nsCSSRule(aCopy),
+  : Rule(aCopy),
     mSelector(aCopy.mSelector),
     mDeclaration(aDeclaration),
     mImportantRule(nsnull),
     mDOMRule(aCopy.mDOMRule),
     mLineNumber(aCopy.mLineNumber),
     mWasMatched(PR_FALSE)
 {
   // The DOM rule is replacing |aCopy| with |this|, so transfer
--- a/layout/style/StyleRule.h
+++ b/layout/style/StyleRule.h
@@ -41,17 +41,17 @@
  * representation of CSS style rules (selectors+declaration) and CSS
  * selectors
  */
 
 #ifndef mozilla_css_StyleRule_h__
 #define mozilla_css_StyleRule_h__
 
 //#include <stdio.h>
-#include "nsCSSRule.h"
+#include "Rule.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsCSSPseudoElements.h"
 #include "nsCSSPseudoClasses.h"
 #include "nsAutoPtr.h"
 
 class nsIAtom;
 class nsCSSStyleSheet;
@@ -289,17 +289,17 @@ private:
 
 namespace mozilla {
 namespace css {
 
 class Declaration;
 class ImportantRule;
 class DOMCSSStyleRule;
 
-class NS_FINAL_CLASS StyleRule : public nsCSSRule
+class NS_FINAL_CLASS StyleRule : public Rule
 {
  public:
   StyleRule(nsCSSSelectorList* aSelector,
             Declaration *aDeclaration);
 private:
   // for |Clone|
   StyleRule(const StyleRule& aCopy);
   // for |DeclarationChanged|
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -75,41 +75,47 @@ nsIDOMCSSRule* _class::GetDOMRuleWeak(ns
 /* virtual */ void _class::MapRuleInfoInto(nsRuleData* aRuleData) { }
 
 #define IMPL_STYLE_RULE_INHERIT2(_class, super) \
 /* virtual */ void _class::MapRuleInfoInto(nsRuleData* aRuleData) { }
 
 
 // base class for all rule types in a CSS style sheet
 
+namespace mozilla {
+namespace css {
+
 /* virtual */ already_AddRefed<nsIStyleSheet>
-nsCSSRule::GetStyleSheet() const
+Rule::GetStyleSheet() const
 {
   NS_IF_ADDREF(mSheet);
   return mSheet;
 }
 
 /* virtual */ void
-nsCSSRule::SetStyleSheet(nsCSSStyleSheet* aSheet)
+Rule::SetStyleSheet(nsCSSStyleSheet* aSheet)
 {
   // We don't reference count this up reference. The style sheet
   // will tell us when it's going away or when we're detached from
   // it.
   mSheet = aSheet;
 }
 
 /* virtual */ void
-nsCSSRule::SetParentRule(css::GroupRule* aRule)
+Rule::SetParentRule(css::GroupRule* aRule)
 {
   // We don't reference count this up reference. The group rule
   // will tell us when it's going away or when we're detached from
   // it.
   mParentRule = aRule;
 }
 
+} // namespace css
+} // namespace mozilla
+
 
 // -------------------------------
 // Style Rule List for group rules
 //
 
 namespace mozilla {
 namespace css {
 
@@ -201,17 +207,17 @@ GroupRuleRuleList::Item(PRUint32 aIndex,
 } // namespace mozilla
 
 // Must be outside the namespace
 DOMCI_DATA(CSSGroupRuleRuleList, css::GroupRuleRuleList)
 
 // -------------------------------------------
 // CharsetRule
 //
-class NS_FINAL_CLASS CSSCharsetRuleImpl : public nsCSSRule,
+class NS_FINAL_CLASS CSSCharsetRuleImpl : public css::Rule,
                                           public nsIDOMCSSCharsetRule
 {
 public:
   CSSCharsetRuleImpl(const nsAString& aEncoding);
   CSSCharsetRuleImpl(const CSSCharsetRuleImpl& aCopy);
 private:
   ~CSSCharsetRuleImpl() {}
 public:
@@ -235,23 +241,23 @@ public:
   NS_IMETHOD GetEncoding(nsAString& aEncoding);
   NS_IMETHOD SetEncoding(const nsAString& aEncoding);
 
 protected:
   nsString  mEncoding;
 };
 
 CSSCharsetRuleImpl::CSSCharsetRuleImpl(const nsAString& aEncoding)
-  : nsCSSRule(),
+  : css::Rule(),
     mEncoding(aEncoding)
 {
 }
 
 CSSCharsetRuleImpl::CSSCharsetRuleImpl(const CSSCharsetRuleImpl& aCopy)
-  : nsCSSRule(aCopy),
+  : css::Rule(aCopy),
     mEncoding(aCopy.mEncoding)
 {
 }
 
 NS_IMPL_ADDREF(CSSCharsetRuleImpl)
 NS_IMPL_RELEASE(CSSCharsetRuleImpl)
 
 DOMCI_DATA(CSSCharsetRule, CSSCharsetRuleImpl)
@@ -261,17 +267,17 @@ NS_INTERFACE_MAP_BEGIN(CSSCharsetRuleImp
   NS_INTERFACE_MAP_ENTRY(nsICSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSCharsetRule)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSCharsetRule)
 NS_INTERFACE_MAP_END
 
-IMPL_STYLE_RULE_INHERIT(CSSCharsetRuleImpl, nsCSSRule)
+IMPL_STYLE_RULE_INHERIT(CSSCharsetRuleImpl, css::Rule)
 
 #ifdef DEBUG
 /* virtual */ void
 CSSCharsetRuleImpl::List(FILE* out, PRInt32 aIndent) const
 {
   // Indent
   for (PRInt32 indent = aIndent; --indent >= 0; ) fputs("  ", out);
 
@@ -372,27 +378,27 @@ CSSCharsetRuleImpl::GetParentRule(nsIDOM
 // -------------------------------------------
 // ImportRule
 //
 
 namespace mozilla {
 namespace css {
 
 ImportRule::ImportRule(nsMediaList* aMedia)
-  : nsCSSRule()
+  : Rule()
   , mURLSpec()
   , mMedia(aMedia)
 {
   // XXXbz This is really silly.... the mMedia here will be replaced
   // with itself if we manage to load a sheet.  Which should really
   // never fail nowadays, in sane cases.
 }
 
 ImportRule::ImportRule(const ImportRule& aCopy)
-  : nsCSSRule(aCopy),
+  : Rule(aCopy),
     mURLSpec(aCopy.mURLSpec)
 {
   // Whether or not an @import rule has a null sheet is a permanent
   // property of that @import rule, since it is null only if the target
   // sheet failed security checks.
   if (aCopy.mChildSheet) {
     nsRefPtr<nsCSSStyleSheet> sheet =
       aCopy.mChildSheet->Clone(nsnull, this, nsnull, nsnull);
@@ -416,17 +422,17 @@ 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)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSImportRule)
 NS_INTERFACE_MAP_END
 
-IMPL_STYLE_RULE_INHERIT(ImportRule, nsCSSRule)
+IMPL_STYLE_RULE_INHERIT(ImportRule, Rule)
 
 #ifdef DEBUG
 /* virtual */ void
 ImportRule::List(FILE* out, PRInt32 aIndent) const
 {
   // Indent
   for (PRInt32 indent = aIndent; --indent >= 0; ) fputs("  ", out);
 
@@ -597,61 +603,61 @@ CloneRuleInto(nsICSSRule* aRule, void* a
   static_cast<nsCOMArray<nsICSSRule>*>(aArray)->AppendObject(clone);
   return PR_TRUE;
 }
 
 namespace mozilla {
 namespace css {
 
 GroupRule::GroupRule()
-  : nsCSSRule()
+  : Rule()
 {
 }
 
 static PRBool
 SetParentRuleReference(nsICSSRule* aRule, void* aParentRule)
 {
   GroupRule* parentRule = static_cast<GroupRule*>(aParentRule);
   aRule->SetParentRule(parentRule);
   return PR_TRUE;
 }
 
 GroupRule::GroupRule(const GroupRule& aCopy)
-  : nsCSSRule(aCopy)
+  : Rule(aCopy)
 {
   const_cast<GroupRule&>(aCopy).mRules.EnumerateForwards(CloneRuleInto, &mRules);
   mRules.EnumerateForwards(SetParentRuleReference, this);
 }
 
 GroupRule::~GroupRule()
 {
   mRules.EnumerateForwards(SetParentRuleReference, nsnull);
   if (mRuleCollection) {
     mRuleCollection->DropReference();
   }
 }
 
 NS_IMPL_ADDREF(GroupRule)
 NS_IMPL_RELEASE(GroupRule)
 
-IMPL_STYLE_RULE_INHERIT2(GroupRule, nsCSSRule)
+IMPL_STYLE_RULE_INHERIT2(GroupRule, Rule)
 
 static PRBool
 SetStyleSheetReference(nsICSSRule* aRule, void* aSheet)
 {
   nsCSSStyleSheet* sheet = (nsCSSStyleSheet*)aSheet;
   aRule->SetStyleSheet(sheet);
   return PR_TRUE;
 }
 
 /* virtual */ void
 GroupRule::SetStyleSheet(nsCSSStyleSheet* aSheet)
 {
   mRules.EnumerateForwards(SetStyleSheetReference, aSheet);
-  nsCSSRule::SetStyleSheet(aSheet);
+  Rule::SetStyleSheet(aSheet);
 }
 
 #ifdef DEBUG
 /* virtual */ void
 GroupRule::List(FILE* out, PRInt32 aIndent) const
 {
   fputs(" {\n", out);
 
@@ -1184,24 +1190,24 @@ DOMCI_DATA(CSSMozDocumentRule, css::Docu
 // -------------------------------------------
 // NameSpaceRule
 //
 
 namespace mozilla {
 namespace css {
 
 NameSpaceRule::NameSpaceRule()
-  : nsCSSRule(),
+  : Rule(),
     mPrefix(nsnull),
     mURLSpec()
 {
 }
 
 NameSpaceRule::NameSpaceRule(const NameSpaceRule& aCopy)
-  : nsCSSRule(aCopy),
+  : Rule(aCopy),
     mPrefix(aCopy.mPrefix),
     mURLSpec(aCopy.mURLSpec)
 {
 }
 
 NameSpaceRule::~NameSpaceRule()
 {
 }
@@ -1219,17 +1225,17 @@ NS_INTERFACE_MAP_BEGIN(NameSpaceRule)
   else
   NS_INTERFACE_MAP_ENTRY(nsICSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSNameSpaceRule)
 NS_INTERFACE_MAP_END
 
-IMPL_STYLE_RULE_INHERIT(NameSpaceRule, nsCSSRule)
+IMPL_STYLE_RULE_INHERIT(NameSpaceRule, Rule)
 
 #ifdef DEBUG
 /* virtual */ void
 NameSpaceRule::List(FILE* out, PRInt32 aIndent) const
 {
   for (PRInt32 indent = aIndent; --indent >= 0; ) fputs("  ", out);
 
   nsAutoString  buffer;
@@ -1681,17 +1687,17 @@ NS_INTERFACE_MAP_BEGIN(nsCSSFontFaceRule
   NS_INTERFACE_MAP_ENTRY(nsICSSRule)
   NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSFontFaceRule)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSRule)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSFontFaceRule)
 NS_INTERFACE_MAP_END
 
-IMPL_STYLE_RULE_INHERIT(nsCSSFontFaceRule, nsCSSRule)
+IMPL_STYLE_RULE_INHERIT(nsCSSFontFaceRule, Rule)
 
 #ifdef DEBUG
 void
 nsCSSFontFaceRule::List(FILE* out, PRInt32 aIndent) const
 {
   nsCString baseInd, descInd;
   for (PRInt32 indent = aIndent; --indent >= 0; ) {
     baseInd.AppendLiteral("  ");
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -38,17 +38,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* rules in a CSS stylesheet other than style rules (e.g., @import rules) */
 
 #ifndef nsCSSRules_h_
 #define nsCSSRules_h_
 
-#include "nsCSSRule.h"
+#include "Rule.h"
 #include "mozilla/css/GroupRule.h"
 #include "nsIDOMCSSMediaRule.h"
 #include "nsIDOMCSSMozDocumentRule.h"
 #include "nsIDOMCSSFontFaceRule.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsAutoPtr.h"
 #include "nsCSSProperty.h"
 #include "nsCSSValue.h"
@@ -196,25 +196,25 @@ protected:
 
 private:
   // NOT TO BE IMPLEMENTED
   // This object cannot be allocated on its own, only as part of
   // nsCSSFontFaceRule.
   void* operator new(size_t size) CPP_THROW_NEW;
 };
 
-class NS_FINAL_CLASS nsCSSFontFaceRule : public nsCSSRule,
+class NS_FINAL_CLASS nsCSSFontFaceRule : public mozilla::css::Rule,
                                          public nsIDOMCSSFontFaceRule
 {
 public:
   nsCSSFontFaceRule() {}
 
   nsCSSFontFaceRule(const nsCSSFontFaceRule& aCopy)
     // copy everything except our reference count
-    : nsCSSRule(aCopy), mDecl(aCopy.mDecl) {}
+    : mozilla::css::Rule(aCopy), mDecl(aCopy.mDecl) {}
 
   NS_DECL_ISUPPORTS
 
   // nsIStyleRule methods
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
 #endif