Backed out 22 changesets (bug 1399787) for failing on mozmake.EXE r=backout a=backout on a CLOSED TREE
authorBogdan Tara <btara@mozilla.com>
Thu, 07 Dec 2017 19:16:08 +0200
changeset 395565 f0afedbc68cf017c206d0d6706cfdff0b44c66ca
parent 395564 9c073ea10cdde4e59e933ef9a345ea556b685d62
child 395566 ba8d6ccb0ffcb348750e1b2de229d3e2023d1498
push id33048
push usercsabou@mozilla.com
push dateFri, 08 Dec 2017 09:54:43 +0000
treeherdermozilla-central@35702424bcfc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout, backout
bugs1399787
milestone59.0a1
backs out0afbd07d821916af688227ad7144639b33d487c4
80c062fd58fbaf0a5d6ab8a738faae3f6de791b2
b1457eabd34e5a3a079c32e4809dbe13db5af9c0
d875e45f591e3a4d445e0fb5c6970ee3cf963d93
8f600ac930ecfa6b064b288f17d7063df2a89247
c478fb75f5cbeb891a3e6cce0716f295b2eec042
c995f4e187245363a4f3c46a04cfb2fa49436338
0b75ef19e695bfa9c38a0d480626f6423542d5be
2382a348a6c1882e2d721d5b613275efba5f51af
93f9a5e253d8a4a59bf9e9ae1c1394d4d0409632
5c50bbde0950ce2770e70faf04d53f004cc45e28
67e530c129c786084f5d4162a8b424b7a5877ac1
682c60e5274907e33c6243bc4240ab29393c2520
ff1436ae1ef7e38f8946a14d7899cf8c7af05da6
cb3ae1dc20b26d284f28de140fb2afe7d461302c
bc52b17816410be51ac941f524e3793ed7a8b4c7
d165846cb5e146b021c62557b4db0758d3ca2756
18536826735456ebddb4ddc4b71bba009d8a4eaf
c385d0f60f8a36f4731cc4947b882e6008a8800e
364b5b44932bfd9a2583c9f1f5e0bf7f3a820c7b
98758e79710d08ac39b81db5b21707c70adaef33
d56497aa53900e0c4e2ed87b7c79fd47c9611f30
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
Backed out 22 changesets (bug 1399787) for failing on mozmake.EXE r=backout a=backout on a CLOSED TREE Backed out changeset 0afbd07d8219 (bug 1399787) Backed out changeset 80c062fd58fb (bug 1399787) Backed out changeset b1457eabd34e (bug 1399787) Backed out changeset d875e45f591e (bug 1399787) Backed out changeset 8f600ac930ec (bug 1399787) Backed out changeset c478fb75f5cb (bug 1399787) Backed out changeset c995f4e18724 (bug 1399787) Backed out changeset 0b75ef19e695 (bug 1399787) Backed out changeset 2382a348a6c1 (bug 1399787) Backed out changeset 93f9a5e253d8 (bug 1399787) Backed out changeset 5c50bbde0950 (bug 1399787) Backed out changeset 67e530c129c7 (bug 1399787) Backed out changeset 682c60e52749 (bug 1399787) Backed out changeset ff1436ae1ef7 (bug 1399787) Backed out changeset cb3ae1dc20b2 (bug 1399787) Backed out changeset bc52b1781641 (bug 1399787) Backed out changeset d165846cb5e1 (bug 1399787) Backed out changeset 185368267354 (bug 1399787) Backed out changeset c385d0f60f8a (bug 1399787) Backed out changeset 364b5b44932b (bug 1399787) Backed out changeset 98758e79710d (bug 1399787) Backed out changeset d56497aa5390 (bug 1399787)
gfx/src/nsDeviceContext.cpp
gfx/src/nsDeviceContext.h
gfx/thebes/PrintTarget.cpp
gfx/thebes/PrintTarget.h
gfx/thebes/PrintTargetEMF.cpp
gfx/thebes/PrintTargetEMF.h
gfx/thebes/gfxFontSrcPrincipal.cpp
gfx/thebes/moz.build
ipc/glue/GeckoChildProcessHost.cpp
layout/printing/ipc/RemotePrintJobChild.cpp
layout/printing/ipc/RemotePrintJobChild.h
layout/printing/ipc/RemotePrintJobParent.cpp
layout/printing/ipc/RemotePrintJobParent.h
layout/printing/nsPagePrintTimer.cpp
layout/printing/nsPrintEngine.cpp
layout/printing/nsPrintEngine.h
modules/pdfium/pdfium.def
security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
security/sandbox/win/src/sandboxbroker/sandboxBroker.h
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsEmbedFunctions.cpp
widget/nsBaseClipboard.h
widget/windows/InkCollector.h
widget/windows/PDFViaEMFPrintHelper.cpp
widget/windows/PDFViaEMFPrintHelper.h
widget/windows/PDFiumChild.cpp
widget/windows/PDFiumChild.h
widget/windows/PDFiumEngineShim.cpp
widget/windows/PDFiumEngineShim.h
widget/windows/PDFiumParent.cpp
widget/windows/PDFiumParent.h
widget/windows/PDFiumProcessChild.cpp
widget/windows/PDFiumProcessChild.h
widget/windows/PDFiumProcessParent.cpp
widget/windows/PDFiumProcessParent.h
widget/windows/PPDFium.ipdl
widget/windows/ScreenHelperWin.cpp
widget/windows/WindowsEMF.cpp
widget/windows/WindowsEMF.h
widget/windows/gtest/TestEMFConversion.cpp
widget/windows/gtest/moz.build
widget/windows/moz.build
widget/windows/nsColorPicker.cpp
widget/windows/nsDataObj.cpp
widget/windows/nsDeviceContextSpecWin.cpp
widget/windows/nsDeviceContextSpecWin.h
widget/windows/nsSound.cpp
xpcom/build/nsXULAppAPI.h
xpcom/system/nsIXULRuntime.idl
--- a/gfx/src/nsDeviceContext.cpp
+++ b/gfx/src/nsDeviceContext.cpp
@@ -730,29 +730,8 @@ nsDeviceContext::GetDesktopToDeviceScale
     if (screen) {
         double scale;
         screen->GetContentsScaleFactor(&scale);
         return DesktopToLayoutDeviceScale(scale);
     }
 
     return DesktopToLayoutDeviceScale(1.0);
 }
-
-bool
-nsDeviceContext::IsSyncPagePrinting() const
-{
-  MOZ_ASSERT(mPrintTarget);
-  return mPrintTarget->IsSyncPagePrinting();
-}
-
-void
-nsDeviceContext::RegisterPageDoneCallback(PrintTarget::PageDoneCallback&& aCallback)
-{
-  MOZ_ASSERT(mPrintTarget && aCallback && !IsSyncPagePrinting());
-  mPrintTarget->RegisterPageDoneCallback(Move(aCallback));
-}
-void
-nsDeviceContext::UnregisterPageDoneCallback()
-{
-  if (mPrintTarget) {
-    mPrintTarget->UnregisterPageDoneCallback();
-  }
-}
--- a/gfx/src/nsDeviceContext.h
+++ b/gfx/src/nsDeviceContext.h
@@ -15,30 +15,35 @@
 #include "nsCOMPtr.h"                   // for nsCOMPtr
 #include "nsCoord.h"                    // for nscoord
 #include "nsError.h"                    // for nsresult
 #include "nsISupports.h"                // for NS_INLINE_DECL_REFCOUNTING
 #include "nsMathUtils.h"                // for NS_round
 #include "nscore.h"                     // for char16_t, nsAString
 #include "mozilla/AppUnits.h"           // for AppUnits
 #include "nsFontMetrics.h"              // for nsFontMetrics::Params
-#include "mozilla/gfx/PrintTarget.h"    // for PrintTarget::PageDoneCallback
 
 class gfxContext;
 class gfxTextPerfMetrics;
 class gfxUserFontSet;
 struct nsFont;
 class nsFontCache;
 class nsAtom;
 class nsIDeviceContextSpec;
 class nsIScreen;
 class nsIScreenManager;
 class nsIWidget;
 struct nsRect;
 
+namespace mozilla {
+namespace gfx {
+class PrintTarget;
+}
+}
+
 class nsDeviceContext final
 {
 public:
     typedef mozilla::gfx::PrintTarget PrintTarget;
 
     nsDeviceContext();
 
     NS_INLINE_DECL_REFCOUNTING(nsDeviceContext)
@@ -270,19 +275,16 @@ public:
 
     /**
      * True if this device context was created for printing.
      */
     bool IsPrinterContext();
 
     mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale();
 
-    bool IsSyncPagePrinting() const;
-    void RegisterPageDoneCallback(PrintTarget::PageDoneCallback&& aCallback);
-    void UnregisterPageDoneCallback();
 private:
     // Private destructor, to discourage deletion outside of Release():
     ~nsDeviceContext();
 
     /**
      * Implementation shared by CreateRenderingContext and
      * CreateReferenceRenderingContext.
      */
--- a/gfx/thebes/PrintTarget.cpp
+++ b/gfx/thebes/PrintTarget.cpp
@@ -224,23 +224,10 @@ PrintTarget::Finish()
     return;
   }
   mIsFinished = true;
 
   // null surfaces are allowed here
   cairo_surface_finish(mCairoSurface);
 }
 
-void
-PrintTarget::RegisterPageDoneCallback(PageDoneCallback&& aCallback)
-{
-  MOZ_ASSERT(aCallback && !IsSyncPagePrinting());
-  mPageDoneCallback = Move(aCallback);
-}
-
-void
-PrintTarget::UnregisterPageDoneCallback()
-{
-  mPageDoneCallback = nullptr;
-}
-
 } // namespace gfx
 } // namespace mozilla
--- a/gfx/thebes/PrintTarget.h
+++ b/gfx/thebes/PrintTarget.h
@@ -1,18 +1,16 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_GFX_PRINTTARGET_H
 #define MOZILLA_GFX_PRINTTARGET_H
 
