Bug 1425178 - Rename nsPrintEngine to nsPrintJob. r=bobowen
authorJonathan Watt <jwatt@jwatt.org>
Mon, 04 Dec 2017 11:44:17 -0600
changeset 396608 31be43353751a97126b1676ea36d11b7ef71fa5c
parent 396607 e15eeb9bbf33b6f73c2a41540931354f4b4ae7df
child 396609 4780efa5f11052cfe775e1d1e76d85cfc0bfc1ea
push id33099
push userncsoregi@mozilla.com
push dateSat, 16 Dec 2017 09:38:13 +0000
treeherdermozilla-central@4780efa5f110 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbobowen
bugs1425178
milestone59.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 1425178 - Rename nsPrintEngine to nsPrintJob. r=bobowen MozReview-Commit-ID: 2HCNmeOLPd3
docshell/base/nsIContentViewerContainer.idl
layout/base/nsDocumentViewer.cpp
layout/base/nsIDocumentViewerPrint.h
layout/printing/ipc/RemotePrintJobChild.cpp
layout/printing/ipc/RemotePrintJobChild.h
layout/printing/moz.build
layout/printing/nsPagePrintTimer.cpp
layout/printing/nsPagePrintTimer.h
layout/printing/nsPrintEngine.cpp
layout/printing/nsPrintEngine.h
layout/printing/nsPrintJob.cpp
layout/printing/nsPrintJob.h
toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp
toolkit/content/browser-content.js
--- a/docshell/base/nsIContentViewerContainer.idl
+++ b/docshell/base/nsIContentViewerContainer.idl
@@ -8,13 +8,13 @@
 
 interface nsIContentViewer;
 
 [scriptable, uuid(ea2ce7a0-5c3d-11d4-90c2-0050041caf44)]
 interface nsIContentViewerContainer : nsISupports {
 	void embed(in nsIContentViewer aDocViewer, in string aCommand, in nsISupports aExtraInfo);
 
   /**
-   * Allows the PrintEngine to make this call on 
-   * an internal interface to the DocShell
+   * Allows nsPrintJob to make this call on an internal interface to the
+   * DocShell.
    */
   void setIsPrinting(in boolean aIsPrinting);
 };
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -91,17 +91,17 @@
 
 //--------------------------
 // Printing Include
 //---------------------------
 #ifdef NS_PRINTING
 
 #include "nsIWebBrowserPrint.h"
 
-#include "nsPrintEngine.h"
+#include "nsPrintJob.h"
 
 // Print Options
 #include "nsIPrintSettings.h"
 #include "nsIPrintSettingsService.h"
 #include "nsISimpleEnumerator.h"
 
 #include "nsIPluginDocument.h"
 
