Allow building non-XFA (master) on the XFA branch.

This first pass is GYP-only, will do GN in the next CL.

R=ochang@chromium.org

Review URL: https://codereview.chromium.org/1480403002 .
diff --git a/public/fpdf_formfill.h b/public/fpdf_formfill.h
index 297bd4a..b3bbb92 100644
--- a/public/fpdf_formfill.h
+++ b/public/fpdf_formfill.h
@@ -11,9 +11,11 @@
 
 typedef void* FPDF_FORMHANDLE;
 
+#ifdef PDF_ENABLE_XFA
 #define DOCTYPE_PDF 0          // Normal pdf Document
 #define DOCTYPE_DYNAMIC_XFA 1  // Dynamic xfa Document Type
 #define DOCTYPE_STATIC_XFA 2   // Static xfa Document Type
+#endif  // PDF_ENABLE_XFA
 
 // Exported Functions
 #ifdef __cplusplus
@@ -50,7 +52,6 @@
   *                           2-Question;
   *                           3-Status.
   *                           4-Asterisk
-
   * Return Value:
   *           The return value could be the folowing type:
   *                           1-OK;
@@ -339,6 +340,7 @@
   unsigned short wMilliseconds; /* milliseconds after the second - [0,999] */
 } FPDF_SYSTEMTIME;
 
+#ifdef PDF_ENABLE_XFA
 // XFA
 /**
  * @name Pageview  event flags
@@ -371,29 +373,31 @@
 #define FXFA_SAVEAS_XML 1
 #define FXFA_SAVEAS_XDP 2
 /*@}*/
+#endif  // PDF_ENABLE_XFA
 
 typedef struct _FPDF_FORMFILLINFO {
   /**
-   * Version number of the interface. Currently must be 2 (with XFA module).
+   * Version number of the interface. Currently must be 1 (when PDFium is built
+   *  without the XFA module) or must be 2 (when built with the XFA module).
    **/
   int version;
 
+  /* Version 1. */
   /**
-*Method: Release
-*         Give implementation a chance to release any data after the interface
-* is no longer used
-*Interface Version:
-*         1
-*Implementation Required:
-*         No
-*Comments:
-*         Called by Foxit SDK during the final cleanup process.
-*Parameters:
-*         pThis       -   Pointer to the interface structure itself
-*Return Value:
-*         None
-*/
-
+   *Method: Release
+   *         Give implementation a chance to release any data after the
+   *         interface is no longer used
+   *Interface Version:
+   *         1
+   *Implementation Required:
+   *         No
+   *Comments:
+   *         Called by Foxit SDK during the final cleanup process.
+   *Parameters:
+   *         pThis       -   Pointer to the interface structure itself
+   *Return Value:
+   *         None
+   */
   void (*Release)(struct _FPDF_FORMFILLINFO* pThis);
 
   /**
@@ -699,6 +703,8 @@
   **/
   IPDF_JSPLATFORM* m_pJsPlatform;
 
+#ifdef PDF_ENABLE_XFA
+  /* Version 2. */
   /**
     * Method: FFI_DisplayCaret
     *           This method will show the caret at specified position.
@@ -728,6 +734,7 @@
                            double top,
                            double right,
                            double bottom);
+
   /**
   * Method: FFI_GetCurrentPageIndex
   *           This method will get the current page index.
@@ -744,6 +751,7 @@
   **/
   int (*FFI_GetCurrentPageIndex)(struct _FPDF_FORMFILLINFO* pThis,
                                  FPDF_DOCUMENT document);
+
   /**
   * Method: FFI_SetCurrentPage
   *           This method will set the current page.
@@ -762,6 +770,7 @@
   void (*FFI_SetCurrentPage)(struct _FPDF_FORMFILLINFO* pThis,
                              FPDF_DOCUMENT document,
                              int iCurPage);
+
   /**
   * Method: FFI_GotoURL
   *           This method will link to the specified URL.
@@ -780,6 +789,7 @@
   void (*FFI_GotoURL)(struct _FPDF_FORMFILLINFO* pThis,
                       FPDF_DOCUMENT document,
                       FPDF_WIDESTRING wsURL);
+
   /**
   * Method: FFI_GetPageViewRect
   *           This method will get the current page view rectangle.
@@ -830,6 +840,7 @@
   *       TRUE indicates success; otherwise false.
   **/
   FPDF_BOOL (*FFI_PopupMenu)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, FPDF_WIDGET hWidget, int menuFlag, float x, float y);
