Move XFA codec code into their own directories.

Move code out of core/fxcodec/codec and into core/fxcodec/foo, where foo
is for a specific codec. e.g. gif or png.

Change-Id: Ie0bf502d68618bb11bd39ab26d0fd97fc8951b34
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/56350
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcodec/BUILD.gn b/core/fxcodec/BUILD.gn
index 07e3182..4a012fe 100644
--- a/core/fxcodec/BUILD.gn
+++ b/core/fxcodec/BUILD.gn
@@ -88,38 +88,38 @@
     ]
     if (pdf_enable_xfa_bmp) {
       sources += [
+        "bmp/bmpmodule.cpp",
+        "bmp/bmpmodule.h",
         "bmp/cfx_bmpcontext.cpp",
         "bmp/cfx_bmpcontext.h",
         "bmp/cfx_bmpdecompressor.cpp",
         "bmp/cfx_bmpdecompressor.h",
         "bmp/fx_bmp.h",
-        "codec/bmpmodule.cpp",
-        "codec/bmpmodule.h",
       ]
     }
     if (pdf_enable_xfa_gif) {
       sources += [
-        "codec/gifmodule.cpp",
-        "codec/gifmodule.h",
         "gif/cfx_gif.cpp",
         "gif/cfx_gif.h",
         "gif/cfx_gifcontext.cpp",
         "gif/cfx_gifcontext.h",
         "gif/cfx_lzwdecompressor.cpp",
         "gif/cfx_lzwdecompressor.h",
+        "gif/gifmodule.cpp",
+        "gif/gifmodule.h",
       ]
     }
     if (pdf_enable_xfa_png) {
       sources += [
-        "codec/pngmodule.cpp",
-        "codec/pngmodule.h",
+        "png/pngmodule.cpp",
+        "png/pngmodule.h",
       ]
       deps += [ "../../third_party:png" ]
     }
     if (pdf_enable_xfa_tiff) {
       sources += [
-        "codec/tiffmodule.cpp",
-        "codec/tiffmodule.h",
+        "tiff/tiffmodule.cpp",
+        "tiff/tiffmodule.h",
       ]
       deps += [ "../../third_party:fx_tiff" ]
     }
diff --git a/core/fxcodec/codec/bmpmodule.cpp b/core/fxcodec/bmp/bmpmodule.cpp
similarity index 98%
rename from core/fxcodec/codec/bmpmodule.cpp
rename to core/fxcodec/bmp/bmpmodule.cpp
index d9919ce..21b9390 100644
--- a/core/fxcodec/codec/bmpmodule.cpp
+++ b/core/fxcodec/bmp/bmpmodule.cpp
@@ -4,7 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "core/fxcodec/codec/bmpmodule.h"
+#include "core/fxcodec/bmp/bmpmodule.h"
 
 #include <utility>
 
diff --git a/core/fxcodec/codec/bmpmodule.h b/core/fxcodec/bmp/bmpmodule.h
similarity index 92%
rename from core/fxcodec/codec/bmpmodule.h
rename to core/fxcodec/bmp/bmpmodule.h
index eb33c37..70e265e 100644
--- a/core/fxcodec/codec/bmpmodule.h
+++ b/core/fxcodec/bmp/bmpmodule.h
@@ -4,8 +4,8 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef CORE_FXCODEC_CODEC_BMPMODULE_H_
-#define CORE_FXCODEC_CODEC_BMPMODULE_H_
+#ifndef CORE_FXCODEC_BMP_BMPMODULE_H_
+#define CORE_FXCODEC_BMP_BMPMODULE_H_
 
 #include <memory>
 #include <vector>
@@ -52,4 +52,4 @@
 
 using BmpModule = fxcodec::BmpModule;
 
-#endif  // CORE_FXCODEC_CODEC_BMPMODULE_H_
+#endif  // CORE_FXCODEC_BMP_BMPMODULE_H_
diff --git a/core/fxcodec/bmp/cfx_bmpcontext.h b/core/fxcodec/bmp/cfx_bmpcontext.h
index 993afdd..e45caf9 100644
--- a/core/fxcodec/bmp/cfx_bmpcontext.h
+++ b/core/fxcodec/bmp/cfx_bmpcontext.h
@@ -7,9 +7,9 @@
 #ifndef CORE_FXCODEC_BMP_CFX_BMPCONTEXT_H_
 #define CORE_FXCODEC_BMP_CFX_BMPCONTEXT_H_
 
