Move default value of pdf_enable_xfa to standalone.gypi

This allows standalone pdfium builds to build with XFA, but
makes a chromium checkout revert to non-xfa even on this
branch. GN implies a chromium checkout at the moment, so
disable XFA there, too.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1508003003 .
diff --git a/BUILD.gn b/BUILD.gn
index 2aef63a..d3006ae 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -123,7 +123,6 @@
     ":fpdfapi",
     ":fpdfdoc",
     ":fpdftext",
-    ":fpdfxfa",
     ":fxcodec",
     ":fxcrt",
     ":fxedit",
@@ -133,7 +132,9 @@
   ]
 
   if (pdf_enable_xfa) {
-    deps += [ ":xfa" ]
+    deps += [
+      ":fpdfxfa",
+    ]
   }
 
   if (is_win) {
@@ -367,8 +368,6 @@
   deps = [
     "third_party:fx_lcms2",
     "third_party:fx_libopenjpeg",
-    "third_party:fx_lpng",
-    "third_party:fx_tiff",
     "third_party:fx_zlib",
 
     # This is a generic JPEG library dependency.
@@ -380,18 +379,12 @@
     "core/include/fxcodec/fx_codec_flate.h",
     "core/src/fxcodec/codec/codec_int.h",
     "core/src/fxcodec/codec/fx_codec.cpp",
-    "core/src/fxcodec/codec/fx_codec_bmp.cpp",
     "core/src/fxcodec/codec/fx_codec_fax.cpp",
     "core/src/fxcodec/codec/fx_codec_flate.cpp",
-    "core/src/fxcodec/codec/fx_codec_gif.cpp",
     "core/src/fxcodec/codec/fx_codec_icc.cpp",
     "core/src/fxcodec/codec/fx_codec_jbig.cpp",
     "core/src/fxcodec/codec/fx_codec_jpeg.cpp",
     "core/src/fxcodec/codec/fx_codec_jpx_opj.cpp",
-    "core/src/fxcodec/codec/fx_codec_png.cpp",
-    "core/src/fxcodec/codec/fx_codec_progress.cpp",
-    "core/src/fxcodec/codec/fx_codec_progress.h",
-    "core/src/fxcodec/codec/fx_codec_tiff.cpp",
     "core/src/fxcodec/jbig2/JBig2_ArithDecoder.cpp",
     "core/src/fxcodec/jbig2/JBig2_ArithDecoder.h",
     "core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp",
@@ -430,13 +423,26 @@
     "core/src/fxcodec/jbig2/JBig2_SymbolDict.h",
     "core/src/fxcodec/jbig2/JBig2_TrdProc.cpp",
     "core/src/fxcodec/jbig2/JBig2_TrdProc.h",
-    "core/src/fxcodec/lbmp/fx_bmp.cpp",
-    "core/src/fxcodec/lbmp/fx_bmp.h",
-    "core/src/fxcodec/lgif/fx_gif.cpp",
-    "core/src/fxcodec/lgif/fx_gif.h",
   ]
   include_dirs = []
-
+  if (pdf_enable_xfa) {
+    sources += [
+      "core/src/fxcodec/codec/fx_codec_bmp.cpp",
+      "core/src/fxcodec/codec/fx_codec_gif.cpp",
+      "core/src/fxcodec/codec/fx_codec_png.cpp",
+      "core/src/fxcodec/codec/fx_codec_progress.cpp",
+      "core/src/fxcodec/codec/fx_codec_progress.h",
+      "core/src/fxcodec/codec/fx_codec_tiff.cpp",
+      "core/src/fxcodec/lbmp/fx_bmp.cpp",
+      "core/src/fxcodec/lbmp/fx_bmp.h",
+      "core/src/fxcodec/lgif/fx_gif.cpp",
+      "core/src/fxcodec/lgif/fx_gif.h",
+    ]
+    deps += [
+      "third_party:fx_lpng",
+      "third_party:fx_tiff",
+    ]
+  }
   if (is_posix) {
     # core/src/fxcodec/fx_libopenjpeg/src/fx_mct.c does an pointer-to-int
     # conversion to check that an address is 16-bit aligned (benign).
@@ -456,7 +462,6 @@
 
 static_library("fxcrt") {
   sources = [
-    "core/include/fxcrt/fx_arb.h",
     "core/include/fxcrt/fx_basic.h",
     "core/include/fxcrt/fx_bidi.h",
     "core/include/fxcrt/fx_coordinates.h",
@@ -469,8 +474,6 @@
     "core/include/fxcrt/fx_ucd.h",
     "core/include/fxcrt/fx_xml.h",
     "core/src/fxcrt/extension.h",
-    "core/src/fxcrt/fx_arabic.cpp",
-    "core/src/fxcrt/fx_arabic.h",
     "core/src/fxcrt/fx_basic_array.cpp",
     "core/src/fxcrt/fx_basic_bstring.cpp",
     "core/src/fxcrt/fx_basic_buffer.cpp",
@@ -498,6 +501,13 @@
     "core/src/fxcrt/plex.h",
     "core/src/fxcrt/xml_int.h",
   ]
+  if (pdf_enable_xfa) {
+    sources += [
+      "core/include/fxcrt/fx_arb.h",
+      "core/src/fxcrt/fx_arabic.cpp",
+      "core/src/fxcrt/fx_arabic.h",
+    ]
+  }
   configs += [ ":pdfium_config" ]
 }
 
@@ -1427,7 +1437,7 @@
       "xfa/src/fxjse/src/value.cpp",
       "xfa/src/fxjse/src/value.h"
     ]
-    include_dirs = [
+    include_dirs += [
       "//v8",
       "//v8/include",
     ]
@@ -1460,8 +1470,6 @@
     "core/src/fxcrt/fx_extension_unittest.cpp",
     "core/src/fxcrt/fx_system_unittest.cpp",
     "third_party/base/nonstd_unique_ptr_unittest.cpp",
-    "xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp",
-    "xfa/src/fxfa/src/parser/xfa_utils_imp_unittest.cpp",
   ]
   deps = [
     "//testing/gtest",
@@ -1469,6 +1477,12 @@
     ":pdfium",
     ":test_support",
   ]
+  if (pdf_enable_xfa) {
+    sources += [
+      "xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp",
+      "xfa/src/fxfa/src/parser/xfa_utils_imp_unittest.cpp",
+    ]
+  }
   configs += [ ":pdfium_config" ]
 }
 
