Remove circular include from fxjs to fpdfsdk/fpdfxfa.
Routes the call through some other circular include as it turns out,
but a step in the right direction.
Change-Id: Ia9beb655fb598b1f180208fb54a8f30810332ac8
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/55779
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index de3587e..46cfc51 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -707,6 +707,7 @@
}
return !m_pFocusAnnot;
}
+
#ifdef PDF_ENABLE_XFA
CPDFXFA_Context* CPDFSDK_FormFillEnvironment::GetXFAContext() const {
if (!m_pCPDFDoc)
@@ -717,6 +718,10 @@
int CPDFSDK_FormFillEnvironment::GetPageViewCount() const {
return pdfium::CollectionSize<int>(m_PageMap);
}
+
+bool CPDFSDK_FormFillEnvironment::ContainsXFAForm() const {
+ return GetXFAContext()->ContainsXFAForm();
+}
#endif // PDF_ENABLE_XFA
int CPDFSDK_FormFillEnvironment::GetPageCount() const {
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h
index fbbe74e..68e4054 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.h
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.h
@@ -112,6 +112,7 @@
#ifdef PDF_ENABLE_XFA
CPDFXFA_Context* GetXFAContext() const;
int GetPageViewCount() const;
+ bool ContainsXFAForm() const;
void DisplayCaret(CPDFXFA_Page* page,
FPDF_BOOL bVisible,
diff --git a/fpdfsdk/fpdfxfa/BUILD.gn b/fpdfsdk/fpdfxfa/BUILD.gn
index 662cbc8..231ac96 100644
--- a/fpdfsdk/fpdfxfa/BUILD.gn
+++ b/fpdfsdk/fpdfxfa/BUILD.gn
@@ -30,7 +30,6 @@
"../../xfa/fxfa",
"../../xfa/fxfa/parser",
]
- allow_circular_includes_from = [ "../../fxjs" ]
configs += [ "../../:pdfium_core_config" ]
visibility = [ "../../*" ]
}
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp
index bcd77e0..6459a00 100644
--- a/fxjs/cjs_app.cpp
+++ b/fxjs/cjs_app.cpp
@@ -17,10 +17,6 @@
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
-#ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
-#endif // PDF_ENABLE_XFA
-
#define JS_STR_VIEWERTYPE L"pdfium"
#define JS_STR_VIEWERVARIATION L"Full"
#define JS_STR_PLATFORM L"WIN"
@@ -151,8 +147,7 @@
CJS_Result CJS_App::get_viewer_version(CJS_Runtime* pRuntime) {
#ifdef PDF_ENABLE_XFA
- CPDFXFA_Context* pXFAContext = pRuntime->GetFormFillEnv()->GetXFAContext();
- if (pXFAContext->ContainsXFAForm())
+ if (pRuntime->GetFormFillEnv()->ContainsXFAForm())
return CJS_Result::Success(pRuntime->NewNumber(JS_NUM_VIEWERVERSION_XFA));
#endif // PDF_ENABLE_XFA
return CJS_Result::Success(pRuntime->NewNumber(JS_NUM_VIEWERVERSION));