+#include "core/fxcodec/bmp/bmpmodule.h"
 #include "core/fxcodec/bmp/cfx_bmpdecompressor.h"
 #include "core/fxcodec/bmp/fx_bmp.h"
-#include "core/fxcodec/codec/bmpmodule.h"
 #include "core/fxcrt/unowned_ptr.h"
 
 namespace fxcodec {
diff --git a/core/fxcodec/bmp/cfx_bmpdecompressor.h b/core/fxcodec/bmp/cfx_bmpdecompressor.h
index dcdd91b..7d2fd03 100644
--- a/core/fxcodec/bmp/cfx_bmpdecompressor.h
+++ b/core/fxcodec/bmp/cfx_bmpdecompressor.h
@@ -11,8 +11,8 @@
 
 #include <vector>
 
+#include "core/fxcodec/bmp/bmpmodule.h"
 #include "core/fxcodec/bmp/fx_bmp.h"
-#include "core/fxcodec/codec/bmpmodule.h"
 #include "core/fxcrt/retain_ptr.h"
 #include "core/fxcrt/unowned_ptr.h"
 
diff --git a/core/fxcodec/codec/DEPS b/core/fxcodec/codec/DEPS
index 8506f19..88af241 100644
--- a/core/fxcodec/codec/DEPS
+++ b/core/fxcodec/codec/DEPS
@@ -3,6 +3,4 @@
   '+third_party/libjpeg/jpeglib.h',
   '+third_party/libjpeg_turbo/jerror.h',
   '+third_party/libjpeg_turbo/jpeglib.h',
-  '+third_party/libpng16/png.h',
-  '+third_party/libtiff/tiffiop.h',
 ]
diff --git a/core/fxcodec/codec/progressivedecoder.h b/core/fxcodec/codec/progressivedecoder.h
index b2eac13..24817d6 100644
--- a/core/fxcodec/codec/progressivedecoder.h
+++ b/core/fxcodec/codec/progressivedecoder.h
@@ -19,19 +19,19 @@
 #include "core/fxge/fx_dib.h"
 
 #ifdef PDF_ENABLE_XFA_BMP
-#include "core/fxcodec/codec/bmpmodule.h"
+#include "core/fxcodec/bmp/bmpmodule.h"
 #endif  // PDF_ENABLE_XFA_BMP
 
 #ifdef PDF_ENABLE_XFA_GIF
-#include "core/fxcodec/codec/gifmodule.h"
+#include "core/fxcodec/gif/gifmodule.h"
 #endif  // PDF_ENABLE_XFA_GIF
 
 #ifdef PDF_ENABLE_XFA_PNG
-#include "core/fxcodec/codec/pngmodule.h"
+#include "core/fxcodec/png/pngmodule.h"
 #endif  // PDF_ENABLE_XFA_PNG
 
 #ifdef PDF_ENABLE_XFA_TIFF
-#include "core/fxcodec/codec/tiffmodule.h"
+#include "core/fxcodec/tiff/tiffmodule.h"
 #endif  // PDF_ENABLE_XFA_TIFF
 
 class CFX_DIBitmap;
diff --git a/core/fxcodec/codec/progressivedecoder_unittest.cpp b/core/fxcodec/codec/progressivedecoder_unittest.cpp
index 9a2a7e6..07eb701 100644
--- a/core/fxcodec/codec/progressivedecoder_unittest.cpp
+++ b/core/fxcodec/codec/progressivedecoder_unittest.cpp
@@ -12,7 +12,7 @@
 #include "third_party/base/span.h"
 
 #ifdef PDF_ENABLE_XFA_GIF
