Bug 1368948: [2/7] Add patch files for PDFium. f=glandium, r=jwatt
authorBruce Sun <brsun@mozilla.com>
Thu, 29 Jun 2017 17:14:00 -0700
changeset 367053 f4e545936d90680d190977bc6b35378ba7a71fb3
parent 367052 4ddf08e4cb5bc66229430349eff6e5a954eb8752
child 367054 aed6e75d9b0ddb1c27962d589f025b32438bcbff
push id32117
push userphilringnalda@gmail.com
push dateSun, 02 Jul 2017 00:39:30 +0000
treeherdermozilla-central@4d3de12dcdc5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1368948
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 1368948: [2/7] Add patch files for PDFium. f=glandium, r=jwatt Add patch files for update.sh to automatically modify pdfium sources: - a patch to fix PDFium build errors due to lacking GDI+ prerequisite headers - a patch to let PDFium use freetype library within Gecko - a patch to let PDFium use libjpeg library within Gecko - a patch to let PDFium use zlib library within Gecko - a patch to remove JPEG 2000 support from PDFium MozReview-Commit-ID: HRLLHQnmAZV
modules/pdfium/patches/bug1368948_gdiplus_prerequisite.patch
modules/pdfium/patches/bug1368948_remove_openjpeg.patch
modules/pdfium/patches/bug1368948_use_gecko_freetype.patch
modules/pdfium/patches/bug1368948_use_gecko_libjpeg.patch
modules/pdfium/patches/bug1368948_use_gecko_zlib.patch
modules/pdfium/update.sh
new file mode 100644
--- /dev/null
+++ b/modules/pdfium/patches/bug1368948_gdiplus_prerequisite.patch
@@ -0,0 +1,34 @@
+# HG changeset patch
+# User Bruce Sun <brsun@mozilla.com>
+# Date 1498781240 25200
+#      Thu Jun 29 17:07:20 2017 -0700
+# Node ID 20556f24d36ccfb4471b9ef86241a6f8912e8a19
+# Parent  5c522cd3d85e88d3cd7415c917985af687a8a0a6
+Bug 1368948: Undefine WIN32_LEAN_AND_MEAN when building PDFium to avoid build errors in GDI+ headers.
+
+Mozilla build system includes mozilla-config.h, which defines WIN32_LEAN_AND_MEAN.
+Some definitions are stripped from header files by WIN32_LEAN_AND_MEAN causing build
+errors in GDI+ headers. Including objidl.h would fix these errors, but since Chromium
+builds PDFium without WIN32_LEAN_AND_MEAN, we do the same.
+
+MozReview-Commit-ID: HQYrtJgQXHP
+
+diff --git a/modules/pdfium/pdfium/core/fxge/win32/fx_win32_gdipext.cpp b/modules/pdfium/pdfium/core/fxge/win32/fx_win32_gdipext.cpp
+--- a/modules/pdfium/pdfium/core/fxge/win32/fx_win32_gdipext.cpp
++++ b/modules/pdfium/pdfium/core/fxge/win32/fx_win32_gdipext.cpp
+@@ -1,14 +1,15 @@
+ // Copyright 2014 PDFium Authors. All rights reserved.
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+ 
+ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+ 
++#undef WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ 
+ #include <algorithm>
+ #include <memory>
+ 
+ #include "core/fxcrt/fx_system.h"
+ #include "core/fxge/cfx_gemodule.h"
+ #include "core/fxge/cfx_graphstatedata.h"
new file mode 100644
--- /dev/null
+++ b/modules/pdfium/patches/bug1368948_remove_openjpeg.patch
@@ -0,0 +1,152 @@
+# HG changeset patch
+# User Bruce Sun <brsun@mozilla.com>
+# Date 1498781299 25200
+#      Thu Jun 29 17:08:19 2017 -0700
+# Node ID ae3e3cc9d3048e4ed01890c362810e3816b7b6ea
+# Parent  dec90fe0b38375822ff169695c2ac18b96be4f51
+Bug 1368948: Prevent PDFium from trying to use the removed OpenJPEG code.
+
+Our PDFium update script at modules/pdfium/update.sh removes the OpenJPEG code
+from our copy of PDFium.  This patch makes sure that the remaining PDFium code
+does not try to use OpenJPEG.
+
+MozReview-Commit-ID: 1ef0OObTzHw
+
+diff --git a/modules/pdfium/pdfium/core/fxcodec/codec/ccodec_jpxmodule.h b/modules/pdfium/pdfium/core/fxcodec/codec/ccodec_jpxmodule.h
+--- a/modules/pdfium/pdfium/core/fxcodec/codec/ccodec_jpxmodule.h
++++ b/modules/pdfium/pdfium/core/fxcodec/codec/ccodec_jpxmodule.h
+@@ -11,26 +11,26 @@
+ 
+ #include "core/fxcrt/fx_system.h"
+ 
+ class CJPX_Decoder;
+ class CPDF_ColorSpace;
+ 
+ class CCodec_JpxModule {
+  public:
+-  CCodec_JpxModule();
+-  ~CCodec_JpxModule();
++  CCodec_JpxModule() {}
++  ~CCodec_JpxModule() {}
+ 
+   CJPX_Decoder* CreateDecoder(const uint8_t* src_buf,
+                               uint32_t src_size,
+-                              CPDF_ColorSpace* cs);
++                              CPDF_ColorSpace* cs) { return nullptr; }
+   void GetImageInfo(CJPX_Decoder* pDecoder,
+                     uint32_t* width,
+                     uint32_t* height,
+-                    uint32_t* components);
++                    uint32_t* components) {}
+   bool Decode(CJPX_Decoder* pDecoder,
+               uint8_t* dest_data,
+               int pitch,
+-              const std::vector<uint8_t>& offsets);
+-  void DestroyDecoder(CJPX_Decoder* pDecoder);
++              const std::vector<uint8_t>& offsets) { return false; }
++  void DestroyDecoder(CJPX_Decoder* pDecoder) {}
+ };
+ 
+ #endif  // CORE_FXCODEC_CODEC_CCODEC_JPXMODULE_H_
+diff --git a/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec.cpp b/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec.cpp
+--- a/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec.cpp
++++ b/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec.cpp
+@@ -6,17 +6,16 @@
+ 
+ #include "core/fxcodec/fx_codec.h"
+ 
+ #include <algorithm>
+ #include <cmath>
+ #include <memory>
+ #include <utility>
+ 
+-#include "core/fxcodec/codec/codec_int.h"
+ #include "core/fxcrt/fx_ext.h"
+ #include "core/fxcrt/fx_safe_types.h"
+ #include "third_party/base/logging.h"
+ #include "third_party/base/ptr_util.h"
+ 
+ CCodec_ModuleMgr::CCodec_ModuleMgr()
+     : m_pBasicModule(new CCodec_BasicModule),
+       m_pFaxModule(new CCodec_FaxModule),
+diff --git a/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_fax.cpp b/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_fax.cpp
+--- a/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_fax.cpp
++++ b/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_fax.cpp
+@@ -3,17 +3,16 @@
+ // found in the LICENSE file.
+ 
+ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+ 
+ #include <algorithm>
+ #include <memory>
+ #include <vector>
+ 
+-#include "core/fxcodec/codec/codec_int.h"
+ #include "core/fxcodec/fx_codec.h"
+ #include "core/fxcrt/fx_memory.h"
+ #include "third_party/base/ptr_util.h"
+ 
+ namespace {
+ 
+ const uint8_t OneLeadPos[256] = {
+     8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3,
+diff --git a/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_flate.cpp b/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_flate.cpp
+--- a/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_flate.cpp
++++ b/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_flate.cpp
+@@ -1,16 +1,14 @@
+ // Copyright 2014 PDFium Authors. All rights reserved.
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+ 
+ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+ 
+-#include "core/fxcodec/codec/codec_int.h"
+-
+ #include <algorithm>
+ #include <memory>
+ #include <utility>
+ #include <vector>
+ 
+ #include "core/fxcodec/fx_codec.h"
+ #include "core/fxcrt/fx_ext.h"
+ #include "third_party/base/ptr_util.h"
+diff --git a/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_icc.cpp b/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_icc.cpp
+--- a/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_icc.cpp
++++ b/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_icc.cpp
+@@ -1,15 +1,14 @@
+ // Copyright 2014 PDFium Authors. All rights reserved.
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+ 
+ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+ 
+-#include "core/fxcodec/codec/codec_int.h"
+ #include "core/fxcodec/fx_codec.h"
+ #include "third_party/lcms2-2.6/include/lcms2.h"
+ 
+ struct CLcmsCmm {
+   cmsHTRANSFORM m_hTransform;
+   int m_nSrcComponents;
+   int m_nDstComponents;
+   bool m_bLab;
+diff --git a/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_jpeg.cpp b/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_jpeg.cpp
+--- a/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_jpeg.cpp
++++ b/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_jpeg.cpp
+@@ -4,17 +4,16 @@
+ 
+ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+ 
+ #include <setjmp.h>
+ 
+ #include <memory>
+ #include <utility>
+ 
+-#include "core/fxcodec/codec/codec_int.h"
+ #include "core/fxcodec/fx_codec.h"
+ #include "core/fxcrt/fx_safe_types.h"
+ #include "core/fxge/fx_dib.h"
+ #include "third_party/base/ptr_util.h"
+ 
+ extern "C" {
+ #undef FAR
+ #if defined(USE_SYSTEM_LIBJPEG)
new file mode 100644
--- /dev/null
+++ b/modules/pdfium/patches/bug1368948_use_gecko_freetype.patch
@@ -0,0 +1,32 @@
+# HG changeset patch
+# User Bruce Sun <brsun@mozilla.com>
+# Date 1498781255 25200
+#      Thu Jun 29 17:07:35 2017 -0700
+# Node ID 528bde20b353af9b8f075c4d2c54f63061eb0e61
+# Parent  20556f24d36ccfb4471b9ef86241a6f8912e8a19
+Bug 1368948: Make PDFium use Mozilla's in-tree copy of FreeType instead of its own copy.
+
+MozReview-Commit-ID: 8P48C8xavbs
+
+diff --git a/modules/pdfium/pdfium/core/fxge/freetype/fx_freetype.cpp b/modules/pdfium/pdfium/core/fxge/freetype/fx_freetype.cpp
+--- a/modules/pdfium/pdfium/core/fxge/freetype/fx_freetype.cpp
++++ b/modules/pdfium/pdfium/core/fxge/freetype/fx_freetype.cpp
+@@ -1,17 +1,17 @@
+ // Copyright 2014 PDFium Authors. All rights reserved.
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+ 
+ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+ 
+ #include "core/fxge/fx_freetype.h"
+ 
+-#include "third_party/freetype/src/psnames/pstables.h"
++#include "psnames/pstables.h"
+ 
+ static int xyq_search_node(char* glyph_name,
+                            int name_offset,
+                            int table_offset,
+                            wchar_t unicode) {
+   int i, count;
+ 
+   // copy letters
new file mode 100644
--- /dev/null
+++ b/modules/pdfium/patches/bug1368948_use_gecko_libjpeg.patch
@@ -0,0 +1,32 @@
+# HG changeset patch
+# User Bruce Sun <brsun@mozilla.com>
+# Date 1498781267 25200
+#      Thu Jun 29 17:07:47 2017 -0700
+# Node ID 7a6b973eaa086031ad64990d96bbf157ef02ea65
+# Parent  528bde20b353af9b8f075c4d2c54f63061eb0e61
+Bug 1368948: Make PDFium use Mozilla's in-tree copy of libjpeg instead of its own copy.
+
+MozReview-Commit-ID: Fbc6EdA4OBY
+
+diff --git a/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_jpeg.cpp b/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_jpeg.cpp
+--- a/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_jpeg.cpp
++++ b/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_jpeg.cpp
+@@ -15,17 +15,17 @@
+ #include "core/fxge/fx_dib.h"
+ #include "third_party/base/ptr_util.h"
+ 
+ extern "C" {
+ #undef FAR
+ #if defined(USE_SYSTEM_LIBJPEG)
+ #include <jpeglib.h>
+ #elif defined(USE_LIBJPEG_TURBO)
+-#include "third_party/libjpeg_turbo/jpeglib.h"
++#include "jpeglib.h"
+ #else
+ #include "third_party/libjpeg/jpeglib.h"
+ #endif
+ }
+ 
+ extern "C" {
+ 
+ static void JpegScanSOI(const uint8_t** src_buf, uint32_t* src_size) {
new file mode 100644
--- /dev/null
+++ b/modules/pdfium/patches/bug1368948_use_gecko_zlib.patch
@@ -0,0 +1,32 @@
+# HG changeset patch
+# User Bruce Sun <brsun@mozilla.com>
+# Date 1498781283 25200
+#      Thu Jun 29 17:08:03 2017 -0700
+# Node ID dec90fe0b38375822ff169695c2ac18b96be4f51
+# Parent  7a6b973eaa086031ad64990d96bbf157ef02ea65
+Bug 1368948: Make PDFium use Mozilla's in-tree copy of zlip instead of its own copy.
+
+MozReview-Commit-ID: FlQwnJ9O3cQ
+
+diff --git a/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_flate.cpp b/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_flate.cpp
+--- a/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_flate.cpp
++++ b/modules/pdfium/pdfium/core/fxcodec/codec/fx_codec_flate.cpp
+@@ -9,17 +9,17 @@
+ #include <algorithm>
+ #include <memory>
+ #include <utility>
+ #include <vector>
+ 
+ #include "core/fxcodec/fx_codec.h"
+ #include "core/fxcrt/fx_ext.h"
+ #include "third_party/base/ptr_util.h"
+-#include "third_party/zlib_v128/zlib.h"
++#include "zlib.h"
+ 
+ extern "C" {
+ static void* my_alloc_func(void* opaque,
+                            unsigned int items,
+                            unsigned int size) {
+   return FX_Alloc2D(uint8_t, items, size);
+ }
+ static void my_free_func(void* opaque, void* address) {
--- a/modules/pdfium/update.sh
+++ b/modules/pdfium/update.sh
@@ -88,19 +88,35 @@ cleanup_files() {
     rm -rf pdfium/testing
 
     # We don't need XFA implementations since the XFA features are disabled.
     echo "Removing pdfium/xfa"
     rm -rf pdfium/xfa
 }
 
 apply_patches() {
-    # Apply patches, ex:
-    # patch -p3 < some.patch
-    return
+    # Patch to fix build errors due to lacking GDI+ prerequisite headers
+    echo "Applying patches/bug1368948_gdiplus_prerequisite.patch"
+    patch -p3 < patches/bug1368948_gdiplus_prerequisite.patch
+
+    # Patch to use freetype library within Gecko
+    echo "Applying patches/bug1368948_use_gecko_freetype.patch"
+    patch -p3 < patches/bug1368948_use_gecko_freetype.patch
+
+    # Patch to use libjpeg library within Gecko
+    echo "Applying patches/bug1368948_use_gecko_libjpeg.patch"
+    patch -p3 < patches/bug1368948_use_gecko_libjpeg.patch
+
+    # 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
 }
 
 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
 }