-#include <functional>
-
 #include "mozilla/RefPtr.h"
 #include "mozilla/gfx/2D.h"
 #include "nsISupportsImpl.h"
 #include "nsStringFwd.h"
 
 namespace mozilla {
 namespace gfx {
 
@@ -23,17 +21,16 @@ class DrawEventRecorder;
  * preview.
  *
  * This class wraps a cairo_surface_t* and provides access to it via a
  * DrawTarget.  The various checkpointing methods manage the state of the
  * platform specific cairo_surface_t*.
  */
 class PrintTarget {
 public:
-  typedef std::function<void(nsresult)> PageDoneCallback;
 
   NS_INLINE_DECL_REFCOUNTING(PrintTarget);
 
   /// Must be matched 1:1 by an EndPrinting/AbortPrinting call.
   virtual nsresult BeginPrinting(const nsAString& aTitle,
                                  const nsAString& aPrintToFileName,
                                  int32_t aStartPage,
                                  int32_t aEndPage) {
@@ -134,27 +131,16 @@ public:
   /**
    * Returns a reference DrawTarget. Unlike MakeDrawTarget, this method is not
    * restricted to being called between BeginPage()/EndPage() calls, and the
    * returned DrawTarget it is still valid to use after EndPage() has been
    * called.
    */
   virtual already_AddRefed<DrawTarget> GetReferenceDrawTarget(DrawEventRecorder* aRecorder);
 
-  /**
-   * If IsSyncPagePrinting returns true, then a user can assume the content of
-   * a page was already printed after EndPage().
-   * If IsSyncPagePrinting returns false, then a user should register a
-   * callback function using RegisterPageDoneCallback to receive page print
-   * done notifications.
-   */
-  virtual bool IsSyncPagePrinting() const { return true; }
-  void RegisterPageDoneCallback(PageDoneCallback&& aCallback);
-  void UnregisterPageDoneCallback();
-
   static void AdjustPrintJobNameForIPP(const nsAString& aJobName,
                                        nsCString& aAdjustedJobName);
   static void AdjustPrintJobNameForIPP(const nsAString& aJobName,
                                        nsString& aAdjustedJobName);
 
 protected:
 
   // Only created via subclass's constructors
@@ -178,16 +164,14 @@ protected:
 
   IntSize mSize;
   bool mIsFinished;
 #ifdef DEBUG
   bool mHasActivePage;
   // owned by mRecordingRefDT, so kept alive for our entire lifetime if set:
   DrawEventRecorder* mRecorder;
 #endif
-
-  PageDoneCallback mPageDoneCallback;
 };
 
 } // namespace gfx
 } // namespace mozilla
 
 #endif /* MOZILLA_GFX_PRINTTARGET_H */
deleted file mode 100644
--- a/gfx/thebes/PrintTargetEMF.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "PrintTargetEMF.h"
-#include "nsAnonymousTemporaryFile.h"
-#include "nsIFile.h"
-#include "mozilla/widget/PDFiumProcessParent.h"
-#include "mozilla/widget/PDFiumParent.h"
-#include "mozilla/widget/WindowsEMF.h"
-#include "mozilla/ipc/FileDescriptor.h"
-#include "private/pprio.h"
-
-using mozilla::gfx::DrawTarget;
-using mozilla::ipc::FileDescriptor;
-
-namespace mozilla {
-namespace gfx {
-
-PrintTargetEMF::PrintTargetEMF(HDC aDC, const IntSize& aSize)
-  : PrintTarget(/* not using cairo_surface_t */ nullptr, aSize)
-  , mPrinterDC(aDC)
-  , mWaitingForEMFConversion(false)
-  , mChannelBroken(false)
-{
-}
-
-PrintTargetEMF::~PrintTargetEMF()
-{
-  if (mPDFiumProcess) {
-    mPDFiumProcess->Delete(mWaitingForEMFConversion);
-  }
-}
-
-/* static */ already_AddRefed<PrintTargetEMF>
-PrintTargetEMF::CreateOrNull(HDC aDC, const IntSize& aSizeInPoints)
-{
-  return do_AddRef(new PrintTargetEMF(aDC, aSizeInPoints));
-}
-
-nsresult
-PrintTargetEMF::BeginPrinting(const nsAString& aTitle,
-                              const nsAString& aPrintToFileName,
-                              int32_t aStartPage,
-                              int32_t aEndPage)
-{
-  mTitle = aTitle;
-
-  const uint32_t DOC_TITLE_LENGTH = MAX_PATH - 1;
-
-  DOCINFOW docinfo;
-
-  nsString titleStr(aTitle);
-  if (titleStr.Length() > DOC_TITLE_LENGTH) {
-    titleStr.SetLength(DOC_TITLE_LENGTH - 3);
-    titleStr.AppendLiteral("...");
-  }
-
-  nsString docName(aPrintToFileName);
-  docinfo.cbSize = sizeof(docinfo);
-  docinfo.lpszDocName = titleStr.Length() > 0 ? titleStr.get() : L"Mozilla Document";
-  docinfo.lpszOutput = docName.Length() > 0 ? docName.get() : nullptr;
-  docinfo.lpszDatatype = nullptr;
-  docinfo.fwType = 0;
-
-  ::StartDocW(mPrinterDC, &docinfo);
-
-  mPDFiumProcess = new PDFiumProcessParent();
-  NS_ENSURE_TRUE(mPDFiumProcess->Launch(this), NS_ERROR_FAILURE);
-
-  mChannelBroken = false;
-
-  return NS_OK;
-}
-
-nsresult
-PrintTargetEMF::EndPrinting()
-{
-  mPDFiumProcess->GetActor()->EndConversion();
-  return (::EndDoc(mPrinterDC) <= 0) ? NS_ERROR_FAILURE : NS_OK;
-}
-
-nsresult
-PrintTargetEMF::AbortPrinting()
-{
-  return (::AbortDoc(mPrinterDC) <= 0) ? NS_ERROR_FAILURE : NS_OK;
-}
-
-nsresult
-PrintTargetEMF::BeginPage()
-{
-  MOZ_ASSERT(!mPDFFileForOnePage && !mTargetForCurrentPage);
-  NS_ENSURE_TRUE(!mChannelBroken, NS_ERROR_FAILURE);
-  NS_ENSURE_TRUE(::StartPage(mPrinterDC) >0, NS_ERROR_FAILURE);
-
-  // We create a new file for each page so that we can make sure each new
-  // mPDFFileForOnePage contains one single page.
-  nsresult rv =
-   NS_OpenAnonymousTemporaryNsIFile(getter_AddRefs(mPDFFileForOnePage));
-  NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
-
-  nsAutoCString filePath;
-  mPDFFileForOnePage->GetNativePath(filePath);
-  auto  stream = MakeUnique<SkFILEWStream>(filePath.get());
-
-  // Creating a new PrintTargetSkPDF for each page so that we can convert each
-  // of them into EMF contents individually by the PDFium processes.
-  mTargetForCurrentPage = PrintTargetSkPDF::CreateOrNull(Move(stream), mSize);
-  mTargetForCurrentPage->BeginPrinting(mTitle, NS_LITERAL_STRING(""), 0, 0);
-  mTargetForCurrentPage->BeginPage();
-
-  return NS_OK;
-}
-
-nsresult
-PrintTargetEMF::EndPage()
-{
-  NS_ENSURE_TRUE(!mChannelBroken, NS_ERROR_FAILURE);
-
-  mTargetForCurrentPage->EndPage();
-  mTargetForCurrentPage->EndPrinting();
-  mTargetForCurrentPage->Finish();
-  mTargetForCurrentPage = nullptr;
-
-  PRFileDesc* prfile;
-  nsresult rv = mPDFFileForOnePage->OpenNSPRFileDesc(PR_RDONLY, PR_IRWXU,
-                                                     &prfile);
-  NS_ENSURE_SUCCESS(rv, rv);
-  FileDescriptor descriptor(FileDescriptor::PlatformHandleType(PR_FileDesc2NativeHandle(prfile)));
-  if (!mPDFiumProcess->GetActor()->SendConvertToEMF(descriptor,
-                                        ::GetDeviceCaps(mPrinterDC, HORZRES),
-                                        ::GetDeviceCaps(mPrinterDC, VERTRES)))
-  {
-    return NS_ERROR_FAILURE;
-  }
-
-  PR_Close(prfile);
-  mWaitingForEMFConversion = true;
-
-  return NS_OK;
-}
-
-already_AddRefed<DrawTarget>
-PrintTargetEMF::MakeDrawTarget(const IntSize& aSize,
-                               DrawEventRecorder* aRecorder)
-{
-  MOZ_ASSERT(!mChannelBroken);
-  return mTargetForCurrentPage->MakeDrawTarget(aSize, aRecorder);
-}
-
-already_AddRefed<DrawTarget>
-PrintTargetEMF::GetReferenceDrawTarget(DrawEventRecorder* aRecorder)
-{
-  if (!mRefTarget) {
-    auto dummy = MakeUnique<SkNullWStream>();
-    mRefTarget = PrintTargetSkPDF::CreateOrNull(Move(dummy), mSize);
-  }
-
-  if (!mRefDT) {
-    mRefDT = mRefTarget->GetReferenceDrawTarget(aRecorder);
-  }
-
-  return mRefDT.forget();
-}
-
-void
-PrintTargetEMF::ConvertToEMFDone(const nsresult& aResult,
-                                 mozilla::ipc::Shmem&& aEMF)
-{
-  MOZ_ASSERT(!mChannelBroken, "It is not possible to get conversion callback "
-                              "after the channel was broken.");
-  mWaitingForEMFConversion = false;
-
-  if (::StartPage(mPrinterDC) > 0) {
-    mozilla::widget::WindowsEMF emf;
-    emf.InitFromFileContents(aEMF.get<BYTE>(), aEMF.Size<BYTE>());
-    RECT printRect = {0, 0, ::GetDeviceCaps(mPrinterDC, HORZRES),
-                      ::GetDeviceCaps(mPrinterDC, VERTRES)};
-    DebugOnly<bool> ret = emf.Playback(mPrinterDC, printRect);
-    MOZ_ASSERT(ret);
-
-    ::EndPage(mPrinterDC);
-  }
-
-  mPDFiumProcess->GetActor()->DeallocShmem(aEMF);
-
-  mPDFFileForOnePage->Remove(/* aRecursive */ false);
-  mPDFFileForOnePage = nullptr;
-
-  if (mPageDoneCallback) {
-    mPageDoneCallback(aResult);
-  }
-}
-
-} // namespace gfx
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/thebes/PrintTargetEMF.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef MOZILLA_GFX_PRINTTARGETEMF_H
-#define MOZILLA_GFX_PRINTTARGETEMF_H
-
-#include "PrintTargetSkPDF.h"
-#include "mozilla/ipc/Shmem.h"
-
-/* include windows.h for the HDC definitions that we need. */
-#include <windows.h>
-
-namespace mozilla {
-namespace widget {
-  class PDFiumProcessParent;
-}
-}
-
-namespace mozilla {
-namespace gfx {
-
-/**
- * A new subclass of PrintTarget.
- * 1. It uses PrintTargetSkPDF to generate one PDF file for one page.
- * 2. It then passes the FileDescriptor of that generated PDF file to the
- *    PDFium process for EMF conversion.
- * 3. After getting the converted EMF contents from the PDFium process, it then
- *    draws it onto the printer DC to finish one page printing task.
- */
-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);
-
-  nsresult BeginPrinting(const nsAString& aTitle,
-                                 const nsAString& aPrintToFileName,
-                                 int32_t aStartPage,
-                                 int32_t aEndPage) final;
-  nsresult EndPrinting() final;
-  nsresult AbortPrinting() final;
-  nsresult BeginPage() final;
-  nsresult EndPage() final;
-
-  already_AddRefed<DrawTarget>
-  MakeDrawTarget(const IntSize& aSize,
-                 DrawEventRecorder* aRecorder = nullptr) final;
-
-  already_AddRefed<DrawTarget>
-  GetReferenceDrawTarget(DrawEventRecorder* aRecorder) final;
-
-  void ConvertToEMFDone(const nsresult& aResult, mozilla::ipc::Shmem&& aEMF);
-  bool IsSyncPagePrinting() const final { return false; }
-  void ChannelIsBroken() { mChannelBroken = true; }
-
-private:
-  PrintTargetEMF(HDC aDC, const IntSize& aSize);
-  ~PrintTargetEMF() override;
-
-  nsString mTitle;
-  RefPtr<PrintTargetSkPDF> mTargetForCurrentPage;
-  nsCOMPtr<nsIFile>        mPDFFileForOnePage;
-  RefPtr<PrintTargetSkPDF> mRefTarget;
-  PDFiumProcessParent*     mPDFiumProcess;
-  HDC mPrinterDC;
-  bool mWaitingForEMFConversion;
-  bool mChannelBroken;
-};
-
-} // namespace gfx
-} // namespace mozilla
-
-#endif /* MOZILLA_GFX_PRINTTARGETEMF_H */
--- a/gfx/thebes/gfxFontSrcPrincipal.cpp
+++ b/gfx/thebes/gfxFontSrcPrincipal.cpp
@@ -2,19 +2,16 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "gfxFontSrcPrincipal.h"
 
 #include "nsProxyRelease.h"
 #include "nsURIHashKey.h"