-#include "core/fxcodec/codec/gifmodule.h"
+#include "core/fxcodec/gif/gifmodule.h"
 #endif  // PDF_ENABLE_XFA_GIF
 
 namespace fxcodec {
diff --git a/core/fxcodec/fx_codec.h b/core/fxcodec/fx_codec.h
index 4c6b94d..c7224ff 100644
--- a/core/fxcodec/fx_codec.h
+++ b/core/fxcodec/fx_codec.h
@@ -18,19 +18,19 @@
 
 #ifdef PDF_ENABLE_XFA
 #ifdef PDF_ENABLE_XFA_BMP
-#include "core/fxcodec/codec/bmpmodule.h"
+#include "core/fxcodec/bmp/bmpmodule.h"
 #endif  // PDF_ENABLE_XFA_BMP
 
 #ifdef PDF_ENABLE_XFA_GIF
-#include "core/fxcodec/codec/gifmodule.h"
+#include "core/fxcodec/gif/gifmodule.h"
 #endif  // PDF_ENABLE_XFA_GIF
 
 #ifdef PDF_ENABLE_XFA_PNG
-#include "core/fxcodec/codec/pngmodule.h"
+#include "core/fxcodec/png/pngmodule.h"
 #endif  // PDF_ENABLE_XFA_PNG
 
 #ifdef PDF_ENABLE_XFA_TIFF
-#include "core/fxcodec/codec/tiffmodule.h"
+#include "core/fxcodec/tiff/tiffmodule.h"
 #endif  // PDF_ENABLE_XFA_TIFF
 #endif  // PDF_ENABLE_XFA
 
diff --git a/core/fxcodec/gif/cfx_gifcontext.cpp b/core/fxcodec/gif/cfx_gifcontext.cpp
index 9f7bf67..07f3781 100644
--- a/core/fxcodec/gif/cfx_gifcontext.cpp
+++ b/core/fxcodec/gif/cfx_gifcontext.cpp
@@ -10,8 +10,8 @@
 #include <utility>
 
 #include "core/fxcodec/codec/cfx_codec_memory.h"
-#include "core/fxcodec/codec/gifmodule.h"
 #include "core/fxcodec/gif/cfx_gif.h"
+#include "core/fxcodec/gif/gifmodule.h"
 #include "third_party/base/ptr_util.h"
 #include "third_party/base/stl_util.h"
 
diff --git a/core/fxcodec/gif/cfx_gifcontext.h b/core/fxcodec/gif/cfx_gifcontext.h
index 7e813a6..d2ccd9d 100644
--- a/core/fxcodec/gif/cfx_gifcontext.h
+++ b/core/fxcodec/gif/cfx_gifcontext.h
@@ -10,9 +10,9 @@
 #include <memory>
 #include <vector>
 
-#include "core/fxcodec/codec/gifmodule.h"
 #include "core/fxcodec/gif/cfx_gif.h"
 #include "core/fxcodec/gif/cfx_lzwdecompressor.h"
+#include "core/fxcodec/gif/gifmodule.h"
 #include "core/fxcrt/fx_string.h"
 #include "core/fxcrt/unowned_ptr.h"
 
diff --git a/core/fxcodec/codec/gifmodule.cpp b/core/fxcodec/gif/gifmodule.cpp
similarity index 98%
rename from core/fxcodec/codec/gifmodule.cpp
rename to core/fxcodec/gif/gifmodule.cpp
index 0e33f64..1c3cdb5 100644
--- a/core/fxcodec/codec/gifmodule.cpp
+++ b/core/fxcodec/gif/gifmodule.cpp
@@ -4,7 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "core/fxcodec/codec/gifmodule.h"
+#include "core/fxcodec/gif/gifmodule.h"
 
 #include "core/fxcodec/codec/cfx_codec_memory.h"
 #include "core/fxcodec/codec/codec_int.h"
diff --git a/core/fxcodec/codec/gifmodule.h b/core/fxcodec/gif/gifmodule.h
similarity index 94%
rename from core/fxcodec/codec/gifmodule.h
rename to core/fxcodec/gif/gifmodule.h
index 9d4d8ed..c8d801d 100644
--- a/core/fxcodec/codec/gifmodule.h
+++ b/core/fxcodec/gif/gifmodule.h
@@ -4,8 +4,8 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef CORE_FXCODEC_CODEC_GIFMODULE_H_
-#define CORE_FXCODEC_CODEC_GIFMODULE_H_
+#ifndef CORE_FXCODEC_GIF_GIFMODULE_H_
+#define CORE_FXCODEC_GIF_GIFMODULE_H_
 
 #include <memory>
 #include <utility>
@@ -59,4 +59,4 @@
 
 using GifModule = fxcodec::GifModule;
 
-#endif  // CORE_FXCODEC_CODEC_GIFMODULE_H_
+#endif  // CORE_FXCODEC_GIF_GIFMODULE_H_
diff --git a/core/fxcodec/png/DEPS b/core/fxcodec/png/DEPS
new file mode 100644
index 0000000..cc73855
--- /dev/null
+++ b/core/fxcodec/png/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+  '+third_party/libpng16/png.h',
+]
diff --git a/core/fxcodec/codec/pngmodule.cpp b/core/fxcodec/png/pngmodule.cpp
similarity index 99%
rename from core/fxcodec/codec/pngmodule.cpp
rename to core/fxcodec/png/pngmodule.cpp
index 8999508..f74fc50 100644
--- a/core/fxcodec/codec/pngmodule.cpp
+++ b/core/fxcodec/png/pngmodule.cpp
@@ -4,7 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "core/fxcodec/codec/pngmodule.h"
+#include "core/fxcodec/png/pngmodule.h"
 
 #include <algorithm>
 
