Bug 1189846 Part 3: Remove CreatePrintSettings nsIPrintOptions and use GetNewPrintSettings instead. r=jimm
authorBob Owen <bobowencode@gmail.com>
Mon, 16 May 2016 10:40:54 +0100
changeset 338522 e673d44f5aa6f68a2b65382f0bfcbfc9a489e04a
parent 338521 ece4ab0326116579d7b9097cb3c80cbf2501ad9b
child 338523 7a7eb2ca6358b17af9ee36a15840e158db2f8e57
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1189846
milestone49.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 1189846 Part 3: Remove CreatePrintSettings nsIPrintOptions and use GetNewPrintSettings instead. r=jimm MozReview-Commit-ID: Esv5zYxpKVo
layout/base/nsDocumentViewer.cpp
widget/nsIPrintOptions.idl
widget/nsIPrintSettingsService.idl
widget/nsPrintOptionsImpl.cpp
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -96,25 +96,19 @@
 #ifdef NS_PRINTING
 
 #include "nsIWebBrowserPrint.h"
 
 #include "nsPrintEngine.h"
 
 // Print Options
 #include "nsIPrintSettings.h"
-#include "nsIPrintOptions.h"
+#include "nsIPrintSettingsService.h"
 #include "nsISimpleEnumerator.h"
 
-#ifdef DEBUG
-// PrintOptions is now implemented by PrintSettingsService
-static const char sPrintOptionsContractID[] =
-  "@mozilla.org/gfx/printsettings-service;1";
-#endif // DEBUG
-
 #include "nsIPluginDocument.h"
 
 #endif // NS_PRINTING
 
 //focus
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMEventListener.h"
 #include "nsISelectionController.h"
@@ -2720,21 +2714,22 @@ nsDocumentViewer::Print(bool            
 
 #ifdef DEBUG
   nsresult rv = NS_ERROR_FAILURE;
 
   mDebugFile = aDebugFile;
   // if they don't pass in a PrintSettings, then make one
   // it will have all the default values
   printSettings = aPrintSettings;
-  nsCOMPtr<nsIPrintOptions> printOptions = do_GetService(sPrintOptionsContractID, &rv);
+  nsCOMPtr<nsIPrintSettingsService> printSettingsSvc
+    = do_GetService("@mozilla.org/gfx/printsettings-service;1", &rv);
   if (NS_SUCCEEDED(rv)) {
     // if they don't pass in a PrintSettings, then make one
     if (printSettings == nullptr) {
-      printOptions->CreatePrintSettings(getter_AddRefs(printSettings));
+      printSettingsSvc->GetNewPrintSettings(getter_AddRefs(printSettings));
     }
     NS_ASSERTION(printSettings, "You can't PrintPreview without a PrintSettings!");
   }
   if (printSettings) printSettings->SetPrintSilent(aSilent);
   if (printSettings) printSettings->SetShowPrintProgress(false);
 #endif
 
 
--- a/widget/nsIPrintOptions.idl
+++ b/widget/nsIPrintOptions.idl
@@ -20,22 +20,16 @@ interface nsIStringEnumerator;
 interface nsIPrintOptions : nsISupports
 {
   /**
    * Show Native Print Options dialog, this may not be supported on all platforms
    */
   void ShowPrintSetupDialog(in nsIPrintSettings aThePrintSettings);
 
   /**
-   * Creates a new PrintSettnigs Object
-   * and initializes it from prefs
-   */
-  nsIPrintSettings CreatePrintSettings();
-
-  /**
    * Get a prefixed integer pref 
    */
   int32_t getPrinterPrefInt(in nsIPrintSettings aPrintSettings, in wstring
                             aPrefName);
 
   /**
    * display Printer Job Properties dialog
    */
--- a/widget/nsIPrintSettingsService.idl
+++ b/widget/nsIPrintSettingsService.idl
@@ -44,17 +44,18 @@ interface nsIPrintSettingsService : nsIS
    *
    * For example, if each browser was to have its own unique
    * PrintSettings, then each browser window would call this to
    * create its own unique PrintSettings object.
    *
    * If each browse window was to use the same PrintSettings object
    * then it should use "globalPrintSettings"
    *
-   * Initializes the newPrintSettings from the default printer
+   * Initializes the newPrintSettings from the unprefixed printer
+   * (Note: this may not happen if there is an OS specific implementation.)
    *
    */
   readonly attribute nsIPrintSettings newPrintSettings;
 
   /**
    * The name of the last printer used, or else the system default printer.
    */
   readonly attribute wstring defaultPrinterName;
--- a/widget/nsPrintOptionsImpl.cpp
+++ b/widget/nsPrintOptionsImpl.cpp
@@ -7,19 +7,19 @@
 
 #include "mozilla/embedding/PPrinting.h"
 #include "mozilla/layout/RemotePrintJobChild.h"
 #include "mozilla/RefPtr.h"
 #include "nsPrintingProxy.h"
 #include "nsReadableUtils.h"
 #include "nsPrintSettingsImpl.h"
 #include "nsIPrintSession.h"
+#include "nsServiceManagerUtils.h"
 
 #include "nsIDOMWindow.h"
-#include "nsIServiceManager.h"
 #include "nsIDialogParamBlock.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIWindowWatcher.h"
 #include "nsISupportsArray.h"
 #include "prprf.h"
 
 #include "nsIStringEnumerator.h"
@@ -1006,38 +1006,33 @@ nsresult nsPrintOptions::_CreatePrintSet
   (*_retval)->SetPrinterName(printerName.get());
 
   (void)InitPrintSettingsFromPrefs(*_retval, false,
                                    nsIPrintSettings::kInitSaveAll);
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsPrintOptions::CreatePrintSettings(nsIPrintSettings **_retval)
-{
-  return _CreatePrintSettings(_retval);
-}
-
 NS_IMETHODIMP
 nsPrintOptions::GetGlobalPrintSettings(nsIPrintSettings **aGlobalPrintSettings)
 {
   nsresult rv;
 
-  rv = CreatePrintSettings(getter_AddRefs(mGlobalPrintSettings));
+  rv = _CreatePrintSettings(getter_AddRefs(mGlobalPrintSettings));
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ADDREF(*aGlobalPrintSettings = mGlobalPrintSettings.get());
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsPrintOptions::GetNewPrintSettings(nsIPrintSettings * *aNewPrintSettings)
 {
-  return CreatePrintSettings(aNewPrintSettings);
+  return _CreatePrintSettings(aNewPrintSettings);
 }
 
 NS_IMETHODIMP
 nsPrintOptions::GetDefaultPrinterName(char16_t * *aDefaultPrinterName)
 {
   nsresult rv;
   nsCOMPtr<nsIPrinterEnumerator> prtEnum =
            do_GetService(NS_PRINTER_ENUMERATOR_CONTRACTID, &rv);