-#include "mozilla/BasePrincipal.h"
-
-using mozilla::BasePrincipal;
 
 gfxFontSrcPrincipal::gfxFontSrcPrincipal(nsIPrincipal* aPrincipal)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aPrincipal);
 
   mPrincipal = aPrincipal;
 
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -212,23 +212,19 @@ UNIFIED_SOURCES += [
     'VsyncSource.cpp',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     UNIFIED_SOURCES += [
         'gfxMacPlatformFontList.mm',
     ]
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
-    EXPORTS.mozilla.gfx += [
-        'PrintTargetEMF.h',
-    ]
     UNIFIED_SOURCES += [
         'D3D11Checks.cpp',
         'DeviceManagerDx.cpp',
-        'PrintTargetEMF.cpp',
     ]
 
 if CONFIG['MOZ_ENABLE_SKIA_PDF']:
     EXPORTS.mozilla.gfx += [
         'PrintTargetSkPDF.h',
     ]
     SOURCES += [
         'PrintTargetSkPDF.cpp',
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -935,27 +935,16 @@ GeckoChildProcessHost::PerformAsyncLaunc
           !PR_GetEnv("MOZ_DISABLE_NPAPI_SANDBOX")) {
         bool ok = mSandboxBroker.SetSecurityLevelForPluginProcess(mSandboxLevel);
         if (!ok) {
           return false;
         }
         shouldSandboxCurrentProcess = true;
       }
       break;
-#ifdef MOZ_ENABLE_SKIA_PDF
-    case GeckoProcessType_PDFium:
-      if (!PR_GetEnv("MOZ_DISABLE_PDFIUM_SANDBOX")) {
-        bool ok = mSandboxBroker.SetSecurityLevelForPDFiumProcess();
-        if (!ok) {
-          return false;
-        }
-        shouldSandboxCurrentProcess = true;
-      }
-      break;
-#endif
     case GeckoProcessType_IPDLUnitTest:
       // XXX: We don't sandbox this process type yet
       break;
     case GeckoProcessType_GMPlugin:
       if (!PR_GetEnv("MOZ_DISABLE_GMP_SANDBOX")) {
         // The Widevine CDM on Windows can only load at USER_RESTRICTED,
         // not at USER_LOCKDOWN. So look in the command line arguments
         // to see if we're loading the path to the Widevine CDM, and if
--- a/layout/printing/ipc/RemotePrintJobChild.cpp
+++ b/layout/printing/ipc/RemotePrintJobChild.cpp
@@ -66,19 +66,17 @@ RemotePrintJobChild::SetNextPageFD(const
 }
 
 void
 RemotePrintJobChild::ProcessPage()
 {
   MOZ_ASSERT(mPagePrintTimer);
 
   mPagePrintTimer->WaitForRemotePrint();
-  if (!mDestroyed) {
-    Unused << SendProcessPage();
-  }
+  Unused << SendProcessPage();
 }
 
 mozilla::ipc::IPCResult
 RemotePrintJobChild::RecvPageProcessed(const mozilla::ipc::FileDescriptor& aFd)
 {
   MOZ_ASSERT(mPagePrintTimer);
   SetNextPageFD(aFd);
 
@@ -113,56 +111,47 @@ RemotePrintJobChild::SetPrintEngine(nsPr
 
 // nsIWebProgressListener
 
 NS_IMETHODIMP
 RemotePrintJobChild::OnStateChange(nsIWebProgress* aProgress,
                                    nsIRequest* aRequest, uint32_t aStateFlags,
                                    nsresult aStatus)
 {
-  if (!mDestroyed) {
-    Unused << SendStateChange(aStateFlags, aStatus);
-  }
-
+  Unused << SendStateChange(aStateFlags, aStatus);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 RemotePrintJobChild::OnProgressChange(nsIWebProgress * aProgress,
                                       nsIRequest * aRequest,
                                       int32_t aCurSelfProgress,
                                       int32_t aMaxSelfProgress,
                                       int32_t aCurTotalProgress,
                                       int32_t aMaxTotalProgress)
 {
-  if (!mDestroyed) {
-    Unused << SendProgressChange(aCurSelfProgress, aMaxSelfProgress,
-                                 aCurTotalProgress, aMaxTotalProgress);
-  }
-
+  Unused << SendProgressChange(aCurSelfProgress, aMaxSelfProgress,
+                               aCurTotalProgress, aMaxTotalProgress);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 RemotePrintJobChild::OnLocationChange(nsIWebProgress* aProgress,
                                       nsIRequest* aRequest, nsIURI* aURI,
                                       uint32_t aFlags)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 RemotePrintJobChild::OnStatusChange(nsIWebProgress* aProgress,
                                     nsIRequest* aRequest, nsresult aStatus,
                                     const char16_t* aMessage)
 {
-  if (!mDestroyed) {
-    Unused << SendStatusChange(aStatus);
-  }
-
+  Unused << SendStatusChange(aStatus);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 RemotePrintJobChild::OnSecurityChange(nsIWebProgress* aProgress,
                                       nsIRequest* aRequest, uint32_t aState)
 {
   return NS_OK;
@@ -174,14 +163,12 @@ RemotePrintJobChild::~RemotePrintJobChil
 {
 }
 
 void
 RemotePrintJobChild::ActorDestroy(ActorDestroyReason aWhy)
 {
   mPagePrintTimer = nullptr;
   mPrintEngine = nullptr;
-
-  mDestroyed = true;
 }
 
 } // namespace layout
 } // namespace mozilla
--- a/layout/printing/ipc/RemotePrintJobChild.h
+++ b/layout/printing/ipc/RemotePrintJobChild.h
@@ -50,17 +50,16 @@ public:
 
   PRFileDesc* GetNextPageFD();
 
 private:
   ~RemotePrintJobChild() final;
   void SetNextPageFD(const mozilla::ipc::FileDescriptor& aFd);
 
   bool mPrintInitialized = false;
-  bool mDestroyed = false;
   nsresult mInitializationResult = NS_OK;
   RefPtr<nsPagePrintTimer> mPagePrintTimer;
   RefPtr<nsPrintEngine> mPrintEngine;
   PRFileDesc* mNextPageFD = nullptr;
 };
 
 } // namespace layout
 } // namespace mozilla
--- a/layout/printing/ipc/RemotePrintJobParent.cpp
+++ b/layout/printing/ipc/RemotePrintJobParent.cpp
@@ -22,17 +22,16 @@
 #include "private/pprio.h"
 #include "nsAnonymousTemporaryFile.h"
 
 namespace mozilla {
 namespace layout {
 
 RemotePrintJobParent::RemotePrintJobParent(nsIPrintSettings* aPrintSettings)
   : mPrintSettings(aPrintSettings)
-  , mIsDoingPrinting(false)
 {
   MOZ_COUNT_CTOR(RemotePrintJobParent);
 }
 
 mozilla::ipc::IPCResult
 RemotePrintJobParent::RecvInitializePrint(const nsString& aDocumentTitle,
                                           const nsString& aPrintToFile,
                                           const int32_t& aStartPage,
@@ -84,22 +83,16 @@ RemotePrintJobParent::InitializePrintDev
   }
 
   rv = mPrintDeviceContext->BeginDocument(aDocumentTitle, aPrintToFile,
                                           aStartPage, aEndPage);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  if (!mPrintDeviceContext->IsSyncPagePrinting()) {
-    mPrintDeviceContext->RegisterPageDoneCallback([this](nsresult aResult) { PageDone(aResult); });
-  }
-
-  mIsDoingPrinting = true;
-
   return NS_OK;
 }
 
 nsresult
 RemotePrintJobParent::PrepareNextPageFD(FileDescriptor* aFd)
 {
   PRFileDesc* prFd = nullptr;
   nsresult rv = NS_OpenAnonymousTemporaryFile(&prFd);
@@ -118,20 +111,29 @@ RemotePrintJobParent::RecvProcessPage()
   if (!mCurrentPageStream.IsOpen()) {
     Unused << SendAbortPrint(NS_ERROR_FAILURE);
     return IPC_OK();
   }
   mCurrentPageStream.Seek(0, PR_SEEK_SET);
   nsresult rv = PrintPage(mCurrentPageStream);
   mCurrentPageStream.Close();
 
-  if (mPrintDeviceContext->IsSyncPagePrinting()) {
-    PageDone(rv);
+  if (NS_FAILED(rv)) {
+    Unused << SendAbortPrint(rv);
+    return IPC_OK();
   }
 
+  FileDescriptor fd;
+  rv = PrepareNextPageFD(&fd);
+  if (NS_FAILED(rv)) {
+    Unused << SendAbortPrint(rv);
+    return IPC_OK();
+  }
+
+  Unused << SendPageProcessed(fd);
   return IPC_OK();
 }
 
 nsresult
 RemotePrintJobParent::PrintPage(PRFileDescStream& aRecording)
 {
   MOZ_ASSERT(mPrintDeviceContext);
 
@@ -146,67 +148,40 @@ RemotePrintJobParent::PrintPage(PRFileDe
   rv = mPrintDeviceContext->EndPage();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   return NS_OK;
 }
 
-void
-RemotePrintJobParent::PageDone(nsresult aResult)
-{
-  MOZ_ASSERT(mIsDoingPrinting);
-
-  if (NS_FAILED(aResult)) {
-    Unused << SendAbortPrint(aResult);
-  } else {
-    FileDescriptor fd;
-    aResult = PrepareNextPageFD(&fd);
-    if (NS_FAILED(aResult)) {
-      Unused << SendAbortPrint(aResult);
-    }
-
-    Unused << SendPageProcessed(fd);
-  }
-}
-
 mozilla::ipc::IPCResult
 RemotePrintJobParent::RecvFinalizePrint()
 {
   // EndDocument is sometimes called in the child even when BeginDocument has
   // not been called. See bug 1223332.
   if (mPrintDeviceContext) {
     DebugOnly<nsresult> rv = mPrintDeviceContext->EndDocument();
 
     // Too late to abort the child just log.
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "EndDocument failed");
-
-    // Since RecvFinalizePrint is called after all page printed, there should
-    // be no more page-done callbacks after that, in theory. Unregistering
-    // page-done callback is not must have, but we still do this for safety.
-    mPrintDeviceContext->UnregisterPageDoneCallback();
   }
 
-  mIsDoingPrinting = false;
 
   Unused << Send__delete__(this);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 RemotePrintJobParent::RecvAbortPrint(const nsresult& aRv)
 {
   if (mPrintDeviceContext) {
     Unused << mPrintDeviceContext->AbortDocument();
-    mPrintDeviceContext->UnregisterPageDoneCallback();
   }
 
-  mIsDoingPrinting = false;
-
   Unused << Send__delete__(this);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 RemotePrintJobParent::RecvStateChange(const long& aStateFlags,
                                       const nsresult& aStatus)
 {
@@ -266,17 +241,12 @@ RemotePrintJobParent::GetPrintSettings()
 RemotePrintJobParent::~RemotePrintJobParent()
 {
   MOZ_COUNT_DTOR(RemotePrintJobParent);
 }
 
 void
 RemotePrintJobParent::ActorDestroy(ActorDestroyReason aWhy)
 {
-  if (mPrintDeviceContext) {
-    mPrintDeviceContext->UnregisterPageDoneCallback();
-  }
-
-  mIsDoingPrinting = false;
 }
 
 } // namespace layout
 } // namespace mozilla
--- a/layout/printing/ipc/RemotePrintJobParent.h
+++ b/layout/printing/ipc/RemotePrintJobParent.h
@@ -71,26 +71,19 @@ private:
                                  const nsString& aPrintToFile,
                                  const int32_t& aStartPage,
                                  const int32_t& aEndPage);
 
   nsresult PrepareNextPageFD(FileDescriptor* aFd);
 
   nsresult PrintPage(PRFileDescStream& aRecording);
 
-  /**
-   * Called to notify our corresponding RemotePrintJobChild once we've
-   * finished printing a page.
-   */
-  void PageDone(nsresult aResult);
-
   nsCOMPtr<nsIPrintSettings> mPrintSettings;
   RefPtr<nsDeviceContext> mPrintDeviceContext;
   UniquePtr<PrintTranslator> mPrintTranslator;
   nsCOMArray<nsIWebProgressListener> mPrintProgressListeners;
   PRFileDescStream mCurrentPageStream;
-  bool mIsDoingPrinting;
 };
 
 } // namespace layout
 } // namespace mozilla
 
 #endif // mozilla_layout_RemotePrintJobParent_h
--- a/layout/printing/nsPagePrintTimer.cpp
+++ b/layout/printing/nsPagePrintTimer.cpp
@@ -75,19 +75,22 @@ nsPagePrintTimer::Run()
   // Check to see if we are done
   // inRange will be true if a page is actually printed
   bool inRange;
   bool donePrinting;
 
   // donePrinting will be true if it completed successfully or
   // if the printing was cancelled
   donePrinting = !mPrintEngine || mPrintEngine->PrintPage(mPrintObj, inRange);
-  if (mPrintEngine && donePrinting) {
-    initNewTimer = false;
-    mDone = true;
+  if (donePrinting) {
+    // now clean up print or print the next webshell
+    if (!mPrintEngine || mPrintEngine->DonePrintingPages(mPrintObj, NS_OK)) {
+      initNewTimer = false;
+      mDone = true;
+    }
   }
 
   // Note that the Stop() destroys this after the print job finishes
   // (The PrintEngine stops holding a reference when DonePrintingPages
   // returns true.)
   Stop();
   if (initNewTimer) {
     ++mFiringCount;
@@ -173,21 +176,16 @@ nsPagePrintTimer::WaitForRemotePrint()
 
 void
 nsPagePrintTimer::RemotePrintFinished()
 {
   if (!mWaitingForRemotePrint) {
     return;
   }
 
-  // now clean up print or print the next webshell
-  if (mDone && mPrintEngine) {
-    mPrintEngine->DonePrintingPages(mPrintObj, NS_OK);
-  }
-
   mWaitingForRemotePrint->SetTarget(
     mDocument->EventTargetFor(mozilla::TaskCategory::Other));
   mozilla::Unused <<
     mWaitingForRemotePrint->InitWithCallback(this, 0, nsITimer::TYPE_ONE_SHOT);
 }
 
 nsresult
 nsPagePrintTimer::Start(nsPrintObject* aPO)
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -675,21 +675,16 @@ nsPrintEngine::DoCommonPrint(bool       
 
   rv = devspec->Init(nullptr, printData->mPrintSettings, aIsPrintPreview);
   NS_ENSURE_SUCCESS(rv, rv);
 
   printData->mPrintDC = new nsDeviceContext();
   rv = printData->mPrintDC->InitForPrinting(devspec);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (XRE_IsParentProcess() && !printData->mPrintDC->IsSyncPagePrinting()) {
-    RefPtr<nsPrintEngine> self(this);
-    printData->mPrintDC->RegisterPageDoneCallback([self](nsresult aResult) { self->PageDone(aResult); });
-  }
-
   if (aIsPrintPreview) {
     printData->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs);
 
     // override any UI that wants to PrintPreview any selection or page range
     // we want to view every page in PrintPreview each time
     printData->mPrintSettings->SetPrintRange(nsIPrintSettings::kRangeAllPages);
   } else {
     // Always check and set the print settings first and then fall back
@@ -2789,17 +2784,16 @@ nsPrintEngine::PrintPage(nsPrintObject* 
 
   PR_PL(("-----------------------------------\n"));
   PR_PL(("------ In DV::PrintPage PO: %p (%s)\n", aPO, gFrameTypesStr[aPO->mFrameType]));
 
   // Check setting to see if someone request it be cancelled
   bool isCancelled = false;
   printData->mPrintSettings->GetIsCancelled(&isCancelled);
   if (isCancelled || printData->mIsAborted) {
-    DonePrintingPages(aPO, NS_OK);
     return true;
   }
 
   int32_t pageNum, numPages, endPage;
   nsIPageSequenceFrame* pageSeqFrame = do_QueryFrame(mPageSeqFrame.GetFrame());
   pageSeqFrame->GetCurrentPageNum(&pageNum);
   pageSeqFrame->GetNumPages(&numPages);
 
@@ -2840,20 +2834,16 @@ nsPrintEngine::PrintPage(nsPrintObject* 
   printData->DoOnProgressChange(++printData->mNumPagesPrinted,
                                 endPage, false, 0);
   if (NS_WARN_IF(mPrt != printData)) {
     // If current printing is canceled or new print is started, let's return
     // true to notify the caller of current printing is done.
     return true;
   }
 
-  if (XRE_IsParentProcess() && !printData->mPrintDC->IsSyncPagePrinting()) {
-    mPagePrintTimer->WaitForRemotePrint();
-  }
-
   // Print the Page
   // if a print job was cancelled externally, an EndPage or BeginPage may
   // fail and the failure is passed back here.
   // Returning true means we are done printing.
   //
   // When rv == NS_ERROR_ABORT, it means we want out of the
   // print job without displaying any error messages
   nsresult rv = pageSeqFrame->PrintNextPage();
@@ -2865,26 +2855,16 @@ nsPrintEngine::PrintPage(nsPrintObject* 
     return true;
   }
 
   pageSeqFrame->DoPageEnd();
 
   return donePrinting;
 }
 
-void
-nsPrintEngine::PageDone(nsresult aResult)
-{
-  MOZ_ASSERT(mIsDoingPrinting);
-
-  // mPagePrintTimer might be released during RemotePrintFinished, keep a
-  // reference here to make sure it lives long enough.
-  RefPtr<nsPagePrintTimer> timer = mPagePrintTimer;
-  timer->RemotePrintFinished();
-}
 
 //-----------------------------------------------------------------
 //-- Done: Printing Methods
 //-----------------------------------------------------------------
 
 
 //-----------------------------------------------------------------
 //-- Section: Misc Support Methods
@@ -3032,18 +3012,16 @@ nsPrintEngine::DonePrintingPages(nsPrint
     nsresult rv;
     bool didPrint = PrintDocContent(printData->mPrintObject, rv);
     if (NS_SUCCEEDED(rv) && didPrint) {
       PR_PL(("****** In DV::DonePrintingPages PO: %p (%s) didPrint:%s (Not Done Printing)\n", aPO, gFrameTypesStr[aPO->mFrameType], PRT_YESNO(didPrint)));
       return false;
     }
   }
 
-  printData->mPrintDC->UnregisterPageDoneCallback();
-
   if (NS_SUCCEEDED(aResult)) {
     FirePrintCompletionEvent();
     // XXX mPrt may be cleared or replaced with new instance here.
     //     However, the following methods will clean up with new mPrt or will
     //     do nothing due to no proper nsPrintData instance.
   }
 
   TurnScriptingOn(true);
--- a/layout/printing/nsPrintEngine.h
+++ b/layout/printing/nsPrintEngine.h
@@ -274,12 +274,11 @@ protected:
   void UpdateZoomRatio(nsPrintObject* aPO, bool aSetPixelScale);
   nsresult ReconstructAndReflow(bool aDoSetPixelScale);
   nsresult UpdateSelectionAndShrinkPrintObject(nsPrintObject* aPO,
                                                bool aDocumentIsTopLevel);
   nsresult InitPrintDocConstruction(bool aHandleError);
   void FirePrintPreviewUpdateEvent();
 private:
   nsPrintEngine& operator=(const nsPrintEngine& aOther) = delete;
-  void PageDone(nsresult aResult);
 };
 
 #endif /* nsPrintEngine_h___ */
--- a/modules/pdfium/pdfium.def
+++ b/modules/pdfium/pdfium.def
@@ -2,14 +2,13 @@
 ; License, v. 2.0. If a copy of the MPL was not distributed with this
 ; file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 LIBRARY pdfium
 EXPORTS
     FPDF_InitLibrary
     FPDF_DestroyLibrary
     FPDF_LoadDocument
-    FPDF_LoadCustomDocument
     FPDF_CloseDocument
     FPDF_GetPageCount
     FPDF_LoadPage
     FPDF_ClosePage
     FPDF_RenderPage
--- a/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
+++ b/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
@@ -842,95 +842,16 @@ SandboxBroker::SetSecurityLevelForPlugin
                             sandbox::TargetPolicy::REG_ALLOW_ANY,
                             L"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedPidlMRULegacy\\*");
   SANDBOX_ENSURE_SUCCESS(result,
                          "With these static arguments AddRule should never fail, what happened?");
 
   return true;
 }
 
-#ifdef MOZ_ENABLE_SKIA_PDF
-bool
-SandboxBroker::SetSecurityLevelForPDFiumProcess()
-{
-  if (!mPolicy) {
-    return false;
-  }
-
-  auto result = SetJobLevel(mPolicy, sandbox::JOB_LOCKDOWN,
-                            0 /* ui_exceptions */);
-  SANDBOX_ENSURE_SUCCESS(result,
-                         "SetJobLevel should never fail with these arguments, what happened?");
-  result = mPolicy->SetTokenLevel(sandbox::USER_RESTRICTED_SAME_ACCESS,
-                                  sandbox::USER_LOCKDOWN);
-  SANDBOX_ENSURE_SUCCESS(result,
-                         "SetTokenLevel should never fail with these arguments, what happened?");
-
-  result = mPolicy->SetAlternateDesktop(true);
-  SANDBOX_ENSURE_SUCCESS(result,
-                         "Failed to create alternate desktop for sandbox.");
-
-  result = mPolicy->SetIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW);
-  MOZ_ASSERT(sandbox::SBOX_ALL_OK == result,
-             "SetIntegrityLevel should never fail with these arguments, what happened?");
-
-  result =
-    mPolicy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_UNTRUSTED);
-  SANDBOX_ENSURE_SUCCESS(result,
-                         "SetIntegrityLevel should never fail with these arguments, what happened?");
-
-  // XXX bug 1412933
-  // We should also disables win32k for the PDFium process by adding
-  // MITIGATION_WIN32K_DISABLE flag here after fixing bug 1412933.
-  sandbox::MitigationFlags mitigations =
-    sandbox::MITIGATION_BOTTOM_UP_ASLR |
-    sandbox::MITIGATION_HEAP_TERMINATE |
-    sandbox::MITIGATION_SEHOP |
-    sandbox::MITIGATION_DEP_NO_ATL_THUNK |
-    sandbox::MITIGATION_DEP |
-    sandbox::MITIGATION_EXTENSION_POINT_DISABLE |
-    sandbox::MITIGATION_IMAGE_LOAD_NO_LOW_LABEL;
-
-  if (!sRunningFromNetworkDrive) {
-    mitigations |= sandbox::MITIGATION_IMAGE_LOAD_NO_REMOTE;
-  }
-
-  result = mPolicy->SetProcessMitigations(mitigations);
-  SANDBOX_ENSURE_SUCCESS(result,
-                         "Invalid flags for SetProcessMitigations.");
-
-  mitigations =
-    sandbox::MITIGATION_STRICT_HANDLE_CHECKS |
-    sandbox::MITIGATION_DLL_SEARCH_ORDER;
-
-  result = mPolicy->SetDelayedProcessMitigations(mitigations);
-  SANDBOX_ENSURE_SUCCESS(result,
-                         "Invalid flags for SetDelayedProcessMitigations.");
-
-  // Add the policy for the client side of a pipe. It is just a file
-  // in the \pipe\ namespace. We restrict it to pipes that start with
-  // "chrome." so the sandboxed process cannot connect to system services.
-  result = mPolicy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
-                            sandbox::TargetPolicy::FILES_ALLOW_ANY,
-                            L"\\??\\pipe\\chrome.*");
-  SANDBOX_ENSURE_SUCCESS(result,
-                         "With these static arguments AddRule should never fail, what happened?");
-
-  // The PDFium process needs to be able to duplicate shared memory handles,
-  // which are Section handles, to the broker process.
-  result = mPolicy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES,
-                            sandbox::TargetPolicy::HANDLES_DUP_BROKER,
-                            L"Section");
-  MOZ_RELEASE_ASSERT(sandbox::SBOX_ALL_OK == result,
-                     "With these static arguments AddRule should never fail, hat happened?");
-
-  return true;
-}
-#endif
-
 bool
 SandboxBroker::SetSecurityLevelForGMPlugin(SandboxLevel aLevel)
 {
   if (!mPolicy) {
     return false;
   }
 
   auto result = SetJobLevel(mPolicy, sandbox::JOB_LOCKDOWN,
--- a/security/sandbox/win/src/sandboxbroker/sandboxBroker.h
+++ b/security/sandbox/win/src/sandboxbroker/sandboxBroker.h
@@ -43,19 +43,16 @@ public:
 #if defined(MOZ_CONTENT_SANDBOX)
   void SetSecurityLevelForContentProcess(int32_t aSandboxLevel,
                                          bool aIsFileProcess);
 #endif
 
   void SetSecurityLevelForGPUProcess(int32_t aSandboxLevel);
 
   bool SetSecurityLevelForPluginProcess(int32_t aSandboxLevel);
-#ifdef MOZ_ENABLE_SKIA_PDF
-  bool SetSecurityLevelForPDFiumProcess();
-#endif
   enum SandboxLevel {
     LockDown,
     Restricted
   };
   bool SetSecurityLevelForGMPlugin(SandboxLevel aLevel);
 
   // File system permissions
   bool AllowReadFile(wchar_t const *file);
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -897,20 +897,19 @@ nsXULAppInfo::GetWidgetToolkit(nsACStrin
                 "GeckoProcessType in nsXULAppAPI.h not synchronized with nsIXULRuntime.idl");
 
 SYNC_ENUMS(DEFAULT, Default)
 SYNC_ENUMS(PLUGIN, Plugin)
 SYNC_ENUMS(CONTENT, Content)
 SYNC_ENUMS(IPDLUNITTEST, IPDLUnitTest)
 SYNC_ENUMS(GMPLUGIN, GMPlugin)
 SYNC_ENUMS(GPU, GPU)
-SYNC_ENUMS(PDFIUM, PDFium)
 
 // .. and ensure that that is all of them:
-static_assert(GeckoProcessType_PDFium + 1 == GeckoProcessType_End,
+static_assert(GeckoProcessType_GPU + 1 == GeckoProcessType_End,
               "Did not find the final GeckoProcessType");
 
 NS_IMETHODIMP
 nsXULAppInfo::GetProcessType(uint32_t* aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
   *aResult = XRE_GetProcessType();
   return NS_OK;
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -111,20 +111,16 @@
 
 using mozilla::_ipdltest::IPDLUnitTestProcessChild;
 #endif  // ifdef MOZ_IPDL_TESTS
 
 #ifdef MOZ_JPROF
 #include "jprof.h"
 #endif
 
-#if defined(XP_WIN) && defined(MOZ_ENABLE_SKIA_PDF)
-#include "mozilla/widget/PDFiumProcessChild.h"
-#endif
-
 using namespace mozilla;
 
 using mozilla::ipc::BrowserProcessSubThread;
 using mozilla::ipc::GeckoChildProcessHost;
 using mozilla::ipc::IOThreadChild;
 using mozilla::ipc::ProcessChild;
 using mozilla::ipc::ScopedXREEmbed;
 
@@ -604,17 +600,16 @@ XRE_InitChildProcess(int aArgc,
   MessageLoop::Type uiLoopType;
   switch (XRE_GetProcessType()) {
   case GeckoProcessType_Content:
   case GeckoProcessType_GPU:
       // Content processes need the XPCOM/chromium frankenventloop
       uiLoopType = MessageLoop::TYPE_MOZILLA_CHILD;
       break;
   case GeckoProcessType_GMPlugin:
-  case GeckoProcessType_PDFium:
       uiLoopType = MessageLoop::TYPE_DEFAULT;
       break;
   default:
       uiLoopType = MessageLoop::TYPE_UI;
       break;
   }
 
   {
@@ -652,21 +647,16 @@ XRE_InitChildProcess(int aArgc,
         MOZ_CRASH("rebuild with --enable-ipdl-tests");
 #endif
         break;
 
       case GeckoProcessType_GMPlugin:
         process = new gmp::GMPProcessChild(parentPID);
         break;
 
-#if defined(XP_WIN) && defined(MOZ_ENABLE_SKIA_PDF)
-      case GeckoProcessType_PDFium:
-        process = new widget::PDFiumProcessChild(parentPID);
-        break;
-#endif
       case GeckoProcessType_GPU:
         process = new gfx::GPUProcessImpl(parentPID);
         break;
 
       default:
         MOZ_CRASH("Unknown main thread class");
       }
 
--- a/widget/nsBaseClipboard.h
+++ b/widget/nsBaseClipboard.h
@@ -35,12 +35,13 @@ protected:
 
   NS_IMETHOD SetNativeClipboardData ( int32_t aWhichClipboard ) = 0;
   NS_IMETHOD GetNativeClipboardData ( nsITransferable * aTransferable, int32_t aWhichClipboard ) = 0;
 
   bool                mEmptyingForSetData;
   bool                mIgnoreEmptyNotification;
   nsCOMPtr<nsIClipboardOwner> mClipboardOwner;
   nsCOMPtr<nsITransferable>   mTransferable;
+
 };
 
 #endif // nsBaseClipboard_h__
 
--- a/widget/windows/InkCollector.h
+++ b/widget/windows/InkCollector.h
@@ -59,17 +59,17 @@ public:
   HWND GetTarget();
   void SetTarget(HWND aTargetWindow);
   void ClearTarget();
 
   uint16_t GetPointerId(); // 0 shows that there is no existing pen.
   void SetPointerId(uint16_t aPointerId);
   void ClearPointerId();
 
-  static mozilla::StaticAutoPtr<InkCollector> sInkCollector;
+  static StaticAutoPtr<InkCollector> sInkCollector;
 
 protected:
   void Initialize();
   void OnInitialize();
   void Enable(bool aNewState);
 
 private:
   RefPtr<IUnknown>          mMarshaller;
--- a/widget/windows/PDFViaEMFPrintHelper.cpp
+++ b/widget/windows/PDFViaEMFPrintHelper.cpp
@@ -5,43 +5,41 @@
 
 #include "PDFViaEMFPrintHelper.h"
 #include "nsIFileStreams.h"
 #include "WindowsEMF.h"
 #include "nsFileStreams.h"
 #include "mozilla/UniquePtrExtensions.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/Unused.h"
-#include "mozilla/ipc/ProtocolUtils.h"
 
 /* Scale DC by keeping aspect ratio */
 static
 float ComputeScaleFactor(int aDCWidth, int aDCHeight,
                          int aPageWidth, int aPageHeight)
 {
   MOZ_ASSERT(aPageWidth !=0 && aPageWidth != 0);
 
   return (aDCWidth >= aPageWidth && aDCHeight >= aPageHeight)
     ? 1.0 /* If page fits DC - no scaling needed. */
     : std::min(static_cast<float>(aDCWidth) / static_cast<float>(aPageWidth),         static_cast<float>(aDCHeight) / static_cast<float>(aPageHeight));
 }
 
 PDFViaEMFPrintHelper::PDFViaEMFPrintHelper()
   : mPDFDoc(nullptr)
-  , mPrfile(nullptr)
 {
 }
 
 PDFViaEMFPrintHelper::~PDFViaEMFPrintHelper()
 {
   CloseDocument();
 }
 
 nsresult
-PDFViaEMFPrintHelper::OpenDocument(nsIFile* aFile)
+PDFViaEMFPrintHelper::OpenDocument(nsIFile *aFile)
 {
   MOZ_ASSERT(aFile);
 
   if (mPDFDoc) {
     MOZ_ASSERT_UNREACHABLE("We can only open one PDF at a time,"
                            "Use CloseDocument() to close the opened file"
                            "before calling OpenDocument()");
     return NS_ERROR_FAILURE;
@@ -72,48 +70,16 @@ PDFViaEMFPrintHelper::OpenDocument(const
   NS_ENSURE_TRUE(CreatePDFiumEngineIfNeed(), NS_ERROR_FAILURE);
 
   mPDFDoc = mPDFiumEngine->LoadDocument(aFileName, nullptr);
   NS_ENSURE_TRUE(mPDFDoc, NS_ERROR_FAILURE);
 
   return NS_OK;
 }
 
-nsresult
-PDFViaEMFPrintHelper::OpenDocument(const FileDescriptor& aFD)
-{
-  MOZ_ASSERT(!mPrfile, "Forget to call CloseDocument?");
-
-  if (mPDFDoc) {
-    MOZ_ASSERT_UNREACHABLE("We can only open one PDF at a time, "
-                           "Use CloseDocument() to close the opened file "
-                           "before calling OpenDocument()");
-    return NS_ERROR_FAILURE;
-  }
-
-  NS_ENSURE_TRUE(CreatePDFiumEngineIfNeed(), NS_ERROR_FAILURE);
-
-  auto rawFD = aFD.ClonePlatformHandle();
-  PRFileDesc* prfile = PR_ImportFile(PROsfd(rawFD.release()));
-  NS_ENSURE_TRUE(prfile, NS_ERROR_FAILURE);
-
-  mPDFDoc = mPDFiumEngine->LoadDocument(prfile, nullptr);
-  if (!mPDFDoc) {
-    PR_Close(prfile);
-    return NS_ERROR_FAILURE;
-  }
-
-  // mPDFiumEngine keeps using this handle until we close mPDFDoc. Instead of
-  // closing this HANDLE here, we close it in
-  // PDFViaEMFPrintHelper::CloseDocument.
-  mPrfile = prfile;
-
-  return NS_OK;
-}
-
 bool
 PDFViaEMFPrintHelper::RenderPageToDC(HDC aDC, unsigned int aPageIndex,
                                      int aPageWidth, int aPageHeight)
 {
   MOZ_ASSERT(aDC && mPDFDoc);
   MOZ_ASSERT(static_cast<int>(aPageIndex) <
              mPDFiumEngine->GetPageCount(mPDFDoc));
 
@@ -178,91 +144,46 @@ PDFViaEMFPrintHelper::DrawPage(HDC aPrin
   NS_ENSURE_TRUE(result, false);
 
   RECT printRect = {0, 0, aPageWidth, aPageHeight};
   result = emf.Playback(aPrinterDC, printRect);
   return result;
 }
 
 bool
-PDFViaEMFPrintHelper::SavePageToFile(const wchar_t* aFilePath,
+PDFViaEMFPrintHelper::DrawPageToFile(const wchar_t* aFilePath,
                                      unsigned int aPageIndex,
                                      int aPageWidth, int aPageHeight)
 {
-  MOZ_ASSERT(aFilePath);
-
   // OpenDocument might fail.
   if (!mPDFDoc) {
     MOZ_ASSERT_UNREACHABLE("Make sure OpenDocument return true before"
                            "using DrawPageToFile.");
     return false;
   }
 
   WindowsEMF emf;
   bool result = emf.InitForDrawing(aFilePath);
   NS_ENSURE_TRUE(result, false);
 
   result = RenderPageToDC(emf.GetDC(), aPageIndex, aPageWidth, aPageHeight);
   NS_ENSURE_TRUE(result, false);
   return emf.SaveToFile();
 }
 
-bool
-PDFViaEMFPrintHelper::SavePageToBuffer(unsigned int aPageIndex,
-                                       int aPageWidth, int aPageHeight,
-                                       ipc::Shmem& aMem,
-                                       mozilla::ipc::IShmemAllocator* aAllocator)
-{
-  MOZ_ASSERT(aAllocator);
-
-  // OpenDocument might fail.
-  if (!mPDFDoc) {
-    MOZ_ASSERT_UNREACHABLE("Make sure OpenDocument return true before"
-                           "using DrawPageToFile.");
-    return false;
-  }
-
-  WindowsEMF emf;
-  bool result = emf.InitForDrawing();
-  NS_ENSURE_TRUE(result, false);
-
-  result = RenderPageToDC(emf.GetDC(), aPageIndex, aPageWidth, aPageHeight);
-  NS_ENSURE_TRUE(result, false);
-
-  UINT emfSize = emf.GetEMFContentSize();
-  NS_ENSURE_TRUE(emfSize != 0, false);
-
-  auto shmType = ipc::SharedMemory::SharedMemoryType::TYPE_BASIC;
-  result = aAllocator->AllocShmem(emfSize, shmType, &aMem);
-  NS_ENSURE_TRUE(result, false);
-
-  if (!emf.GetEMFContentBits(aMem.get<BYTE>())) {
-    aAllocator->DeallocShmem(aMem);
-    return false;;
-  }
-
-  return true;
-}
-
 void
 PDFViaEMFPrintHelper::CloseDocument()
 {
   if (mPDFDoc) {
     mPDFiumEngine->CloseDocument(mPDFDoc);
     mPDFDoc = nullptr;
   }
-
-  if (mPrfile) {
-    PR_Close(mPrfile);
-    mPrfile = nullptr;
-  }
 }
 
 bool
 PDFViaEMFPrintHelper::CreatePDFiumEngineIfNeed()
 {
   if (!mPDFiumEngine) {
     mPDFiumEngine = PDFiumEngineShim::GetInstanceOrNull();
-    MOZ_ASSERT(mPDFiumEngine);
   }
 
   return !!mPDFiumEngine;
 }
\ No newline at end of file
--- a/widget/windows/PDFViaEMFPrintHelper.h
+++ b/widget/windows/PDFViaEMFPrintHelper.h
@@ -4,79 +4,60 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef PDFVIAEMFPRINTHELPER_H_
 #define PDFVIAEMFPRINTHELPER_H_
 
 #include "nsCOMPtr.h"
 #include "PDFiumEngineShim.h"
 #include "mozilla/Vector.h"
-#include "mozilla/ipc/FileDescriptor.h"
-#include "mozilla/ipc/Shmem.h"
 
 /* include windows.h for the HDC definitions that we need. */
 #include <windows.h>
 
 class nsIFile;
 class nsFileInputStream;
 
 namespace mozilla {
-
-namespace ipc {
-  class IShmemAllocator;
-}
-
 namespace widget {
 
 /**
  * This class helps draw a PDF file to a given Windows DC.
  * To do that it first converts the PDF file to EMF.
  * Windows EMF:
  * https://msdn.microsoft.com/en-us/windows/hardware/drivers/print/emf-data-type
  */
 class PDFViaEMFPrintHelper
 {
 public:
-  typedef mozilla::ipc::FileDescriptor FileDescriptor;
-
   PDFViaEMFPrintHelper();
   virtual ~PDFViaEMFPrintHelper();
 
   /** Loads the specified PDF file. */
-  NS_IMETHOD OpenDocument(nsIFile* aFile);
+  NS_IMETHOD OpenDocument(nsIFile *aFile);
   NS_IMETHOD OpenDocument(const char* aFileName);
-  NS_IMETHOD OpenDocument(const FileDescriptor& aFD);
 
   /** Releases document buffer. */
   void CloseDocument();
 
   int GetPageCount() const { return mPDFiumEngine->GetPageCount(mPDFDoc); }
 
-  /**
-   * Convert the specified PDF page to EMF and draw the EMF onto the
-   * given DC.
-   */
+  /** Convert specified PDF page to EMF and draw the EMF onto the given DC. */
   bool DrawPage(HDC aPrinterDC, unsigned int aPageIndex,
                 int aPageWidth, int aPageHeight);
 
-  /** Convert the specified PDF page to EMF and save it to file. */
-  bool SavePageToFile(const wchar_t* aFilePath, unsigned int aPageIndex,
+  /** Convert specified PDF page to EMF and save it to file. */
+  bool DrawPageToFile(const wchar_t* aFilePath, unsigned int aPageIndex,
                       int aPageWidth, int aPageHeight);
 
-  /** Create a share memory and serialize the EMF content into it. */
-  bool SavePageToBuffer(unsigned int aPageIndex, int aPageWidth,
-                        int aPageHeight, ipc::Shmem& aMem,
-                        mozilla::ipc::IShmemAllocator* aAllocator);
-
 protected:
   virtual bool CreatePDFiumEngineIfNeed();
   bool RenderPageToDC(HDC aDC, unsigned int aPageIndex,
                       int aPageWidth, int aPageHeight);
 
   RefPtr<PDFiumEngineShim>    mPDFiumEngine;
   FPDF_DOCUMENT               mPDFDoc;
-  PRFileDesc*                 mPrfile;
 };
 
 } // namespace widget
 } // namespace mozilla
 
 #endif /* PDFVIAEMFPRINTHELPER_H_ */
deleted file mode 100644
--- a/widget/windows/PDFiumChild.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "PDFiumChild.h"
-#include "nsLocalFile.h"
-#include "mozilla/widget/PDFViaEMFPrintHelper.h"
-
-namespace mozilla {
-namespace widget {
-
-PDFiumChild::PDFiumChild()
-{
-}
-
-PDFiumChild::~PDFiumChild()
-{
-}
-
-bool
-PDFiumChild::Init(base::ProcessId aParentPid,
-                  MessageLoop* aIOLoop,
-                  IPC::Channel* aChannel)
-{
-  if (NS_WARN_IF(!Open(aChannel, aParentPid, aIOLoop))) {
-    return false;
-  }
-
-  return true;
-}
-
-mozilla::ipc::IPCResult
-PDFiumChild::RecvConvertToEMF(const FileDescriptor& aFD,
-                              const int& aPageWidth,
-                              const int& aPageHeight)
-{
-  MOZ_ASSERT(aFD.IsValid() && aPageWidth != 0 && aPageHeight != 0);
-
-  PDFViaEMFPrintHelper convertor;
-  if (NS_FAILED(convertor.OpenDocument(aFD))) {
-    Unused << SendConvertToEMFDone(NS_ERROR_FAILURE, ipc::Shmem());
-    return IPC_OK();
-  }
-
-  MOZ_ASSERT(convertor.GetPageCount() == 1, "we assume each given PDF contains"                                        "one page only");
-
-  ipc::Shmem smem;
-  if (!convertor.SavePageToBuffer(0, aPageWidth, aPageHeight, smem, this)) {
-    Unused << SendConvertToEMFDone(NS_ERROR_FAILURE, smem);
-    return IPC_OK();
-  }
-
-  if (!smem.IsReadable()) {
-    Unused << SendConvertToEMFDone(NS_ERROR_FAILURE, smem);
-    return IPC_OK();
-  }
-
-  Unused << SendConvertToEMFDone(NS_OK, smem);
-  return IPC_OK();
-}
-
-void
-PDFiumChild::OnChannelConnected(int32_t pid)
-{
-  SetOtherProcessId(pid);
-}
-
-void
-PDFiumChild::ActorDestroy(ActorDestroyReason why)
-{
-  XRE_ShutdownChildProcess();
-}
-
-} // namespace widget
-} // namespace mozilla
deleted file mode 100644
--- a/widget/windows/PDFiumChild.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef PDFIUMCHILD_H_
-#define PDFIUMCHILD_H_
-
-#include "mozilla/widget/PPDFiumChild.h"
-
-namespace mozilla {
-namespace widget {
-
-class PDFiumChild final : public PPDFiumChild,
-                          public mozilla::ipc::IShmemAllocator
-{
-public:
-  PDFiumChild();
-  virtual ~PDFiumChild();
-
-  bool Init(base::ProcessId aParentPid,
-            MessageLoop* aIOLoop,
-            IPC::Channel* aChannel);
-
-  FORWARD_SHMEM_ALLOCATOR_TO(PPDFiumChild)
-
-private:
-  // PPDFiumChild functions.
-  mozilla::ipc::IPCResult RecvConvertToEMF(const FileDescriptor& aFD,
-                                           const int& aPageWidth,
-                                           const int& aPageHeight) override;
-  void ActorDestroy(ActorDestroyReason aWhy) override;
-  void OnChannelConnected(int32_t pid) override;
-};
-
-} // namespace widget
-} // namespace mozilla
-
-#endif // PDFIUMCHILD_H_
\ No newline at end of file
--- a/widget/windows/PDFiumEngineShim.cpp
+++ b/widget/windows/PDFiumEngineShim.cpp
@@ -1,68 +1,21 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "PDFiumEngineShim.h"
-#include "private/pprio.h"
 
-typedef void (STDCALL *FPDF_InitLibrary_Pfn)();
-typedef void (STDCALL *FPDF_DestroyLibrary_Pfn)();
-
-typedef FPDF_DOCUMENT (STDCALL *FPDF_LoadDocument_Pfn)(FPDF_STRING file_path,
-                                                      FPDF_BYTESTRING password);
-typedef FPDF_DOCUMENT (STDCALL *FPDF_LoadCustomDocument_Pfn)(FPDF_FILEACCESS* pFileAccess,
-                                                             FPDF_BYTESTRING password);
-typedef void(STDCALL *FPDF_CloseDocument_Pfn)(FPDF_DOCUMENT aDocument);
-
-typedef int (STDCALL *FPDF_GetPageCount_Pfn)(FPDF_DOCUMENT aDocument);
-
-typedef FPDF_PAGE (STDCALL *FPDF_LoadPage_Pfn)(FPDF_DOCUMENT aDocument,
-                                               int aPageIndex);
-typedef void (STDCALL *FPDF_ClosePage_Pfn)(FPDF_PAGE aPage);
-typedef void (STDCALL *FPDF_RenderPage_Pfn)(HDC aDC,
-                                            FPDF_PAGE aPage,
-                                            int aStartX,
-                                            int aStartY,
-                                            int aSizeX,
-                                            int aSizeY,
-                                            int aRotate,
-                                            int aFlags);
 
 namespace mozilla {
 namespace widget {
 
 static PDFiumEngineShim* sPDFiumEngineShim;
 
-struct PDFFunctionPointerTable
-{
-  PDFFunctionPointerTable()
-    : mFPDF_InitLibrary(nullptr)
-    , mFPDF_DestroyLibrary(nullptr)
-    , mFPDF_CloseDocument(nullptr)
-    , mFPDF_GetPageCount(nullptr)
-    , mFPDF_LoadPage(nullptr)
-    , mFPDF_ClosePage(nullptr)
-    , mFPDF_RenderPage(nullptr)
-  {
-  }
-
-  FPDF_InitLibrary_Pfn        mFPDF_InitLibrary;
-  FPDF_DestroyLibrary_Pfn     mFPDF_DestroyLibrary;
-  FPDF_LoadDocument_Pfn       mFPDF_LoadDocument;
-  FPDF_LoadCustomDocument_Pfn mFPDF_LoadCustomDocument;
-  FPDF_CloseDocument_Pfn      mFPDF_CloseDocument;
-  FPDF_GetPageCount_Pfn       mFPDF_GetPageCount;
-  FPDF_LoadPage_Pfn           mFPDF_LoadPage;
-  FPDF_ClosePage_Pfn          mFPDF_ClosePage;
-  FPDF_RenderPage_Pfn         mFPDF_RenderPage;
-};
-
 /* static */
 already_AddRefed<PDFiumEngineShim>
 PDFiumEngineShim::GetInstanceOrNull()
 {
   RefPtr<PDFiumEngineShim> inst = sPDFiumEngineShim;
   if (!inst) {
     inst = new PDFiumEngineShim();
     if (!inst->Init(nsCString("pdfium.dll"))) {
@@ -82,26 +35,32 @@ PDFiumEngineShim::GetInstanceOrNull(cons
   if (!shim->Init(aLibrary)) {
     return nullptr;
   }
 
   return shim.forget();
 }
 
 PDFiumEngineShim::PDFiumEngineShim()
-  : mTable(MakeUnique<PDFFunctionPointerTable>())
-  , mInitialized(false)
+  : mInitialized(false)
+  , mFPDF_InitLibrary(nullptr)
+  , mFPDF_DestroyLibrary(nullptr)
+  , mFPDF_CloseDocument(nullptr)
+  , mFPDF_GetPageCount(nullptr)
+  , mFPDF_LoadPage(nullptr)
+  , mFPDF_ClosePage(nullptr)
+  , mFPDF_RenderPage(nullptr)
   , mPRLibrary(nullptr)
 {
 }
 
 PDFiumEngineShim::~PDFiumEngineShim()
 {
   if (mInitialized) {
-    mTable->mFPDF_DestroyLibrary();
+    mFPDF_DestroyLibrary();
   }
 
   sPDFiumEngineShim = nullptr;
 
   if (mPRLibrary) {
     PR_UnloadLibrary(mPRLibrary);
   }
 }
@@ -111,138 +70,94 @@ PDFiumEngineShim::Init(const nsCString& 
 {
   if (mInitialized) {
     return true;
   }
 
   mPRLibrary = PR_LoadLibrary(aLibrary.get());
   NS_ENSURE_TRUE(mPRLibrary, false);
 
-  mTable->mFPDF_InitLibrary =
-    (FPDF_InitLibrary_Pfn)PR_FindFunctionSymbol(mPRLibrary,
-                                                "FPDF_InitLibrary");
-  NS_ENSURE_TRUE(mTable->mFPDF_InitLibrary, false);
+  mFPDF_InitLibrary = (FPDF_InitLibrary_Pfn)PR_FindFunctionSymbol(
+    mPRLibrary, "FPDF_InitLibrary");
+  NS_ENSURE_TRUE(mFPDF_InitLibrary, false);
 
-  mTable->mFPDF_DestroyLibrary =
-    (FPDF_DestroyLibrary_Pfn)PR_FindFunctionSymbol(mPRLibrary,
-                                                  "FPDF_DestroyLibrary");
-  NS_ENSURE_TRUE(mTable->mFPDF_DestroyLibrary, false);
+  mFPDF_DestroyLibrary = (FPDF_DestroyLibrary_Pfn)PR_FindFunctionSymbol(
+    mPRLibrary, "FPDF_DestroyLibrary");
+  NS_ENSURE_TRUE(mFPDF_DestroyLibrary, false);
 
-  mTable->mFPDF_LoadDocument =
-    (FPDF_LoadDocument_Pfn)PR_FindFunctionSymbol(mPRLibrary,
-                                                 "FPDF_LoadDocument");
-  NS_ENSURE_TRUE(mTable->mFPDF_LoadDocument, false);
+  mFPDF_LoadDocument = (FPDF_LoadDocument_Pfn)PR_FindFunctionSymbol(
+    mPRLibrary, "FPDF_LoadDocument");
+  NS_ENSURE_TRUE(mFPDF_LoadDocument, false);
 
-  mTable->mFPDF_LoadCustomDocument =
-    (FPDF_LoadCustomDocument_Pfn)PR_FindFunctionSymbol(mPRLibrary,
-                                                       "FPDF_LoadCustomDocument");
-  NS_ENSURE_TRUE(mTable->mFPDF_LoadCustomDocument, false);
+  mFPDF_CloseDocument = (FPDF_CloseDocument_Pfn)PR_FindFunctionSymbol(
+    mPRLibrary, "FPDF_CloseDocument");
+  NS_ENSURE_TRUE(mFPDF_CloseDocument, false);
 
-  mTable->mFPDF_CloseDocument =
-    (FPDF_CloseDocument_Pfn)PR_FindFunctionSymbol(mPRLibrary,
-                                                  "FPDF_CloseDocument");
-  NS_ENSURE_TRUE(mTable->mFPDF_CloseDocument, false);
+  mFPDF_GetPageCount = (FPDF_GetPageCount_Pfn)PR_FindFunctionSymbol(
+    mPRLibrary, "FPDF_GetPageCount");
+  NS_ENSURE_TRUE(mFPDF_GetPageCount, false);
 
-  mTable->mFPDF_GetPageCount =
-    (FPDF_GetPageCount_Pfn)PR_FindFunctionSymbol(mPRLibrary,
-                                                 "FPDF_GetPageCount");
-  NS_ENSURE_TRUE(mTable->mFPDF_GetPageCount, false);
+  mFPDF_LoadPage = (FPDF_LoadPage_Pfn)PR_FindFunctionSymbol(
+    mPRLibrary, "FPDF_LoadPage");
+  NS_ENSURE_TRUE(mFPDF_LoadPage, false);
 
-  mTable->mFPDF_LoadPage =
-    (FPDF_LoadPage_Pfn)PR_FindFunctionSymbol(mPRLibrary, "FPDF_LoadPage");
-  NS_ENSURE_TRUE(mTable->mFPDF_LoadPage, false);
+  mFPDF_ClosePage = (FPDF_ClosePage_Pfn)PR_FindFunctionSymbol(
+    mPRLibrary, "FPDF_ClosePage");
+  NS_ENSURE_TRUE(mFPDF_ClosePage, false);
 
-  mTable->mFPDF_ClosePage =
-    (FPDF_ClosePage_Pfn)PR_FindFunctionSymbol(mPRLibrary, "FPDF_ClosePage");
-  NS_ENSURE_TRUE(mTable->mFPDF_ClosePage, false);
+  mFPDF_RenderPage = (FPDF_RenderPage_Pfn)PR_FindFunctionSymbol(
+    mPRLibrary, "FPDF_RenderPage");
+  NS_ENSURE_TRUE(mFPDF_RenderPage, false);
 
-  mTable->mFPDF_RenderPage =
-    (FPDF_RenderPage_Pfn)PR_FindFunctionSymbol(mPRLibrary, "FPDF_RenderPage");
-  NS_ENSURE_TRUE(mTable->mFPDF_RenderPage, false);
-
-  mTable->mFPDF_InitLibrary();
+  mFPDF_InitLibrary();
   mInitialized = true;
   return true;
 }
 
 FPDF_DOCUMENT
 PDFiumEngineShim::LoadDocument(FPDF_STRING file_path,
                                FPDF_BYTESTRING aPassword)
 {
   MOZ_ASSERT(mInitialized);
-  return mTable->mFPDF_LoadDocument(file_path, aPassword);
-}
-
-FPDF_DOCUMENT
-PDFiumEngineShim::LoadDocument(PRFileDesc* aPrfile,
-                               FPDF_BYTESTRING aPassword)
-{
-  MOZ_ASSERT(mInitialized && aPrfile);
-
-  PROffset32 fileLength = PR_Seek64(aPrfile, 0, PR_SEEK_END);
-  if (fileLength == -1) {
-    NS_WARNING("Failed to access the given FD.");
-    return nullptr;
-  }
-
-  FPDF_FILEACCESS fileAccess;
-  fileAccess.m_FileLen = static_cast<unsigned long>(fileLength);
-  fileAccess.m_Param = reinterpret_cast<void*>(aPrfile);
-  fileAccess.m_GetBlock =
-    [](void* param, unsigned long pos, unsigned char* buf, unsigned long size)
-    {
-      PRFileDesc* prfile = reinterpret_cast<PRFileDesc*>(param);
-
-      if (PR_Seek64(prfile, pos, PR_SEEK_SET) != pos) {
-        return 0;
-      }
-
-      if (PR_Read(prfile, buf, size) <= 0) {
-        return 0;
-      }
-
-      return 1;
-    };
-
-  return mTable->mFPDF_LoadCustomDocument(&fileAccess, aPassword);
+  return mFPDF_LoadDocument(file_path, aPassword);
 }
 
 void
 PDFiumEngineShim::CloseDocument(FPDF_DOCUMENT aDocument)
 {
   MOZ_ASSERT(mInitialized);
-  mTable->mFPDF_CloseDocument(aDocument);
+  mFPDF_CloseDocument(aDocument);
 }
 
 int
 PDFiumEngineShim::GetPageCount(FPDF_DOCUMENT aDocument)
 {
   MOZ_ASSERT(mInitialized);
-  return mTable->mFPDF_GetPageCount(aDocument);
+  return mFPDF_GetPageCount(aDocument);
 }
 
 FPDF_PAGE
 PDFiumEngineShim::LoadPage(FPDF_DOCUMENT aDocument, int aPageIndex)
 {
   MOZ_ASSERT(mInitialized);
-  return mTable->mFPDF_LoadPage(aDocument, aPageIndex);
+  return mFPDF_LoadPage(aDocument, aPageIndex);
 }
 
 void
 PDFiumEngineShim::ClosePage(FPDF_PAGE aPage)
 {
   MOZ_ASSERT(mInitialized);
-  mTable->mFPDF_ClosePage(aPage);
+  mFPDF_ClosePage(aPage);
 }
 
 void
 PDFiumEngineShim::RenderPage(HDC aDC, FPDF_PAGE aPage,
                              int aStartX, int aStartY,
                              int aSizeX, int aSizeY,
                              int aRotate, int aFlags)
 {
   MOZ_ASSERT(mInitialized);
-  mTable->mFPDF_RenderPage(aDC, aPage, aStartX, aStartY,
-                           aSizeX, aSizeY, aRotate, aFlags);
+  mFPDF_RenderPage(aDC, aPage, aStartX, aStartY,
+                   aSizeX, aSizeY, aRotate, aFlags);
 }
 
 } // namespace widget
 } // namespace mozilla
--- a/widget/windows/PDFiumEngineShim.h
+++ b/widget/windows/PDFiumEngineShim.h
@@ -6,23 +6,41 @@
 #ifndef PDFIUMENGINESHIM_H
 #define PDFIUMENGINESHIM_H
 
 #include "prlink.h"
 #include "fpdfview.h"
 
 /* include windows.h for the HDC definitions that we need. */
 #include <windows.h>
-#include "private/pprio.h"
-#include "mozilla/UniquePtr.h"
 
 namespace mozilla {
 namespace widget {
 
-struct PDFFunctionPointerTable;
+typedef void (STDCALL *FPDF_InitLibrary_Pfn)();
+typedef void (STDCALL *FPDF_DestroyLibrary_Pfn)();
+
+typedef FPDF_DOCUMENT (STDCALL *FPDF_LoadDocument_Pfn)(FPDF_STRING file_path,
+                                                      FPDF_BYTESTRING password);
+
+typedef void(STDCALL *FPDF_CloseDocument_Pfn)(FPDF_DOCUMENT aDocument);
+
+typedef int (STDCALL *FPDF_GetPageCount_Pfn)(FPDF_DOCUMENT aDocument);
+
+typedef FPDF_PAGE (STDCALL *FPDF_LoadPage_Pfn)(FPDF_DOCUMENT aDocument,
+                                               int aPageIndex);
+typedef void (STDCALL *FPDF_ClosePage_Pfn)(FPDF_PAGE aPage);
+typedef void (STDCALL *FPDF_RenderPage_Pfn)(HDC aDC,
+                                            FPDF_PAGE aPage,
+                                            int aStartX,
+                                            int aStartY,
+                                            int aSizeX,
+                                            int aSizeY,
+                                            int aRotate,
+                                            int aFlags);
 
 /**
  * This class exposes an interface to the PDFium library and
  * takes care of loading and linking to the appropriate PDFium symbols.
  */
 class PDFiumEngineShim
 {
 public:
@@ -32,18 +50,16 @@ public:
   static already_AddRefed<PDFiumEngineShim> GetInstanceOrNull();
   // This function is used for testing purpose only, do not call it in regular
   // code.
   static already_AddRefed<PDFiumEngineShim>
   GetInstanceOrNull(const nsCString& aLibrary);
 
   FPDF_DOCUMENT LoadDocument(FPDF_STRING file_path,
                              FPDF_BYTESTRING aPassword);
-  FPDF_DOCUMENT LoadDocument(PRFileDesc* aPrfile,
-                             FPDF_BYTESTRING aPassword);
   void CloseDocument(FPDF_DOCUMENT aDocument);
   int GetPageCount(FPDF_DOCUMENT aDocument);
   int GetPageSizeByIndex(FPDF_DOCUMENT aDocument, int aPageIndex,
                          double* aWidth, double* aHeight);
 
   FPDF_PAGE LoadPage(FPDF_DOCUMENT aDocument, int aPageIndex);
   void ClosePage(FPDF_PAGE aPage);
   void RenderPage(HDC aDC, FPDF_PAGE aPage,
@@ -51,18 +67,26 @@ public:
                   int aSizeX, int aSizeY,
                   int aRotate, int aFlags);
 
 private:
   PDFiumEngineShim();
   ~PDFiumEngineShim();
   bool Init(const nsCString& aLibrary);
 
-  UniquePtr<PDFFunctionPointerTable> mTable;
   bool        mInitialized ;
 
+  FPDF_InitLibrary_Pfn        mFPDF_InitLibrary;
+  FPDF_DestroyLibrary_Pfn     mFPDF_DestroyLibrary;
+  FPDF_LoadDocument_Pfn       mFPDF_LoadDocument;
+  FPDF_CloseDocument_Pfn      mFPDF_CloseDocument;
+  FPDF_GetPageCount_Pfn       mFPDF_GetPageCount;
+  FPDF_LoadPage_Pfn           mFPDF_LoadPage;
+  FPDF_ClosePage_Pfn          mFPDF_ClosePage;
+  FPDF_RenderPage_Pfn         mFPDF_RenderPage;
+
   PRLibrary*  mPRLibrary;
 };
 
 } // namespace widget
 } // namespace mozilla
 
 #endif /* PDFIUMENGINESHIM_H */
\ No newline at end of file
deleted file mode 100644
--- a/widget/windows/PDFiumParent.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "PDFiumParent.h"
-#include "nsDeviceContextSpecWin.h"
-#include "mozilla/gfx/PrintTargetEMF.h"
-
-namespace mozilla {
-namespace widget {
-
-PDFiumParent::PDFiumParent(PrintTargetEMF* aTarget)
-  : mTarget(aTarget)
-{
-}
-
-bool
-PDFiumParent::Init(IPC::Channel* aChannel, base::ProcessId aPid)
-{
-  if (NS_WARN_IF(!Open(aChannel, aPid))) {
-    return false;
-  }
-
-  AddRef();
-  return true;
-}
-
-void
-PDFiumParent::ActorDestroy(ActorDestroyReason aWhy)
-{
-  if (mTarget) {
-    mTarget->ChannelIsBroken();
-  }
-
-  if (mConversionDoneCallback) {
-    // Since this printing job was aborted, we do not need to report EMF buffer
-    // back to mTarget.
-    mConversionDoneCallback();
-  }
-}
-
-mozilla::ipc::IPCResult
-PDFiumParent::RecvConvertToEMFDone(const nsresult& aResult,
-                                   mozilla::ipc::Shmem&& aEMFContents)
-{
-  MOZ_ASSERT(aEMFContents.IsReadable());
-
-  if (mTarget) {
-    MOZ_ASSERT(!mConversionDoneCallback);
-    mTarget->ConvertToEMFDone(aResult, Move(aEMFContents));
-  }
-
-  return IPC_OK();
-}
-
-void
-PDFiumParent::AbortConversion(ConversionDoneCallback aCallback)
-{
-  // There is no need to report EMF contents back to mTarget since the print
-  // job was aborted, unset mTarget.
-  mTarget = nullptr;
-  mConversionDoneCallback = aCallback;
-}
-
-void PDFiumParent::EndConversion()
-{
-  // The printing job is finished correctly, mTarget is no longer needed.
-  mTarget = nullptr;
-}
-
-void
-PDFiumParent::OnChannelConnected(int32_t pid)
-{
-  SetOtherProcessId(pid);
-}
-
-void
-PDFiumParent::DeallocPPDFiumParent()
-{
-  Release();
-}
-
-} // namespace widget
-} // namespace mozilla
deleted file mode 100644
--- a/widget/windows/PDFiumParent.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef PDFIUMPARENT_H_
-#define PDFIUMPARENT_H_
-
-#include "mozilla/widget/PPDFiumParent.h"
-
-namespace mozilla {
-namespace gfx {
-  class PrintTargetEMF;
-}
-}
-
-namespace mozilla {
-namespace widget {
-
-class PDFiumParent final : public PPDFiumParent,
-                           public mozilla::ipc::IShmemAllocator
-{
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PDFiumParent)
-
-  typedef mozilla::gfx::PrintTargetEMF PrintTargetEMF;
-  typedef std::function<void()> ConversionDoneCallback;
-
-  explicit PDFiumParent(PrintTargetEMF* aTarget);
-
-  bool Init(IPC::Channel* aChannel, base::ProcessId aPid);
-
-  void AbortConversion(ConversionDoneCallback aCallback);
-  void EndConversion();
-
-  FORWARD_SHMEM_ALLOCATOR_TO(PPDFiumParent)
-private:
-  ~PDFiumParent() {}
-
-  // PPDFiumParent functions.
-  void ActorDestroy(ActorDestroyReason aWhy) override;
-
-  mozilla::ipc::IPCResult RecvConvertToEMFDone(const nsresult& aResult,
-                                               mozilla::ipc::Shmem&& aEMFContents) override;
-  void OnChannelConnected(int32_t pid) override;
-  void DeallocPPDFiumParent() override;
-
-  PrintTargetEMF* mTarget;
-  ConversionDoneCallback mConversionDoneCallback;
-};
-
-} // namespace widget
-} // namespace mozilla
-
-#endif // PDFIUMPARENT_H_
deleted file mode 100644
--- a/widget/windows/PDFiumProcessChild.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "PDFiumProcessChild.h"
-
-#include "mozilla/ipc/IOThreadChild.h"
-#include "mozilla/BackgroundHangMonitor.h"
-#include "mozilla/dom/ContentChild.h"
-#include "mozilla/dom/ContentParent.h"
-#if defined(MOZ_SANDBOX)
-#include "mozilla/sandboxTarget.h"
-#endif
-
-using mozilla::ipc::IOThreadChild;
-
-namespace mozilla {
-namespace widget {
-
-PDFiumProcessChild::PDFiumProcessChild(ProcessId aParentPid)
-  : ProcessChild(aParentPid)
-#if defined(MOZ_SANDBOX)
-  , mPDFium(nullptr)
-#endif
-{
-}
-
-PDFiumProcessChild::~PDFiumProcessChild()
-{
-#if defined(MOZ_SANDBOX)
-  if (mPDFium) {
-    PR_UnloadLibrary(mPDFium);
-  }
-#endif
-}
-
-bool
-PDFiumProcessChild::Init(int aArgc, char* aArgv[])
-{
-  BackgroundHangMonitor::Startup();
-
-#if defined(MOZ_SANDBOX)
-  // XXX bug 1417000
-  // We really should load "pdfium.dll" after calling StartSandbox(). For
-  // an unknown reason, "pdfium.dll" can not be loaded correctly after
-  // StartSandbox() been called. Temporary preload this library until we fix
-  // bug 1417000.
-  mPDFium = PR_LoadLibrary("pdfium.dll");
-  mozilla::SandboxTarget::Instance()->StartSandbox();
-#endif
-
-  mPDFiumActor.Init(ParentPid(),IOThreadChild::message_loop(),
-                    IOThreadChild::channel());
-
-  return true;
-}
-
-void
-PDFiumProcessChild::CleanUp()
-{
-  BackgroundHangMonitor::Shutdown();
-}
-
-} // namespace widget
-} // namespace mozilla
deleted file mode 100644
--- a/widget/windows/PDFiumProcessChild.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef PDFIUMPROCESSCHILD_H_
-#define PDFIUMPROCESSCHILD_H_
-
-#include "mozilla/ipc/ProcessChild.h"
-#include "PDFiumChild.h"
-
-namespace mozilla {
-namespace widget {
-
-/**
- * Contains the PDFiumChild object that facilitates IPC communication to/from
- * the instance of the PDFium library that is run in this process.
- */
-class PDFiumProcessChild final : public mozilla::ipc::ProcessChild
-{
-protected:
-  typedef mozilla::ipc::ProcessChild ProcessChild;
-
-public:
-  explicit PDFiumProcessChild(ProcessId aParentPid);
-  ~PDFiumProcessChild();
-
-  // ProcessChild functions.
-  bool Init(int aArgc, char* aArgv[]) override;
-  void CleanUp() override;
-
-private:
-  DISALLOW_COPY_AND_ASSIGN(PDFiumProcessChild);
-
-  PDFiumChild mPDFiumActor;
-#if defined(MOZ_SANDBOX)
-  PRLibrary*  mPDFium;
-#endif
-};
-
-} // namespace widget
-} // namespace mozilla
-
-#endif // PDFIUMPROCESSCHILD_H_
deleted file mode 100644
--- a/widget/windows/PDFiumProcessParent.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: sw=2 ts=2 et :
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "PDFiumProcessParent.h"
-#include "nsIRunnable.h"
-#if defined(XP_WIN) && defined(MOZ_SANDBOX)
-#include "WinUtils.h"
-#endif
-#include "nsDeviceContextSpecWin.h"
-#include "PDFiumParent.h"
-
-using mozilla::ipc::GeckoChildProcessHost;
-
-namespace mozilla {
-namespace widget {
-
-PDFiumProcessParent::PDFiumProcessParent()
-  : GeckoChildProcessHost(GeckoProcessType_PDFium)
-{
-  MOZ_COUNT_CTOR(PDFiumProcessParent);
-}
-
-PDFiumProcessParent::~PDFiumProcessParent()
-{
-  MOZ_COUNT_DTOR(PDFiumProcessParent);
-
-  if (mPDFiumParentActor) {
-    mPDFiumParentActor->Close();
-  }
-}
-
-bool
-PDFiumProcessParent::Launch(PrintTargetEMF* aTarget)
-{
-  mLaunchThread = NS_GetCurrentThread();
-
-  if (!SyncLaunch()) {
-    return false;
-  }
-
-  // Open the top level protocol for PDFium process.
-  MOZ_ASSERT(!mPDFiumParentActor);
-  mPDFiumParentActor = new PDFiumParent(aTarget);
-  return mPDFiumParentActor->Init(GetChannel(),
-                            base::GetProcId(GetChildProcessHandle()));
-}
-
-void
-PDFiumProcessParent::Delete(bool aWaitingForEMFConversion)
-{
-  if (aWaitingForEMFConversion) {
-    // Can not kill the PDFium process yet since we are still waiting for a
-    // EMF conversion response.
-    mPDFiumParentActor->AbortConversion([this]() { Delete(false); });
-    mPDFiumParentActor->Close();
-    return;
-  }
-
-  // PDFiumProcessParent::Launch is not called, protocol is not created.
-  // It is safe to destroy this object on any thread.
-  if (!mLaunchThread) {
-    delete this;
-    return;
-  }
-
-  if (mLaunchThread == NS_GetCurrentThread()) {
-    delete this;
-    return;
-  }
-
-  mLaunchThread->Dispatch(
-    NewNonOwningRunnableMethod<bool>("PDFiumProcessParent::Delete",
-                                     this,
-                                     &PDFiumProcessParent::Delete,
-                                     false));
-}
-
-} // namespace widget
-} // namespace mozilla
deleted file mode 100644
--- a/widget/windows/PDFiumProcessParent.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: sw=4 ts=4 et :
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef PDFIUMPROCESSPARENT_H
-#define PDFIUMPROCESSPARENT_H
-
-#include "chrome/common/child_process_host.h"
-#include "mozilla/ipc/GeckoChildProcessHost.h"
-
-class nsIRunnable;
-class nsDeviceContextSpecWin;
-
-#ifdef MOZ_ENABLE_SKIA_PDF
-namespace mozilla {
-namespace widget {
-  class PDFiumParent;
-}
-namespace gfx {
-  class PrintTargetEMF;
-}
-}
-#endif
-
-namespace mozilla {
-namespace widget {
-
-class PDFiumProcessParent final : public mozilla::ipc::GeckoChildProcessHost
-{
-public:
-  typedef mozilla::gfx::PrintTargetEMF PrintTargetEMF;
-
-  PDFiumProcessParent();
-  ~PDFiumProcessParent();
-
-  bool Launch(PrintTargetEMF* aTarget);
-
-  void Delete(bool aWaitingForEMFConversion);
-
-  bool CanShutdown() override { return true; }
-
-  PDFiumParent* GetActor() const { return mPDFiumParentActor; }
-private:
-
-  DISALLOW_COPY_AND_ASSIGN(PDFiumProcessParent);
-
-  RefPtr<PDFiumParent> mPDFiumParentActor;
-  nsCOMPtr<nsIThread> mLaunchThread;
-};
-
-} // namespace widget
-} // namespace mozilla
-
-#endif // ifndef PDFIUMPROCESSPARENT_H
deleted file mode 100644
--- a/widget/windows/PPDFium.ipdl
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-namespace mozilla {
-namespace widget {
-
-
-/**
- * A protocol for communicating with the PDFium processes. Useful for
- * converting a PDF file to EMF contents.
- *
- * PDFium processes are created on-demand as necessary.
- */
-protocol PPDFium
-{
-parent:
-  /**
-   * Called by the PDFium process once the PDF has been converted to EMF.
-   */
-  async ConvertToEMFDone(nsresult aResult, Shmem aEMFContents);
-
-child:
-  /**
-   * Start to convert a PDF file to EMF contents.
-   */
-  async ConvertToEMF(FileDescriptor aFD, int aPageWidth, int aPageHeight);
-};
-
-} // namespace widget
-} // namespace mozilla
--- a/widget/windows/ScreenHelperWin.cpp
+++ b/widget/windows/ScreenHelperWin.cpp
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ScreenHelperWin.h"
 
 #include "mozilla/Logging.h"
 #include "nsTArray.h"
 #include "WinUtils.h"
 
-static mozilla::LazyLogModule sScreenLog("WidgetScreen");
+static LazyLogModule sScreenLog("WidgetScreen");
 
 namespace mozilla {
 namespace widget {
 
 BOOL CALLBACK
 CollectMonitors(HMONITOR aMon, HDC hDCScreen, LPRECT, LPARAM ioParam)
 {
   auto screens = reinterpret_cast<nsTArray<RefPtr<Screen>>*>(ioParam);
--- a/widget/windows/WindowsEMF.cpp
+++ b/widget/windows/WindowsEMF.cpp
@@ -35,27 +35,16 @@ WindowsEMF::InitFromFileContents(const w
   MOZ_ASSERT(aMetafilePath);
   ReleaseAllResource();
 
   mEmf = ::GetEnhMetaFileW(aMetafilePath);
   return !!mEmf;
 }
 
 bool
-WindowsEMF::InitFromFileContents(LPBYTE aBytes, UINT aSize)
-{
-  MOZ_ASSERT(aBytes && aSize != 0);
-  ReleaseAllResource();
-
-  mEmf = SetEnhMetaFileBits(aSize, aBytes);
-
-  return !!mEmf;
-}
-
-bool
 WindowsEMF::FinishDocument()
 {
   if (mDC) {
      mEmf = ::CloseEnhMetaFile(mDC);
      mDC = nullptr;
   }
   return !!mEmf;
 }
@@ -74,49 +63,27 @@ WindowsEMF::ReleaseAllResource()
 {
   FinishDocument();
   ReleaseEMFHandle();
 }
 
 bool
 WindowsEMF::Playback(HDC aDeviceContext, const RECT& aRect)
 {
-  DebugOnly<bool> result = FinishDocument();
-  MOZ_ASSERT(result, "This function should be used after InitXXX.");
+  if (!FinishDocument()) {
+    return false;
+  }
 
   return ::PlayEnhMetaFile(aDeviceContext, mEmf, &aRect) != 0;
 }
 
 bool
 WindowsEMF::SaveToFile()
 {
-  DebugOnly<bool> result = FinishDocument();
-  MOZ_ASSERT(result, "This function should be used after InitXXX.");
-
-  ReleaseEMFHandle();
-  return true;
-}
-
-UINT
-WindowsEMF::GetEMFContentSize()
-{
-  DebugOnly<bool> result = FinishDocument();
-  MOZ_ASSERT(result, "This function should be used after InitXXX.");
-
-  return GetEnhMetaFileBits(mEmf, 0, NULL);
-}
-
-bool
-WindowsEMF::GetEMFContentBits(LPBYTE aBytes)
-{
-  DebugOnly<bool> result = FinishDocument();
-  MOZ_ASSERT(result, "This function should be used after InitXXX.");
-
-  UINT emfSize = GetEMFContentSize();
-  if (GetEnhMetaFileBits(mEmf, emfSize, aBytes) != emfSize) {
+  if (!FinishDocument()) {
     return false;
   }
-
+  ReleaseEMFHandle();
   return true;
 }
 
 } // namespace widget
 } // namespace mozilla
\ No newline at end of file
--- a/widget/windows/WindowsEMF.h
+++ b/widget/windows/WindowsEMF.h
@@ -39,24 +39,16 @@ public:
 
   /**
    * Initializes the object with an existing EMF file. Consumers cannot use
    * GetDC() to obtain an HDC to modify the file. They can only use Playback().
    */
   bool InitFromFileContents(const wchar_t* aMetafilePath);
 
   /**
-   * Creates the EMF from the specified data
-   *
-   * @param aByte Pointer to a buffer that contains EMF data.
-   * @param aSize Specifies the size, in bytes, of aByte.
-   */
-  bool InitFromFileContents(PBYTE aBytes, UINT aSize);
-
-  /**
    * If this object was initiaziled using InitForDrawing() then this function
    * returns an HDC that can be drawn to generate the EMF output. Otherwise it
    * returns null. After finishing with the HDC, consumers could call Playback()
    * to draw EMF onto the given DC or call SaveToFile() to finish writing the
    * EMF file.
    */
   HDC GetDC() const
   {
@@ -73,28 +65,16 @@ public:
 
   /**
    * Called to generate the EMF file once a consumer has finished drawing to
    * the HDC returned by GetDC(), if initializes the object with the path of a
    * file.
    */
   bool SaveToFile();
 
-  /**
-   * Return the size of the enhanced metafile, in bytes.
-   */
-  UINT GetEMFContentSize();
-
-  /**
-   * Retrieves the contents of the EMF and copies them into a buffer.
-   *
-   * @param aByte the buffer to receive the data.
-   */
-  bool GetEMFContentBits(PBYTE aBytes);
-
 private:
 
   WindowsEMF(const WindowsEMF& aEMF) = delete;
   bool FinishDocument();
   void ReleaseEMFHandle();
   void ReleaseAllResource();
 
   /* Compiled EMF data handle. */
--- a/widget/windows/gtest/TestEMFConversion.cpp
+++ b/widget/windows/gtest/TestEMFConversion.cpp
@@ -147,31 +147,31 @@ TEST(TestEMFConversion, CompareEMFWithRe
   const int pageWidth = 4961;
   const int pageHeight = 7016;
 
   // Convert a PDF file to an EMF file(PrinterTestPage.pdf -> gtest.emf)
   nsAutoString emfPath;
   ASSERT_TRUE(NS_SUCCEEDED(GetFilePathViaSpecialDirectory(NS_OS_TEMP_DIR,
                                                         "gtest.emf",
                                                         emfPath)));
-  ASSERT_TRUE(PDFHelper->SavePageToFile(emfPath.get(), 0,
+  ASSERT_TRUE(PDFHelper->DrawPageToFile(emfPath.get(), 0,
                                         pageWidth, pageHeight));
   PDFHelper->CloseDocument();
 #ifdef _WIN64
   // Convert a PDF file to an EMF file by external library.
   // (PrinterTestPage.pdf -> gtestRef.emf)
   UniquePtr<EMFViaExtDLLHelper> ExtHelper = MakeUnique<EMFViaExtDLLHelper>();
   ASSERT_TRUE(SetupPrintHelper("PrinterTestPage.pdf", ExtHelper.get()));
 
   nsAutoString emfPathRef;
   ASSERT_TRUE(NS_SUCCEEDED(GetFilePathViaSpecialDirectory(NS_OS_TEMP_DIR,
                                                           "gtestRef.emf",
                                                           emfPathRef)));
 
-  ASSERT_TRUE(ExtHelper->SavePageToFile(emfPathRef.get(), 0,
+  ASSERT_TRUE(ExtHelper->DrawPageToFile(emfPathRef.get(), 0,
                                         pageWidth, pageHeight));
   ExtHelper->CloseDocument();
 
   CompareTwoFiles(emfPath, emfPathRef);
 #endif
 }
 
 // Input a PDF file which does not exist
@@ -189,16 +189,16 @@ TEST(TestEMFConversion, TestInsufficient
     MakeUnique<PDFViaEMFPrintHelper>();
   ASSERT_TRUE(SetupPrintHelper("PrinterTestPage.pdf", PDFHelper.get()));
 
   nsAutoString emfPath;
   ASSERT_TRUE(NS_SUCCEEDED(GetFilePathViaSpecialDirectory(NS_OS_TEMP_DIR,
                                                          "gtest.emf",
                                                           emfPath)));
 
-  ASSERT_FALSE(PDFHelper->SavePageToFile(emfPath.get(), 0, 0, 0));
-  ASSERT_FALSE(PDFHelper->SavePageToFile(emfPath.get(), 0, 100, -1));
+  ASSERT_FALSE(PDFHelper->DrawPageToFile(emfPath.get(), 0, 0, 0));
+  ASSERT_FALSE(PDFHelper->DrawPageToFile(emfPath.get(), 0, 100, -1));
 
   PDFHelper->CloseDocument();
 }
 
 } // namespace widget
 } // namespace mozilla
\ No newline at end of file
--- a/widget/windows/gtest/moz.build
+++ b/widget/windows/gtest/moz.build
@@ -4,17 +4,16 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, you can obtain one at http://mozilla.org/MPL/2.0/.
 
 UNIFIED_SOURCES = [
     'TestEMFConversion.cpp',
 ]
 
 LOCAL_INCLUDES += [
-    '/ipc/chromium/src',
     '/modules/pdfium/pdfium/public',
     '/widget/windows',
 ]
 
 TEST_HARNESS_FILES.gtest += [
     'pdfium_ref_x64.dll',
     'pdfium_ref_x86.dll',
     'PrinterTestPage.pdf',
--- a/widget/windows/moz.build
+++ b/widget/windows/moz.build
@@ -18,24 +18,19 @@ EXPORTS += [
     'WinUtils.h',
 ]
 
 EXPORTS.mozilla.widget += [
     'AudioSession.h',
     'CompositorWidgetChild.h',
     'CompositorWidgetParent.h',
     'InProcessWinCompositorWidget.h',
-    'PDFiumChild.h',
     'PDFiumEngineShim.h',
-    'PDFiumParent.h',
-    'PDFiumProcessChild.h',
-    'PDFiumProcessParent.h',
     'PDFViaEMFPrintHelper.h',
     'WinCompositorWidget.h',
-    'WindowsEMF.h',
     'WinMessages.h',
     'WinModifierKeyState.h',
     'WinNativeEventData.h',
 ]
 
 UNIFIED_SOURCES += [
     'AudioSession.cpp',
     'CompositorWidgetChild.cpp',
@@ -96,28 +91,20 @@ SOURCES += [
 if CONFIG['NS_PRINTING']:
     UNIFIED_SOURCES += [
         'nsDeviceContextSpecWin.cpp',
         'nsPrintDialogUtil.cpp',
         'nsPrintDialogWin.cpp',
         'nsPrintOptionsWin.cpp',
         'nsPrintSettingsWin.cpp',
     ]
-
 if CONFIG['MOZ_ENABLE_SKIA_PDF']:
     DIRS += ['/modules/pdfium']
-    IPDL_SOURCES += [
-        'PPDFium.ipdl',
-    ]
     UNIFIED_SOURCES += [
-        'PDFiumChild.cpp',
         'PDFiumEngineShim.cpp',
-        'PDFiumParent.cpp',
-        'PDFiumProcessChild.cpp',
-        'PDFiumProcessParent.cpp',
         'PDFViaEMFPrintHelper.cpp',
         'WindowsEMF.cpp',
     ]
 
 if CONFIG['NS_ENABLE_TSF']:
     SOURCES += [
         'TSFTextStore.cpp',
     ]
--- a/widget/windows/nsColorPicker.cpp
+++ b/widget/windows/nsColorPicker.cpp
@@ -7,17 +7,16 @@
 #include "nsColorPicker.h"
 
 #include <shlwapi.h>
 
 #include "mozilla/AutoRestore.h"
 #include "nsIWidget.h"
 #include "nsString.h"
 #include "WidgetUtils.h"
-#include "nsPIDOMWindow.h"
 
 using namespace mozilla::widget;
 
 namespace
 {
 // Manages NS_NATIVE_TMP_WINDOW child windows. NS_NATIVE_TMP_WINDOWs are
 // temporary child windows of mParentWidget created to address RTL issues
 // in picker dialogs. We are responsible for destroying these.
--- a/widget/windows/nsDataObj.cpp
+++ b/widget/windows/nsDataObj.cpp
@@ -29,17 +29,16 @@
 #include "nscore.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsITimer.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Preferences.h"
 #include "nsIContentPolicy.h"
 #include "nsContentUtils.h"
 #include "nsIPrincipal.h"
-#include "nsNativeCharsetUtils.h"
 
 #include "WinUtils.h"
 #include "mozilla/LazyIdleThread.h"
 #include <algorithm>
 
 
 using namespace mozilla;
 using namespace mozilla::widget;
--- a/widget/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/windows/nsDeviceContextSpecWin.cpp
@@ -31,21 +31,18 @@
 #include "nsIDOMWindow.h"
 #include "mozilla/Services.h"
 #include "nsWindowsHelpers.h"
 
 #include "mozilla/gfx/Logging.h"
 
 #ifdef MOZ_ENABLE_SKIA_PDF
 #include "mozilla/gfx/PrintTargetSkPDF.h"
-#include "mozilla/gfx/PrintTargetEMF.h"
 #include "nsIUUIDGenerator.h"
-#include "nsDirectoryServiceDefs.h"
-#include "nsPrintfCString.h"
-#include "nsThreadUtils.h"
+#include "mozilla/widget/PDFViaEMFPrintHelper.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;
 
@@ -93,16 +90,23 @@ struct AutoFreeGlobalPrinters
     GlobalPrinters::GetInstance()->FreeGlobalPrinters();
   }
 };
 
 //----------------------------------------------------------------------------------
 nsDeviceContextSpecWin::nsDeviceContextSpecWin()
 {
   mDevMode       = nullptr;
+#ifdef MOZ_ENABLE_SKIA_PDF
+  mPrintViaSkPDF          = false;
+  mDC                     = NULL;
+  mPDFPageCount           = 0;
+  mPDFCurrentPageNum      = 0;
+  mPrintViaPDFInProgress  = false;
+#endif
 }
 
 
 //----------------------------------------------------------------------------------
 
 NS_IMPL_ISUPPORTS(nsDeviceContextSpecWin, nsIDeviceContextSpec)
 
 nsDeviceContextSpecWin::~nsDeviceContextSpecWin()
@@ -111,16 +115,21 @@ nsDeviceContextSpecWin::~nsDeviceContext
 
   nsCOMPtr<nsIPrintSettingsWin> psWin(do_QueryInterface(mPrintSettings));
   if (psWin) {
     psWin->SetDeviceName(EmptyString());
     psWin->SetDriverName(EmptyString());
     psWin->SetDevMode(nullptr);
   }
 
+#ifdef MOZ_ENABLE_SKIA_PDF
+  if (mPrintViaSkPDF ) {
+    CleanupPrintViaPDF();
+  }
+#endif
   // Free them, we won't need them for a while
   GlobalPrinters::GetInstance()->FreeGlobalPrinters();
 }
 
 //----------------------------------------------------------------------------------
 NS_IMETHODIMP nsDeviceContextSpecWin::Init(nsIWidget* aWidget,
                                            nsIPrintSettings* aPrintSettings,
                                            bool aIsPrintPreview)
@@ -223,24 +232,47 @@ already_AddRefed<PrintTarget> nsDeviceCo
       mPrintSettings->GetToFileName(filename);
 
       nsAutoCString printFile(NS_ConvertUTF16toUTF8(filename).get());
       auto skStream = MakeUnique<SkFILEWStream>(printFile.get());
       return PrintTargetSkPDF::CreateOrNull(Move(skStream), size);
     }
 
     if (mDevMode) {
-      NS_WARNING_ASSERTION(!mDriverName.IsEmpty(), "No driver!");
-      HDC dc = ::CreateDCW(mDriverName.get(), mDeviceName.get(), nullptr, mDevMode);
-      if (!dc) {
-        gfxCriticalError(gfxCriticalError::DefaultOptions(false))
-          << "Failed to create device context in GetSurfaceForPrinter";
+      // When printing to a printer via Skia PDF we open a temporary file that
+      // we draw the print output into as PDF output, then once we reach
+      // EndDcoument we'll convert that PDF file to EMF page by page to print
+      // each page. Here we create the temporary file and wrap it in a
+      // PrintTargetSkPDF that we return.
+      nsresult rv =
+        NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(mPDFTempFile));
+      NS_ENSURE_SUCCESS(rv, nullptr);
+
+      nsCOMPtr<nsIUUIDGenerator> uuidGenerator =
+        do_GetService("@mozilla.org/uuid-generator;1", &rv);
+      if (NS_WARN_IF(NS_FAILED(rv))) {
         return nullptr;
       }
-      return PrintTargetEMF::CreateOrNull(dc, size);
+      nsID uuid;
+      rv = uuidGenerator->GenerateUUIDInPlace(&uuid);
+      if (NS_WARN_IF(NS_FAILED(rv))) {
+        return nullptr;
+      }
+      char uuidChars[NSID_LENGTH];
+      uuid.ToProvidedString(uuidChars);
+
+      nsAutoCString printFile("tmp-printing");
+      printFile.Append(nsPrintfCString("%s.pdf", uuidChars));
+      rv = mPDFTempFile->AppendNative(printFile);
+      NS_ENSURE_SUCCESS(rv, nullptr);
+
+      nsAutoCString filePath;
+      mPDFTempFile->GetNativePath(filePath);
+      auto skStream = MakeUnique<SkFILEWStream>(filePath.get());
+      return PrintTargetSkPDF::CreateOrNull(Move(skStream), size);
     }
   }
 #endif
 
   if (mOutputFormat == nsIPrintSettings::kOutputFormatPDF) {
     nsString filename;
     mPrintSettings->GetToFileName(filename);
 
@@ -313,16 +345,155 @@ nsDeviceContextSpecWin::GetPrintingScale
   }
 
   // The print settings will have the resolution stored from the real device.
   int32_t resolution;
   mPrintSettings->GetResolution(&resolution);
   return float(resolution) / GetDPI();
 }
 
+#ifdef MOZ_ENABLE_SKIA_PDF
+void
+nsDeviceContextSpecWin::CleanupPrintViaPDF()
+{
+  if (mPDFPrintHelper) {
+    mPDFPrintHelper->CloseDocument();
+    mPDFPrintHelper = nullptr;
+    mPDFPageCount = 0;
+  }
+
+  if (mPDFTempFile) {
+    mPDFTempFile->Remove(/* aRecursive */ false);
+    mPDFTempFile = nullptr;
+  }
+
+  if (mDC != NULL) {
+    if (mPrintViaPDFInProgress) {
+      ::EndDoc(mDC);
+      mPrintViaPDFInProgress = false;
+    }
+    ::DeleteDC(mDC);
+    mDC = NULL;
+  }
+}
+
+void
+nsDeviceContextSpecWin::FinishPrintViaPDF()
+{
+  MOZ_ASSERT(mDC != NULL);
+  MOZ_ASSERT(mPDFPrintHelper);
+  MOZ_ASSERT(mPDFTempFile);
+  MOZ_ASSERT(mPrintViaPDFInProgress);
+
+  bool isPrinted = false;
+  bool endPageSuccess = false;
+  if (::StartPage(mDC) > 0) {
+    isPrinted = mPDFPrintHelper->DrawPage(mDC, mPDFCurrentPageNum++,
+                                          ::GetDeviceCaps(mDC, HORZRES),
+                                          ::GetDeviceCaps(mDC, VERTRES));
+    if (::EndPage(mDC) > 0) {
+      endPageSuccess = true;
+    }
+  }
+
+  if (mPDFCurrentPageNum < mPDFPageCount && isPrinted && endPageSuccess) {
+    nsresult rv = NS_DispatchToCurrentThread(NewRunnableMethod(
+      "nsDeviceContextSpecWin::PrintPDFOnThread",
+      this,
+      &nsDeviceContextSpecWin::FinishPrintViaPDF));
+    if (NS_SUCCEEDED(rv)) {
+      return;
+    }
+  }
+
+  CleanupPrintViaPDF();
+}
+#endif
+
+nsresult
+nsDeviceContextSpecWin::BeginDocument(const nsAString& aTitle,
+                                      const nsAString& aPrintToFileName,
+                                      int32_t          aStartPage,
+                                      int32_t          aEndPage)
+{
+#ifdef MOZ_ENABLE_SKIA_PDF
+  if (mPrintViaSkPDF && (mOutputFormat != nsIPrintSettings::kOutputFormatPDF)) {
+    // Here we create mDC which we'll draw each page from our temporary PDF file
+    // to once we reach EndDocument. The only reason we create it here rather
+    // than in EndDocument is so that we don't need to store aTitle and
+    // aPrintToFileName as member data.
+    NS_WARNING_ASSERTION(!mDriverName.IsEmpty(), "No driver!");
+    mDC = ::CreateDCW(mDriverName.get(), mDeviceName.get(), nullptr, mDevMode);
+    if (mDC == NULL) {
+      gfxCriticalError(gfxCriticalError::DefaultOptions(false))
+        << "Failed to create device context in GetSurfaceForPrinter";
+      return NS_ERROR_FAILURE;
+    }
+
+    const uint32_t DOC_TITLE_LENGTH = MAX_PATH - 1;
+    nsString title(aTitle);
+    nsString printToFileName(aPrintToFileName);
+    if (title.Length() > DOC_TITLE_LENGTH) {
+      title.SetLength(DOC_TITLE_LENGTH - 3);
+      title.AppendLiteral("...");
+    }
+
+    DOCINFOW di;
+    di.cbSize = sizeof(di);
+    di.lpszDocName = title.Length() > 0 ? title.get() : L"Mozilla Document";
+    di.lpszOutput = printToFileName.Length() > 0 ?
+                      printToFileName.get() : nullptr;
+    di.lpszDatatype = nullptr;
+    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;
+  }
+#endif
+
+  return NS_OK;
+}
+
+nsresult
+nsDeviceContextSpecWin::EndDocument()
+{
+  nsresult rv = NS_OK;
+#ifdef MOZ_ENABLE_SKIA_PDF
+  if (mPrintViaSkPDF &&
+      mOutputFormat != nsIPrintSettings::kOutputFormatPDF &&
+      mPrintViaPDFInProgress) {
+
+    mPDFPrintHelper = MakeUnique<PDFViaEMFPrintHelper>();
+    rv = mPDFPrintHelper->OpenDocument(mPDFTempFile);
+    NS_ENSURE_SUCCESS(rv, rv);
+    mPDFPageCount = mPDFPrintHelper->GetPageCount();
+    if (mPDFPageCount <= 0) {
+      CleanupPrintViaPDF();
+      return NS_ERROR_FAILURE;
+    }
+    mPDFCurrentPageNum = 0;
+
+    rv = NS_DispatchToCurrentThread(NewRunnableMethod(
+      "nsDeviceContextSpecWin::PrintPDFOnThread",
+      this,
+      &nsDeviceContextSpecWin::FinishPrintViaPDF));
+    if (NS_FAILED(rv)) {
+      CleanupPrintViaPDF();
+      NS_WARNING("Failed to dispatch to the current thread!");
+    }
+  }
+#endif
+  return rv;
+}
+
 //----------------------------------------------------------------------------------
 void nsDeviceContextSpecWin::SetDeviceName(const nsAString& aDeviceName)
 {
   mDeviceName = aDeviceName;
 }
 
 //----------------------------------------------------------------------------------
 void nsDeviceContextSpecWin::SetDriverName(const nsAString& aDriverName)
--- a/widget/windows/nsDeviceContextSpecWin.h
+++ b/widget/windows/nsDeviceContextSpecWin.h
@@ -12,29 +12,41 @@
 #include "nsIPrintSettings.h"
 #include "nsISupportsPrimitives.h"
 #include <windows.h>
 #include "mozilla/Attributes.h"
 #include "mozilla/RefPtr.h"
 
 class nsIWidget;
 
+#ifdef MOZ_ENABLE_SKIA_PDF
+namespace mozilla {
+namespace widget {
+class PDFViaEMFPrintHelper;
+}
+}
+#endif
+
 class nsDeviceContextSpecWin : public nsIDeviceContextSpec
 {
+#ifdef MOZ_ENABLE_SKIA_PDF
+  typedef mozilla::widget::PDFViaEMFPrintHelper PDFViaEMFPrintHelper;
+#endif
+
 public:
   nsDeviceContextSpecWin();
 
   NS_DECL_ISUPPORTS
 
   virtual already_AddRefed<PrintTarget> MakePrintTarget() final;
   NS_IMETHOD BeginDocument(const nsAString& aTitle,
                            const nsAString& aPrintToFileName,
                            int32_t          aStartPage,
-                           int32_t          aEndPage) override { return NS_OK; }
-  NS_IMETHOD EndDocument() override { return NS_OK; }
+                           int32_t          aEndPage) override;
+  NS_IMETHOD EndDocument() override;
   NS_IMETHOD BeginPage() override { return NS_OK; }
   NS_IMETHOD EndPage() override { return NS_OK; }
 
   NS_IMETHOD Init(nsIWidget* aWidget, nsIPrintSettings* aPS, bool aIsPrintPreview) override;
 
   float GetDPI() final;
 
   float GetPrintingScale() final;
@@ -63,21 +75,29 @@ protected:
   nsString mDriverName;
   nsString mDeviceName;
   LPDEVMODEW mDevMode;
 
   nsCOMPtr<nsIPrintSettings> mPrintSettings;
   int16_t mOutputFormat = nsIPrintSettings::kOutputFormatNative;
 
 #ifdef MOZ_ENABLE_SKIA_PDF
+  void  FinishPrintViaPDF();
+  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;
+  mozilla::UniquePtr<PDFViaEMFPrintHelper> mPDFPrintHelper;
+  int mPDFPageCount;
+  int mPDFCurrentPageNum;
 #endif
 };
 
 
 //-------------------------------------------------------------------------
 // Printer Enumerator
 //-------------------------------------------------------------------------
 class nsPrinterEnumeratorWin final : public nsIPrinterEnumerator
--- a/widget/windows/nsSound.cpp
+++ b/widget/windows/nsSound.cpp
@@ -23,17 +23,16 @@
 #include "nsIObserverService.h"
 
 #include "mozilla/Logging.h"
 #include "prtime.h"
 
 #include "nsNativeCharsetUtils.h"
 #include "nsThreadUtils.h"
 #include "mozilla/ClearOnShutdown.h"
-#include "gfxPlatform.h"
 
 using mozilla::LogLevel;
 
 static mozilla::LazyLogModule gWin32SoundLog("nsSound");
 
 class nsSoundPlayer: public mozilla::Runnable {
 public:
   explicit nsSoundPlayer(const nsAString& aSoundName)
@@ -88,17 +87,17 @@ nsSoundPlayer::~nsSoundPlayer()
 
 mozilla::StaticRefPtr<nsISound> nsSound::sInstance;
 
 /* static */ already_AddRefed<nsISound>
 nsSound::GetInstance()
 {
   if (!sInstance) {
     if (gfxPlatform::IsHeadless()) {
-      sInstance = new mozilla::widget::HeadlessSound();
+      sInstance = new widget::HeadlessSound();
     } else {
       RefPtr<nsSound> sound = new nsSound();
       nsresult rv = sound->CreatePlayerThread();
       if(NS_WARN_IF(NS_FAILED(rv))) {
         return nullptr;
       }
       sInstance = sound.forget();
     }
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -369,29 +369,28 @@ enum GeckoProcessType
   GeckoProcessType_Plugin,
   GeckoProcessType_Content,
 
   GeckoProcessType_IPDLUnitTest,
 
   GeckoProcessType_GMPlugin, // Gecko Media Plugin
 
   GeckoProcessType_GPU,      // GPU and compositor process
-  GeckoProcessType_PDFium,   // Gecko PDFium process
+
   GeckoProcessType_End,
   GeckoProcessType_Invalid = GeckoProcessType_End
 };
 
 static const char* const kGeckoProcessTypeString[] = {
   "default",
   "plugin",
   "tab",
   "ipdlunittest",
   "geckomediaplugin",
-  "gpu",
-  "pdfium"
+  "gpu"
 };
 
 static_assert(MOZ_ARRAY_LENGTH(kGeckoProcessTypeString) ==
               GeckoProcessType_End,
               "Array length mismatch");
 
 XRE_API(const char*,
         XRE_ChildProcessTypeToString, (GeckoProcessType aProcessType))
--- a/xpcom/system/nsIXULRuntime.idl
+++ b/xpcom/system/nsIXULRuntime.idl
@@ -71,17 +71,16 @@ interface nsIXULRuntime : nsISupports
    * The legal values of processType.
    */
   const unsigned long PROCESS_TYPE_DEFAULT = 0;
   const unsigned long PROCESS_TYPE_PLUGIN = 1;
   const unsigned long PROCESS_TYPE_CONTENT = 2;
   const unsigned long PROCESS_TYPE_IPDLUNITTEST = 3;
   const unsigned long PROCESS_TYPE_GMPLUGIN = 4;
   const unsigned long PROCESS_TYPE_GPU = 5;
-  const unsigned long PROCESS_TYPE_PDFIUM = 6;
 
   /**
    * The type of the caller's process.  Returns one of the values above.
    */
   readonly attribute unsigned long processType;
 
   /**
    * The system process ID of the caller's process.