Commit 0d78c92d authored by Jonathan Watt's avatar Jonathan Watt
Browse files

Bug 1769746 - Stop using mPrtPreview in nsPrintJob::Print. r=emilio

We create a new nsPrintJob every time Print() or PrintPreview() is invoked
now ( https://phabricator.services.mozilla.com/D87417 ), so the mPrtPreview
member is never set this early on.

This also renames aSourceDoc to just aDoc since the document that is passed is
nowadays the actual document we're going to print from (the static clone,
which nowadays is created before these methods are invoked rather than being
created by them).

Differential Revision: https://phabricator.services.mozilla.com/D146563
parent 223f99d6
Loading
Loading
Loading
Loading
+4 −20
Original line number Diff line number Diff line
@@ -429,12 +429,6 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview,

  if (aIsPrintPreview) {
    mIsCreatingPrintPreview = true;

    // Our new print preview nsPrintData is stored in mPtr until we move it
    // to mPrtPreview once we've finish creating the print preview. We must
    // clear mPtrPreview so that code will use mPtr until that happens.
    mPrtPreview = nullptr;

    SetIsPrintPreview(true);
  } else {
    SetIsPrinting(true);
@@ -527,23 +521,14 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview,
}

//---------------------------------------------------------------------------------
nsresult nsPrintJob::Print(Document* aSourceDoc,
                           nsIPrintSettings* aPrintSettings,
nsresult nsPrintJob::Print(Document* aDoc, nsIPrintSettings* aPrintSettings,
                           RemotePrintJobChild* aRemotePrintJob,
                           nsIWebProgressListener* aWebProgressListener) {
  mRemotePrintJob = aRemotePrintJob;

  // 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.
  RefPtr<Document> doc = mPrtPreview && mPrtPreview->mPrintObject
                             ? mPrtPreview->mPrintObject->mDocument.get()
                             : aSourceDoc;

  return CommonPrint(false, aPrintSettings, aWebProgressListener, doc);
  return CommonPrint(false, aPrintSettings, aWebProgressListener, aDoc);
}

nsresult nsPrintJob::PrintPreview(Document* aSourceDoc,
nsresult nsPrintJob::PrintPreview(Document* aDoc,
                                  nsIPrintSettings* aPrintSettings,
                                  nsIWebProgressListener* aWebProgressListener,
                                  PrintPreviewResolver&& aCallback) {
@@ -551,8 +536,7 @@ nsresult nsPrintJob::PrintPreview(Document* aSourceDoc,
  // stack will call it to signal failure (by passing zero).
  mPrintPreviewCallback = std::move(aCallback);

  nsresult rv =
      CommonPrint(true, aPrintSettings, aWebProgressListener, aSourceDoc);
  nsresult rv = CommonPrint(true, aPrintSettings, aWebProgressListener, aDoc);
  if (NS_FAILED(rv)) {
    if (mPrintPreviewCallback) {
      // signal error