Hide CPDF_FormControl from CFFL_Button
The FFL side of the house manages PWL, and the CPDFSDK side of the
house manages CPDF, and so let's begin disentangling these.
-- Add a missing const while at it.
Change-Id: I0b8485cce44cf31d80e83107ceb72899ab12b958
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/100051
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index ab2b463..ad43ea5 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -341,7 +341,8 @@
}
#endif // PDF_ENABLE_XFA
-bool CPDFSDK_Widget::IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode) {
+bool CPDFSDK_Widget::IsWidgetAppearanceValid(
+ CPDF_Annot::AppearanceMode mode) const {
RetainPtr<const CPDF_Dictionary> pAP =
GetAnnotDict()->GetDictFor(pdfium::annotation::kAP);
if (!pAP)
@@ -380,6 +381,10 @@
}
}
+bool CPDFSDK_Widget::IsPushHighlighted() const {
+ return GetFormControl()->GetHighlightingMode() == CPDF_FormControl::kPush;
+}
+
FormFieldType CPDFSDK_Widget::GetFieldType() const {
CPDF_FormField* pField = GetFormField();
return pField ? pField->GetFieldType() : FormFieldType::kUnknown;
diff --git a/fpdfsdk/cpdfsdk_widget.h b/fpdfsdk/cpdfsdk_widget.h
index c7dad0b..68fad87 100644
--- a/fpdfsdk/cpdfsdk_widget.h
+++ b/fpdfsdk/cpdfsdk_widget.h
@@ -134,7 +134,8 @@
uint32_t GetAppearanceAge() const { return m_nAppearanceAge; }
uint32_t GetValueAge() const { return m_nValueAge; }
- bool IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode);
+ bool IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode) const;
+ bool IsPushHighlighted() const;
CFX_Matrix GetMatrix() const;
CFX_FloatRect GetClientRect() const;
CFX_FloatRect GetRotatedRect() const;
diff --git a/fpdfsdk/formfiller/cffl_button.cpp b/fpdfsdk/formfiller/cffl_button.cpp
index e8039d4..6ee1562 100644
--- a/fpdfsdk/formfiller/cffl_button.cpp
+++ b/fpdfsdk/formfiller/cffl_button.cpp
@@ -6,7 +6,6 @@
#include "fpdfsdk/formfiller/cffl_button.h"
-#include "core/fpdfdoc/cpdf_formcontrol.h"
#include "fpdfsdk/cpdfsdk_widget.h"
#include "third_party/base/check.h"
@@ -64,8 +63,7 @@
CFX_RenderDevice* pDevice,
const CFX_Matrix& mtUser2Device) {
DCHECK(pPageView);
- CPDF_FormControl* pCtrl = pWidget->GetFormControl();
- if (pCtrl->GetHighlightingMode() != CPDF_FormControl::kPush) {
+ if (!pWidget->IsPushHighlighted()) {
pWidget->DrawAppearance(pDevice, mtUser2Device,
CPDF_Annot::AppearanceMode::kNormal);
return;