De-bloat fxfa.h
Much of the contents relates to two callback interfaces, which are
not used anywhere near as widely as the other basic enum types in
the header.
Change-Id: I9afda45b997c4a75f8e3ca4a86f11ef0532ee237
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/81614
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h
index e777e27..d62389a 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h
@@ -20,6 +20,7 @@
#include "fpdfsdk/fpdfxfa/cpdfxfa_page.h"
#include "fxjs/gc/heap.h"
#include "v8/include/cppgc/persistent.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
#include "xfa/fxfa/cxfa_ffdoc.h"
class CFX_XMLDocument;
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
index 92e00a1..6612790 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
@@ -10,7 +10,7 @@
#include "core/fxcrt/retain_ptr.h"
#include "core/fxcrt/unowned_ptr.h"
#include "public/fpdfview.h"
-#include "xfa/fxfa/fxfa.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
class CFX_XMLDocument;
class CPDFXFA_Context;
diff --git a/xfa/fxfa/cxfa_eventparam.cpp b/xfa/fxfa/cxfa_eventparam.cpp
index ae5f392..d91cc52 100644
--- a/xfa/fxfa/cxfa_eventparam.cpp
+++ b/xfa/fxfa/cxfa_eventparam.cpp
@@ -6,9 +6,6 @@
#include "xfa/fxfa/cxfa_eventparam.h"
-#include "xfa/fxfa/fxfa.h"
-#include "xfa/fxfa/parser/cxfa_node.h"
-
CXFA_EventParam::CXFA_EventParam() = default;
CXFA_EventParam::CXFA_EventParam(const CXFA_EventParam& other) = default;
diff --git a/xfa/fxfa/cxfa_ffapp.h b/xfa/fxfa/cxfa_ffapp.h
index 0425bbf..f25d602 100644
--- a/xfa/fxfa/cxfa_ffapp.h
+++ b/xfa/fxfa/cxfa_ffapp.h
@@ -12,12 +12,118 @@
#include "v8/include/cppgc/garbage-collected.h"
#include "v8/include/cppgc/member.h"
#include "xfa/fwl/cfwl_app.h"
-#include "xfa/fxfa/fxfa.h"
class CFWL_WidgetMgr;
-class CXFA_FontMgr;
+class CXFA_FFDoc;
class CXFA_FWLAdapterWidgetMgr;
class CXFA_FWLTheme;
+class CXFA_FontMgr;
+class IFX_SeekableReadStream;
+
+// Probably should be CXFA_FFApp::CallbackIface.
+class IXFA_AppProvider {
+ public:
+ virtual ~IXFA_AppProvider() = default;
+
+ /**
+ * Returns the language of the running host application. Such as zh_CN
+ */
+ virtual WideString GetLanguage() = 0;
+
+ /**
+ * Returns the platform of the machine running the script. Such as WIN
+ */
+ virtual WideString GetPlatform() = 0;
+
+ /**
+ * Get application name, such as Phantom.
+ */
+ virtual WideString GetAppName() = 0;
+
+ /**
+ * Get application message box title.
+ */
+ virtual WideString GetAppTitle() const = 0;
+
+ /**
+ * Causes the system to play a sound.
+ * @param[in] dwType The system code for the appropriate sound.0 (Error)1
+ * (Warning)2 (Question)3 (Status)4 (Default)
+ */
+ virtual void Beep(uint32_t dwType) = 0;
+
+ /**
+ * Displays a message box.
+ * @param[in] wsMessage - Message string to display in box.
+ * @param[in] wsTitle - Title string for box.
+ * @param[in] dwIconType - Icon type, refer to XFA_MBICON.
+ * @param[in] dwButtonType - Button type, refer to XFA_MESSAGEBUTTON.
+ * @return A valid integer representing the value of the button pressed by the
+ * user, refer to XFA_ID.
+ */
+ virtual int32_t MsgBox(const WideString& wsMessage,
+ const WideString& wsTitle,
+ uint32_t dwIconType,
+ uint32_t dwButtonType) = 0;
+
+ /**
+ * Get a response from the user.
+ * @param[in] wsQuestion - Message string to display in box.
+ * @param[in] wsTitle - Title string for box.
+ * @param[in] wsDefaultAnswer - Initial contents for answer.
+ * @param[in] bMask - Mask the user input with asterisks when true,
+ * @return A string containing the user's response.
+ */
+ virtual WideString Response(const WideString& wsQuestion,
+ const WideString& wsTitle,
+ const WideString& wsDefaultAnswer,
+ bool bMask) = 0;
+
+ /**
+ * Download something from somewhere.
+ * @param[in] wsURL - http, ftp, such as
+ * "http://www.w3.org/TR/REC-xml-names/".
+ */
+ virtual RetainPtr<IFX_SeekableReadStream> DownloadURL(
+ const WideString& wsURL) = 0;
+
+ /**
+ * POST data to the given url.
+ * @param[in] wsURL the URL being uploaded.
+ * @param[in] wsData the data being uploaded.
+ * @param[in] wsContentType the content type of data including text/html,
+ * text/xml, text/plain, multipart/form-data,
+ * application/x-www-form-urlencoded,
+ * application/octet-stream, any valid MIME type.
+ * @param[in] wsEncode the encode of data including UTF-8, UTF-16,
+ * ISO8859-1, any recognized [IANA]character encoding
+ * @param[in] wsHeader any additional HTTP headers to be included in the
+ * post.
+ * @param[out] wsResponse decoded response from server.
+ * @return true Server permitted the post request, false otherwise.
+ */
+ virtual bool PostRequestURL(const WideString& wsURL,
+ const WideString& wsData,
+ const WideString& wsContentType,
+ const WideString& wsEncode,
+ const WideString& wsHeader,
+ WideString& wsResponse) = 0;
+
+ /**
+ * PUT data to the given url.
+ * @param[in] wsURL the URL being uploaded.
+ * @param[in] wsData the data being uploaded.
+ * @param[in] wsEncode the encode of data including UTF-8, UTF-16,
+ * ISO8859-1, any recognized [IANA]character encoding
+ * @return true Server permitted the post request, false otherwise.
+ */
+ virtual bool PutRequestURL(const WideString& wsURL,
+ const WideString& wsData,
+ const WideString& wsEncode) = 0;
+
+ virtual CFX_Timer::HandlerIface* GetTimerHandler() const = 0;
+ virtual cppgc::Heap* GetGCHeap() const = 0;
+};
class CXFA_FFApp : public cppgc::GarbageCollected<CXFA_FFApp>,
public CFWL_App::AdapterIface {
diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h
index f99d344..6e1b0ac 100644
--- a/xfa/fxfa/cxfa_ffdoc.h
+++ b/xfa/fxfa/cxfa_ffdoc.h
@@ -10,9 +10,11 @@
#include <map>
#include <memory>
+#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_stream.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxcrt/unowned_ptr.h"
+#include "core/fxge/dib/fx_dib.h"
#include "fxjs/gc/heap.h"
#include "v8/include/cppgc/garbage-collected.h"
#include "v8/include/cppgc/member.h"
@@ -27,13 +29,73 @@
class CFX_XMLDocument;
class CPDF_Document;
class CXFA_FFApp;
+class CXFA_FFDoc;
class CXFA_FFNotify;
class CXFA_FFDocView;
+class CXFA_FFPageView;
class CXFA_LayoutProcessor;
+class IJS_Runtime;
-namespace cppgc {
-class Heap;
-} // namespace cppgc
+// Probably should be called CFXA_FFDoc::CallbackIface.
+class IXFA_DocEnvironment {
+ public:
+ enum class PageViewEvent {
+ kPostAdded = 1,
+ kPostRemoved = 3,
+ kStopLayout = 4,
+ };
+
+ virtual ~IXFA_DocEnvironment() = default;
+
+ virtual void SetChangeMark(CXFA_FFDoc* hDoc) = 0;
+ virtual void InvalidateRect(CXFA_FFPageView* pPageView,
+ const CFX_RectF& rt) = 0;
+ // Show or hide caret.
+ virtual void DisplayCaret(CXFA_FFWidget* hWidget,
+ bool bVisible,
+ const CFX_RectF* pRtAnchor) = 0;
+
+ virtual bool GetPopupPos(CXFA_FFWidget* hWidget,
+ float fMinPopup,
+ float fMaxPopup,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF* pPopupRect) = 0;
+ virtual bool PopupMenu(CXFA_FFWidget* hWidget, const CFX_PointF& ptPopup) = 0;
+
+ virtual void OnPageViewEvent(CXFA_FFPageView* pPageView,
+ PageViewEvent eEvent) = 0;
+
+ virtual void WidgetPostAdd(CXFA_FFWidget* hWidget) = 0;
+ virtual void WidgetPreRemove(CXFA_FFWidget* hWidget) = 0;
+ virtual int32_t CountPages(const CXFA_FFDoc* hDoc) const = 0;
+ virtual int32_t GetCurrentPage(const CXFA_FFDoc* hDoc) const = 0;
+ virtual void SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) = 0;
+ virtual bool IsCalculationsEnabled(const CXFA_FFDoc* hDoc) const = 0;
+ virtual void SetCalculationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) = 0;
+ virtual WideString GetTitle(const CXFA_FFDoc* hDoc) const = 0;
+ virtual void SetTitle(CXFA_FFDoc* hDoc, const WideString& wsTitle) = 0;
+ virtual void ExportData(CXFA_FFDoc* hDoc,
+ const WideString& wsFilePath,
+ bool bXDP) = 0;
+ virtual void GotoURL(CXFA_FFDoc* hDoc, const WideString& bsURL) = 0;
+ virtual bool IsValidationsEnabled(const CXFA_FFDoc* hDoc) const = 0;
+ virtual void SetValidationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) = 0;
+ virtual void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) = 0;
+ virtual void Print(CXFA_FFDoc* hDoc,
+ int32_t nStartPage,
+ int32_t nEndPage,
+ XFA_PrintOptMask dwOptions) = 0;
+ virtual FX_ARGB GetHighlightColor(const CXFA_FFDoc* hDoc) const = 0;
+ virtual IJS_Runtime* GetIJSRuntime(const CXFA_FFDoc* hDoc) const = 0;
+ virtual CFX_XMLDocument* GetXMLDoc() const = 0;
+ virtual RetainPtr<IFX_SeekableReadStream> OpenLinkedFile(
+ CXFA_FFDoc* hDoc,
+ const WideString& wsLink) = 0;
+
+#ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED
+ virtual bool Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) = 0;
+#endif // PDF_XFA_ELEMENT_SUBMIT_ENABLED
+};
struct FX_IMAGEDIB_AND_DPI {
FX_IMAGEDIB_AND_DPI();
diff --git a/xfa/fxfa/cxfa_ffnotify.h b/xfa/fxfa/cxfa_ffnotify.h
index a189ea7..c307cd1 100644
--- a/xfa/fxfa/cxfa_ffnotify.h
+++ b/xfa/fxfa/cxfa_ffnotify.h
@@ -12,7 +12,8 @@
#include "v8/include/cppgc/member.h"
#include "v8/include/cppgc/visitor.h"
#include "xfa/fxfa/cxfa_eventparam.h"
-#include "xfa/fxfa/fxfa.h"
+#include "xfa/fxfa/cxfa_ffapp.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
#include "xfa/fxfa/parser/cxfa_document.h"
class CXFA_FFWidgetHandler;
diff --git a/xfa/fxfa/cxfa_ffpageview.h b/xfa/fxfa/cxfa_ffpageview.h
index 371819a..0a429fc 100644
--- a/xfa/fxfa/cxfa_ffpageview.h
+++ b/xfa/fxfa/cxfa_ffpageview.h
@@ -9,6 +9,7 @@
#include <vector>
+#include "core/fxcrt/fx_string.h"
#include "fxjs/gc/heap.h"
#include "v8/include/cppgc/garbage-collected.h"
#include "v8/include/cppgc/member.h"
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index 897dcba..7b2e23b5 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -33,6 +33,8 @@
class CXFA_FFPageView;
class CXFA_FFWidgetHandler;
class CXFA_Margin;
+class IFX_SeekableReadStream;
+class IXFA_AppProvider;
enum class FWL_WidgetHit;
inline float XFA_UnitPx2Pt(float fPx, float fDpi) {
diff --git a/xfa/fxfa/cxfa_ffwidgethandler.h b/xfa/fxfa/cxfa_ffwidgethandler.h
index f8d5a52..6a3a01f 100644
--- a/xfa/fxfa/cxfa_ffwidgethandler.h
+++ b/xfa/fxfa/cxfa_ffwidgethandler.h
@@ -7,6 +7,7 @@
#ifndef XFA_FXFA_CXFA_FFWIDGETHANDLER_H_
#define XFA_FXFA_CXFA_FFWIDGETHANDLER_H_
+#include "core/fxcrt/fx_coordinates.h"
#include "fxjs/gc/heap.h"
#include "v8/include/cppgc/garbage-collected.h"
#include "v8/include/cppgc/member.h"
diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h
index 59b36f5..a50342a 100644
--- a/xfa/fxfa/fxfa.h
+++ b/xfa/fxfa/fxfa.h
@@ -9,24 +9,7 @@
#include <type_traits>
-#include "core/fxcrt/cfx_timer.h"
-#include "core/fxcrt/fx_coordinates.h"
-#include "core/fxcrt/retain_ptr.h"
-#include "core/fxcrt/widestring.h"
-#include "core/fxge/dib/fx_dib.h"
-#include "xfa/fxfa/fxfa_basic.h"
-
-class CFX_XMLDocument;
-class CXFA_FFDoc;
-class CXFA_FFPageView;
class CXFA_FFWidget;
-class CXFA_Submit;
-class IFX_SeekableReadStream;
-class IJS_Runtime;
-
-namespace cppgc {
-class Heap;
-} // namespace cppgc
// Note, values must match fpdf_formfill.h JSPLATFORM_ALERT_BUTTON_* flags.
enum class AlertButton {
@@ -94,172 +77,6 @@
};
using XFA_WidgetStatusMask = std::underlying_type<XFA_WidgetStatus>::type;
-// Probably should be CXFA_FFApp::CallbackIface in cxfa_ffapp.h
-class IXFA_AppProvider {
- public:
- virtual ~IXFA_AppProvider() = default;
-
- /**
- * Returns the language of the running host application. Such as zh_CN
- */
- virtual WideString GetLanguage() = 0;
-
- /**
- * Returns the platform of the machine running the script. Such as WIN
- */
- virtual WideString GetPlatform() = 0;
-
- /**
- * Get application name, such as Phantom.
- */
- virtual WideString GetAppName() = 0;
-
- /**
- * Get application message box title.
- */
- virtual WideString GetAppTitle() const = 0;
-
- /**
- * Causes the system to play a sound.
- * @param[in] dwType The system code for the appropriate sound.0 (Error)1
- * (Warning)2 (Question)3 (Status)4 (Default)
- */
- virtual void Beep(uint32_t dwType) = 0;
-
- /**
- * Displays a message box.
- * @param[in] wsMessage - Message string to display in box.
- * @param[in] wsTitle - Title string for box.
- * @param[in] dwIconType - Icon type, refer to XFA_MBICON.
- * @param[in] dwButtonType - Button type, refer to XFA_MESSAGEBUTTON.
- * @return A valid integer representing the value of the button pressed by the
- * user, refer to XFA_ID.
- */
- virtual int32_t MsgBox(const WideString& wsMessage,
- const WideString& wsTitle,
- uint32_t dwIconType,
- uint32_t dwButtonType) = 0;
-
- /**
- * Get a response from the user.
- * @param[in] wsQuestion - Message string to display in box.
- * @param[in] wsTitle - Title string for box.
- * @param[in] wsDefaultAnswer - Initial contents for answer.
- * @param[in] bMask - Mask the user input with asterisks when true,
- * @return A string containing the user's response.
- */
- virtual WideString Response(const WideString& wsQuestion,
- const WideString& wsTitle,
- const WideString& wsDefaultAnswer,
- bool bMask) = 0;
-
- /**
- * Download something from somewhere.
- * @param[in] wsURL - http, ftp, such as
- * "http://www.w3.org/TR/REC-xml-names/".
- */
- virtual RetainPtr<IFX_SeekableReadStream> DownloadURL(
- const WideString& wsURL) = 0;
-
- /**
- * POST data to the given url.
- * @param[in] wsURL the URL being uploaded.
- * @param[in] wsData the data being uploaded.
- * @param[in] wsContentType the content type of data including text/html,
- * text/xml, text/plain, multipart/form-data,
- * application/x-www-form-urlencoded,
- * application/octet-stream, any valid MIME type.
- * @param[in] wsEncode the encode of data including UTF-8, UTF-16,
- * ISO8859-1, any recognized [IANA]character encoding
- * @param[in] wsHeader any additional HTTP headers to be included in the
- * post.
- * @param[out] wsResponse decoded response from server.
- * @return true Server permitted the post request, false otherwise.
- */
- virtual bool PostRequestURL(const WideString& wsURL,
- const WideString& wsData,
- const WideString& wsContentType,
- const WideString& wsEncode,
- const WideString& wsHeader,
- WideString& wsResponse) = 0;
-
- /**
- * PUT data to the given url.
- * @param[in] wsURL the URL being uploaded.
- * @param[in] wsData the data being uploaded.
- * @param[in] wsEncode the encode of data including UTF-8, UTF-16,
- * ISO8859-1, any recognized [IANA]character encoding
- * @return true Server permitted the post request, false otherwise.
- */
- virtual bool PutRequestURL(const WideString& wsURL,
- const WideString& wsData,
- const WideString& wsEncode) = 0;
-
- virtual CFX_Timer::HandlerIface* GetTimerHandler() const = 0;
- virtual cppgc::Heap* GetGCHeap() const = 0;
-};
-
-// Probably should be called CFXA_FFDoc::CallbackIface in cxfa_ffdoc.h
-class IXFA_DocEnvironment {
- public:
- enum class PageViewEvent {
- kPostAdded = 1,
- kPostRemoved = 3,
- kStopLayout = 4,
- };
-
- virtual ~IXFA_DocEnvironment() = default;
-
- virtual void SetChangeMark(CXFA_FFDoc* hDoc) = 0;
- virtual void InvalidateRect(CXFA_FFPageView* pPageView,
- const CFX_RectF& rt) = 0;
- // Show or hide caret.
- virtual void DisplayCaret(CXFA_FFWidget* hWidget,
- bool bVisible,
- const CFX_RectF* pRtAnchor) = 0;
-
- virtual bool GetPopupPos(CXFA_FFWidget* hWidget,
- float fMinPopup,
- float fMaxPopup,
- const CFX_RectF& rtAnchor,
- CFX_RectF* pPopupRect) = 0;
- virtual bool PopupMenu(CXFA_FFWidget* hWidget, const CFX_PointF& ptPopup) = 0;
-
- virtual void OnPageViewEvent(CXFA_FFPageView* pPageView,
- PageViewEvent eEvent) = 0;
-
- virtual void WidgetPostAdd(CXFA_FFWidget* hWidget) = 0;
- virtual void WidgetPreRemove(CXFA_FFWidget* hWidget) = 0;
- virtual int32_t CountPages(const CXFA_FFDoc* hDoc) const = 0;
- virtual int32_t GetCurrentPage(const CXFA_FFDoc* hDoc) const = 0;
- virtual void SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) = 0;
- virtual bool IsCalculationsEnabled(const CXFA_FFDoc* hDoc) const = 0;
- virtual void SetCalculationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) = 0;
- virtual WideString GetTitle(const CXFA_FFDoc* hDoc) const = 0;
- virtual void SetTitle(CXFA_FFDoc* hDoc, const WideString& wsTitle) = 0;
- virtual void ExportData(CXFA_FFDoc* hDoc,
- const WideString& wsFilePath,
- bool bXDP) = 0;
- virtual void GotoURL(CXFA_FFDoc* hDoc, const WideString& bsURL) = 0;
- virtual bool IsValidationsEnabled(const CXFA_FFDoc* hDoc) const = 0;
- virtual void SetValidationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) = 0;
- virtual void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) = 0;
- virtual void Print(CXFA_FFDoc* hDoc,
- int32_t nStartPage,
- int32_t nEndPage,
- XFA_PrintOptMask dwOptions) = 0;
- virtual FX_ARGB GetHighlightColor(const CXFA_FFDoc* hDoc) const = 0;
- virtual IJS_Runtime* GetIJSRuntime(const CXFA_FFDoc* hDoc) const = 0;
- virtual CFX_XMLDocument* GetXMLDoc() const = 0;
- virtual RetainPtr<IFX_SeekableReadStream> OpenLinkedFile(
- CXFA_FFDoc* hDoc,
- const WideString& wsLink) = 0;
-
-#ifdef PDF_XFA_ELEMENT_SUBMIT_ENABLED
- virtual bool Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) = 0;
-#endif // PDF_XFA_ELEMENT_SUBMIT_ENABLED
-};
-
class IXFA_WidgetIterator {
public:
virtual ~IXFA_WidgetIterator() = default;
diff --git a/xfa/fxfa/parser/cxfa_document.h b/xfa/fxfa/parser/cxfa_document.h
index 3631566..b06dd7b 100644
--- a/xfa/fxfa/parser/cxfa_document.h
+++ b/xfa/fxfa/parser/cxfa_document.h
@@ -21,6 +21,7 @@
#include "v8/include/cppgc/persistent.h"
#include "v8/include/cppgc/visitor.h"
#include "xfa/fxfa/fxfa.h"
+#include "xfa/fxfa/fxfa_basic.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
#include "xfa/fxfa/parser/cxfa_nodeowner.h"
diff --git a/xfa/fxfa/parser/cxfa_document_builder.cpp b/xfa/fxfa/parser/cxfa_document_builder.cpp
index b69bb52..9933e7c 100644
--- a/xfa/fxfa/parser/cxfa_document_builder.cpp
+++ b/xfa/fxfa/parser/cxfa_document_builder.cpp
@@ -24,7 +24,6 @@
#include "third_party/base/check.h"
#include "third_party/base/notreached.h"
#include "third_party/base/optional.h"
-#include "xfa/fxfa/fxfa.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_subform.h"