@@ -215,17 +215,17 @@ class nsDocumentViewer final : public ns
 
 #ifdef NS_PRINTING
                              , public nsIWebBrowserPrint
 #endif
 
 {
   friend class nsDocViewerSelectionListener;
   friend class nsPagePrintTimer;
-  friend class nsPrintEngine;
+  friend class nsPrintJob;
 
 public:
   nsDocumentViewer();
 
   // nsISupports interface...
   NS_DECL_ISUPPORTS
 
   // nsIContentViewer interface...
@@ -375,17 +375,17 @@ protected:
   unsigned                         mPrintPreviewZoomed : 1;
 
   // These data members support delayed printing when the document is loading
   unsigned                         mPrintIsPending : 1;
   unsigned                         mPrintDocIsFullyLoaded : 1;
   nsCOMPtr<nsIPrintSettings>       mCachedPrintSettings;
   nsCOMPtr<nsIWebProgressListener> mCachedPrintWebProgressListner;
 
-  RefPtr<nsPrintEngine>          mPrintEngine;
+  RefPtr<nsPrintJob>               mPrintJob;
   float                            mOriginalPrintPreviewScale;
   float                            mPrintPreviewZoom;
   nsAutoPtr<AutoPrintEventDispatcher> mAutoBeforeAndAfterPrint;
 #endif // NS_PRINT_PREVIEW
 
 #endif // NS_PRINTING
 
   /* character set member data */
@@ -478,19 +478,19 @@ void nsDocumentViewer::PrepareToStartLoa
   mDeferredWindowClose = false;
 
 #ifdef NS_PRINTING
   mPrintIsPending        = false;
   mPrintDocIsFullyLoaded = false;
   mClosingWhilePrinting  = false;
 
   // Make sure we have destroyed it and cleared the data member
-  if (mPrintEngine) {
-    mPrintEngine->Destroy();
-    mPrintEngine = nullptr;
+  if (mPrintJob) {
+    mPrintJob->Destroy();
+    mPrintJob = nullptr;
 #ifdef NS_PRINT_PREVIEW
     SetIsPrintPreview(false);
 #endif
   }
 
 #endif // NS_PRINTING
 }
 
@@ -544,19 +544,19 @@ NS_INTERFACE_MAP_END
 
 nsDocumentViewer::~nsDocumentViewer()
 {
   if (mDocument) {
     Close(nullptr);
     mDocument->Destroy();
   }
 
-  if (mPrintEngine) {
-    mPrintEngine->Destroy();
-    mPrintEngine = nullptr;
+  if (mPrintJob) {
+    mPrintJob->Destroy();
+    mPrintJob = nullptr;
   }
 
   MOZ_RELEASE_ASSERT(mDestroyRefCount == 0);
   NS_ASSERTION(!mPresShell && !mPresContext,
                "User did not call nsIContentViewer::Destroy");
   if (mPresShell || mPresContext) {
     // Make sure we don't hand out a reference to the content viewer to
     // the SHEntry!
@@ -1574,26 +1574,26 @@ nsDocumentViewer::Close(nsISHEntry *aSHE
   // to disable scripts during paint suppression.
 
   if (!mDocument)
     return NS_OK;
 
 #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
   // Turn scripting back on
   // after PrintPreview had turned it off
-  if (GetIsPrintPreview() && mPrintEngine) {
-    mPrintEngine->TurnScriptingOn(true);
+  if (GetIsPrintPreview() && mPrintJob) {
+    mPrintJob->TurnScriptingOn(true);
   }
 #endif
 
 #ifdef NS_PRINTING
   // A Close was called while we were printing
   // so don't clear the ScriptGlobalObject
   // or clear the mDocument below
-  if (mPrintEngine && !mClosingWhilePrinting) {
+  if (mPrintJob && !mClosingWhilePrinting) {
     mClosingWhilePrinting = true;
   } else
 #endif
     {
       // out of band cleanup of docshell
       mDocument->SetScriptGlobalObject(nullptr);
 
       if (!mSHEntry && mDocument)
@@ -1656,18 +1656,18 @@ nsDocumentViewer::Destroy()
 #ifdef NS_PRINTING
   // Here is where we check to see if the document was still being prepared
   // for printing when it was asked to be destroy from someone externally
   // This usually happens if the document is unloaded while the user is in the
   // Print Dialog
   //
   // So we flip the bool to remember that the document is going away
   // and we can clean up and abort later after returning from the Print Dialog
-  if (mPrintEngine) {
-    if (mPrintEngine->CheckBeforeDestroy()) {
+  if (mPrintJob) {
+    if (mPrintJob->CheckBeforeDestroy()) {
       return NS_OK;
     }
   }
   // Dispatch the 'afterprint' event now, if pending:
   mAutoBeforeAndAfterPrint = nullptr;
 #endif
 
   // Don't let the document get unloaded while we are printing.
@@ -1786,28 +1786,28 @@ nsDocumentViewer::Destroy()
   }
 
   // All callers are supposed to call destroy to break circular
   // references.  If we do this stuff in the destructor, the
   // destructor might never be called (especially if we're being
   // used from JS.
 
 #ifdef NS_PRINTING
-  if (mPrintEngine) {
-    RefPtr<nsPrintEngine> printEngine = mozilla::Move(mPrintEngine);
+  if (mPrintJob) {
+    RefPtr<nsPrintJob> printJob = mozilla::Move(mPrintJob);
 #ifdef NS_PRINT_PREVIEW
     bool doingPrintPreview;
-    printEngine->GetDoingPrintPreview(&doingPrintPreview);
+    printJob->GetDoingPrintPreview(&doingPrintPreview);
     if (doingPrintPreview) {
-      printEngine->FinishPrintPreview();
+      printJob->FinishPrintPreview();
     }
 #endif
-    printEngine->Destroy();
-    MOZ_ASSERT(!mPrintEngine,
-               "mPrintEngine shouldn't be recreated while destroying it");
+    printJob->Destroy();
+    MOZ_ASSERT(!mPrintJob,
+               "mPrintJob shouldn't be recreated while destroying it");
   }
 #endif
 
   // Avoid leaking the old viewer.
   if (mPreviousViewer) {
     mPreviousViewer->Destroy();
     mPreviousViewer = nullptr;
   }
@@ -2304,17 +2304,17 @@ nsDocumentViewer::SetSticky(bool aSticky
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::RequestWindowClose(bool* aCanClose)
 {
 #ifdef NS_PRINTING
-  if (mPrintIsPending || (mPrintEngine && mPrintEngine->GetIsPrinting())) {
+  if (mPrintIsPending || (mPrintJob && mPrintJob->GetIsPrinting())) {
     *aCanClose = false;
     mDeferredWindowClose = true;
   } else
 #endif
     *aCanClose = true;
 
   return NS_OK;
 }
@@ -3910,18 +3910,18 @@ nsDocumentViewer::Print(nsIPrintSettings
   // if we are printing another URL, then exit
   // the reason we check here is because this method can be called while
   // another is still in here (the printing dialog is a good example).
   // the only time we can print more than one job at a time is the regression tests
   if (GetIsPrinting()) {
     // Let the user know we are not ready to print.
     rv = NS_ERROR_NOT_AVAILABLE;
 
-    if (mPrintEngine) {
-      mPrintEngine->FirePrintingErrorEvent(rv);
+    if (mPrintJob) {
+      mPrintJob->FirePrintingErrorEvent(rv);
     }
 
     return rv;
   }
 
   // Dispatch 'beforeprint' event and ensure 'afterprint' will be dispatched:
   MOZ_ASSERT(!mAutoBeforeAndAfterPrint,
              "We don't want to dispatch nested beforeprint/afterprint");
@@ -3929,44 +3929,44 @@ nsDocumentViewer::Print(nsIPrintSettings
     new AutoPrintEventDispatcher(mDocument));
   NS_ENSURE_STATE(!GetIsPrinting());
   // If we are hosting a full-page plugin, tell it to print
   // first. It shows its own native print UI.
   nsCOMPtr<nsIPluginDocument> pDoc(do_QueryInterface(mDocument));
   if (pDoc)
     return pDoc->Print();
 
-  // Our call to nsPrintEngine::Print() may cause mPrintEngine to be
+  // Our call to nsPrintJob::Print() may cause mPrintJob to be
   // Release()'d in Destroy().  Therefore, we need to grab the instance with
   // a local variable, so that it won't be deleted during its own method.
-  RefPtr<nsPrintEngine> printEngine = mPrintEngine;
-  if (!printEngine) {
+  RefPtr<nsPrintJob> printJob = mPrintJob;
+  if (!printJob) {
     NS_ENSURE_STATE(mDeviceContext);
-    printEngine = new nsPrintEngine();
-
-    rv = printEngine->Initialize(this, mContainer, mDocument,
-                                 float(mDeviceContext->AppUnitsPerCSSInch()) /
-                                 float(mDeviceContext->AppUnitsPerDevPixel()) /
-                                 mPageZoom);
+    printJob = new nsPrintJob();
+
+    rv = printJob->Initialize(this, mContainer, mDocument,
+                              float(mDeviceContext->AppUnitsPerCSSInch()) /
+                              float(mDeviceContext->AppUnitsPerDevPixel()) /
+                              mPageZoom);
     if (NS_FAILED(rv)) {
-      printEngine->Destroy();
+      printJob->Destroy();
       return rv;
     }
-    mPrintEngine = printEngine;
+    mPrintJob = printJob;
   }
-  if (printEngine->HasPrintCallbackCanvas()) {
+  if (printJob->HasPrintCallbackCanvas()) {
     // Postpone the 'afterprint' event until after the mozPrintCallback
     // callbacks have been called:
     mAutoBeforeAndAfterPrint = autoBeforeAndAfterPrint;
   }
   dom::Element* root = mDocument->GetRootElement();
   if (root && root->HasAttr(kNameSpaceID_None, nsGkAtoms::mozdisallowselectionprint)) {
-    printEngine->SetDisallowSelectionPrint(true);
+    printJob->SetDisallowSelectionPrint(true);
   }
-  rv = printEngine->Print(aPrintSettings, aWebProgressListener);
+  rv = printJob->Print(aPrintSettings, aWebProgressListener);
   if (NS_FAILED(rv)) {
     OnDonePrinting();
   }
   return rv;
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::PrintPreview(nsIPrintSettings* aPrintSettings,
@@ -3977,24 +3977,24 @@ nsDocumentViewer::PrintPreview(nsIPrintS
   NS_WARNING_ASSERTION(
     IsInitializedForPrintPreview(),
     "Using docshell.printPreview is the preferred way for print previewing!");
 
   NS_ENSURE_ARG_POINTER(aChildDOMWin);
   nsresult rv = NS_OK;
 
   if (GetIsPrinting()) {
-    nsPrintEngine::CloseProgressDialog(aWebProgressListener);
+    nsPrintJob::CloseProgressDialog(aWebProgressListener);
     return NS_ERROR_FAILURE;
   }
 
   // Printing XUL documents is not supported.
   nsCOMPtr<nsIXULDocument> xulDoc(do_QueryInterface(mDocument));
   if (xulDoc) {
-    nsPrintEngine::CloseProgressDialog(aWebProgressListener);
+    nsPrintJob::CloseProgressDialog(aWebProgressListener);
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIDocShell> docShell(mContainer);
   if (!docShell || !mDeviceContext) {
     PR_PL(("Can't Print Preview without device context and docshell"));
     return NS_ERROR_FAILURE;
   }
@@ -4016,81 +4016,81 @@ nsDocumentViewer::PrintPreview(nsIPrintS
   if (!mAutoBeforeAndAfterPrint) {
     autoBeforeAndAfterPrint = new AutoPrintEventDispatcher(doc);
   }
   NS_ENSURE_STATE(!GetIsPrinting());
   // beforeprint event may have caused ContentViewer to be shutdown.
   NS_ENSURE_STATE(mContainer);
   NS_ENSURE_STATE(mDeviceContext);
 
-  // Our call to nsPrintEngine::PrintPreview() may cause mPrintEngine to be
+  // Our call to nsPrintJob::PrintPreview() may cause mPrintJob to be
   // Release()'d in Destroy().  Therefore, we need to grab the instance with
   // a local variable, so that it won't be deleted during its own method.
-  RefPtr<nsPrintEngine> printEngine = mPrintEngine;
-  if (!printEngine) {
-    printEngine = new nsPrintEngine();
-
-    rv = printEngine->Initialize(this, mContainer, doc,
-                                 float(mDeviceContext->AppUnitsPerCSSInch()) /
-                                 float(mDeviceContext->AppUnitsPerDevPixel()) /
-                                 mPageZoom);
+  RefPtr<nsPrintJob> printJob = mPrintJob;
+  if (!printJob) {
+    printJob = new nsPrintJob();
+
+    rv = printJob->Initialize(this, mContainer, doc,
+                              float(mDeviceContext->AppUnitsPerCSSInch()) /
+                              float(mDeviceContext->AppUnitsPerDevPixel()) /
+                              mPageZoom);
     if (NS_FAILED(rv)) {
-      printEngine->Destroy();
+      printJob->Destroy();
       return rv;
     }
-    mPrintEngine = printEngine;
+    mPrintJob = printJob;
   }
   if (autoBeforeAndAfterPrint &&
-      printEngine->HasPrintCallbackCanvas()) {
+      printJob->HasPrintCallbackCanvas()) {
     // Postpone the 'afterprint' event until after the mozPrintCallback
     // callbacks have been called:
     mAutoBeforeAndAfterPrint = autoBeforeAndAfterPrint;
   }
   dom::Element* root = doc->GetRootElement();
   if (root && root->HasAttr(kNameSpaceID_None, nsGkAtoms::mozdisallowselectionprint)) {
     PR_PL(("PrintPreview: found mozdisallowselectionprint"));
-    printEngine->SetDisallowSelectionPrint(true);
+    printJob->SetDisallowSelectionPrint(true);
   }
-  rv = printEngine->PrintPreview(aPrintSettings, aChildDOMWin,
-                                 aWebProgressListener);
+  rv = printJob->PrintPreview(aPrintSettings, aChildDOMWin,
+                              aWebProgressListener);
   mPrintPreviewZoomed = false;
   if (NS_FAILED(rv)) {
     OnDonePrinting();
   }
   return rv;
 #else
   return NS_ERROR_FAILURE;
 #endif
 }
 
 //----------------------------------------------------------------------
 NS_IMETHODIMP
 nsDocumentViewer::PrintPreviewNavigate(int16_t aType, int32_t aPageNum)
 {
   if (!GetIsPrintPreview() ||
-      mPrintEngine->GetIsCreatingPrintPreview())
+      mPrintJob->GetIsCreatingPrintPreview())
     return NS_ERROR_FAILURE;
 
   nsIScrollableFrame* sf =
-    mPrintEngine->GetPrintPreviewPresShell()->GetRootScrollFrameAsScrollable();
+    mPrintJob->GetPrintPreviewPresShell()->GetRootScrollFrameAsScrollable();
   if (!sf)
     return NS_OK;
 
   // Check to see if we can short circut scrolling to the top
   if (aType == nsIWebBrowserPrint::PRINTPREVIEW_HOME ||
       (aType == nsIWebBrowserPrint::PRINTPREVIEW_GOTO_PAGENUM && aPageNum == 1)) {
     sf->ScrollTo(nsPoint(0, 0), nsIScrollableFrame::INSTANT);
     return NS_OK;
   }
 
   // Finds the SimplePageSequencer frame
   // in PP mPrtPreview->mPrintObject->mSeqFrame is null
   nsIFrame* seqFrame  = nullptr;
   int32_t   pageCount = 0;
-  if (NS_FAILED(mPrintEngine->GetSeqFrameAndCountPages(seqFrame, pageCount))) {
+  if (NS_FAILED(mPrintJob->GetSeqFrameAndCountPages(seqFrame, pageCount))) {
     return NS_ERROR_FAILURE;
   }
 
   // Figure where we are currently scrolled to
   nsPoint pt = sf->GetScrollPosition();
 
   int32_t    pageNum = 1;
   nsIFrame * fndPageFrame  = nullptr;
@@ -4137,173 +4137,173 @@ nsDocumentViewer::PrintPreviewNavigate(i
   } else { // If we get here we are doing "GoTo"
     if (aPageNum < 0 || aPageNum > pageCount) {
       return NS_OK;
     }
   }
 
   if (fndPageFrame) {
     nscoord newYPosn =
-      nscoord(mPrintEngine->GetPrintPreviewScale() * fndPageFrame->GetPosition().y);
+      nscoord(mPrintJob->GetPrintPreviewScale() * fndPageFrame->GetPosition().y);
     sf->ScrollTo(nsPoint(pt.x, newYPosn), nsIScrollableFrame::INSTANT);
   }
   return NS_OK;
 
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::GetGlobalPrintSettings(nsIPrintSettings * *aGlobalPrintSettings)
 {
-  return nsPrintEngine::GetGlobalPrintSettings(aGlobalPrintSettings);
+  return nsPrintJob::GetGlobalPrintSettings(aGlobalPrintSettings);
 }
 
 // XXX This always returns false for subdocuments
 NS_IMETHODIMP
 nsDocumentViewer::GetDoingPrint(bool *aDoingPrint)
 {
   NS_ENSURE_ARG_POINTER(aDoingPrint);
 
   *aDoingPrint = false;
-  if (mPrintEngine) {
+  if (mPrintJob) {
     // XXX shouldn't this be GetDoingPrint() ?
-    return mPrintEngine->GetDoingPrintPreview(aDoingPrint);
+    return mPrintJob->GetDoingPrintPreview(aDoingPrint);
   }
   return NS_OK;
 }
 
 // XXX This always returns false for subdocuments
 NS_IMETHODIMP
 nsDocumentViewer::GetDoingPrintPreview(bool *aDoingPrintPreview)
 {
   NS_ENSURE_ARG_POINTER(aDoingPrintPreview);
 
   *aDoingPrintPreview = false;
-  if (mPrintEngine) {
-    return mPrintEngine->GetDoingPrintPreview(aDoingPrintPreview);
+  if (mPrintJob) {
+    return mPrintJob->GetDoingPrintPreview(aDoingPrintPreview);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::GetCurrentPrintSettings(nsIPrintSettings * *aCurrentPrintSettings)
 {
   NS_ENSURE_ARG_POINTER(aCurrentPrintSettings);
 
   *aCurrentPrintSettings = nullptr;
-  NS_ENSURE_TRUE(mPrintEngine, NS_ERROR_FAILURE);
-
-  return mPrintEngine->GetCurrentPrintSettings(aCurrentPrintSettings);
+  NS_ENSURE_TRUE(mPrintJob, NS_ERROR_FAILURE);
+
+  return mPrintJob->GetCurrentPrintSettings(aCurrentPrintSettings);
 }
 
 
 NS_IMETHODIMP
 nsDocumentViewer::GetCurrentChildDOMWindow(mozIDOMWindowProxy** aCurrentChildDOMWindow)
 {
   NS_ENSURE_ARG_POINTER(aCurrentChildDOMWindow);
   *aCurrentChildDOMWindow = nullptr;
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::Cancel()
 {
-  NS_ENSURE_TRUE(mPrintEngine, NS_ERROR_FAILURE);
-  return mPrintEngine->Cancelled();
+  NS_ENSURE_TRUE(mPrintJob, NS_ERROR_FAILURE);
+  return mPrintJob->Cancelled();
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::ExitPrintPreview()
 {
   if (GetIsPrinting())
     return NS_ERROR_FAILURE;
-  NS_ENSURE_TRUE(mPrintEngine, NS_ERROR_FAILURE);
+  NS_ENSURE_TRUE(mPrintJob, NS_ERROR_FAILURE);
 
   if (GetIsPrintPreview()) {
     ReturnToGalleyPresentation();
   }
   return NS_OK;
 }
 
 //----------------------------------------------------------------------------------
 // Enumerate all the documents for their titles
 NS_IMETHODIMP
 nsDocumentViewer::EnumerateDocumentNames(uint32_t* aCount,
                                            char16_t*** aResult)
 {
 #ifdef NS_PRINTING
   NS_ENSURE_ARG(aCount);
   NS_ENSURE_ARG_POINTER(aResult);
-  NS_ENSURE_TRUE(mPrintEngine, NS_ERROR_FAILURE);
-
-  return mPrintEngine->EnumerateDocumentNames(aCount, aResult);
+  NS_ENSURE_TRUE(mPrintJob, NS_ERROR_FAILURE);
+
+  return mPrintJob->EnumerateDocumentNames(aCount, aResult);
 #else
   return NS_ERROR_FAILURE;
 #endif
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::GetIsFramesetFrameSelected(bool *aIsFramesetFrameSelected)
 {
 #ifdef NS_PRINTING
   *aIsFramesetFrameSelected = false;
-  NS_ENSURE_TRUE(mPrintEngine, NS_ERROR_FAILURE);
-
-  return mPrintEngine->GetIsFramesetFrameSelected(aIsFramesetFrameSelected);
+  NS_ENSURE_TRUE(mPrintJob, NS_ERROR_FAILURE);
+
+  return mPrintJob->GetIsFramesetFrameSelected(aIsFramesetFrameSelected);
 #else
   return NS_ERROR_FAILURE;
 #endif
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::GetPrintPreviewNumPages(int32_t *aPrintPreviewNumPages)
 {
 #ifdef NS_PRINTING
   NS_ENSURE_ARG_POINTER(aPrintPreviewNumPages);
-  NS_ENSURE_TRUE(mPrintEngine, NS_ERROR_FAILURE);
-
-  return mPrintEngine->GetPrintPreviewNumPages(aPrintPreviewNumPages);
+  NS_ENSURE_TRUE(mPrintJob, NS_ERROR_FAILURE);
+
+  return mPrintJob->GetPrintPreviewNumPages(aPrintPreviewNumPages);
 #else
   return NS_ERROR_FAILURE;
 #endif
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::GetIsFramesetDocument(bool *aIsFramesetDocument)
 {
 #ifdef NS_PRINTING
   *aIsFramesetDocument = false;
-  NS_ENSURE_TRUE(mPrintEngine, NS_ERROR_FAILURE);
-
-  return mPrintEngine->GetIsFramesetDocument(aIsFramesetDocument);
+  NS_ENSURE_TRUE(mPrintJob, NS_ERROR_FAILURE);
+
+  return mPrintJob->GetIsFramesetDocument(aIsFramesetDocument);
 #else
   return NS_ERROR_FAILURE;
 #endif
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::GetIsIFrameSelected(bool *aIsIFrameSelected)
 {
 #ifdef NS_PRINTING
   *aIsIFrameSelected = false;
-  NS_ENSURE_TRUE(mPrintEngine, NS_ERROR_FAILURE);
-
-  return mPrintEngine->GetIsIFrameSelected(aIsIFrameSelected);
+  NS_ENSURE_TRUE(mPrintJob, NS_ERROR_FAILURE);
+
+  return mPrintJob->GetIsIFrameSelected(aIsIFrameSelected);
 #else
   return NS_ERROR_FAILURE;
 #endif
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::GetIsRangeSelection(bool *aIsRangeSelection)
 {
 #ifdef NS_PRINTING
   *aIsRangeSelection = false;
-  NS_ENSURE_TRUE(mPrintEngine, NS_ERROR_FAILURE);
-
-  return mPrintEngine->GetIsRangeSelection(aIsRangeSelection);
+  NS_ENSURE_TRUE(mPrintJob, NS_ERROR_FAILURE);
+
+  return mPrintJob->GetIsRangeSelection(aIsRangeSelection);
 #else
   return NS_ERROR_FAILURE;
 #endif
 }
 
 //----------------------------------------------------------------------------------
 // Printing/Print Preview Helpers
 //----------------------------------------------------------------------------------
@@ -4389,25 +4389,25 @@ nsDocumentViewer::ShouldAttachToTopLevel
 }
 
 //------------------------------------------------------------
 // XXX this always returns false for subdocuments
 bool
 nsDocumentViewer::GetIsPrinting()
 {
 #ifdef NS_PRINTING
-  if (mPrintEngine) {
-    return mPrintEngine->GetIsPrinting();
+  if (mPrintJob) {
+    return mPrintJob->GetIsPrinting();
   }
 #endif
   return false;
 }
 
 //------------------------------------------------------------
-// Notification from the PrintEngine of the current Printing status
+// Notification from the PrintJob of the current Printing status
 void
 nsDocumentViewer::SetIsPrinting(bool aIsPrinting)
 {
 #ifdef NS_PRINTING
   // Set all the docShells in the docshell tree to be printing.
   // that way if anyone of them tries to "navigate" it can't
   nsCOMPtr<nsIDocShell> docShell(mContainer);
   if (docShell || !aIsPrinting) {
@@ -4419,32 +4419,32 @@ nsDocumentViewer::SetIsPrinting(bool aIs
   if (!aIsPrinting) {
     // Dispatch the 'afterprint' event now, if pending:
     mAutoBeforeAndAfterPrint = nullptr;
   }
 #endif
 }
 
 //------------------------------------------------------------
-// The PrintEngine holds the current value
+// The PrintJob holds the current value
 // this called from inside the DocViewer.
 // XXX it always returns false for subdocuments
 bool
 nsDocumentViewer::GetIsPrintPreview()
 {
 #ifdef NS_PRINTING
-  if (mPrintEngine) {
-    return mPrintEngine->GetIsPrintPreview();
+  if (mPrintJob) {
+    return mPrintJob->GetIsPrintPreview();
   }
 #endif
   return false;
 }
 
 //------------------------------------------------------------
-// Notification from the PrintEngine of the current PP status
+// Notification from the PrintJob of the current PP status
 void
 nsDocumentViewer::SetIsPrintPreview(bool aIsPrintPreview)
 {
 #ifdef NS_PRINTING
   // Set all the docShells in the docshell tree to be printing.
   // that way if anyone of them tries to "navigate" it can't
   nsCOMPtr<nsIDocShell> docShell(mContainer);
   if (docShell || !aIsPrintPreview) {
@@ -4516,59 +4516,59 @@ nsDocumentViewer::ReturnToGalleyPresenta
 #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
   if (!GetIsPrintPreview()) {
     NS_ERROR("Wow, we should never get here!");
     return;
   }
 
   SetIsPrintPreview(false);
 
-  mPrintEngine->TurnScriptingOn(true);
-  mPrintEngine->Destroy();
-  mPrintEngine = nullptr;
+  mPrintJob->TurnScriptingOn(true);
+  mPrintJob->Destroy();
+  mPrintJob = nullptr;
 
   nsCOMPtr<nsIDocShell> docShell(mContainer);
   ResetFocusState(docShell);
 
   SetTextZoom(mTextZoom);
   SetFullZoom(mPageZoom);
   SetOverrideDPPX(mOverrideDPPX);
   SetMinFontSize(mMinFontSize);
   Show();
 
 #endif // NS_PRINTING && NS_PRINT_PREVIEW
 }
 
 //------------------------------------------------------------
 // This called ONLY when printing has completed and the DV
-// is being notified that it should get rid of the PrintEngine.
+// is being notified that it should get rid of the nsPrintJob.
 //
 // BUT, if we are in Print Preview then we want to ignore the
-// notification (we do not get rid of the PrintEngine)
+// notification (we do not get rid of the nsPrintJob)
 //
 // One small caveat:
 //   This IS called from two places in this module for cleaning
 //   up when an error occurred during the start up printing
 //   and print preview
 //
 void
 nsDocumentViewer::OnDonePrinting()
 {
 #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
-  // If Destroy() has been called during calling nsPrintEngine::Print() or
-  // nsPrintEngine::PrintPreview(), mPrintEngine is already nullptr here.
+  // If Destroy() has been called during calling nsPrintJob::Print() or
+  // nsPrintJob::PrintPreview(), mPrintJob is already nullptr here.
   // So, the following clean up does nothing in such case.
   // (Do we need some of this for that case?)
-  if (mPrintEngine) {
-    RefPtr<nsPrintEngine> pe = mPrintEngine;
+  if (mPrintJob) {
+    RefPtr<nsPrintJob> printJob = mPrintJob;
     if (GetIsPrintPreview()) {
-      pe->DestroyPrintingData();
+      printJob->DestroyPrintingData();
     } else {
-      mPrintEngine = nullptr;
-      pe->Destroy();
+      mPrintJob = nullptr;
+      printJob->Destroy();
     }
 
     // We are done printing, now cleanup
     if (mDeferredWindowClose) {
       mDeferredWindowClose = false;
       if (mContainer) {
         if (nsCOMPtr<nsPIDOMWindowOuter> win = do_QueryInterface(mContainer->GetWindow())) {
           win->Close();
--- a/layout/base/nsIDocumentViewerPrint.h
+++ b/layout/base/nsIDocumentViewerPrint.h
@@ -18,17 +18,17 @@ class nsViewManager;
 
 // {c6f255cf-cadd-4382-b57f-cd2a9874169b}
 #define NS_IDOCUMENT_VIEWER_PRINT_IID \
 { 0xc6f255cf, 0xcadd, 0x4382, \
   { 0xb5, 0x7f, 0xcd, 0x2a, 0x98, 0x74, 0x16, 0x9b } }
 
 /**
  * A DocumentViewerPrint is an INTERNAL Interface used for interaction
- * between the DocumentViewer and the PrintEngine
+ * between the DocumentViewer and nsPrintJob.
  */
 class nsIDocumentViewerPrint : public nsISupports
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_VIEWER_PRINT_IID)
 
   virtual void SetIsPrinting(bool aIsPrinting) = 0;
   virtual bool GetIsPrinting() = 0;
--- a/layout/printing/ipc/RemotePrintJobChild.cpp
+++ b/layout/printing/ipc/RemotePrintJobChild.cpp
@@ -3,17 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "RemotePrintJobChild.h"
 
 #include "mozilla/Unused.h"
 #include "nsPagePrintTimer.h"
-#include "nsPrintEngine.h"
+#include "nsPrintJob.h"
 #include "private/pprio.h"
 
 namespace mozilla {
 namespace layout {
 
 NS_IMPL_ISUPPORTS(RemotePrintJobChild,
                   nsIWebProgressListener)
 
@@ -84,36 +84,36 @@ RemotePrintJobChild::RecvPageProcessed(c
 
   mPagePrintTimer->RemotePrintFinished();
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 RemotePrintJobChild::RecvAbortPrint(const nsresult& aRv)
 {
-  MOZ_ASSERT(mPrintEngine);
+  MOZ_ASSERT(mPrintJob);
 
-  mPrintEngine->CleanupOnFailure(aRv, true);
+  mPrintJob->CleanupOnFailure(aRv, true);
   return IPC_OK();
 }
 
 void
 RemotePrintJobChild::SetPagePrintTimer(nsPagePrintTimer* aPagePrintTimer)
 {
   MOZ_ASSERT(aPagePrintTimer);
 
   mPagePrintTimer = aPagePrintTimer;
 }
 
 void
-RemotePrintJobChild::SetPrintEngine(nsPrintEngine* aPrintEngine)
+RemotePrintJobChild::SetPrintJob(nsPrintJob* aPrintJob)
 {
-  MOZ_ASSERT(aPrintEngine);
+  MOZ_ASSERT(aPrintJob);
 
-  mPrintEngine = aPrintEngine;
+  mPrintJob = aPrintJob;
 }
 
 // nsIWebProgressListener
 
 NS_IMETHODIMP
 RemotePrintJobChild::OnStateChange(nsIWebProgress* aProgress,
                                    nsIRequest* aRequest, uint32_t aStateFlags,
                                    nsresult aStatus)
@@ -173,15 +173,15 @@ RemotePrintJobChild::OnSecurityChange(ns
 RemotePrintJobChild::~RemotePrintJobChild()
 {
 }
 
 void
 RemotePrintJobChild::ActorDestroy(ActorDestroyReason aWhy)
 {
   mPagePrintTimer = nullptr;
-  mPrintEngine = nullptr;
+  mPrintJob = nullptr;
 
   mDestroyed = true;
 }
 
 } // namespace layout
 } // namespace mozilla
--- a/layout/printing/ipc/RemotePrintJobChild.h
+++ b/layout/printing/ipc/RemotePrintJobChild.h
@@ -8,17 +8,17 @@
 #define mozilla_layout_RemotePrintJobChild_h
 
 #include "mozilla/layout/PRemotePrintJobChild.h"
 
 #include "mozilla/RefPtr.h"
 #include "nsIWebProgressListener.h"
 
 class nsPagePrintTimer;
-class nsPrintEngine;
+class nsPrintJob;
 
 namespace mozilla {
 namespace layout {
 
 class RemotePrintJobChild final : public PRemotePrintJobChild
                                 , public nsIWebProgressListener
 {
 public:
@@ -41,28 +41,28 @@ public:
   void ProcessPage();
 
   mozilla::ipc::IPCResult RecvPageProcessed(const FileDescriptor& aFd) final;
 
   mozilla::ipc::IPCResult RecvAbortPrint(const nsresult& aRv) final;
 
   void SetPagePrintTimer(nsPagePrintTimer* aPagePrintTimer);
 
-  void SetPrintEngine(nsPrintEngine* aPrintEngine);
+  void SetPrintJob(nsPrintJob* aPrintJob);
 
   PRFileDesc* GetNextPageFD();
 
 private:
   ~RemotePrintJobChild() final;
   void SetNextPageFD(const mozilla::ipc::FileDescriptor& aFd);
 
   bool mPrintInitialized = false;
   bool mDestroyed = false;
   nsresult mInitializationResult = NS_OK;
   RefPtr<nsPagePrintTimer> mPagePrintTimer;
-  RefPtr<nsPrintEngine> mPrintEngine;
+  RefPtr<nsPrintJob> mPrintJob;
   PRFileDesc* mNextPageFD = nullptr;
 };
 
 } // namespace layout
 } // namespace mozilla
 
 #endif // mozilla_layout_RemotePrintJobChild_h
--- a/layout/printing/moz.build
+++ b/layout/printing/moz.build
@@ -22,17 +22,17 @@ EXPORTS.mozilla.layout.printing += [
 XPIDL_MODULE = 'layout_printing'
 
 UNIFIED_SOURCES += [
     'DrawEventRecorder.cpp',
     'ipc/RemotePrintJobChild.cpp',
     'ipc/RemotePrintJobParent.cpp',
     'nsPagePrintTimer.cpp',
     'nsPrintData.cpp',
-    'nsPrintEngine.cpp',
+    'nsPrintJob.cpp',
     'nsPrintObject.cpp',
     'nsPrintPreviewListener.cpp',
     'PrintTranslator.cpp',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
--- a/layout/printing/nsPagePrintTimer.cpp
+++ b/layout/printing/nsPagePrintTimer.cpp
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsPagePrintTimer.h"
 
 #include "mozilla/Unused.h"
 #include "nsIContentViewer.h"
 #include "nsIServiceManager.h"
-#include "nsPrintEngine.h"
+#include "nsPrintJob.h"
 
 using namespace mozilla;
 
 NS_IMPL_ISUPPORTS_INHERITED(nsPagePrintTimer, mozilla::Runnable, nsITimerCallback)
 
 nsPagePrintTimer::~nsPagePrintTimer()
 {
   // "Destroy" the document viewer; this normally doesn't actually
@@ -74,39 +74,39 @@ nsPagePrintTimer::Run()
   bool initNewTimer = true;
   // Check to see if we are done
   // inRange will be true if a page is actually printed
   bool inRange;
   bool donePrinting;
 
   // donePrinting will be true if it completed successfully or
   // if the printing was cancelled
-  donePrinting = !mPrintEngine || mPrintEngine->PrintPage(mPrintObj, inRange);
+  donePrinting = !mPrintJob || mPrintJob->PrintPage(mPrintObj, inRange);
   if (donePrinting) {
 
     if (mWaitingForRemotePrint ||
         // If we are not waiting for the remote printing, it is the time to
         // end printing task by calling DonePrintingPages.
-        (!mPrintEngine || mPrintEngine->DonePrintingPages(mPrintObj, NS_OK))) {
+        (!mPrintJob || mPrintJob->DonePrintingPages(mPrintObj, NS_OK))) {
       initNewTimer = false;
       mDone = true;
     }
   }
 
   // Note that the Stop() destroys this after the print job finishes
-  // (The PrintEngine stops holding a reference when DonePrintingPages
+  // (The nsPrintJob stops holding a reference when DonePrintingPages
   // returns true.)
   Stop();
   if (initNewTimer) {
     ++mFiringCount;
     nsresult result = StartTimer(inRange);
     if (NS_FAILED(result)) {
       mDone = true;     // had a failure.. we are finished..
-      if (mPrintEngine) {
-        mPrintEngine->SetIsPrinting(false);
+      if (mPrintJob) {
+        mPrintJob->SetIsPrinting(false);
       }
     }
   }
   return NS_OK;
 }
 
 // nsITimerCallback
 NS_IMETHODIMP
@@ -144,18 +144,18 @@ nsPagePrintTimer::Notify(nsITimer *timer
       Fail();
       return NS_OK;
     }
   }
 
   if (mDocViewerPrint) {
     bool donePrePrint = true;
     // Don't start to pre-print if we're waiting on the parent still.
-    if (mPrintEngine && !mWaitingForRemotePrint) {
-      donePrePrint = mPrintEngine->PrePrintPage();
+    if (mPrintJob && !mWaitingForRemotePrint) {
+      donePrePrint = mPrintJob->PrePrintPage();
     }
 
     if (donePrePrint && !mWaitingForRemotePrint) {
       StopWatchDogTimer();
       // Pass nullptr here since name already was set in constructor.
       mDocument->Dispatch(TaskCategory::Other, do_AddRef(this));
     } else {
       // Start the watch dog if we're waiting for preprint to ensure that if any
@@ -180,18 +180,18 @@ nsPagePrintTimer::WaitForRemotePrint()
 void
 nsPagePrintTimer::RemotePrintFinished()
 {
   if (!mWaitingForRemotePrint) {
     return;
   }
 
   // now clean up print or print the next webshell
-  if (mDone && mPrintEngine) {
-    mDone = mPrintEngine->DonePrintingPages(mPrintObj, NS_OK);
+  if (mDone && mPrintJob) {
+    mDone = mPrintJob->DonePrintingPages(mPrintObj, NS_OK);
   }
 
   mWaitingForRemotePrint->SetTarget(
     mDocument->EventTargetFor(mozilla::TaskCategory::Other));
   mozilla::Unused <<
     mWaitingForRemotePrint->InitWithCallback(this, 0, nsITimer::TYPE_ONE_SHOT);
 }
 
@@ -216,12 +216,12 @@ nsPagePrintTimer::Stop()
 
 void
 nsPagePrintTimer::Fail()
 {
   NS_WARNING("nsPagePrintTimer::Fail called");
 
   mDone = true;
   Stop();
-  if (mPrintEngine) {
-    mPrintEngine->CleanupOnFailure(NS_OK, false);
+  if (mPrintJob) {
+    mPrintJob->CleanupOnFailure(NS_OK, false);
   }
 }
--- a/layout/printing/nsPagePrintTimer.h
+++ b/layout/printing/nsPagePrintTimer.h
@@ -9,35 +9,35 @@
 // Timer Includes
 #include "nsITimer.h"
 
 #include "nsIDocumentViewerPrint.h"
 #include "nsPrintObject.h"
 #include "mozilla/Attributes.h"
 #include "nsThreadUtils.h"
 
-class nsPrintEngine;
+class nsPrintJob;
 class nsIDocument;
 
 //---------------------------------------------------
 //-- Page Timer Class
 //---------------------------------------------------
 class nsPagePrintTimer final : public mozilla::Runnable,
                                public nsITimerCallback
 {
 public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
-  nsPagePrintTimer(nsPrintEngine* aPrintEngine,
+  nsPagePrintTimer(nsPrintJob* aPrintJob,
                    nsIDocumentViewerPrint* aDocViewerPrint,
                    nsIDocument* aDocument,
                    uint32_t aDelay)
     : Runnable("nsPagePrintTimer")
-    , mPrintEngine(aPrintEngine)
+    , mPrintJob(aPrintJob)
     , mDocViewerPrint(aDocViewerPrint)
     , mDocument(aDocument)
     , mDelay(aDelay)
     , mFiringCount(0)
     , mPrintObj(nullptr)
     , mWatchDogCount(0)
     , mDone(false)
   {
@@ -53,29 +53,29 @@ public:
 
   void Stop();
 
   void WaitForRemotePrint();
   void RemotePrintFinished();
 
   void Disconnect()
   {
-    mPrintEngine = nullptr;
+    mPrintJob = nullptr;
     mPrintObj = nullptr;
   }
 
 private:
   ~nsPagePrintTimer();
 
   nsresult StartTimer(bool aUseDelay);
   nsresult StartWatchDogTimer();
   void     StopWatchDogTimer();
   void     Fail();
 
-  nsPrintEngine*             mPrintEngine;
+  nsPrintJob*                mPrintJob;
   nsCOMPtr<nsIDocumentViewerPrint> mDocViewerPrint;
   nsCOMPtr<nsIDocument>      mDocument;
   nsCOMPtr<nsITimer>         mTimer;
   nsCOMPtr<nsITimer>         mWatchDogTimer;
   nsCOMPtr<nsITimer>         mWaitingForRemotePrint;
   uint32_t                   mDelay;
   uint32_t                   mFiringCount;
   nsPrintObject *            mPrintObj;
rename from layout/printing/nsPrintEngine.cpp
rename to layout/printing/nsPrintJob.cpp
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintJob.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsPrintEngine.h"
+#include "nsPrintJob.h"
 
 #include "nsIStringBundle.h"
 #include "nsReadableUtils.h"
 #include "nsCRT.h"
 
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/dom/Selection.h"
 #include "mozilla/dom/CustomEvent.h"
@@ -173,143 +173,148 @@ static void DumpPrintObjectsTreeLayout(n
 #define DUMP_DOC_LIST(_title)
 #define DUMP_DOC_TREE
 #define DUMP_DOC_TREELAYOUT
 #endif
 
 class nsScriptSuppressor
 {
 public:
-  explicit nsScriptSuppressor(nsPrintEngine* aPrintEngine)
-  : mPrintEngine(aPrintEngine), mSuppressed(false) {}
+  explicit nsScriptSuppressor(nsPrintJob* aPrintJob)
+    : mPrintJob(aPrintJob)
+    , mSuppressed(false)
+  {}
 
   ~nsScriptSuppressor() { Unsuppress(); }
 
   void Suppress()
   {
-    if (mPrintEngine) {
+    if (mPrintJob) {
       mSuppressed = true;
-      mPrintEngine->TurnScriptingOn(false);
+      mPrintJob->TurnScriptingOn(false);
     }
   }
 
   void Unsuppress()
   {
-    if (mPrintEngine && mSuppressed) {
-      mPrintEngine->TurnScriptingOn(true);
+    if (mPrintJob && mSuppressed) {
+      mPrintJob->TurnScriptingOn(true);
     }
     mSuppressed = false;
   }
 
-  void Disconnect() { mPrintEngine = nullptr; }
+  void Disconnect() { mPrintJob = nullptr; }
 protected:
-  RefPtr<nsPrintEngine> mPrintEngine;
+  RefPtr<nsPrintJob>      mPrintJob;
   bool                    mSuppressed;
 };
 
-NS_IMPL_ISUPPORTS(nsPrintEngine, nsIWebProgressListener,
+NS_IMPL_ISUPPORTS(nsPrintJob, nsIWebProgressListener,
                   nsISupportsWeakReference, nsIObserver)
 
 //---------------------------------------------------
-//-- nsPrintEngine Class Impl
+//-- nsPrintJob Class Impl
 //---------------------------------------------------
-nsPrintEngine::nsPrintEngine()
+nsPrintJob::nsPrintJob()
   : mIsCreatingPrintPreview(false)
   , mIsDoingPrinting(false)
   , mIsDoingPrintPreview(false)
   , mProgressDialogIsShown(false)
   , mScreenDPI(115.0f)
   , mPagePrintTimer(nullptr)
   , mLoadCounter(0)
   , mDidLoadDataForPrinting(false)
   , mIsDestroying(false)
   , mDisallowSelectionPrint(false)
 {
 }
 
 //-------------------------------------------------------
-nsPrintEngine::~nsPrintEngine()
+nsPrintJob::~nsPrintJob()
 {
   Destroy(); // for insurance
   DisconnectPagePrintTimer();
 }
 
 //-------------------------------------------------------
-void nsPrintEngine::Destroy()
+void
+nsPrintJob::Destroy()
 {
   if (mIsDestroying) {
     return;
   }
   mIsDestroying = true;
 
   mPrt = nullptr;
 
 #ifdef NS_PRINT_PREVIEW
   mPrtPreview = nullptr;
   mOldPrtPreview = nullptr;
 #endif
   mDocViewerPrint = nullptr;
 }
 
 //-------------------------------------------------------
-void nsPrintEngine::DestroyPrintingData()
+void
+nsPrintJob::DestroyPrintingData()
 {
   mPrt = nullptr;
 }
 
 //---------------------------------------------------------------------------------
 //-- Section: Methods needed by the DocViewer
 //---------------------------------------------------------------------------------
 
 //--------------------------------------------------------
-nsresult nsPrintEngine::Initialize(nsIDocumentViewerPrint* aDocViewerPrint,
-                                   nsIDocShell*            aContainer,
-                                   nsIDocument*            aDocument,
-                                   float                   aScreenDPI)
+nsresult
+nsPrintJob::Initialize(nsIDocumentViewerPrint* aDocViewerPrint,
+                       nsIDocShell*            aContainer,
+                       nsIDocument*            aDocument,
+                       float                   aScreenDPI)
 {
   NS_ENSURE_ARG_POINTER(aDocViewerPrint);
   NS_ENSURE_ARG_POINTER(aContainer);
   NS_ENSURE_ARG_POINTER(aDocument);
 
   mDocViewerPrint = aDocViewerPrint;
   mContainer      = do_GetWeakReference(aContainer);
   mDocument       = aDocument;
   mScreenDPI      = aScreenDPI;
 
   return NS_OK;
 }
 
 //-------------------------------------------------------
 bool
-nsPrintEngine::CheckBeforeDestroy()
+nsPrintJob::CheckBeforeDestroy()
 {
   if (mPrt && mPrt->mPreparingForPrint) {
     mPrt->mDocWasToBeDestroyed = true;
     return true;
   }
   return false;
 }
 
 //-------------------------------------------------------
 nsresult
-nsPrintEngine::Cancelled()
+nsPrintJob::Cancelled()
 {
   if (mPrt && mPrt->mPrintSettings) {
     return mPrt->mPrintSettings->SetIsCancelled(true);
   }
   return NS_ERROR_FAILURE;
 }
 
 //-------------------------------------------------------
 // Install our event listeners on the document to prevent
 // some events from being processed while in PrintPreview
 //
 // No return code - if this fails, there isn't much we can do
 void
-nsPrintEngine::InstallPrintPreviewListener()
+nsPrintJob::InstallPrintPreviewListener()
 {
   if (!mPrt->mPPEventListeners) {
     nsCOMPtr<nsIDocShell> docShell = do_QueryReferent(mContainer);
     if (!docShell) {
       return;
     }
 
     if (nsPIDOMWindowOuter* win = docShell->GetWindow()) {
@@ -317,19 +322,19 @@ nsPrintEngine::InstallPrintPreviewListen
       mPrt->mPPEventListeners = new nsPrintPreviewListener(target);
       mPrt->mPPEventListeners->AddListeners();
     }
   }
 }
 
 //----------------------------------------------------------------------
 nsresult
-nsPrintEngine::GetSeqFrameAndCountPagesInternal(const UniquePtr<nsPrintObject>& aPO,
-                                                nsIFrame*&    aSeqFrame,
-                                                int32_t&      aCount)
+nsPrintJob::GetSeqFrameAndCountPagesInternal(const UniquePtr<nsPrintObject>& aPO,
+                                             nsIFrame*&    aSeqFrame,
+                                             int32_t&      aCount)
 {
   NS_ENSURE_ARG_POINTER(aPO);
 
   // This is sometimes incorrectly called before the pres shell has been created
   // (bug 1141756). MOZ_DIAGNOSTIC_ASSERT so we'll still see the crash in
   // Nightly/Aurora in case the other patch fixes this.
   if (!aPO->mPresShell) {
     MOZ_DIAGNOSTIC_ASSERT(false,
@@ -346,17 +351,18 @@ nsPrintEngine::GetSeqFrameAndCountPagesI
 
   // count the total number of pages
   aCount = aSeqFrame->PrincipalChildList().GetLength();
 
   return NS_OK;
 }
 
 //-----------------------------------------------------------------
-nsresult nsPrintEngine::GetSeqFrameAndCountPages(nsIFrame*& aSeqFrame, int32_t& aCount)
+nsresult
+nsPrintJob::GetSeqFrameAndCountPages(nsIFrame*& aSeqFrame, int32_t& aCount)
 {
   MOZ_ASSERT(mPrtPreview);
   // Guarantee that mPrintPreview->mPrintObject won't be deleted during a call
   // of GetSeqFrameAndCountPagesInternal().
   RefPtr<nsPrintData> printDataForPrintPreview = mPrtPreview;
   return GetSeqFrameAndCountPagesInternal(
            printDataForPrintPreview->mPrintObject, aSeqFrame, aCount);
 }
@@ -381,20 +387,20 @@ static void DumpLayoutData(char* aTitleS
                            nsPresContext* aPresContext,
                            nsDeviceContext * aDC, nsIFrame * aRootFrame,
                            nsIDocShell * aDocShell, FILE* aFD);
 #endif
 
 //--------------------------------------------------------------------------------
 
 nsresult
-nsPrintEngine::CommonPrint(bool                    aIsPrintPreview,
-                           nsIPrintSettings*       aPrintSettings,
-                           nsIWebProgressListener* aWebProgressListener,
-                           nsIDOMDocument* aDoc)
+nsPrintJob::CommonPrint(bool                    aIsPrintPreview,
+                        nsIPrintSettings*       aPrintSettings,
+                        nsIWebProgressListener* aWebProgressListener,
+                        nsIDOMDocument* aDoc)
 {
   // Callers must hold a strong reference to |this| to ensure that we stay
   // alive for the duration of this method, because our main owning reference
   // (on nsDocumentViewer) might be cleared during this function (if we cause
   // script to run and it cancels the print operation).
 
   nsresult rv = DoCommonPrint(aIsPrintPreview, aPrintSettings,
                               aWebProgressListener, aDoc);
@@ -412,20 +418,20 @@ nsPrintEngine::CommonPrint(bool         
     }
     mPrt = nullptr;
   }
 
   return rv;
 }
 
 nsresult
-nsPrintEngine::DoCommonPrint(bool                    aIsPrintPreview,
-                             nsIPrintSettings*       aPrintSettings,
-                             nsIWebProgressListener* aWebProgressListener,
-                             nsIDOMDocument*         aDoc)
+nsPrintJob::DoCommonPrint(bool                    aIsPrintPreview,
+                          nsIPrintSettings*       aPrintSettings,
+                          nsIWebProgressListener* aWebProgressListener,
+                          nsIDOMDocument*         aDoc)
 {
   nsresult rv;
 
   if (aIsPrintPreview) {
     // The WebProgressListener can be QI'ed to nsIPrintingPromptService
     // then that means the progress dialog is already being shown.
     nsCOMPtr<nsIPrintingPromptService> pps(do_QueryInterface(aWebProgressListener));
     mProgressDialogIsShown = pps != nullptr;
@@ -678,17 +684,17 @@ nsPrintEngine::DoCommonPrint(bool       
   rv = devspec->Init(nullptr, printData->mPrintSettings, aIsPrintPreview);
   NS_ENSURE_SUCCESS(rv, rv);
 
   printData->mPrintDC = new nsDeviceContext();
   rv = printData->mPrintDC->InitForPrinting(devspec);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (XRE_IsParentProcess() && !printData->mPrintDC->IsSyncPagePrinting()) {
-    RefPtr<nsPrintEngine> self(this);
+    RefPtr<nsPrintJob> self(this);
     printData->mPrintDC->RegisterPageDoneCallback([self](nsresult aResult) { self->PageDone(aResult); });
   }
 
   if (aIsPrintPreview) {
     printData->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs);
 
     // override any UI that wants to PrintPreview any selection or page range
     // we want to view every page in PrintPreview each time
@@ -790,33 +796,33 @@ nsPrintEngine::DoCommonPrint(bool       
   // We will enable scripting later after printing has finished.
   scriptSuppressor.Disconnect();
 
   return NS_OK;
 }
 
 //---------------------------------------------------------------------------------
 NS_IMETHODIMP
-nsPrintEngine::Print(nsIPrintSettings*       aPrintSettings,
-                     nsIWebProgressListener* aWebProgressListener)
+nsPrintJob::Print(nsIPrintSettings*       aPrintSettings,
+                  nsIWebProgressListener* aWebProgressListener)
 {
   // If we have a print preview document, use that instead of the original
   // mDocument. That way animated images etc. get printed using the same state
   // as in print preview.
   nsCOMPtr<nsIDOMDocument> doc =
     do_QueryInterface(mPrtPreview && mPrtPreview->mPrintObject ?
                         mPrtPreview->mPrintObject->mDocument : mDocument);
 
   return CommonPrint(false, aPrintSettings, aWebProgressListener, doc);
 }
 
 NS_IMETHODIMP
-nsPrintEngine::PrintPreview(nsIPrintSettings* aPrintSettings,
-                            mozIDOMWindowProxy* aChildDOMWin,
-                            nsIWebProgressListener* aWebProgressListener)
+nsPrintJob::PrintPreview(nsIPrintSettings* aPrintSettings,
+                         mozIDOMWindowProxy* aChildDOMWin,
+                         nsIWebProgressListener* aWebProgressListener)
 {
   // Get the DocShell and see if it is busy
   // (We can't Print Preview this document if it is still busy)
   nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mContainer));
   NS_ENSURE_STATE(docShell);
 
   uint32_t busyFlags = nsIDocShell::BUSY_FLAGS_NONE;
   if (NS_FAILED(docShell->GetBusyFlags(&busyFlags)) ||
@@ -834,26 +840,26 @@ nsPrintEngine::PrintPreview(nsIPrintSett
   MOZ_ASSERT(domDoc);
 
   // Document is not busy -- go ahead with the Print Preview
   return CommonPrint(true, aPrintSettings, aWebProgressListener, domDoc);
 }
 
 //----------------------------------------------------------------------------------
 NS_IMETHODIMP
-nsPrintEngine::GetIsFramesetDocument(bool *aIsFramesetDocument)
+nsPrintJob::GetIsFramesetDocument(bool* aIsFramesetDocument)
 {
   nsCOMPtr<nsIDocShell> webContainer(do_QueryReferent(mContainer));
   *aIsFramesetDocument = IsParentAFrameSet(webContainer);
   return NS_OK;
 }
 
 //----------------------------------------------------------------------------------
 NS_IMETHODIMP
-nsPrintEngine::GetIsIFrameSelected(bool *aIsIFrameSelected)
+nsPrintJob::GetIsIFrameSelected(bool* aIsIFrameSelected)
 {
   *aIsIFrameSelected = false;
 
   // Get the docshell for this documentviewer
   nsCOMPtr<nsIDocShell> webContainer(do_QueryReferent(mContainer));
   // Get the currently focused window
   nsCOMPtr<nsPIDOMWindowOuter> currentFocusWin = FindFocusedDOMWindow();
   if (currentFocusWin && webContainer) {
@@ -863,37 +869,37 @@ nsPrintEngine::GetIsIFrameSelected(bool 
     bool isParentFrameSet;
     *aIsIFrameSelected = IsThereAnIFrameSelected(webContainer, currentFocusWin, isParentFrameSet);
   }
   return NS_OK;
 }
 
 //----------------------------------------------------------------------------------
 NS_IMETHODIMP
-nsPrintEngine::GetIsRangeSelection(bool *aIsRangeSelection)
+nsPrintJob::GetIsRangeSelection(bool* aIsRangeSelection)
 {
   // Get the currently focused window
   nsCOMPtr<nsPIDOMWindowOuter> currentFocusWin = FindFocusedDOMWindow();
   *aIsRangeSelection = IsThereARangeSelection(currentFocusWin);
   return NS_OK;
 }
 
 //----------------------------------------------------------------------------------
 NS_IMETHODIMP
-nsPrintEngine::GetIsFramesetFrameSelected(bool *aIsFramesetFrameSelected)
+nsPrintJob::GetIsFramesetFrameSelected(bool* aIsFramesetFrameSelected)
 {
   // Get the currently focused window
   nsCOMPtr<nsPIDOMWindowOuter> currentFocusWin = FindFocusedDOMWindow();
   *aIsFramesetFrameSelected = currentFocusWin != nullptr;
   return NS_OK;
 }
 
 //----------------------------------------------------------------------------------
 NS_IMETHODIMP
-nsPrintEngine::GetPrintPreviewNumPages(int32_t *aPrintPreviewNumPages)
+nsPrintJob::GetPrintPreviewNumPages(int32_t* aPrintPreviewNumPages)
 {
   NS_ENSURE_ARG_POINTER(aPrintPreviewNumPages);
 
   nsIFrame* seqFrame  = nullptr;
   *aPrintPreviewNumPages = 0;
 
   // When calling this function, the FinishPrintPreview() function might not
   // been called as there are still some
@@ -908,18 +914,18 @@ nsPrintEngine::GetPrintPreviewNumPages(i
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 //----------------------------------------------------------------------------------
 // Enumerate all the documents for their titles
 NS_IMETHODIMP
-nsPrintEngine::EnumerateDocumentNames(uint32_t* aCount,
-                                      char16_t*** aResult)
+nsPrintJob::EnumerateDocumentNames(uint32_t* aCount,
+                                   char16_t*** aResult)
 {
   NS_ENSURE_ARG(aCount);
   NS_ENSURE_ARG_POINTER(aResult);
 
   *aCount = 0;
   *aResult = nullptr;
 
   int32_t     numDocs = mPrt->mPrintDocList.Length();
@@ -944,50 +950,50 @@ nsPrintEngine::EnumerateDocumentNames(ui
   *aResult = array;
 
   return NS_OK;
 
 }
 
 //----------------------------------------------------------------------------------
 nsresult
-nsPrintEngine::GetGlobalPrintSettings(nsIPrintSettings **aGlobalPrintSettings)
+nsPrintJob::GetGlobalPrintSettings(nsIPrintSettings** aGlobalPrintSettings)
 {
   NS_ENSURE_ARG_POINTER(aGlobalPrintSettings);
 
   nsresult rv = NS_ERROR_FAILURE;
   nsCOMPtr<nsIPrintSettingsService> printSettingsService =
     do_GetService(sPrintSettingsServiceContractID, &rv);
   if (NS_SUCCEEDED(rv)) {
     rv = printSettingsService->GetGlobalPrintSettings(aGlobalPrintSettings);
   }
   return rv;
 }
 
 //----------------------------------------------------------------------------------
 NS_IMETHODIMP
-nsPrintEngine::GetDoingPrint(bool *aDoingPrint)
+nsPrintJob::GetDoingPrint(bool* aDoingPrint)
 {
   NS_ENSURE_ARG_POINTER(aDoingPrint);
   *aDoingPrint = mIsDoingPrinting;
   return NS_OK;
 }
 
 //----------------------------------------------------------------------------------
 NS_IMETHODIMP
-nsPrintEngine::GetDoingPrintPreview(bool *aDoingPrintPreview)
+nsPrintJob::GetDoingPrintPreview(bool* aDoingPrintPreview)
 {
   NS_ENSURE_ARG_POINTER(aDoingPrintPreview);
   *aDoingPrintPreview = mIsDoingPrintPreview;
   return NS_OK;
 }
 
 //----------------------------------------------------------------------------------
 NS_IMETHODIMP
-nsPrintEngine::GetCurrentPrintSettings(nsIPrintSettings * *aCurrentPrintSettings)
+nsPrintJob::GetCurrentPrintSettings(nsIPrintSettings** aCurrentPrintSettings)
 {
   NS_ENSURE_ARG_POINTER(aCurrentPrintSettings);
 
   if (mPrt) {
     *aCurrentPrintSettings = mPrt->mPrintSettings;
 
   } else if (mPrtPreview) {
     *aCurrentPrintSettings = mPrtPreview->mPrintSettings;
@@ -1003,17 +1009,17 @@ nsPrintEngine::GetCurrentPrintSettings(n
 //-- Section: Pre-Reflow Methods
 //-----------------------------------------------------------------
 
 //---------------------------------------------------------------------
 // This method checks to see if there is at least one printer defined
 // and if so, it sets the first printer in the list as the default name
 // in the PrintSettings which is then used for Printer Preview
 nsresult
-nsPrintEngine::CheckForPrinters(nsIPrintSettings* aPrintSettings)
+nsPrintJob::CheckForPrinters(nsIPrintSettings* aPrintSettings)
 {
 #if defined(XP_MACOSX) || defined(ANDROID)
   // Mac doesn't support retrieving a printer list.
   return NS_OK;
 #else
 #if defined(MOZ_X11)
   // On Linux, default printer name should be requested on the parent side.
   // Unless we are in the parent, we ignore this function
@@ -1041,17 +1047,17 @@ nsPrintEngine::CheckForPrinters(nsIPrint
   }
   return rv;
 #endif
 }
 
 //----------------------------------------------------------------------
 // Set up to use the "pluggable" Print Progress Dialog
 void
-nsPrintEngine::ShowPrintProgress(bool aIsForPrinting, bool& aDoNotify)
+nsPrintJob::ShowPrintProgress(bool aIsForPrinting, bool& aDoNotify)
 {
   // default to not notifying, that if something here goes wrong
   // or we aren't going to show the progress dialog we can straight into
   // reflowing the doc for printing.
   aDoNotify = false;
 
   // Assume we can't do progress and then see if we can
   bool showProgresssDialog = false;
@@ -1118,17 +1124,17 @@ nsPrintEngine::ShowPrintProgress(bool aI
         }
       }
     }
   }
 }
 
 //---------------------------------------------------------------------
 bool
-nsPrintEngine::IsThereARangeSelection(nsPIDOMWindowOuter* aDOMWin)
+nsPrintJob::IsThereARangeSelection(nsPIDOMWindowOuter* aDOMWin)
 {
   if (mDisallowSelectionPrint)
     return false;
 
   nsCOMPtr<nsIPresShell> presShell;
   if (aDOMWin) {
     presShell = aDOMWin->GetDocShell()->GetPresShell();
   }
@@ -1153,17 +1159,17 @@ nsPrintEngine::IsThereARangeSelection(ns
   }
 
   // check to make sure it isn't an insertion selection
   return selection->GetRangeAt(0) && !selection->IsCollapsed();
 }
 
 //---------------------------------------------------------------------
 bool
-nsPrintEngine::IsParentAFrameSet(nsIDocShell * aParent)
+nsPrintJob::IsParentAFrameSet(nsIDocShell* aParent)
 {
   // See if the incoming doc is the root document
   if (!aParent) return false;
 
   // When it is the top level document we need to check
   // to see if it contains a frameset. If it does, then
   // we only want to print the doc's children and not the document itself
   // For anything else we always print all the children and the document
@@ -1188,19 +1194,19 @@ nsPrintEngine::IsParentAFrameSet(nsIDocS
   return isFrameSet;
 }
 
 
 //---------------------------------------------------------------------
 // Recursively build a list of sub documents to be printed
 // that mirrors the document tree
 void
-nsPrintEngine::BuildDocTree(nsIDocShell *      aParentNode,
-                            nsTArray<nsPrintObject*> * aDocList,
-                            const UniquePtr<nsPrintObject>& aPO)
+nsPrintJob::BuildDocTree(nsIDocShell*      aParentNode,
+                         nsTArray<nsPrintObject*>* aDocList,
+                         const UniquePtr<nsPrintObject>& aPO)
 {
   NS_ASSERTION(aParentNode, "Pointer is null!");
   NS_ASSERTION(aDocList, "Pointer is null!");
   NS_ASSERTION(aPO, "Pointer is null!");
 
   int32_t childWebshellCount;
   aParentNode->GetChildCount(&childWebshellCount);
   if (childWebshellCount > 0) {
@@ -1223,19 +1229,19 @@ nsPrintEngine::BuildDocTree(nsIDocShell 
         BuildDocTree(childAsShell, aDocList, aPO->mKids.LastElement());
       }
     }
   }
 }
 
 //---------------------------------------------------------------------
 void
-nsPrintEngine::GetDocumentTitleAndURL(nsIDocument* aDoc,
-                                      nsAString&   aTitle,
-                                      nsAString&   aURLStr)
+nsPrintJob::GetDocumentTitleAndURL(nsIDocument* aDoc,
+                                   nsAString&   aTitle,
+                                   nsAString&   aURLStr)
 {
   NS_ASSERTION(aDoc, "Pointer is null!");
 
   aTitle.Truncate();
   aURLStr.Truncate();
 
   nsCOMPtr<nsIDOMDocument> doc = do_QueryInterface(aDoc);
   doc->GetTitle(aTitle);
@@ -1265,18 +1271,18 @@ nsPrintEngine::GetDocumentTitleAndURL(ns
 
 //---------------------------------------------------------------------
 // The walks the PO tree and for each document it walks the content
 // tree looking for any content that are sub-shells
 //
 // It then sets the mContent pointer in the "found" PO object back to the
 // the document that contained it.
 void
-nsPrintEngine::MapContentToWebShells(const UniquePtr<nsPrintObject>& aRootPO,
-                                     const UniquePtr<nsPrintObject>& aPO)
+nsPrintJob::MapContentToWebShells(const UniquePtr<nsPrintObject>& aRootPO,
+                                  const UniquePtr<nsPrintObject>& aPO)
 {
   NS_ASSERTION(aRootPO, "Pointer is null!");
   NS_ASSERTION(aPO, "Pointer is null!");
 
   // Recursively walk the content from the root item
   // XXX Would be faster to enumerate the subdocuments, although right now
   //     nsIDocument doesn't expose quite what would be needed.
   nsCOMPtr<nsIContentViewer> viewer;
@@ -1312,17 +1318,17 @@ nsPrintEngine::MapContentToWebShells(con
 //
 // This method walks the PO tree and checks to see if the PrintObject is
 // an eFrame and has children that are eFrames (meaning it's a Frame containing a FrameSet)
 // If so, then the mFrameType need to be changed to eFrameSet
 //
 // Also note: We only want to call this we are printing "Each Frame Separately"
 //            when printing "As Is" leave it as an eFrame
 void
-nsPrintEngine::CheckForChildFrameSets(const UniquePtr<nsPrintObject>& aPO)
+nsPrintJob::CheckForChildFrameSets(const UniquePtr<nsPrintObject>& aPO)
 {
   NS_ASSERTION(aPO, "Pointer is null!");
 
   // Continue recursively walking the chilren of this PO
   bool hasChildFrames = false;
   for (const UniquePtr<nsPrintObject>& po : aPO->mKids) {
     if (po->mFrameType == eFrame) {
       hasChildFrames = true;
@@ -1346,18 +1352,18 @@ nsPrintEngine::CheckForChildFrameSets(co
 // This is used later to (after reflow) to find the absolute location
 // of the sub-doc on its parent's page frame so it can be
 // printed in the correct location.
 //
 // This method recursvely "walks" the content for a document finding
 // all the Frames and IFrames, then sets the "mFrameType" data member
 // which tells us what type of PO we have
 void
-nsPrintEngine::MapContentForPO(const UniquePtr<nsPrintObject>& aPO,
-                               nsIContent*      aContent)
+nsPrintJob::MapContentForPO(const UniquePtr<nsPrintObject>& aPO,
+                            nsIContent* aContent)
 {
   NS_PRECONDITION(aPO && aContent, "Null argument");
 
   nsIDocument* doc = aContent->GetComposedDoc();
 
   NS_ASSERTION(doc, "Content without a document from a document tree?");
 
   nsIDocument* subDoc = doc->GetSubDocumentFor(aContent);
@@ -1397,19 +1403,19 @@ nsPrintEngine::MapContentForPO(const Uni
        child;
        child = child->GetNextSibling()) {
     MapContentForPO(aPO, child);
   }
 }
 
 //---------------------------------------------------------------------
 bool
-nsPrintEngine::IsThereAnIFrameSelected(nsIDocShell* aDocShell,
-                                       nsPIDOMWindowOuter* aDOMWin,
-                                       bool& aIsParentFrameSet)
+nsPrintJob::IsThereAnIFrameSelected(nsIDocShell* aDocShell,
+                                    nsPIDOMWindowOuter* aDOMWin,
+                                    bool& aIsParentFrameSet)
 {
   aIsParentFrameSet = IsParentAFrameSet(aDocShell);
   bool iFrameIsSelected = false;
   if (mPrt && mPrt->mPrintObject) {
     nsPrintObject* po = FindPrintObjectByDOMWin(mPrt->mPrintObject.get(), aDOMWin);
     iFrameIsSelected = po && po->mFrameType == eIFrame;
   } else {
     // First, check to see if we are a frameset
@@ -1430,17 +1436,17 @@ nsPrintEngine::IsThereAnIFrameSelected(n
 
   return iFrameIsSelected;
 }
 
 //---------------------------------------------------------------------
 // Recursively sets all the PO items to be printed
 // from the given item down into the tree
 void
-nsPrintEngine::SetPrintPO(nsPrintObject* aPO, bool aPrint)
+nsPrintJob::SetPrintPO(nsPrintObject* aPO, bool aPrint)
 {
   NS_ASSERTION(aPO, "Pointer is null!");
 
   // Set whether to print flag
   aPO->mDontPrint = !aPrint;
 
   for (const UniquePtr<nsPrintObject>& kid : aPO->mKids) {
     SetPrintPO(kid.get(), aPrint);
@@ -1448,20 +1454,20 @@ nsPrintEngine::SetPrintPO(nsPrintObject*
 }
 
 //---------------------------------------------------------------------
 // This will first use a Title and/or URL from the PrintSettings
 // if one isn't set then it uses the one from the document
 // then if not title is there we will make sure we send something back
 // depending on the situation.
 void
-nsPrintEngine::GetDisplayTitleAndURL(const UniquePtr<nsPrintObject>& aPO,
-                                     nsAString&       aTitle,
-                                     nsAString&       aURLStr,
-                                     eDocTitleDefault aDefType)
+nsPrintJob::GetDisplayTitleAndURL(const UniquePtr<nsPrintObject>& aPO,
+                                  nsAString& aTitle,
+                                  nsAString& aURLStr,
+                                  eDocTitleDefault aDefType)
 {
   NS_ASSERTION(aPO, "Pointer is null!");
 
   if (!mPrt)
     return;
 
   aTitle.Truncate();
   aURLStr.Truncate();
@@ -1492,17 +1498,18 @@ nsPrintEngine::GetDisplayTitleAndURL(con
           aTitle = mPrt->mBrandName;
         }
       }
     }
   }
 }
 
 //---------------------------------------------------------------------
-nsresult nsPrintEngine::DocumentReadyForPrinting()
+nsresult
+nsPrintJob::DocumentReadyForPrinting()
 {
   if (mPrt->mPrintFrameType == nsIPrintSettings::kEachFrameSep) {
     // Guarantee that mPrt->mPrintObject won't be deleted during a call of
     // CheckForChildFrameSets().
     RefPtr<nsPrintData> printData = mPrt;
     CheckForChildFrameSets(printData->mPrintObject);
   }
 
@@ -1516,17 +1523,18 @@ nsresult nsPrintEngine::DocumentReadyFor
     DonePrintingPages(nullptr, rv);
   }
   return rv;
 }
 
 /** ---------------------------------------------------
  *  Cleans up when an error occurred
  */
-nsresult nsPrintEngine::CleanupOnFailure(nsresult aResult, bool aIsPrinting)
+nsresult
+nsPrintJob::CleanupOnFailure(nsresult aResult, bool aIsPrinting)
 {
   PR_PL(("****  Failed %s - rv 0x%" PRIX32, aIsPrinting?"Printing":"Print Preview",
          static_cast<uint32_t>(aResult)));
 
   /* cleanup... */
   if (mPagePrintTimer) {
     mPagePrintTimer->Stop();
     DisconnectPagePrintTimer();
@@ -1552,17 +1560,17 @@ nsresult nsPrintEngine::CleanupOnFailure
   FirePrintCompletionEvent();
 
   return aResult;
 
 }
 
 //---------------------------------------------------------------------
 void
-nsPrintEngine::FirePrintingErrorEvent(nsresult aPrintError)
+nsPrintJob::FirePrintingErrorEvent(nsresult aPrintError)
 {
   nsCOMPtr<nsIContentViewer> cv = do_QueryInterface(mDocViewerPrint);
   if (NS_WARN_IF(!cv)) {
     return;
   }
 
   nsCOMPtr<nsIDocument> doc = cv->GetDocument();
   RefPtr<CustomEvent> event =
@@ -1593,17 +1601,17 @@ nsPrintEngine::FirePrintingErrorEvent(ns
   }
 }
 
 //-----------------------------------------------------------------
 //-- Section: Reflow Methods
 //-----------------------------------------------------------------
 
 nsresult
-nsPrintEngine::ReconstructAndReflow(bool doSetPixelScale)
+nsPrintJob::ReconstructAndReflow(bool doSetPixelScale)
 {
   if (NS_WARN_IF(!mPrt)) {
     return NS_ERROR_FAILURE;
   }
 
 #if defined(XP_WIN) && defined(EXTENDED_DEBUG_PRINTING)
   // We need to clear all the output files here
   // because they will be re-created with second reflow of the docs
@@ -1677,17 +1685,17 @@ nsPrintEngine::ReconstructAndReflow(bool
     nsresult rv = UpdateSelectionAndShrinkPrintObject(po, documentIsTopLevel);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   return NS_OK;
 }
 
 //-------------------------------------------------------
 nsresult
-nsPrintEngine::SetupToPrintContent()
+nsPrintJob::SetupToPrintContent()
 {
   // This method may be called while DoCommonPrint() initializes the instance
   // when its script blocker goes out of scope.  In such case, this cannot do
   // its job as expected because some objects in mPrt have not been initialized
   // yet but they are necessary.
   // Note: it shouldn't be possible for mPrt->mPrintObject to be null; we check
   // it for good measure (after we check its owner) before we start
   // dereferencing it below.
@@ -1886,18 +1894,18 @@ nsPrintEngine::SetupToPrintContent()
 
   return rv;
 }
 
 //-------------------------------------------------------
 // Recursively reflow each sub-doc and then calc
 // all the frame locations of the sub-docs
 nsresult
-nsPrintEngine::ReflowDocList(const UniquePtr<nsPrintObject>& aPO,
-                             bool aSetPixelScale)
+nsPrintJob::ReflowDocList(const UniquePtr<nsPrintObject>& aPO,
+                          bool aSetPixelScale)
 {
   NS_ENSURE_ARG_POINTER(aPO);
 
   // Check to see if the subdocument's element has been hidden by the parent document
   if (aPO->mParent && aPO->mParent->mPresShell) {
     nsIFrame* frame = aPO->mContent ? aPO->mContent->GetPrimaryFrame() : nullptr;
     if (!frame || !frame->StyleVisibility()->IsVisible()) {
       SetPrintPO(aPO.get(), false);
@@ -1916,30 +1924,30 @@ nsPrintEngine::ReflowDocList(const Uniqu
   for (const UniquePtr<nsPrintObject>& kid : aPO->mKids) {
     rv = ReflowDocList(kid, aSetPixelScale);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   return NS_OK;
 }
 
 void
-nsPrintEngine::FirePrintPreviewUpdateEvent()
+nsPrintJob::FirePrintPreviewUpdateEvent()
 {
   // Dispatch the event only while in PrintPreview. When printing, there is no
   // listener bound to this event and therefore no need to dispatch it.
   if (mIsDoingPrintPreview && !mIsDoingPrinting) {
     nsCOMPtr<nsIContentViewer> cv = do_QueryInterface(mDocViewerPrint);
     (new AsyncEventDispatcher(
        cv->GetDocument(), NS_LITERAL_STRING("printPreviewUpdate"), true, true)
     )->RunDOMEventWhenSafe();
   }
 }
 
 nsresult
-nsPrintEngine::InitPrintDocConstruction(bool aHandleError)
+nsPrintJob::InitPrintDocConstruction(bool aHandleError)
 {
   nsresult rv;
   // Guarantee that mPrt->mPrintObject won't be deleted.  It's owned by mPrt.
   // So, we should grab it with local variable.
   RefPtr<nsPrintData> printData = mPrt;
   rv = ReflowDocList(printData->mPrintObject, DoSetPixelScale());
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -1947,17 +1955,17 @@ nsPrintEngine::InitPrintDocConstruction(
 
   if (mLoadCounter == 0) {
     AfterNetworkPrint(aHandleError);
   }
   return rv;
 }
 
 nsresult
-nsPrintEngine::AfterNetworkPrint(bool aHandleError)
+nsPrintJob::AfterNetworkPrint(bool aHandleError)
 {
   // If Destroy() has already been called, mPtr is nullptr.  Then, the instance
   // needs to do nothing anymore in this method.
   // Note: it shouldn't be possible for mPrt->mPrintObject to be null; we
   // just check it for good measure, as we check its owner.
   // Note: it shouldn't be possible for mPrt->mPrintObject->mDocShell to be
   // null; we just check it for good measure, as we check its owner.
   if (!mPrt ||
@@ -1975,31 +1983,31 @@ nsPrintEngine::AfterNetworkPrint(bool aH
   if (mIsDoingPrinting) {
     rv = DocumentReadyForPrinting();
   } else {
     rv = FinishPrintPreview();
   }
 
   /* cleaup on failure + notify user */
   if (aHandleError && NS_FAILED(rv)) {
-    NS_WARNING("nsPrintEngine::AfterNetworkPrint failed");
+    NS_WARNING("nsPrintJob::AfterNetworkPrint failed");
     CleanupOnFailure(rv, !mIsDoingPrinting);
   }
 
   return rv;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIWebProgressListener
 
 NS_IMETHODIMP
-nsPrintEngine::OnStateChange(nsIWebProgress* aWebProgress,
-                             nsIRequest* aRequest,
-                             uint32_t aStateFlags,
-                             nsresult aStatus)
+nsPrintJob::OnStateChange(nsIWebProgress* aWebProgress,
+                          nsIRequest* aRequest,
+                          uint32_t aStateFlags,
+                          nsresult aStatus)
 {
   nsAutoCString name;
   aRequest->GetName(name);
   if (name.EqualsLiteral("about:document-onload-blocker")) {
     return NS_OK;
   }
   if (aStateFlags & STATE_START) {
     ++mLoadCounter;
@@ -2012,62 +2020,61 @@ nsPrintEngine::OnStateChange(nsIWebProgr
     if (mLoadCounter == 0) {
       AfterNetworkPrint(true);
     }
   }
   return NS_OK;
 }
 
 
-
 NS_IMETHODIMP
-nsPrintEngine::OnProgressChange(nsIWebProgress* aWebProgress,
-                                 nsIRequest* aRequest,
-                                 int32_t aCurSelfProgress,
-                                 int32_t aMaxSelfProgress,
-                                 int32_t aCurTotalProgress,
-                                 int32_t aMaxTotalProgress)
+nsPrintJob::OnProgressChange(nsIWebProgress* aWebProgress,
+                             nsIRequest* aRequest,
+                             int32_t aCurSelfProgress,
+                             int32_t aMaxSelfProgress,
+                             int32_t aCurTotalProgress,
+                             int32_t aMaxTotalProgress)
 {
   NS_NOTREACHED("notification excluded in AddProgressListener(...)");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPrintEngine::OnLocationChange(nsIWebProgress* aWebProgress,
-                                nsIRequest* aRequest,
-                                nsIURI* aLocation,
-                                uint32_t aFlags)
+nsPrintJob::OnLocationChange(nsIWebProgress* aWebProgress,
+                             nsIRequest* aRequest,
+                             nsIURI* aLocation,
+                             uint32_t aFlags)
 {
   NS_NOTREACHED("notification excluded in AddProgressListener(...)");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPrintEngine::OnStatusChange(nsIWebProgress *aWebProgress,
-                              nsIRequest *aRequest,
-                              nsresult aStatus,
-                              const char16_t *aMessage)
+nsPrintJob::OnStatusChange(nsIWebProgress* aWebProgress,
+                           nsIRequest* aRequest,
+                           nsresult aStatus,
+                           const char16_t* aMessage)
 {
   NS_NOTREACHED("notification excluded in AddProgressListener(...)");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPrintEngine::OnSecurityChange(nsIWebProgress *aWebProgress,
-                                  nsIRequest *aRequest,
-                                  uint32_t aState)
+nsPrintJob::OnSecurityChange(nsIWebProgress* aWebProgress,
+                             nsIRequest* aRequest,
+                             uint32_t aState)
 {
   NS_NOTREACHED("notification excluded in AddProgressListener(...)");
   return NS_OK;
 }
 
 //-------------------------------------------------------
 
 void
-nsPrintEngine::UpdateZoomRatio(nsPrintObject* aPO, bool aSetPixelScale)
+nsPrintJob::UpdateZoomRatio(nsPrintObject* aPO, bool aSetPixelScale)
 {
   // Here is where we set the shrinkage value into the DC
   // and this is what actually makes it shrink
   if (aSetPixelScale && aPO->mFrameType != eIFrame) {
     float ratio;
     if (mPrt->mPrintFrameType == nsIPrintSettings::kFramesAsIs || mPrt->mPrintFrameType == nsIPrintSettings::kNoFrames) {
       ratio = mPrt->mShrinkRatio - 0.005f; // round down
     } else {
@@ -2077,18 +2084,18 @@ nsPrintEngine::UpdateZoomRatio(nsPrintOb
   } else if (!mPrt->mShrinkToFit) {
     double scaling;
     mPrt->mPrintSettings->GetScaling(&scaling);
     aPO->mZoomRatio = float(scaling);
   }
 }
 
 nsresult
-nsPrintEngine::UpdateSelectionAndShrinkPrintObject(nsPrintObject* aPO,
-                                                   bool aDocumentIsTopLevel)
+nsPrintJob::UpdateSelectionAndShrinkPrintObject(nsPrintObject* aPO,
+                                                bool aDocumentIsTopLevel)
 {
   nsCOMPtr<nsIPresShell> displayShell = aPO->mDocShell->GetPresShell();
   // Transfer Selection Ranges to the new Print PresShell
   RefPtr<Selection> selection, selectionPS;
   // It's okay if there is no display shell, just skip copying the selection
   if (displayShell) {
     selection = displayShell->GetCurrentSelection(SelectionType::eNormal);
   }
@@ -2128,17 +2135,17 @@ nsPrintEngine::UpdateSelectionAndShrinkP
       float minShrinkRatio = float(limitPercent) / 100;
       aPO->mShrinkRatio = std::max(aPO->mShrinkRatio, minShrinkRatio);
     }
   }
   return NS_OK;
 }
 
 bool
-nsPrintEngine::DoSetPixelScale()
+nsPrintJob::DoSetPixelScale()
 {
   // This is an Optimization
   // If we are in PP then we already know all the shrinkage information
   // so just transfer it to the PrintData and we will skip the extra shrinkage reflow
   //
   // doSetPixelScale tells Reflow whether to set the shrinkage value into the DC
   // The first time we do not want to do this, the second time through we do
   bool doSetPixelScale = false;
@@ -2146,34 +2153,32 @@ nsPrintEngine::DoSetPixelScale()
   if (ppIsShrinkToFit) {
     mPrt->mShrinkRatio = mPrtPreview->mShrinkRatio;
     doSetPixelScale = true;
   }
   return doSetPixelScale;
 }
 
 nsView*
-nsPrintEngine::GetParentViewForRoot()
+nsPrintJob::GetParentViewForRoot()
 {
   if (mIsCreatingPrintPreview) {
     nsCOMPtr<nsIContentViewer> cv = do_QueryInterface(mDocViewerPrint);
     if (cv) {
       return cv->FindContainerView();
     }
   }
   return nullptr;
 }
 
 nsresult
-nsPrintEngine::SetRootView(
-    nsPrintObject* aPO,
-    bool& doReturn,
-    bool& documentIsTopLevel,
-    nsSize& adjSize
-)
+nsPrintJob::SetRootView(nsPrintObject* aPO,
+                        bool& doReturn,
+                        bool& documentIsTopLevel,
+                        nsSize& adjSize)
 {
   bool canCreateScrollbars = true;
 
   nsView* rootView;
   nsView* parentView = nullptr;
 
   doReturn = false;
 
@@ -2231,17 +2236,17 @@ nsPrintEngine::SetRootView(
   // Setup hierarchical relationship in view manager
   aPO->mViewManager->SetRootView(rootView);
 
   return NS_OK;
 }
 
 // Reflow a nsPrintObject
 nsresult
-nsPrintEngine::ReflowPrintObject(const UniquePtr<nsPrintObject>& aPO)
+nsPrintJob::ReflowPrintObject(const UniquePtr<nsPrintObject>& aPO)
 {
   NS_ENSURE_STATE(aPO);
 
   if (!aPO->IsPrintable()) {
     return NS_OK;
   }
 
   NS_ASSERTION(!aPO->mPresContext, "Recreating prescontext");
@@ -2392,17 +2397,17 @@ nsPrintEngine::ReflowPrintObject(const U
 #endif
 
   return NS_OK;
 }
 
 //-------------------------------------------------------
 // Figure out how many documents and how many total pages we are printing
 void
-nsPrintEngine::CalcNumPrintablePages(int32_t& aNumPages)
+nsPrintJob::CalcNumPrintablePages(int32_t& aNumPages)
 {
   aNumPages = 0;
   // Count the number of printable documents
   // and printable pages
   for (uint32_t i=0; i<mPrt->mPrintDocList.Length(); i++) {
     nsPrintObject* po = mPrt->mPrintDocList.ElementAt(i);
     NS_ASSERTION(po, "nsPrintObject can't be null!");
     // Note: The po->mPresContext null-check below is necessary, because it's
@@ -2425,18 +2430,18 @@ nsPrintEngine::CalcNumPrintablePages(int
 
 //-----------------------------------------------------------------
 //-- Section: Printing Methods
 //-----------------------------------------------------------------
 
 //-------------------------------------------------------
 // Called for each DocShell that needs to be printed
 bool
-nsPrintEngine::PrintDocContent(const UniquePtr<nsPrintObject>& aPO,
-                               nsresult& aStatus)
+nsPrintJob::PrintDocContent(const UniquePtr<nsPrintObject>& aPO,
+                            nsresult& aStatus)
 {
   NS_ASSERTION(aPO, "Pointer is null!");
   aStatus = NS_OK;
 
   if (!aPO->mHasBeenPrinted && aPO->IsPrintable()) {
     aStatus = DoPrint(aPO);
     return true;
   }
@@ -2565,17 +2570,17 @@ DeleteUnselectedNodes(nsIDocument* aOrig
   }
 
   selection->DeleteFromDocument();
   return NS_OK;
 }
 
 //-------------------------------------------------------
 nsresult
-nsPrintEngine::DoPrint(const UniquePtr<nsPrintObject>& aPO)
+nsPrintJob::DoPrint(const UniquePtr<nsPrintObject>& aPO)
 {
   PR_PL(("\n"));
   PR_PL(("**************************** %s ****************************\n", gFrameTypesStr[aPO->mFrameType]));
   PR_PL(("****** In DV::DoPrint   PO: %p \n", aPO.get()));
 
   nsIPresShell*   poPresShell   = aPO->mPresShell;
   nsPresContext*  poPresContext = aPO->mPresContext;
 
@@ -2636,18 +2641,18 @@ nsPrintEngine::DoPrint(const UniquePtr<n
     StartPagePrintTimer(aPO);
   }
 
   return NS_OK;
 }
 
 //---------------------------------------------------------------------
 void
-nsPrintEngine::SetDocAndURLIntoProgress(const UniquePtr<nsPrintObject>& aPO,
-                                        nsIPrintProgressParams* aParams)
+nsPrintJob::SetDocAndURLIntoProgress(const UniquePtr<nsPrintObject>& aPO,
+                                     nsIPrintProgressParams* aParams)
 {
   NS_ASSERTION(aPO, "Must have valid nsPrintObject");
   NS_ASSERTION(aParams, "Must have valid nsIPrintProgressParams");
 
   if (!aPO || !aPO->mDocShell || !aParams) {
     return;
   }
   const uint32_t kTitleLength = 64;
@@ -2661,17 +2666,17 @@ nsPrintEngine::SetDocAndURLIntoProgress(
   EllipseLongString(docURLStr, kTitleLength, true);
 
   aParams->SetDocTitle(docTitleStr);
   aParams->SetDocURL(docURLStr);
 }
 
 //---------------------------------------------------------------------
 void
-nsPrintEngine::EllipseLongString(nsAString& aStr, const uint32_t aLen, bool aDoFront)
+nsPrintJob::EllipseLongString(nsAString& aStr, const uint32_t aLen, bool aDoFront)
 {
   // Make sure the URLS don't get too long for the progress dialog
   if (aLen >= 3 && aStr.Length() > aLen) {
     if (aDoFront) {
       nsAutoString newStr;
       newStr.AppendLiteral("...");
       newStr += Substring(aStr, aStr.Length() - (aLen - 3), aLen - 3);
       aStr = newStr;
@@ -2717,31 +2722,31 @@ DocHasPrintCallbackCanvas(nsIDocument* a
 }
 
 /**
  * Checks to see if the document this print engine is associated with has any
  * canvases that have a mozPrintCallback.
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement#Properties
  */
 bool
-nsPrintEngine::HasPrintCallbackCanvas()
+nsPrintJob::HasPrintCallbackCanvas()
 {
   if (!mDocument) {
     return false;
   }
   // First check this mDocument.
   bool result = false;
   DocHasPrintCallbackCanvas(mDocument, static_cast<void*>(&result));
   // Also check the sub documents.
   return result || DocHasPrintCallbackCanvas(mDocument);
 }
 
 //-------------------------------------------------------
 bool
-nsPrintEngine::PrePrintPage()
+nsPrintJob::PrePrintPage()
 {
   NS_ASSERTION(mPageSeqFrame.IsAlive(), "mPageSeqFrame is not alive!");
   NS_ASSERTION(mPrt,           "mPrt is null!");
 
   // Although these should NEVER be nullptr
   // This is added insurance, to make sure we don't crash in optimized builds
   if (!mPrt || !mPageSeqFrame.IsAlive()) {
     return true; // means we are done preparing the page.
@@ -2772,18 +2777,18 @@ nsPrintEngine::PrePrintPage()
       printData->mIsAborted = true;
     }
     done = true;
   }
   return done;
 }
 
 bool
-nsPrintEngine::PrintPage(nsPrintObject*    aPO,
-                         bool&           aInRange)
+nsPrintJob::PrintPage(nsPrintObject* aPO,
+                      bool& aInRange)
 {
   NS_ASSERTION(aPO,            "aPO is null!");
   NS_ASSERTION(mPageSeqFrame.IsAlive(), "mPageSeqFrame is not alive!");
   NS_ASSERTION(mPrt,           "mPrt is null!");
 
   // Although these should NEVER be nullptr
   // This is added insurance, to make sure we don't crash in optimized builds
   if (!mPrt || !aPO || !mPageSeqFrame.IsAlive()) {
@@ -2874,17 +2879,17 @@ nsPrintEngine::PrintPage(nsPrintObject* 
   }
 
   pageSeqFrame->DoPageEnd();
 
   return donePrinting;
 }
 
 void
-nsPrintEngine::PageDone(nsresult aResult)
+nsPrintJob::PageDone(nsresult aResult)
 {
   MOZ_ASSERT(mIsDoingPrinting);
 
   // mPagePrintTimer might be released during RemotePrintFinished, keep a
   // reference here to make sure it lives long enough.
   RefPtr<nsPagePrintTimer> timer = mPagePrintTimer;
   timer->RemotePrintFinished();
 }
@@ -2894,54 +2899,57 @@ nsPrintEngine::PageDone(nsresult aResult
 //-----------------------------------------------------------------
 
 
 //-----------------------------------------------------------------
 //-- Section: Misc Support Methods
 //-----------------------------------------------------------------
 
 //---------------------------------------------------------------------
-void nsPrintEngine::SetIsPrinting(bool aIsPrinting)
+void
+nsPrintJob::SetIsPrinting(bool aIsPrinting)
 {
   mIsDoingPrinting = aIsPrinting;
   // Calling SetIsPrinting while in print preview confuses the document viewer
   // This is safe because we prevent exiting print preview while printing
   if (!mIsDoingPrintPreview && mDocViewerPrint) {
     mDocViewerPrint->SetIsPrinting(aIsPrinting);
   }
   if (mPrt && aIsPrinting) {
     mPrt->mPreparingForPrint = true;
   }
 }
 
 //---------------------------------------------------------------------
-void nsPrintEngine::SetIsPrintPreview(bool aIsPrintPreview)
+void
+nsPrintJob::SetIsPrintPreview(bool aIsPrintPreview)
 {
   mIsDoingPrintPreview = aIsPrintPreview;
 
   if (mDocViewerPrint) {
     mDocViewerPrint->SetIsPrintPreview(aIsPrintPreview);
   }
 }
 
 //---------------------------------------------------------------------
 void
-nsPrintEngine::CleanupDocTitleArray(char16_t**& aArray, int32_t& aCount)
+nsPrintJob::CleanupDocTitleArray(char16_t**& aArray, int32_t& aCount)
 {
   for (int32_t i = aCount - 1; i >= 0; i--) {
     free(aArray[i]);
   }
   free(aArray);
   aArray = nullptr;
   aCount = 0;
 }
 
 //---------------------------------------------------------------------
 // static
-bool nsPrintEngine::HasFramesetChild(nsIContent* aContent)
+bool
+nsPrintJob::HasFramesetChild(nsIContent* aContent)
 {
   if (!aContent) {
     return false;
   }
 
   // do a breadth search across all siblings
   for (nsIContent* child = aContent->GetFirstChild();
        child;
@@ -2955,17 +2963,17 @@ bool nsPrintEngine::HasFramesetChild(nsI
 }
 
 
 
 /** ---------------------------------------------------
  *  Get the Focused Frame for a documentviewer
  */
 already_AddRefed<nsPIDOMWindowOuter>
-nsPrintEngine::FindFocusedDOMWindow()
+nsPrintJob::FindFocusedDOMWindow()
 {
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
   NS_ENSURE_TRUE(fm, nullptr);
 
   nsPIDOMWindowOuter* window = mDocument->GetWindow();
   NS_ENSURE_TRUE(window, nullptr);
 
   nsCOMPtr<nsPIDOMWindowOuter> rootWindow = window->GetPrivateRoot();
@@ -2981,17 +2989,17 @@ nsPrintEngine::FindFocusedDOMWindow()
     return focusedWindow.forget();
   }
 
   return nullptr;
 }
 
 //---------------------------------------------------------------------
 bool
-nsPrintEngine::IsWindowsInOurSubTree(nsPIDOMWindowOuter* window)
+nsPrintJob::IsWindowsInOurSubTree(nsPIDOMWindowOuter* window)
 {
   bool found = false;
 
   // now check to make sure it is in "our" tree of docshells
   if (window) {
     nsCOMPtr<nsIDocShell> docShell = window->GetDocShell();
 
     if (docShell) {
@@ -3013,17 +3021,17 @@ nsPrintEngine::IsWindowsInOurSubTree(nsP
     }
   } // scriptobj
 
   return found;
 }
 
 //-------------------------------------------------------
 bool
-nsPrintEngine::DonePrintingPages(nsPrintObject* aPO, nsresult aResult)
+nsPrintJob::DonePrintingPages(nsPrintObject* aPO, nsresult aResult)
 {
   //NS_ASSERTION(aPO, "Pointer is null!");
   PR_PL(("****** In DV::DonePrintingPages PO: %p (%s)\n", aPO, aPO?gFrameTypesStr[aPO->mFrameType]:""));
 
   // If there is a pageSeqFrame, make sure there are no more printCanvas active
   // that might call |Notify| on the pagePrintTimer after things are cleaned up
   // and printing was marked as being done.
   if (mPageSeqFrame.IsAlive()) {
@@ -3063,31 +3071,31 @@ nsPrintEngine::DonePrintingPages(nsPrint
 
   return true;
 }
 
 //-------------------------------------------------------
 // Recursively sets the PO items to be printed "As Is"
 // from the given item down into the tree
 void
-nsPrintEngine::SetPrintAsIs(nsPrintObject* aPO, bool aAsIs)
+nsPrintJob::SetPrintAsIs(nsPrintObject* aPO, bool aAsIs)
 {
   NS_ASSERTION(aPO, "Pointer is null!");
 
   aPO->mPrintAsIs = aAsIs;
   for (const UniquePtr<nsPrintObject>& kid : aPO->mKids) {
     SetPrintAsIs(kid.get(), aAsIs);
   }
 }
 
 //-------------------------------------------------------
 // Given a DOMWindow it recursively finds the PO object that matches
 nsPrintObject*
-nsPrintEngine::FindPrintObjectByDOMWin(nsPrintObject* aPO,
-                                       nsPIDOMWindowOuter* aDOMWin)
+nsPrintJob::FindPrintObjectByDOMWin(nsPrintObject* aPO,
+                                    nsPIDOMWindowOuter* aDOMWin)
 {
   NS_ASSERTION(aPO, "Pointer is null!");
 
   // Often the CurFocused DOMWindow is passed in
   // andit is valid for it to be null, so short circut
   if (!aDOMWin) {
     return nullptr;
   }
@@ -3104,17 +3112,17 @@ nsPrintEngine::FindPrintObjectByDOMWin(n
     }
   }
 
   return nullptr;
 }
 
 //-------------------------------------------------------
 nsresult
-nsPrintEngine::EnablePOsForPrinting()
+nsPrintJob::EnablePOsForPrinting()
 {
   // Guarantee that mPrt and the objects it owns won't be deleted.
   RefPtr<nsPrintData> printData = mPrt;
 
   // NOTE: All POs have been "turned off" for printing
   // this is where we decided which POs get printed.
 
   if (!printData->mPrintSettings) {
@@ -3126,17 +3134,17 @@ nsPrintEngine::EnablePOsForPrinting()
 
   int16_t printHowEnable = nsIPrintSettings::kFrameEnableNone;
   printData->mPrintSettings->GetHowToEnableFrameUI(&printHowEnable);
 
   int16_t printRangeType = nsIPrintSettings::kRangeAllPages;
   printData->mPrintSettings->GetPrintRange(&printRangeType);
 
   PR_PL(("\n"));
-  PR_PL(("********* nsPrintEngine::EnablePOsForPrinting *********\n"));
+  PR_PL(("********* nsPrintJob::EnablePOsForPrinting *********\n"));
   PR_PL(("PrintFrameType:     %s \n",
          gPrintFrameTypeStr[printData->mPrintFrameType]));
   PR_PL(("HowToEnableFrameUI: %s \n", gFrameHowToEnableStr[printHowEnable]));
   PR_PL(("PrintRange:         %s \n", gPrintRangeStr[printRangeType]));
   PR_PL(("----\n"));
 
   // ***** This is the ultimate override *****
   // if we are printing the selection (either an IFrame or selection range)
@@ -3315,17 +3323,17 @@ nsPrintEngine::EnablePOsForPrinting()
 
   return NS_OK;
 }
 
 //-------------------------------------------------------
 // Return the nsPrintObject with that is XMost (The widest frameset frame) AND
 // contains the XMost (widest) layout frame
 nsPrintObject*
-nsPrintEngine::FindSmallestSTF()
+nsPrintJob::FindSmallestSTF()
 {
   float smallestRatio = 1.0f;
   nsPrintObject* smallestPO = nullptr;
 
   for (uint32_t i=0;i<mPrt->mPrintDocList.Length();i++) {
     nsPrintObject* po = mPrt->mPrintDocList.ElementAt(i);
     NS_ASSERTION(po, "nsPrintObject can't be null!");
     if (po->mFrameType != eFrameSet && po->mFrameType != eIFrame) {
@@ -3339,17 +3347,17 @@ nsPrintEngine::FindSmallestSTF()
 #ifdef EXTENDED_DEBUG_PRINTING
   if (smallestPO) printf("*PO: %p  Type: %d  %10.3f\n", smallestPO, smallestPO->mFrameType, smallestPO->mShrinkRatio);
 #endif
   return smallestPO;
 }
 
 //-------------------------------------------------------
 void
-nsPrintEngine::TurnScriptingOn(bool aDoTurnOn)
+nsPrintJob::TurnScriptingOn(bool aDoTurnOn)
 {
   if (mIsDoingPrinting && aDoTurnOn && mDocViewerPrint &&
       mDocViewerPrint->GetIsPrintPreview()) {
     // We don't want to turn scripting on if print preview is shown still after
     // printing.
     return;
   }
 
@@ -3412,26 +3420,26 @@ nsPrintEngine::TurnScriptingOn(bool aDoT
 
 
 //-----------------------------------------------------------------
 //-- Section: Finishing up or Cleaning up
 //-----------------------------------------------------------------
 
 //-----------------------------------------------------------------
 void
-nsPrintEngine::CloseProgressDialog(nsIWebProgressListener* aWebProgressListener)
+nsPrintJob::CloseProgressDialog(nsIWebProgressListener* aWebProgressListener)
 {
   if (aWebProgressListener) {
     aWebProgressListener->OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP|nsIWebProgressListener::STATE_IS_DOCUMENT, NS_OK);
   }
 }
 
 //-----------------------------------------------------------------
 nsresult
-nsPrintEngine::FinishPrintPreview()
+nsPrintJob::FinishPrintPreview()
 {
   nsresult rv = NS_OK;
 
 #ifdef NS_PRINT_PREVIEW
 
   if (!mPrt) {
     /* we're already finished with print preview */
     return rv;
@@ -3485,17 +3493,17 @@ nsPrintEngine::FinishPrintPreview()
 
 //-----------------------------------------------------------------
 //-- Done: Finishing up or Cleaning up
 //-----------------------------------------------------------------
 
 
 /*=============== Timer Related Code ======================*/
 nsresult
-nsPrintEngine::StartPagePrintTimer(const UniquePtr<nsPrintObject>& aPO)
+nsPrintJob::StartPagePrintTimer(const UniquePtr<nsPrintObject>& aPO)
 {
   if (!mPagePrintTimer) {
     // Get the delay time in between the printing of each page
     // this gives the user more time to press cancel
     int32_t printPageDelay = 50;
     mPrt->mPrintSettings->GetPrintPageDelay(&printPageDelay);
 
     nsCOMPtr<nsIContentViewer> cv = do_QueryInterface(mDocViewerPrint);
@@ -3509,27 +3517,27 @@ nsPrintEngine::StartPagePrintTimer(const
 
     nsCOMPtr<nsIPrintSession> printSession;
     nsresult rv = mPrt->mPrintSettings->GetPrintSession(getter_AddRefs(printSession));
     if (NS_SUCCEEDED(rv) && printSession) {
       RefPtr<mozilla::layout::RemotePrintJobChild> remotePrintJob;
       printSession->GetRemotePrintJob(getter_AddRefs(remotePrintJob));
       if (NS_SUCCEEDED(rv) && remotePrintJob) {
         remotePrintJob->SetPagePrintTimer(mPagePrintTimer);
-        remotePrintJob->SetPrintEngine(this);
+        remotePrintJob->SetPrintJob(this);
       }
     }
   }
 
   return mPagePrintTimer->Start(aPO.get());
 }
 
 /*=============== nsIObserver Interface ======================*/
 NS_IMETHODIMP
-nsPrintEngine::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *aData)
+nsPrintJob::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
 {
   nsresult rv = NS_ERROR_FAILURE;
 
   rv = InitPrintDocConstruction(true);
   if (!mIsDoingPrinting && mPrtPreview) {
     RefPtr<nsPrintData> printDataOfPrintPreview = mPrtPreview;
     printDataOfPrintPreview->OnEndPrinting();
   }
@@ -3557,30 +3565,30 @@ public:
   }
 
 private:
   nsCOMPtr<nsIDocumentViewerPrint> mDocViewerPrint;
 };
 
 //-----------------------------------------------------------
 void
-nsPrintEngine::FirePrintCompletionEvent()
+nsPrintJob::FirePrintCompletionEvent()
 {
   MOZ_ASSERT(NS_IsMainThread());
   nsCOMPtr<nsIRunnable> event = new nsPrintCompletionEvent(mDocViewerPrint);
   nsCOMPtr<nsIContentViewer> cv = do_QueryInterface(mDocViewerPrint);
   NS_ENSURE_TRUE_VOID(cv);
   nsCOMPtr<nsIDocument> doc = cv->GetDocument();
   NS_ENSURE_TRUE_VOID(doc);
 
   NS_ENSURE_SUCCESS_VOID(doc->Dispatch(TaskCategory::Other, event.forget()));
 }
 
 void
-nsPrintEngine::DisconnectPagePrintTimer()
+nsPrintJob::DisconnectPagePrintTimer()
 {
   if (mPagePrintTimer) {
     mPagePrintTimer->Disconnect();
     NS_RELEASE(mPagePrintTimer);
   }
 }
 
 //---------------------------------------------------------------
@@ -3704,17 +3712,17 @@ static void DumpFrames(FILE*            
 static void
 DumpViews(nsIDocShell* aDocShell, FILE* out)
 {
   NS_ASSERTION(aDocShell, "Pointer is null!");
   NS_ASSERTION(out, "Pointer is null!");
 
   if (nullptr != aDocShell) {
     fprintf(out, "docshell=%p \n", aDocShell);
-    nsIPresShell* shell = nsPrintEngine::GetPresShellFor(aDocShell);
+    nsIPresShell* shell = nsPrintJob::GetPresShellFor(aDocShell);
     if (shell) {
       nsViewManager* vm = shell->GetViewManager();
       if (vm) {
         nsView* root = vm->GetRootView();
         if (root) {
           root->List(out);
         }
       }
@@ -3852,19 +3860,19 @@ static void DumpPrintObjectsTree(nsPrint
 
 //-------------------------------------------------------------
 static void GetDocTitleAndURL(const UniquePtr<nsPrintObject>& aPO,
                               nsACString& aDocStr,
                               nsACString& aURLStr)
 {
   nsAutoString docTitleStr;
   nsAutoString docURLStr;
-  nsPrintEngine::GetDisplayTitleAndURL(aPO,
-                                       docTitleStr, docURLStr,
-                                       nsPrintEngine::eDocTitleDefURLDoc);
+  nsPrintJob::GetDisplayTitleAndURL(aPO,
+                                    docTitleStr, docURLStr,
+                                    nsPrintJob::eDocTitleDefURLDoc);
   aDocStr = NS_ConvertUTF16toUTF8(docTitleStr);
   aURLStr = NS_ConvertUTF16toUTF8(docURLStr);
 }
 
 //-------------------------------------------------------------
 static void DumpPrintObjectsTreeLayout(nsPrintObject * aPO,
                                        nsDeviceContext * aDC,
                                        int aLevel, FILE * aFD)
rename from layout/printing/nsPrintEngine.h
rename to layout/printing/nsPrintJob.h
--- a/layout/printing/nsPrintEngine.h
+++ b/layout/printing/nsPrintJob.h
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#ifndef nsPrintEngine_h___
-#define nsPrintEngine_h___
+#ifndef nsPrintJob_h
+#define nsPrintJob_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/UniquePtr.h"
 
 #include "nsCOMPtr.h"
 
 #include "nsPrintObject.h"
 #include "nsPrintData.h"
@@ -27,23 +27,23 @@
 class nsPagePrintTimer;
 class nsIDocShell;
 class nsIDocument;
 class nsIDocumentViewerPrint;
 class nsPrintObject;
 class nsIDocShell;
 class nsIPageSequenceFrame;
 
-//------------------------------------------------------------------------
-// nsPrintEngine Class
-//
-//------------------------------------------------------------------------
-class nsPrintEngine final : public nsIObserver,
-                            public nsIWebProgressListener,
-                            public nsSupportsWeakReference
+/**
+ * A print job may be instantiated either for printing to an actual physical
+ * printer, or for creating a print preview.
+ */
+class nsPrintJob final : public nsIObserver
+                       , public nsIWebProgressListener
+                       , public nsSupportsWeakReference
 {
 public:
   // nsISupports interface...
   NS_DECL_ISUPPORTS
 
   // nsIObserver
   NS_DECL_NSIOBSERVER
 
@@ -69,17 +69,17 @@ public:
 
   // This enum tells indicates what the default should be for the title
   // if the title from the document is null
   enum eDocTitleDefault {
     eDocTitleDefBlank,
     eDocTitleDefURLDoc
   };
 
-  nsPrintEngine();
+  nsPrintJob();
 
   void Destroy();
   void DestroyPrintingData();
 
   nsresult Initialize(nsIDocumentViewerPrint* aDocViewerPrint,
                       nsIDocShell*            aContainer,
                       nsIDocument*            aDocument,
                       float                   aScreenDPI);
@@ -153,19 +153,16 @@ public:
                                bool& aIsParentFrameSet);
 
   static nsPrintObject* FindPrintObjectByDOMWin(nsPrintObject* aParentObject,
                                                 nsPIDOMWindowOuter* aDOMWin);
 
   // get the currently infocus frame for the document viewer
   already_AddRefed<nsPIDOMWindowOuter> FindFocusedDOMWindow();
 
-  //---------------------------------------------------------------------
-  // Static Methods
-  //---------------------------------------------------------------------
   static void GetDocumentTitleAndURL(nsIDocument* aDoc,
                                      nsAString&   aTitle,
                                      nsAString&   aURLStr);
   void GetDisplayTitleAndURL(const mozilla::UniquePtr<nsPrintObject>& aPO,
                              nsAString&       aTitle,
                              nsAString&       aURLStr,
                              eDocTitleDefault aDefType);
 
@@ -201,18 +198,20 @@ public:
     return mIsCreatingPrintPreview;
   }
 
   void SetDisallowSelectionPrint(bool aDisallowSelectionPrint)
   {
     mDisallowSelectionPrint = aDisallowSelectionPrint;
   }
 
-protected:
-  ~nsPrintEngine();
+private:
+  nsPrintJob& operator=(const nsPrintJob& aOther) = delete;
+
+  ~nsPrintJob();
 
   nsresult CommonPrint(bool aIsPrintPreview, nsIPrintSettings* aPrintSettings,
                        nsIWebProgressListener* aWebProgressListener,
                        nsIDOMDocument* aDoc);
 
   nsresult DoCommonPrint(bool aIsPrintPreview, nsIPrintSettings* aPrintSettings,
                          nsIWebProgressListener* aWebProgressListener,
                          nsIDOMDocument* aDoc);
@@ -227,59 +226,59 @@ protected:
 
   static void MapContentToWebShells(const mozilla::UniquePtr<nsPrintObject>& aRootPO,
                                     const mozilla::UniquePtr<nsPrintObject>& aPO);
 
   static void SetPrintAsIs(nsPrintObject* aPO, bool aAsIs = true);
 
   void DisconnectPagePrintTimer();
 
-  // Static member variables
+  nsresult AfterNetworkPrint(bool aHandleError);
+
+  nsresult SetRootView(nsPrintObject* aPO,
+                       bool& aDoReturn,
+                       bool& aDocumentIsTopLevel,
+                       nsSize& aAdjSize);
+  nsView* GetParentViewForRoot();
+  bool DoSetPixelScale();
+  void UpdateZoomRatio(nsPrintObject* aPO, bool aSetPixelScale);
+  nsresult ReconstructAndReflow(bool aDoSetPixelScale);
+  nsresult UpdateSelectionAndShrinkPrintObject(nsPrintObject* aPO,
+                                               bool aDocumentIsTopLevel);
+  nsresult InitPrintDocConstruction(bool aHandleError);
+  void FirePrintPreviewUpdateEvent();
+
+  void PageDone(nsresult aResult);
+
+
   bool mIsCreatingPrintPreview;
   bool mIsDoingPrinting;
-  bool mIsDoingPrintPreview; // per DocumentViewer
+  bool mIsDoingPrintPreview;
   bool mProgressDialogIsShown;
 
   nsCOMPtr<nsIDocumentViewerPrint> mDocViewerPrint;
   nsWeakPtr               mContainer;
   float                   mScreenDPI;
 
   // We are the primary owner of our nsPrintData member vars.  These vars
   // are refcounted so that functions (e.g. nsPrintData methods) can create
   // temporary owning references when they need to fire a callback that
-  // could conceivably destroy this nsPrintEngine owner object and all its
+  // could conceivably destroy this nsPrintJob owner object and all its
   // member-data.
   RefPtr<nsPrintData> mPrt;
 
   nsPagePrintTimer*       mPagePrintTimer;
   WeakFrame               mPageSeqFrame;
 
   // Print Preview
   RefPtr<nsPrintData> mPrtPreview;
   RefPtr<nsPrintData> mOldPrtPreview;
 
   nsCOMPtr<nsIDocument>   mDocument;
 
   int32_t mLoadCounter;
   bool mDidLoadDataForPrinting;
   bool mIsDestroying;
   bool mDisallowSelectionPrint;
-
-  nsresult AfterNetworkPrint(bool aHandleError);
-
-  nsresult SetRootView(nsPrintObject* aPO,
-                       bool& aDoReturn,
-                       bool& aDocumentIsTopLevel,
-                       nsSize& aAdjSize);
-  nsView* GetParentViewForRoot();
-  bool DoSetPixelScale();
-  void UpdateZoomRatio(nsPrintObject* aPO, bool aSetPixelScale);
-  nsresult ReconstructAndReflow(bool aDoSetPixelScale);
-  nsresult UpdateSelectionAndShrinkPrintObject(nsPrintObject* aPO,
-                                               bool aDocumentIsTopLevel);
-  nsresult InitPrintDocConstruction(bool aHandleError);
-  void FirePrintPreviewUpdateEvent();
-private:
-  nsPrintEngine& operator=(const nsPrintEngine& aOther) = delete;
-  void PageDone(nsresult aResult);
 };
 
-#endif /* nsPrintEngine_h___ */
+#endif // nsPrintJob_h
+
--- a/toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp
+++ b/toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp
@@ -33,17 +33,17 @@ PrintProgressDialogChild::~PrintProgress
   // the parent to decrement its refcount, as well as prevent it from attempting
   // to contact us further.
   Unused << Send__delete__(this);
 }
 
 mozilla::ipc::IPCResult
 PrintProgressDialogChild::RecvDialogOpened()
 {
-  // nsPrintEngine's observer, which we're reporting to here, doesn't care
+  // nsPrintJob's observer, which we're reporting to here, doesn't care
   // what gets passed as the subject, topic or data, so we'll just send
   // nullptrs.
   mOpenObserver->Observe(nullptr, nullptr, nullptr);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 PrintProgressDialogChild::RecvCancelledCurrentJob()
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -492,17 +492,17 @@ PopupBlocking.init();
 
 XPCOMUtils.defineLazyGetter(this, "console", () => {
   // Set up console.* for frame scripts.
   let Console = Components.utils.import("resource://gre/modules/Console.jsm", {});
   return new Console.ConsoleAPI();
 });
 
 var Printing = {
-  // Bug 1088061: nsPrintEngine's DoCommonPrint currently expects the
+  // Bug 1088061: nsPrintJob's DoCommonPrint currently expects the
   // progress listener passed to it to QI to an nsIPrintingPromptService
   // in order to know that a printing progress dialog has been shown. That's
   // really all the interface is used for, hence the fact that I don't actually
   // implement the interface here. Bug 1088061 has been filed to remove
   // this hackery.
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
                                          Ci.nsIPrintingPromptService]),