Remove dependence between fpdfdk/formfiller and fpdfapi/parser.
There's a better way to get the same information through another object
that the formfiller already holds.
-- Make method private while we're at it.
Change-Id: Ibba5c535096409ac64c260bb130b4e3419d95ce3
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/64070
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/formfiller/BUILD.gn b/fpdfsdk/formfiller/BUILD.gn
index b49fa49..e612ef4 100644
--- a/fpdfsdk/formfiller/BUILD.gn
+++ b/fpdfsdk/formfiller/BUILD.gn
@@ -32,7 +32,6 @@
"../../:pdfium_public_headers",
"../../constants",
"../../core/fpdfapi/page",
- "../../core/fpdfapi/parser",
"../../core/fpdfdoc",
"../../core/fxcrt",
"../../core/fxge",
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
index e4caa62..6766e1c 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
@@ -8,7 +8,6 @@
#include "constants/form_flags.h"
#include "core/fpdfapi/page/cpdf_page.h"
-#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fxcrt/autorestorer.h"
#include "core/fxge/cfx_graphstatedata.h"
#include "core/fxge/cfx_pathdata.h"
@@ -468,15 +467,14 @@
return !!(nFieldFlags & pdfium::form_flags::kReadOnly);
}
-bool CFFL_InteractiveFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget) {
+bool CFFL_InteractiveFormFiller::IsFillingAllowed(
+ CPDFSDK_Widget* pWidget) const {
if (pWidget->GetFieldType() == FormFieldType::kPushButton)
return false;
- CPDF_Page* pPage = pWidget->GetPDFPage();
- uint32_t dwPermissions = pPage->GetDocument()->GetUserPermissions();
- return (dwPermissions & FPDFPERM_FILL_FORM) ||
- (dwPermissions & FPDFPERM_ANNOT_FORM) ||
- (dwPermissions & FPDFPERM_MODIFY);
+ return m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM) ||
+ m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) ||
+ m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY);
}
CFFL_FormFiller* CFFL_InteractiveFormFiller::GetFormFiller(
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.h b/fpdfsdk/formfiller/cffl_interactiveformfiller.h
index d618d92..3adfe4e 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.h
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.h
@@ -97,7 +97,6 @@
static bool IsVisible(CPDFSDK_Widget* pWidget);
static bool IsReadOnly(CPDFSDK_Widget* pWidget);
- static bool IsFillingAllowed(CPDFSDK_Widget* pWidget);
static bool IsValidAnnot(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot);
bool OnKeyStrokeCommit(ObservedPtr<CPDFSDK_Annot>* pAnnot,
@@ -161,6 +160,7 @@
uint32_t nFlag);
#endif // PDF_ENABLE_XFA
+ bool IsFillingAllowed(CPDFSDK_Widget* pWidget) const;
CFFL_FormFiller* GetFormFiller(CPDFSDK_Annot* pAnnot);
CFFL_FormFiller* GetOrCreateFormFiller(CPDFSDK_Annot* pAnnot);
void UnRegisterFormFiller(CPDFSDK_Annot* pAnnot);