Bug 1399787 - Part 4. Launch the PDFium process.
MozReview-Commit-ID: FK4jdb9hvgB
--- a/widget/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/windows/nsDeviceContextSpecWin.cpp
@@ -36,16 +36,17 @@
#ifdef MOZ_ENABLE_SKIA_PDF
#include "mozilla/gfx/PrintTargetSkPDF.h"
#include "nsIUUIDGenerator.h"
#include "mozilla/widget/PDFViaEMFPrintHelper.h"
#include "nsDirectoryServiceDefs.h"
#include "nsPrintfCString.h"
#include "nsThreadUtils.h"
+#include "PDFiumProcessParent.h"
#endif
static mozilla::LazyLogModule kWidgetPrintingLogMod("printing-widget");
#define PR_PL(_p1) MOZ_LOG(kWidgetPrintingLogMod, mozilla::LogLevel::Debug, _p1)
using namespace mozilla;
using namespace mozilla::gfx;
@@ -99,16 +100,17 @@ nsDeviceContextSpecWin::nsDeviceContextS
{
mDevMode = nullptr;
#ifdef MOZ_ENABLE_SKIA_PDF
mPrintViaSkPDF = false;
mDC = NULL;
mPDFPageCount = 0;
mPDFCurrentPageNum = 0;
mPrintViaPDFInProgress = false;
+ mPDFiumProcess = nullptr;
#endif
}
//----------------------------------------------------------------------------------
NS_IMPL_ISUPPORTS(nsDeviceContextSpecWin, nsIDeviceContextSpec)
@@ -371,16 +373,21 @@ nsDeviceContextSpecWin::CleanupPrintViaP
if (mDC != NULL) {
if (mPrintViaPDFInProgress) {
::EndDoc(mDC);
mPrintViaPDFInProgress = false;
}
::DeleteDC(mDC);
mDC = NULL;
}
+
+ if (mPDFiumProcess) {
+ mPDFiumProcess->Delete();
+ mPDFiumProcess = nullptr;
+ }
}
void
nsDeviceContextSpecWin::FinishPrintViaPDF()
{
MOZ_ASSERT(mDC != NULL);
MOZ_ASSERT(mPDFPrintHelper);
MOZ_ASSERT(mPDFTempFile);
@@ -449,16 +456,20 @@ nsDeviceContextSpecWin::BeginDocument(co
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);
+ mPDFiumProcess = new PDFiumProcessParent();
+ NS_ENSURE_TRUE(mPDFiumProcess->Launch(), NS_ERROR_FAILURE);
}
#endif
return NS_OK;
}
nsresult
nsDeviceContextSpecWin::EndDocument()
--- a/widget/windows/nsDeviceContextSpecWin.h
+++ b/widget/windows/nsDeviceContextSpecWin.h
@@ -16,24 +16,26 @@
#include "mozilla/RefPtr.h"
class nsIWidget;
#ifdef MOZ_ENABLE_SKIA_PDF
namespace mozilla {
namespace widget {
class PDFViaEMFPrintHelper;
+class PDFiumProcessParent;
}
}
#endif
class nsDeviceContextSpecWin : public nsIDeviceContextSpec
{
#ifdef MOZ_ENABLE_SKIA_PDF
typedef mozilla::widget::PDFViaEMFPrintHelper PDFViaEMFPrintHelper;
+ typedef mozilla::widget::PDFiumProcessParent PDFiumProcessParent;
#endif
public:
nsDeviceContextSpecWin();
NS_DECL_ISUPPORTS
virtual already_AddRefed<PrintTarget> MakePrintTarget() final;
@@ -88,16 +90,18 @@ protected:
// whether print-to-PDF uses Skia.
bool mPrintViaSkPDF;
nsCOMPtr<nsIFile> mPDFTempFile;
HDC mDC;
bool mPrintViaPDFInProgress;
mozilla::UniquePtr<PDFViaEMFPrintHelper> mPDFPrintHelper;
int mPDFPageCount;
int mPDFCurrentPageNum;
+
+ PDFiumProcessParent* mPDFiumProcess;
#endif
};
//-------------------------------------------------------------------------
// Printer Enumerator
//-------------------------------------------------------------------------
class nsPrinterEnumeratorWin final : public nsIPrinterEnumerator