diff --git a/build/standalone.gypi b/build/standalone.gypi
index 402c726..2eac198 100644
--- a/build/standalone.gypi
+++ b/build/standalone.gypi
@@ -13,6 +13,7 @@
     'use_goma%': 0,
     'gomadir%': '',
     'msvs_multi_core_compile%': '1',
+    'pdf_enable_xfa%': 1,
     'variables': {
       'variables': {
         'variables': {
diff --git a/pdfium.gni b/pdfium.gni
index 7f08c71..ec71db9 100644
--- a/pdfium.gni
+++ b/pdfium.gni
@@ -13,7 +13,7 @@
   pdf_enable_v8 = true
 
   # Build PDFium either with or without XFA Forms support.
-  pdf_enable_xfa = true
+  pdf_enable_xfa = false
 
   # Build PDFium against skia (experimental) rather than agg.
   pdf_use_skia = false
diff --git a/pdfium.gyp b/pdfium.gyp
index aa18478..82a170d 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -8,7 +8,7 @@
     #'chromium_code': 1,
     'pdf_use_skia%': 0,
     'pdf_enable_v8%': 1,
-    'pdf_enable_xfa%': 1,
+    'pdf_enable_xfa%': 0, # Set to 1 by standalone.gypi in a standalone build.
     'conditions': [
       ['OS=="linux"', {
         'bundle_freetype%': 0,
diff --git a/samples/BUILD.gn b/samples/BUILD.gn
index 6a9a516..e1192c4 100644
--- a/samples/BUILD.gn
+++ b/samples/BUILD.gn
@@ -31,8 +31,9 @@
 executable("pdfium_test") {
   testonly = true
   sources = [
-    "image_diff_png.cc",
     "pdfium_test.cc",
+    "image_diff_png.cc",
+    "image_diff_png.h",
   ]
   deps = [
     "//build/config/sanitizers:deps",
@@ -44,6 +45,9 @@
     # of results across platforms.
     "//third_party/pdfium/third_party:fx_freetype",
   ]
+  if (!pdf_enable_xfa) {
+    deps += [ "../third_party:fx_lpng" ]
+  }
   if (pdf_enable_v8) {
     deps += [ "//v8:v8_libplatform" ]
     include_dirs = [
@@ -65,6 +69,9 @@
     "//build/config/sanitizers:deps",
     "//third_party/pdfium",
   ]
+  if (!pdf_enable_xfa) {
+    deps += [ "../third_party:fx_lpng" ]
+  }
   configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [
     ":pdfium_samples_config",
diff --git a/samples/samples.gyp b/samples/samples.gyp
index 31fcbf7..da9ce74 100644
--- a/samples/samples.gyp
+++ b/samples/samples.gyp
@@ -5,7 +5,7 @@
 {
   'variables': {
     'pdf_enable_v8%': 1,
-    'pdf_enable_xfa%': 1,
+    'pdf_enable_xfa%': 0,  # Set to 1 in standalone builds by standalone.gypi.
   },
   'target_defaults': {
     'defines' : [