+
   /**
   * Method: FFI_OpenFile
   *           This method will open the specified file with the specified mode.
@@ -851,6 +862,7 @@
                                     int fileFlag,
                                     FPDF_WIDESTRING wsURL,
                                     const char* mode);
+
   /**
   * Method: FFI_EmailTo
   *           This method will email the specified file stream to the specified
@@ -881,6 +893,7 @@
                       FPDF_WIDESTRING pCC,
                       FPDF_WIDESTRING pBcc,
                       FPDF_WIDESTRING pMsg);
+
   /**
   * Method: FFI_UploadTo
   *           This method will get upload the specified file stream to the
@@ -922,6 +935,7 @@
   int (*FFI_GetPlatform)(struct _FPDF_FORMFILLINFO* pThis,
                          void* platform,
                          int length);
+
   /**
   * Method: FFI_GetLanguage
   *           This method will get the current language.
@@ -941,6 +955,7 @@
   int (*FFI_GetLanguage)(struct _FPDF_FORMFILLINFO* pThis,
                          void* language,
                          int length);
+
   /**
   * Method: FFI_DownloadFromURL
   *           This method will download the specified file from the URL.
@@ -978,6 +993,7 @@
   *       TRUE indicates success, otherwise FALSE.
   **/
   FPDF_BOOL   (*FFI_PostRequestURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING wsURL, FPDF_WIDESTRING wsData, FPDF_WIDESTRING wsContentType, FPDF_WIDESTRING wsEncode, FPDF_WIDESTRING wsHeader, FPDF_BSTR* respone);
+
   /**
   * Method: FFI_PutRequestURL
   *           This method will put the request to the server URL.
@@ -995,6 +1011,7 @@
   *       TRUE indicates success, otherwise FALSE.
   **/
   FPDF_BOOL   (*FFI_PutRequestURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING wsURL, FPDF_WIDESTRING wsData, FPDF_WIDESTRING wsEncode);
+#endif  // PDF_ENABLE_XFA
 
 } FPDF_FORMFILLINFO;
 
@@ -1212,6 +1229,7 @@
                                              double page_x,
                                              double page_y);
 
+#ifdef PDF_ENABLE_XFA
 DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle,
                                                FPDF_PAGE page,
                                                int modifier,
@@ -1222,6 +1240,7 @@
                                              int modifier,
                                              double page_x,
                                              double page_y);