diff --git a/core/fxcodec/codec/pngmodule.h b/core/fxcodec/png/pngmodule.h
similarity index 91%
rename from core/fxcodec/codec/pngmodule.h
rename to core/fxcodec/png/pngmodule.h
index c5f1980..0056ed5 100644
--- a/core/fxcodec/codec/pngmodule.h
+++ b/core/fxcodec/png/pngmodule.h
@@ -4,8 +4,8 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef CORE_FXCODEC_CODEC_PNGMODULE_H_
-#define CORE_FXCODEC_CODEC_PNGMODULE_H_
+#ifndef CORE_FXCODEC_PNG_PNGMODULE_H_
+#define CORE_FXCODEC_PNG_PNGMODULE_H_
 
 #include <memory>
 
@@ -47,4 +47,4 @@
 
 using PngModule = fxcodec::PngModule;
 
-#endif  // CORE_FXCODEC_CODEC_PNGMODULE_H_
+#endif  // CORE_FXCODEC_PNG_PNGMODULE_H_
diff --git a/core/fxcodec/tiff/DEPS b/core/fxcodec/tiff/DEPS
new file mode 100644
index 0000000..83b566a
--- /dev/null
+++ b/core/fxcodec/tiff/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+  '+third_party/libtiff/tiffiop.h',
+]
diff --git a/core/fxcodec/codec/tiffmodule.cpp b/core/fxcodec/tiff/tiffmodule.cpp
similarity index 99%
rename from core/fxcodec/codec/tiffmodule.cpp
rename to core/fxcodec/tiff/tiffmodule.cpp
index 08567f6..5633e95 100644
--- a/core/fxcodec/codec/tiffmodule.cpp
+++ b/core/fxcodec/tiff/tiffmodule.cpp
@@ -4,7 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "core/fxcodec/codec/tiffmodule.h"
+#include "core/fxcodec/tiff/tiffmodule.h"
 
 #include <limits>
 #include <memory>
diff --git a/core/fxcodec/codec/tiffmodule.h b/core/fxcodec/tiff/tiffmodule.h
similarity index 90%
rename from core/fxcodec/codec/tiffmodule.h
rename to core/fxcodec/tiff/tiffmodule.h
index cc957f2..8d5a89e 100644
--- a/core/fxcodec/codec/tiffmodule.h
+++ b/core/fxcodec/tiff/tiffmodule.h
@@ -4,8 +4,8 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef CORE_FXCODEC_CODEC_TIFFMODULE_H_
-#define CORE_FXCODEC_CODEC_TIFFMODULE_H_
+#ifndef CORE_FXCODEC_TIFF_TIFFMODULE_H_
+#define CORE_FXCODEC_TIFF_TIFFMODULE_H_
 
 #include <memory>
 
@@ -43,4 +43,4 @@
 
 using TiffModule = fxcodec::TiffModule;
 
-#endif  // CORE_FXCODEC_CODEC_TIFFMODULE_H_
+#endif  // CORE_FXCODEC_TIFF_TIFFMODULE_H_
diff --git a/third_party/libtiff/0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch b/third_party/libtiff/0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
index 9ef4749..4f1fdea 100644
--- a/third_party/libtiff/0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
+++ b/third_party/libtiff/0006-HeapBufferOverflow-ChopUpSingleUncompressedStrip.patch
@@ -1,7 +1,7 @@
-diff --git a/core/fxcodec/codec/tiffmodule.cpp b/core/fxcodec/codec/tiffmodule.cpp
+diff --git a/core/fxcodec/tiff/tiffmodule.cpp b/core/fxcodec/tiff/tiffmodule.cpp
 index 09cfea4..20fda63 100644
---- a/core/fxcodec/codec/tiffmodule.cpp
-+++ b/core/fxcodec/codec/tiffmodule.cpp
+--- a/core/fxcodec/tiff/tiffmodule.cpp
++++ b/core/fxcodec/tiff/tiffmodule.cpp
 @@ -79,6 +79,10 @@ int _TIFFmemcmp(const void* ptr1, const void* ptr2, tmsize_t size) {
    return memcmp(ptr1, ptr2, (size_t)size);
  }