Bug 1399787 - Part 8. Remove nsDeviceContextSpecWin::mPrintViaPDFInProgress. draft
authorcku <cku@mozilla.com>
Thu, 19 Oct 2017 14:18:37 +0800
changeset 686700 b51ee5e2c406b49011d0723a05c0a0f606b02cfa
parent 686699 488afc93b788a8f4984c2e5a81d7d0e4970cbbcb
child 686701 5117679f9f4aa97609f991d34be5073f1c36fdd5
push id86258
push usercku@mozilla.com
push dateThu, 26 Oct 2017 08:49:17 +0000
bugs1399787
milestone58.0a1
Bug 1399787 - Part 8. Remove nsDeviceContextSpecWin::mPrintViaPDFInProgress. mPrintViaPDFInProgress is true iff mPDFiumProcess is not nullptr. We only need one of them. MozReview-Commit-ID: GAN6IrN3b1i
widget/windows/nsDeviceContextSpecWin.cpp
widget/windows/nsDeviceContextSpecWin.h
--- a/widget/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/windows/nsDeviceContextSpecWin.cpp
@@ -97,19 +97,18 @@ struct AutoFreeGlobalPrinters
   }
 };
 
 //----------------------------------------------------------------------------------
 nsDeviceContextSpecWin::nsDeviceContextSpecWin()
 {
   mDevMode       = nullptr;
 #ifdef MOZ_ENABLE_SKIA_PDF
-  mPrintViaSkPDF          = false;
-  mDC                     = NULL;
-  mPrintViaPDFInProgress  = false;
+  mPrintViaSkPDF = false;
+  mDC            = NULL;
   mPDFiumProcess = nullptr;
 #endif
 }
 
 
 //----------------------------------------------------------------------------------
 
 NS_IMPL_ISUPPORTS(nsDeviceContextSpecWin, nsIDeviceContextSpec)
@@ -368,26 +367,22 @@ nsDeviceContextSpecWin::FinishPrint()
 void
 nsDeviceContextSpecWin::CleanupPrintViaPDF()
 {
   if (mPDFTempFile) {
     mPDFTempFile->Remove(/* aRecursive */ false);
     mPDFTempFile = nullptr;
   }
 
-  if (mDC != NULL) {
-    if (mPrintViaPDFInProgress) {
-      ::EndDoc(mDC);
-      mPrintViaPDFInProgress = false;
-    }
+  MOZ_ASSERT_IF(mPDFiumProcess, mDC);
+  if (mPDFiumProcess) {
+    ::EndDoc(mDC);
     ::DeleteDC(mDC);
     mDC = NULL;
-  }
 
-  if (mPDFiumProcess) {
     mPDFiumProcess->Delete();
     mPDFiumProcess = nullptr;
   }
 }
 
 void
 nsDeviceContextSpecWin::PrintEMFInternal(nsString aEMFFilePath)
 {
@@ -459,18 +454,16 @@ nsDeviceContextSpecWin::BeginDocument(co
     di.fwType = 0;
 
     if (::StartDocW(mDC, &di) <= 0) {
       // Defer calling CleanupPrintViaPDF() in destructor because PDF temp file
       // is not ready yet.
       return NS_ERROR_FAILURE;
     }
 
-    mPrintViaPDFInProgress = true;
-
     MOZ_ASSERT(!mPDFiumProcess && mDC);
     mPDFiumProcess = new PDFiumProcessParent();
     NS_ENSURE_TRUE(mPDFiumProcess->Launch(this), NS_ERROR_FAILURE);
   }
 #endif
 
   return NS_OK;
 }
--- a/widget/windows/nsDeviceContextSpecWin.h
+++ b/widget/windows/nsDeviceContextSpecWin.h
@@ -91,17 +91,16 @@ protected:
   void CleanupPrintViaPDF();
 
   // This variable is independant of nsIPrintSettings::kOutputFormatPDF.
   // It controls both whether normal printing is done via PDF using Skia and
   // whether print-to-PDF uses Skia.
   bool mPrintViaSkPDF;
   nsCOMPtr<nsIFile> mPDFTempFile;
   HDC mDC;
-  bool mPrintViaPDFInProgress;
 
   PDFiumProcessParent* mPDFiumProcess;
 #endif
 };
 
 
 //-------------------------------------------------------------------------
 // Printer Enumerator