Bug 868729 - Remove nsHTMLCSSStyleSheet::Init; r=bz
authorMs2ger <ms2ger@gmail.com>
Sun, 05 May 2013 09:03:20 +0200
changeset 141795 c8e47b184aba8cf8665a7d53ca74889390cb1d0e
parent 141794 c2df00e9434f0aea55030e357c08ab99e30cc9cb
child 141796 b47de8314e7f1d6fcf0e8ed8e41aadadfeb0baa5
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs868729
milestone23.0a1
first release with
nightly linux32
c8e47b184aba / 23.0a1 / 20130505030916 / files
nightly linux64
c8e47b184aba / 23.0a1 / 20130505030916 / files
nightly mac
c8e47b184aba / 23.0a1 / 20130505030916 / files
nightly win32
c8e47b184aba / 23.0a1 / 20130505030916 / files
nightly win64
c8e47b184aba / 23.0a1 / 20130505030916 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 868729 - Remove nsHTMLCSSStyleSheet::Init; r=bz
content/base/src/nsDocument.cpp
layout/style/nsHTMLCSSStyleSheet.cpp
layout/style/nsHTMLCSSStyleSheet.h
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -2227,19 +2227,17 @@ nsDocument::ResetStylesheetsToURI(nsIURI
     // Remove this sheet from all style sets
     nsCOMPtr<nsIPresShell> shell = GetShell();
     if (shell) {
       shell->StyleSet()->
         RemoveStyleSheet(nsStyleSet::eStyleAttrSheet, mStyleAttrStyleSheet);
     }
     mStyleAttrStyleSheet->Reset(aURI);
   } else {
-    mStyleAttrStyleSheet = new nsHTMLCSSStyleSheet();
-    nsresult rv = mStyleAttrStyleSheet->Init(aURI, this);
-    NS_ENSURE_SUCCESS(rv, rv);
+    mStyleAttrStyleSheet = new nsHTMLCSSStyleSheet(aURI, this);
   }
 
   // The loop over style sets below will handle putting this sheet
   // into style sets as needed.
   mStyleAttrStyleSheet->SetOwningDocument(this);
 
   // Now set up our style sets
   nsCOMPtr<nsIPresShell> shell = GetShell();
--- a/layout/style/nsHTMLCSSStyleSheet.cpp
+++ b/layout/style/nsHTMLCSSStyleSheet.cpp
@@ -34,19 +34,23 @@ ClearAttrCache(const nsAString& aKey, Mi
   aValue->mValue.mCSSStyleRule->SetHTMLCSSStyleSheet(nullptr);
   aValue->mValue.mCached = 0;
 
   return PL_DHASH_REMOVE;
 }
 
 } // anonymous namespace
 
-nsHTMLCSSStyleSheet::nsHTMLCSSStyleSheet()
-  : mDocument(nullptr)
+nsHTMLCSSStyleSheet::nsHTMLCSSStyleSheet(nsIURI* aURL, nsIDocument* aDocument)
+  : mURL(aURL)
+  , mDocument(aDocument) // not refcounted!
 {
+  MOZ_ASSERT(aURL);
+  MOZ_ASSERT(aDocument);
+  mCachedStyleAttrs.Init();
 }
 
 nsHTMLCSSStyleSheet::~nsHTMLCSSStyleSheet()
 {
   // We may go away before all of our cached style attributes do,
   // so clean up any that are left.
   mCachedStyleAttrs.Enumerate(ClearAttrCache, nullptr);
 }
@@ -97,32 +101,16 @@ nsHTMLCSSStyleSheet::RulesMatching(AnonB
 
 #ifdef MOZ_XUL
 /* virtual */ void
 nsHTMLCSSStyleSheet::RulesMatching(XULTreeRuleProcessorData* aData)
 {
 }
 #endif
 
-nsresult
-nsHTMLCSSStyleSheet::Init(nsIURI* aURL, nsIDocument* aDocument)
-{
-  NS_PRECONDITION(aURL && aDocument, "null ptr");
-  if (! aURL || ! aDocument)
-    return NS_ERROR_NULL_POINTER;
-
-  if (mURL || mDocument)
-    return NS_ERROR_ALREADY_INITIALIZED;
-
-  mDocument = aDocument; // not refcounted!
-  mURL = aURL;
-  mCachedStyleAttrs.Init();
-  return NS_OK;
-}
-
 // Test if style is dependent on content state
 /* virtual */ nsRestyleHint
 nsHTMLCSSStyleSheet::HasStateDependentStyle(StateRuleProcessorData* aData)
 {
   return nsRestyleHint(0);
 }
 
 /* virtual */ bool
--- a/layout/style/nsHTMLCSSStyleSheet.h
+++ b/layout/style/nsHTMLCSSStyleSheet.h
@@ -15,24 +15,24 @@
 #include "nsCOMPtr.h"
 #include "nsDataHashtable.h"
 #include "nsIStyleSheet.h"
 #include "nsIStyleRuleProcessor.h"
 
 struct MiscContainer;
 
 class nsHTMLCSSStyleSheet MOZ_FINAL : public nsIStyleSheet,
-                                      public nsIStyleRuleProcessor {
+                                      public nsIStyleRuleProcessor
+{
 public:
-  nsHTMLCSSStyleSheet();
+  nsHTMLCSSStyleSheet(nsIURI* aURL, nsIDocument* aDocument);
   ~nsHTMLCSSStyleSheet();
 
   NS_DECL_ISUPPORTS
 
-  nsresult Init(nsIURI* aURL, nsIDocument* aDocument);
   void Reset(nsIURI* aURL);
 
   // nsIStyleSheet
   virtual nsIURI* GetSheetURI() const;
   virtual nsIURI* GetBaseURI() const MOZ_OVERRIDE;
   virtual void GetTitle(nsString& aTitle) const MOZ_OVERRIDE;
   virtual void GetType(nsString& aType) const MOZ_OVERRIDE;
   virtual bool HasRules() const MOZ_OVERRIDE;