Bug 1245978 part 1: Make nsDocumentViewer::CreateStyleSet directly return the thing it creates. r=heycam
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 29 Feb 2016 15:09:13 -0800
changeset 322512 b2b51d8c60cfefbf29bdac04d4e7119d3f36d819
parent 322511 8209287ef070c335c85b45b3a07ed728568a5f7f
child 322513 ceea6cf9be9d9fd850e0dab7ef78e30922e7dfb3
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1245978
milestone47.0a1
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 1245978 part 1: Make nsDocumentViewer::CreateStyleSet directly return the thing it creates. r=heycam
layout/base/nsDocumentViewer.cpp
layout/base/nsIDocumentViewerPrint.h
layout/printing/nsPrintEngine.cpp
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -623,19 +623,17 @@ nsDocumentViewer::InitPresentationStuff(
 {
   if (GetIsPrintPreview())
     return NS_OK;
 
   NS_ASSERTION(!mPresShell,
                "Someone should have destroyed the presshell!");
 
   // Create the style set...
-  StyleSetHandle styleSet;
-  nsresult rv = CreateStyleSet(mDocument, &styleSet);
-  NS_ENSURE_SUCCESS(rv, rv);
+  StyleSetHandle styleSet = CreateStyleSet(mDocument);
 
   // Now make the shell for the document
   mPresShell = mDocument->CreateShell(mPresContext, mViewManager, styleSet);
   if (!mPresShell) {
     styleSet->Delete();
     return NS_ERROR_FAILURE;
   }
 
@@ -694,17 +692,17 @@ nsDocumentViewer::InitPresentationStuff(
     mSelectionListener = selectionListener;
   }
 
   RefPtr<mozilla::dom::Selection> selection = GetDocumentSelection();
   if (!selection) {
     return NS_ERROR_FAILURE;
   }
 
-  rv = selection->AddSelectionListener(mSelectionListener);
+  nsresult rv = selection->AddSelectionListener(mSelectionListener);
   if (NS_FAILED(rv))
     return rv;
 
   // Save old listener so we can unregister it
   RefPtr<nsDocViewerFocusListener> oldFocusListener = mFocusListener;
 
   // focus listener
   //
@@ -2160,19 +2158,18 @@ StyleBackendTypeForDocument(nsIDocument*
   return nsPresContext::StyloEnabled() &&
          aDocument->IsHTMLOrXHTML() &&
          aContainer &&
          aContainer->ItemType() == nsIDocShell::typeContent ?
            StyleBackendType::Servo :
            StyleBackendType::Gecko;
 }
 
-nsresult
-nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
-                                 StyleSetHandle* aStyleSet)
+StyleSetHandle
+nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
 {
   // Make sure this does the same thing as PresShell::AddSheet wrt ordering.
 
   // this should eventually get expanded to allow for creating
   // different sets for different media
 
   StyleBackendType backendType =
     StyleBackendTypeForDocument(aDocument, mContainer);
@@ -2194,18 +2191,17 @@ nsDocumentViewer::CreateStyleSet(nsIDocu
 
     // SVG-as-an-image must be kept as light and small as possible. We
     // deliberately skip loading everything and leave svg.css (and html.css and
     // xul.css) to be loaded on-demand.
     // XXXjwatt Nothing else is loaded on-demand, but I don't think that
     // should matter for SVG-as-an-image. If it does, I want to know why!
 
     // Caller will handle calling EndUpdate, per contract.
-    *aStyleSet = styleSet;
-    return NS_OK;
+    return styleSet;
   }
 
   auto cache = nsLayoutStylesheetCache::For(backendType);
 
   // Handle the user sheets.
   StyleSheetHandle sheet = nullptr;
   if (nsContentUtils::IsInChromeDocshell(aDocument)) {
     sheet = cache->UserChromeSheet();
@@ -2349,18 +2345,17 @@ nsDocumentViewer::CreateStyleSet(nsIDocu
         styleSet->PrependStyleSheet(SheetType::User, sheet);
       }
     }
   } else {
     NS_ERROR("stylo: nsStyleSheetService doesn't handle ServoStyleSheets yet");
   }
 
   // Caller will handle calling EndUpdate, per contract.
-  *aStyleSet = styleSet;
-  return NS_OK;
+  return styleSet;
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::ClearHistoryEntry()
 {
   mSHEntry = nullptr;
   return NS_OK;
 }
--- a/layout/base/nsIDocumentViewerPrint.h
+++ b/layout/base/nsIDocumentViewerPrint.h
@@ -33,18 +33,17 @@ public:
   virtual bool GetIsPrinting() = 0;
 
   virtual void SetIsPrintPreview(bool aIsPrintPreview) = 0;
   virtual bool GetIsPrintPreview() = 0;
 
   // The style set returned by CreateStyleSet is in the middle of an
   // update batch so that the caller can add sheets to it if needed.
   // Callers should call EndUpdate() on it when ready to use.
-  virtual nsresult CreateStyleSet(nsIDocument* aDocument,
-                                  mozilla::StyleSetHandle* aStyleSet) = 0;
+  virtual mozilla::StyleSetHandle CreateStyleSet(nsIDocument* aDocument) = 0;
 
   virtual void IncrementDestroyRefCount() = 0;
 
   virtual void ReturnToGalleyPresentation() = 0;
 
   virtual void OnDonePrinting() = 0;
 
   /**
@@ -69,18 +68,17 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumen
                               NS_IDOCUMENT_VIEWER_PRINT_IID)
 
 /* Use this macro when declaring classes that implement this interface. */
 #define NS_DECL_NSIDOCUMENTVIEWERPRINT \
   virtual void     SetIsPrinting(bool aIsPrinting) override; \
   virtual bool     GetIsPrinting() override; \
   virtual void     SetIsPrintPreview(bool aIsPrintPreview) override; \
   virtual bool     GetIsPrintPreview() override; \
-  virtual nsresult CreateStyleSet(nsIDocument* aDocument, \
-                                  mozilla::StyleSetHandle* aStyleSet) override; \
+  virtual mozilla::StyleSetHandle CreateStyleSet(nsIDocument* aDocument) override; \
   virtual void     IncrementDestroyRefCount() override; \
   virtual void     ReturnToGalleyPresentation() override; \
   virtual void     OnDonePrinting() override; \
   virtual bool     IsInitializedForPrintPreview() override; \
   virtual void     InitializeForPrintPreview() override; \
   virtual void     SetPrintPreviewPresentation(nsViewManager* aViewManager, \
                                                nsPresContext* aPresContext, \
                                                nsIPresShell* aPresShell) override;
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -2120,19 +2120,17 @@ nsPrintEngine::ReflowPrintObject(nsPrint
   nsresult rv = aPO->mPresContext->Init(mPrt->mPrintDC);
   NS_ENSURE_SUCCESS(rv, rv);
 
   aPO->mViewManager = new nsViewManager();
 
   rv = aPO->mViewManager->Init(mPrt->mPrintDC);
   NS_ENSURE_SUCCESS(rv,rv);
 
-  StyleSetHandle styleSet;
-  rv = mDocViewerPrint->CreateStyleSet(aPO->mDocument, &styleSet);
-  NS_ENSURE_SUCCESS(rv, rv);
+  StyleSetHandle styleSet = mDocViewerPrint->CreateStyleSet(aPO->mDocument);
 
   aPO->mPresShell = aPO->mDocument->CreateShell(aPO->mPresContext,
                                                 aPO->mViewManager, styleSet);
   if (!aPO->mPresShell) {
     styleSet->Delete();
     return NS_ERROR_FAILURE;
   }