Bug 576877 Part 3: De-virtualize methods in NameSpaceRule. r=bzbarsky
authorCraig Topper <craig.topper@gmail.com>
Thu, 17 Mar 2011 13:41:52 -0400
changeset 63732 298776804644de03f6e667f9ef6b9e6f7c040d72
parent 63731 d7ccd31d9c84753c3a811e03bd5214e6c9f122b7
child 63733 ecf6c47436b6f7ab93a0bac434bf9500cd333493
push idunknown
push userunknown
push dateunknown
reviewersbzbarsky
bugs576877
milestone2.0b13pre
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 576877 Part 3: De-virtualize methods in NameSpaceRule. r=bzbarsky
layout/style/NameSpaceRule.h
layout/style/nsCSSRules.cpp
layout/style/nsCSSStyleSheet.cpp
--- a/layout/style/NameSpaceRule.h
+++ b/layout/style/NameSpaceRule.h
@@ -75,27 +75,27 @@ public:
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
 #endif
 
   // nsICSSRule methods
   virtual PRInt32 GetType() const;
   virtual already_AddRefed<nsICSSRule> Clone() const;
 
-  NS_IMETHOD  GetPrefix(nsIAtom*& aPrefix) const;
-  NS_IMETHOD  SetPrefix(nsIAtom* aPrefix);
+  nsIAtom* GetPrefix() const { return mPrefix; }
+  void SetPrefix(nsIAtom* aPrefix) { mPrefix = aPrefix; }
 
-  NS_IMETHOD  GetURLSpec(nsString& aURLSpec) const;
-  NS_IMETHOD  SetURLSpec(const nsString& aURLSpec);
+  void GetURLSpec(nsString& aURLSpec) const { aURLSpec = mURLSpec; }
+  void SetURLSpec(const nsString& aURLSpec) { mURLSpec = aURLSpec; }
 
   // nsIDOMCSSRule interface
   NS_DECL_NSIDOMCSSRULE
 
 private:
-  nsIAtom*          mPrefix;
+  nsCOMPtr<nsIAtom> mPrefix;
   nsString          mURLSpec;
 };
 
 } // namespace css
 } // namespace mozilla
 
 NS_DEFINE_STATIC_IID_ACCESSOR(mozilla::css::NameSpaceRule, NS_CSS_NAMESPACE_RULE_IMPL_CID)
 
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -53,19 +53,17 @@
 #include "nsCOMPtr.h"
 #include "nsIDOMCSSStyleSheet.h"
 #include "nsIDOMCSSImportRule.h"
 #include "nsIDOMCSSMediaRule.h"
 #include "nsIDOMCSSMozDocumentRule.h"
 #include "nsIDOMCSSCharsetRule.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsIMediaList.h"
-#include "nsIDOMMediaList.h"
 #include "nsICSSRuleList.h"
-#include "nsIDOMStyleSheet.h"
 #include "nsIDocument.h"
 #include "nsPresContext.h"
 
 #include "nsContentUtils.h"
 #include "nsStyleConsts.h"
 #include "nsDOMError.h"
 #include "nsStyleUtil.h"
 #include "mozilla/css/Declaration.h"
@@ -1242,22 +1240,20 @@ NameSpaceRule::NameSpaceRule()
 {
 }
 
 NameSpaceRule::NameSpaceRule(const NameSpaceRule& aCopy)
   : nsCSSRule(aCopy),
     mPrefix(aCopy.mPrefix),
     mURLSpec(aCopy.mURLSpec)
 {
-  NS_IF_ADDREF(mPrefix);
 }
 
 NameSpaceRule::~NameSpaceRule()
 {
-  NS_IF_RELEASE(mPrefix);
 }
 
 NS_IMPL_ADDREF(NameSpaceRule)
 NS_IMPL_RELEASE(NameSpaceRule)
 
 // QueryInterface implementation for NameSpaceRule
 NS_INTERFACE_MAP_BEGIN(NameSpaceRule)
   if (aIID.Equals(NS_GET_IID(css::NameSpaceRule))) {
@@ -1306,47 +1302,16 @@ NameSpaceRule::GetType() const
 /* virtual */ already_AddRefed<nsICSSRule>
 NameSpaceRule::Clone() const
 {
   nsCOMPtr<nsICSSRule> clone = new NameSpaceRule(*this);
   return clone.forget();
 }
 
 NS_IMETHODIMP
-NameSpaceRule::GetPrefix(nsIAtom*& aPrefix) const
-{
-  aPrefix = mPrefix;
-  NS_IF_ADDREF(aPrefix);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-NameSpaceRule::SetPrefix(nsIAtom* aPrefix)
-{
-  NS_IF_RELEASE(mPrefix);
-  mPrefix = aPrefix;
-  NS_IF_ADDREF(mPrefix);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-NameSpaceRule::GetURLSpec(nsString& aURLSpec) const
-{
-  aURLSpec = mURLSpec;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-NameSpaceRule::SetURLSpec(const nsString& aURLSpec)
-{
-  mURLSpec = aURLSpec;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 NameSpaceRule::GetType(PRUint16* aType)
 {
   // XXX What should really happen here?
   *aType = nsIDOMCSSRule::UNKNOWN_RULE;
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/layout/style/nsCSSStyleSheet.cpp
+++ b/layout/style/nsCSSStyleSheet.cpp
@@ -947,22 +947,20 @@ nsCSSStyleSheetInner::RemoveSheet(nsCSSS
 
 static void
 AddNamespaceRuleToMap(nsICSSRule* aRule, nsXMLNameSpaceMap* aMap)
 {
   NS_ASSERTION(aRule->GetType() == nsICSSRule::NAMESPACE_RULE, "Bogus rule type");
 
   nsRefPtr<css::NameSpaceRule> nameSpaceRule = do_QueryObject(aRule);
 
-  nsCOMPtr<nsIAtom> prefix;
   nsAutoString  urlSpec;
-  nameSpaceRule->GetPrefix(*getter_AddRefs(prefix));
   nameSpaceRule->GetURLSpec(urlSpec);
 
-  aMap->AddPrefix(prefix, urlSpec);
+  aMap->AddPrefix(nameSpaceRule->GetPrefix(), urlSpec);
 }
 
 static PRBool
 CreateNameSpace(nsICSSRule* aRule, void* aNameSpacePtr)
 {
   PRInt32 type = aRule->GetType();
   if (nsICSSRule::NAMESPACE_RULE == type) {
     AddNamespaceRuleToMap(aRule,