Bug 1367948 - Part1. Add a patch file to patch PDFium to prevent it from using GDIPlusExt to avoid garbage rendering. r=jwatt
authorFarmer Tseng <fatseng@mozilla.com>
Thu, 27 Jul 2017 11:22:20 +0800
changeset 419954 ac08e5a6a6cfc51dfc62fcecb1703d69af2d2241
parent 419953 4415d55c49f7160165d590a09a6990503a931a67
child 419955 6abd15012dcd2e345ba694ae5480e223502e59b7
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1367948
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1367948 - Part1. Add a patch file to patch PDFium to prevent it from using GDIPlusExt to avoid garbage rendering. r=jwatt MozReview-Commit-ID: 9571a5b7G5m
modules/pdfium/patches/bug1367948_avoid_using_GDIPlusExt.patch
modules/pdfium/update.sh
new file mode 100644
--- /dev/null
+++ b/modules/pdfium/patches/bug1367948_avoid_using_GDIPlusExt.patch
@@ -0,0 +1,37 @@
+# HG changeset patch
+# User Farmer Tseng <fatseng@mozilla.com>
+# Date 1501050302 -28800
+#      Wed Jul 26 14:25:02 2017 +0800
+# Node ID 29d89e1872c50736819c365f538a86cf79a94e6d
+# Parent  4a23ddee84be23934eb5ce5f408f53ddb059fa18
+Bug 1367948 - Part2. Prevent PDFium from using GDIPlusExt to avoid garbage rendering.
+
+MozReview-Commit-ID: 8hE0q6jKFzj
+
+diff --git a/modules/pdfium/pdfium/core/fxge/win32/fx_win32_device.cpp b/modules/pdfium/pdfium/core/fxge/win32/fx_win32_device.cpp
+--- a/modules/pdfium/pdfium/core/fxge/win32/fx_win32_device.cpp
++++ b/modules/pdfium/pdfium/core/fxge/win32/fx_win32_device.cpp
+@@ -75,16 +75,23 @@ bool GetSubFontName(CFX_ByteString* name
+       *name = g_JpFontNameMap[i].m_pSubFontName;
+       return true;
+     }
+   }
+   return false;
+ }
+ 
+ bool IsGDIEnabled() {
++  // In Chromium, PDFium runs in sandboxed process which can't get the screen
++  // DC. Therefore, we |return false| here to avoid using the GDIPlusExt class
++  // within PDFium in order to take the same code paths as Chromium.
++  // This avoids an issue where PDFium can render some garbage to EMF
++  // (see bug 1367948).
++  return false;
++
+   // If GDI is disabled then GetDC for the desktop will fail.
+   HDC hdc = ::GetDC(nullptr);
+   if (!hdc)
+     return false;
+   ::ReleaseDC(nullptr, hdc);
+   return true;
+ }
+ 
--- a/modules/pdfium/update.sh
+++ b/modules/pdfium/update.sh
@@ -107,16 +107,20 @@ apply_patches() {
 
     # Patch to use zlib library within Gecko
     echo "Applying patches/bug1368948_use_gecko_zlib.patch"
     patch -p3 < patches/bug1368948_use_gecko_zlib.patch
 
     # Patch to remove openjpeg support
     echo "Applying patches/bug1368948_remove_openjpeg.patch"
     patch -p3 < patches/bug1368948_remove_openjpeg.patch
+
+    # Patch to avoid using GDIPlusExt while rendering EMF
+    echo "Applying patches/bug1367948_avoid_using_GDIPlusExt.patch"
+    patch -p3 < patches/bug1367948_avoid_using_GDIPlusExt.patch
 }
 
 update_readme() {
     echo "Updating README_MOZILLA"
     PREFIX="The git commit ID last used to import was"
     perl -p -i -e "s/${PREFIX} [0-9A-Fa-f]+ \(.+\)/${PREFIX} ${COMMIT} (${COMMIT_DATE})/" README_MOZILLA
 }