Bug 1399787 - Part 7. Have PrintTargetEMF launch the PDFium process. r=jwatt

MozReview-Commit-ID: CVfB81ifV2p

--HG--
extra : rebase_source : 88725db5962ce59282fc3df298f3224446c9e086
This commit is contained in:
cku 2017-11-29 17:15:31 +08:00
parent 2755ec8823
commit 2615f0ab34
3 changed files with 21 additions and 0 deletions

View File

@ -6,6 +6,7 @@
#include "PrintTargetEMF.h"
#include "nsAnonymousTemporaryFile.h"
#include "nsIFile.h"
#include "mozilla/widget/PDFiumProcessParent.h"
using mozilla::gfx::DrawTarget;
@ -18,6 +19,13 @@ PrintTargetEMF::PrintTargetEMF(HDC aDC, const IntSize& aSize)
{
}
PrintTargetEMF::~PrintTargetEMF()
{
if (mPDFiumProcess) {
mPDFiumProcess->Delete();
}
}
/* static */ already_AddRefed<PrintTargetEMF>
PrintTargetEMF::CreateOrNull(HDC aDC, const IntSize& aSizeInPoints)
{
@ -51,6 +59,9 @@ PrintTargetEMF::BeginPrinting(const nsAString& aTitle,
::StartDocW(mPrinterDC, &docinfo);
mPDFiumProcess = new PDFiumProcessParent();
NS_ENSURE_TRUE(mPDFiumProcess->Launch(), NS_ERROR_FAILURE);
return NS_OK;
}

View File

@ -11,6 +11,12 @@
/* include windows.h for the HDC definitions that we need. */
#include <windows.h>
namespace mozilla {
namespace widget {
class PDFiumProcessParent;
}
}
namespace mozilla {
namespace gfx {
@ -26,6 +32,7 @@ class PrintTargetEMF final : public mozilla::gfx::PrintTarget
{
public:
typedef gfx::IntSize IntSize;
typedef mozilla::widget::PDFiumProcessParent PDFiumProcessParent;
static already_AddRefed<PrintTargetEMF>
CreateOrNull(HDC aDC, const IntSize& aSizeInPoints);
@ -48,11 +55,13 @@ public:
private:
PrintTargetEMF(HDC aDC, const IntSize& aSize);
~PrintTargetEMF() override;
nsString mTitle;
RefPtr<PrintTargetSkPDF> mTargetForCurrentPage;
nsCOMPtr<nsIFile> mPDFFileForOnePage;
RefPtr<PrintTargetSkPDF> mRefTarget;
PDFiumProcessParent* mPDFiumProcess;
HDC mPrinterDC;
};

View File

@ -27,6 +27,7 @@ EXPORTS.mozilla.widget += [
'PDFiumEngineShim.h',
'PDFiumParent.h',
'PDFiumProcessChild.h',
'PDFiumProcessParent.h',
'PDFViaEMFPrintHelper.h',
'WinCompositorWidget.h',
'WinMessages.h',