Bug 1769999 - Remove the last of the nsPrintJob::mPrtPreview code. r=emilio
authorJonathan Watt <jwatt@jwatt.org>
Thu, 19 May 2022 09:38:19 +0000
changeset 618221 0822a76e35d2c7ad13a537fa63faab612894c937
parent 618220 52649d6014b8cf4227d336ba4495b1219e4f857a
child 618222 4d2390d6d742112bdb03f4c8565db97970e09be2
push id39719
push usersmolnar@mozilla.com
push dateThu, 19 May 2022 16:03:14 +0000
treeherdermozilla-central@cc776278c4ea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1769999, 1659432
milestone102.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 1769999 - Remove the last of the nsPrintJob::mPrtPreview code. r=emilio Since bug 1659432 landed, we no longer keep the nsPrintJob around across print settings changes, only replacing the nsPrintData. Now that we throw away everything on a settings change it doesn't make sense to have code that was written for juggling nsPrintData objects. That code was just making things difficult to understand. Differential Revision: https://phabricator.services.mozilla.com/D146718
layout/printing/nsPrintJob.cpp
layout/printing/nsPrintJob.h
--- a/layout/printing/nsPrintJob.cpp
+++ b/layout/printing/nsPrintJob.cpp
@@ -280,19 +280,16 @@ bool nsPrintJob::CheckBeforeDestroy() co
 void nsPrintJob::Destroy() {
   if (mIsDestroying) {
     return;
   }
   mIsDestroying = true;
 
   mPrt = nullptr;
 
-#ifdef NS_PRINT_PREVIEW
-  mPrtPreview = nullptr;
-#endif
   mDocViewerPrint = nullptr;
 }
 
 //-------------------------------------------------------
 void nsPrintJob::DestroyPrintingData() { mPrt = nullptr; }
 
 //---------------------------------------------------------------------------------
 //-- Section: Methods needed by the DocViewer
@@ -329,22 +326,21 @@ nsresult nsPrintJob::Initialize(nsIDocum
   }
 
   return NS_OK;
 }
 
 //-----------------------------------------------------------------
 std::tuple<nsPageSequenceFrame*, int32_t>
 nsPrintJob::GetSeqFrameAndCountSheets() const {
-  nsPrintData* printData = mPrtPreview ? mPrtPreview : mPrt;
-  if (NS_WARN_IF(!printData)) {
+  if (NS_WARN_IF(!mPrt)) {
     return {nullptr, 0};
   }
 
-  const nsPrintObject* po = printData->mPrintObject.get();
+  const nsPrintObject* po = mPrt->mPrintObject.get();
   if (NS_WARN_IF(!po)) {
     return {nullptr, 0};
   }
 
   // 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 (!po->mPresShell) {
@@ -875,19 +871,17 @@ nsresult nsPrintJob::SetupToPrintContent
     if (NS_WARN_IF(mPrt != printData)) {
       return NS_ERROR_FAILURE;
     }
     didReconstruction = true;
   }
 
   // Here is where we figure out if extra reflow for shrinking the content
   // is required.
-  // But skip this step if we are in PrintPreview
-  bool ppIsShrinkToFit = mPrtPreview && mPrtPreview->mShrinkToFit;
-  if (printData->mShrinkToFit && !ppIsShrinkToFit) {
+  if (printData->mShrinkToFit) {
     printData->mShrinkRatio = printData->mPrintObject->mShrinkRatio;
 
     if (printData->mShrinkRatio < 0.998f) {
       nsresult rv = ReconstructAndReflow();
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       // If the printing was canceled or restarted with different data,
@@ -2076,22 +2070,16 @@ nsresult nsPrintJob::FinishPrintPreview(
         maybeLandscape));
     mPrintPreviewCallback = nullptr;
   }
 
   // At this point we are done preparing everything
   // before it is to be created
 
   printData->OnEndPrinting();
-  // XXX If mPrt becomes nullptr or different instance here, what should we
-  //     do?
-
-  // PrintPreview was built using the mPrt (code reuse)
-  // then we assign it over
-  mPrtPreview = std::move(mPrt);
 
 #endif  // NS_PRINT_PREVIEW
 
   return NS_OK;
 }
 
 //-----------------------------------------------------------------
 //-- Done: Finishing up or Cleaning up
--- a/layout/printing/nsPrintJob.h
+++ b/layout/printing/nsPrintJob.h
@@ -239,22 +239,16 @@ class nsPrintJob final : public nsIWebPr
 
   // 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 nsPrintJob owner object and all its
   // member-data.
   RefPtr<nsPrintData> mPrt;
 
-  // The nsPrintData for our last print preview (replaced every time the
-  // user changes settings in the print preview window).
-  // Note: Our new print preview nsPrintData is stored in mPtr until we move it
-  // to mPrtPreview once we've finish creating the print preview.
-  RefPtr<nsPrintData> mPrtPreview;
-
   RefPtr<nsPagePrintTimer> mPagePrintTimer;
 
   // Only set if this nsPrintJob was created for a real print.
   RefPtr<RemotePrintJobChild> mRemotePrintJob;
 
   // If the code that initiates a print preview passes a PrintPreviewResolver
   // (a std::function) to be notified of the final sheet/page counts (once
   // we've sufficiently laid out the document to know what those are), that