+#endif  // PDF_ENABLE_XFA
 
 /**
  * Function: FORM_OnKeyDown
@@ -1303,7 +1322,9 @@
 #define FPDF_FORMFIELD_COMBOBOX 4     // combo box type.
 #define FPDF_FORMFIELD_LISTBOX 5      // list box type.
 #define FPDF_FORMFIELD_TEXTFIELD 6    // text field type.
+#ifdef PDF_ENABLE_XFA
 #define FPDF_FORMFIELD_XFA 7          // text field type.
+#endif  // PDF_ENABLE_XFA
 
 /**
  * Function: FPDFPage_HasFormFieldAtPoint
@@ -1451,6 +1472,8 @@
                                     int size_y,
                                     int rotate,
                                     int flags);
+
+#ifdef PDF_ENABLE_XFA
 /**
  * Function: FPDF_HasXFAField
  *                      This method is designed to check whether a pdf document
@@ -1663,6 +1686,7 @@
 FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringHandle,
                            FPDF_BYTESTRING bsText,
                            FPDF_DWORD size);
+#endif  // PDF_ENABLE_XFA
 
 #ifdef __cplusplus
 }
diff --git a/public/fpdfview.h b/public/fpdfview.h
index d5c5a32..8731292 100644
--- a/public/fpdfview.h
+++ b/public/fpdfview.h
@@ -14,42 +14,49 @@
 #include <windows.h>
 #endif
 
+#ifdef PDF_ENABLE_XFA
 //  TODO: remove the #define when XFA is officially in pdfium
 #define PDF_USE_XFA
-
-// Data types
-typedef void* FPDF_MODULEMGR;
+#endif  // PDF_ENABLE_XFA
 
 // PDF types
-typedef void* FPDF_DOCUMENT;
-typedef void* FPDF_PAGE;
-typedef void* FPDF_WIDGET;
-typedef void* FPDF_STRINGHANDLE;
-typedef void* FPDF_PAGEOBJECT;  // Page object(text, path, etc)
-typedef void* FPDF_PATH;
-typedef void* FPDF_CLIPPATH;
-typedef void* FPDF_BITMAP;
-typedef void* FPDF_FONT;
-typedef void* FPDF_TEXTPAGE;
-typedef void* FPDF_SCHHANDLE;
-typedef void* FPDF_PAGELINK;
-typedef void* FPDF_HMODULE;
-typedef void* FPDF_DOCSCHHANDLE;
-typedef void* FPDF_BOOKMARK;
-typedef void* FPDF_DEST;
 typedef void* FPDF_ACTION;
+typedef void* FPDF_BITMAP;
+typedef void* FPDF_BOOKMARK;
+typedef void* FPDF_CLIPPATH;
+typedef void* FPDF_DEST;
+typedef void* FPDF_DOCSCHHANDLE;
+typedef void* FPDF_DOCUMENT;
+typedef void* FPDF_FONT;
+typedef void* FPDF_HMODULE;
 typedef void* FPDF_LINK;
+typedef void* FPDF_MODULEMGR;
+typedef void* FPDF_PAGE;
+typedef void* FPDF_PAGELINK;
+typedef void* FPDF_PAGEOBJECT;  // Page object(text, path, etc)
 typedef void* FPDF_PAGERANGE;
+typedef void* FPDF_PATH;
+typedef void* FPDF_SCHHANDLE;
+typedef void* FPDF_TEXTPAGE;
+
+#ifdef PDF_ENABLE_XFA
+typedef void* FPDF_STRINGHANDLE;
+typedef void* FPDF_WIDGET;
+#endif  // PDF_ENABLE_XFA
 
 // Basic data types
-typedef void* FPDF_LPVOID;
-typedef void const* FPDF_LPCVOID;
-typedef int FPDF_RESULT;
 typedef int FPDF_BOOL;
 typedef int FPDF_ERROR;
 typedef unsigned long FPDF_DWORD;
 typedef float FS_FLOAT;
 
+#ifdef PDF_ENABLE_XFA
+typedef void* FPDF_LPVOID;
+typedef void const* FPDF_LPCVOID;
+typedef char const* FPDF_LPCSTR;
+typedef int FPDF_RESULT;
+#endif
+
 // Duplex types
 typedef enum _FPDF_DUPLEXTYPE_ {
   DuplexUndefined = 0,
@@ -61,7 +68,6 @@
 // String types
 typedef unsigned short FPDF_WCHAR;
 typedef unsigned char const* FPDF_LPCBYTE;
-typedef char const* FPDF_LPCSTR;
 
 // FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE
 // encoded), and platform dependent string
@@ -71,8 +77,7 @@
 // bytes (except surrogation), with the low byte first.
 typedef const unsigned short* FPDF_WIDESTRING;
 
-#ifndef _FPDF_DEF_STR_
-#define _FPDF_DEF_STR_
+#ifdef PDF_ENABLE_XFA
 // Structure for a byte string.
 // Note, a byte string commonly means a UTF-16LE formated string.
 typedef struct _FPDF_BSTR {
@@ -81,8 +86,7 @@
   // Length of the string, in bytes.
   int len;
 } FPDF_BSTR;
-
-#endif
+#endif  // PDF_ENABLE_XFA
 
 // For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a
 // Windows unicode string, however, special care needs to be taken if you
@@ -91,7 +95,6 @@
 // For Linux/Unix programmers: most compiler/library environments use 4 bytes
 // for a Unicode character, and you have to convert between FPDF_WIDESTRING and
 // system wide string by yourself.
-
 #ifdef _WIN32_WCE
 typedef const unsigned short* FPDF_STRING;
 #else
@@ -222,9 +225,6 @@
 //          Loaded document can be closed by FPDF_CloseDocument().
 //          If this function fails, you can use FPDF_GetLastError() to retrieve
 //          the reason why it failed.
-// Notes:
-//          The application should call FPDF_LoadXFA function after PDF
-//          document loaded to support XFA fields in fpdfformfill.h file.
 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
                                                   FPDF_BYTESTRING password);
 
@@ -243,8 +243,9 @@
 //          If this function fails, you can use FPDF_GetLastError() to retrieve
 //          the reason why it failed.
 // Notes:
-//          The application should call FPDF_LoadXFA function after the
-//          document is loaded to support form fields.
+//          If PDFium is built with the XFA module, the application should call
+//          FPDF_LoadXFA() function after the PDF document loaded to support XFA
+//          fields defined in the fpdfformfill.h file.
 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
                                                      int size,
                                                      FPDF_BYTESTRING password);
@@ -270,6 +271,7 @@
   void* m_Param;
 } FPDF_FILEACCESS;
 
+#ifdef PDF_ENABLE_XFA
 /**
  * @brief Structure for file reading or writing (I/O).
  *
@@ -349,6 +351,7 @@
 
 } FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
 
+#endif
 // Function: FPDF_LoadCustomDocument
 //          Load PDF document from a custom access descriptor.
 // Parameters:
@@ -362,8 +365,9 @@
 //
 //          The loaded document can be closed with FPDF_CloseDocument.
 // Notes:
-//          The application should call the FPDF_LoadXFA function after the
-//          document is loaded to support form fields.
+//          If PDFium is built with the XFA module, the application should call
+//          FPDF_LoadXFA() function after the PDF document loaded to support XFA
+//          fields defined in the fpdfformfill.h file.
 DLLEXPORT FPDF_DOCUMENT STDCALL
 FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
 
@@ -388,8 +392,10 @@
 #define FPDF_ERR_PASSWORD 4   // Password required or incorrect password.
 #define FPDF_ERR_SECURITY 5   // Unsupported security scheme.
 #define FPDF_ERR_PAGE 6       // Page not found or content error.
+#ifdef PDF_ENABLE_XFA
 #define FPDF_ERR_XFALOAD 7    // Load XFA error.
 #define FPDF_ERR_XFALAYOUT 8  // Layout XFA error.
+#endif  // PDF_ENABLE_XFA
 
 // Function: FPDF_GetLastError
 //          Get last error code when a function fails.
@@ -912,6 +918,7 @@
                                               void* buffer,
                                               long* buflen);
 
+#ifdef PDF_ENABLE_XFA
 // Function: FPDF_BStr_Init
 //          Helper function to initialize a byte string.
 DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str);
@@ -925,6 +932,7 @@
 // Function: FPDF_BStr_Clear
 //          Helper function to clear a byte string.
 DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str);
+#endif  // PDF_ENABLE_XFA
 
 #ifdef __cplusplus
 }