Bug 1270447 Part 1: Use the RemotePrintJob's print settings in the parent when available. r=jimm
authorBob Owen <bobowencode@gmail.com>
Sun, 29 May 2016 19:53:24 +0100
changeset 338543 34fa89cabbdb2e2fa50719b2ca5f6fb9d6c34404
parent 338542 51cc934506df685dc203ef24846779634512c82d
child 338544 fd97954bd82a4272b1863638c2de356b489954a6
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1270447
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 1270447 Part 1: Use the RemotePrintJob's print settings in the parent when available. r=jimm MozReview-Commit-ID: 4PnVf4pzHWr
embedding/components/printingui/ipc/PrintingParent.cpp
layout/printing/ipc/RemotePrintJobParent.cpp
layout/printing/ipc/RemotePrintJobParent.h
--- a/embedding/components/printingui/ipc/PrintingParent.cpp
+++ b/embedding/components/printingui/ipc/PrintingParent.cpp
@@ -93,30 +93,35 @@ PrintingParent::ShowPrintDialog(PBrowser
     return NS_ERROR_FAILURE;
   }
 
   // The initSettings we got can be wrapped using
   // PrintDataUtils' MockWebBrowserPrint, which implements enough of
   // nsIWebBrowserPrint to keep the dialogs happy.
   nsCOMPtr<nsIWebBrowserPrint> wbp = new MockWebBrowserPrint(aData);
 
+  // Use the existing RemotePrintJob and its settings, if we have one, to make
+  // sure they stay current.
+  RemotePrintJobParent* remotePrintJob =
+    static_cast<RemotePrintJobParent*>(aData.remotePrintJobParent());
   nsCOMPtr<nsIPrintSettings> settings;
-  nsresult rv = mPrintSettingsSvc->GetNewPrintSettings(getter_AddRefs(settings));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsresult rv;
+  if (remotePrintJob) {
+    settings = remotePrintJob->GetPrintSettings();
+  } else {
+    rv = mPrintSettingsSvc->GetNewPrintSettings(getter_AddRefs(settings));
+    NS_ENSURE_SUCCESS(rv, rv);
+  }
 
   rv = mPrintSettingsSvc->DeserializeToPrintSettings(aData, settings);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = pps->ShowPrintDialog(parentWin, wbp, settings);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  // Serialize back to aResult. Use the existing RemotePrintJob if we have one
-  // otherwise SerializeAndEnsureRemotePrintJob() will create a new one.
-  RemotePrintJobParent* remotePrintJob =
-    static_cast<RemotePrintJobParent*>(aData.remotePrintJobParent());
   rv = SerializeAndEnsureRemotePrintJob(settings, nullptr, remotePrintJob,
                                         aResult);
 
   return rv;
 }
 
 bool
 PrintingParent::RecvShowPrintDialog(PPrintSettingsDialogParent* aDialog,
--- a/layout/printing/ipc/RemotePrintJobParent.cpp
+++ b/layout/printing/ipc/RemotePrintJobParent.cpp
@@ -195,16 +195,23 @@ RemotePrintJobParent::RecvStatusChange(c
 void
 RemotePrintJobParent::RegisterListener(nsIWebProgressListener* aListener)
 {
   MOZ_ASSERT(aListener);
 
   mPrintProgressListeners.AppendElement(aListener);
 }
 
+already_AddRefed<nsIPrintSettings>
+RemotePrintJobParent::GetPrintSettings()
+{
+  nsCOMPtr<nsIPrintSettings> printSettings = mPrintSettings;
+  return printSettings.forget();
+}
+
 RemotePrintJobParent::~RemotePrintJobParent()
 {
   MOZ_COUNT_DTOR(RemotePrintJobParent);
 }
 
 void
 RemotePrintJobParent::ActorDestroy(ActorDestroyReason aWhy)
 {
--- a/layout/printing/ipc/RemotePrintJobParent.h
+++ b/layout/printing/ipc/RemotePrintJobParent.h
@@ -52,16 +52,21 @@ public:
 
   /**
     * Register a progress listener to receive print progress updates.
     *
     * @param aListener the progress listener to register. Must not be null.
     */
   void RegisterListener(nsIWebProgressListener* aListener);
 
+  /**
+    * @return the print settings for this remote print job.
+    */
+  already_AddRefed<nsIPrintSettings> GetPrintSettings();
+
 private:
   ~RemotePrintJobParent() final;
 
   nsresult InitializePrintDevice(const nsString& aDocumentTitle,
                                  const nsString& aPrintToFile,
                                  const int32_t& aStartPage,
                                  const int32_t& aEndPage);