Remove knowlege of whether XFA is present from pwl/ window layer
This involves making no-op callbacks in the non-xfa case, but
a long term goal is more unification of the xfa/non-xfa paths.
Change-Id: I51d2d4fe50a098595d628a1dea6fa185b47e304b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/59090
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
index 1f5a386..e4caa62 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
@@ -807,26 +807,6 @@
return true;
}
-bool CFFL_InteractiveFormFiller::OnPopupPreOpen(
- const IPWL_SystemHandler::PerWindowData* pAttached,
- uint32_t nFlag) {
- auto* pData = static_cast<const CFFL_PrivateData*>(pAttached);
- ASSERT(pData->pWidget);
-
- ObservedPtr<CPDFSDK_Annot> pObserved(pData->GetWidget());
- return OnPreOpen(&pObserved, pData->pPageView, nFlag) || !pObserved;
-}
-
-bool CFFL_InteractiveFormFiller::OnPopupPostOpen(
- const IPWL_SystemHandler::PerWindowData* pAttached,
- uint32_t nFlag) {
- auto* pData = static_cast<const CFFL_PrivateData*>(pAttached);
- ASSERT(pData->pWidget);
-
- ObservedPtr<CPDFSDK_Annot> pObserved(pData->GetWidget());
- return OnPostOpen(&pObserved, pData->pPageView, nFlag) || !pObserved;
-}
-
bool CFFL_InteractiveFormFiller::OnPreOpen(ObservedPtr<CPDFSDK_Annot>* pAnnot,
CPDFSDK_PageView* pPageView,
uint32_t nFlag) {
@@ -979,6 +959,34 @@
return {false, true};
}
+bool CFFL_InteractiveFormFiller::OnPopupPreOpen(
+ const IPWL_SystemHandler::PerWindowData* pAttached,
+ uint32_t nFlag) {
+#ifdef PDF_ENABLE_XFA
+ auto* pData = static_cast<const CFFL_PrivateData*>(pAttached);
+ ASSERT(pData->pWidget);
+
+ ObservedPtr<CPDFSDK_Annot> pObserved(pData->GetWidget());
+ return OnPreOpen(&pObserved, pData->pPageView, nFlag) || !pObserved;
+#else
+ return false;
+#endif
+}
+
+bool CFFL_InteractiveFormFiller::OnPopupPostOpen(
+ const IPWL_SystemHandler::PerWindowData* pAttached,
+ uint32_t nFlag) {
+#ifdef PDF_ENABLE_XFA
+ auto* pData = static_cast<const CFFL_PrivateData*>(pAttached);
+ ASSERT(pData->pWidget);
+
+ ObservedPtr<CPDFSDK_Annot> pObserved(pData->GetWidget());
+ return OnPostOpen(&pObserved, pData->pPageView, nFlag) || !pObserved;
+#else
+ return false;
+#endif
+}
+
CFFL_PrivateData::CFFL_PrivateData() = default;
CFFL_PrivateData::CFFL_PrivateData(const CFFL_PrivateData& that) = default;
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.h b/fpdfsdk/formfiller/cffl_interactiveformfiller.h
index 9a2233d..1d2c39b 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.h
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.h
@@ -155,11 +155,12 @@
int nSelEnd,
bool bKeyDown,
uint32_t nFlag) override;
-#ifdef PDF_ENABLE_XFA
bool OnPopupPreOpen(const IPWL_SystemHandler::PerWindowData* pAttached,
uint32_t nFlag) override;
bool OnPopupPostOpen(const IPWL_SystemHandler::PerWindowData* pAttached,
uint32_t nFlag) override;
+
+#ifdef PDF_ENABLE_XFA
void SetFocusAnnotTab(CPDFSDK_Annot* pWidget, bool bSameField, bool bNext);
#endif // PDF_ENABLE_XFA
diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp
index b3da885..8192da2 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box.cpp
@@ -448,13 +448,10 @@
return true;
ObservedPtr<CPWL_ComboBox> thisObserved(this);
-
-#ifdef PDF_ENABLE_XFA
if (m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), 0))
return !!thisObserved;
if (!thisObserved)
return false;
-#endif // PDF_ENABLE_XFA
float fBorderWidth = m_pList->GetBorderWidth() * 2;
float fPopupMin = 0.0f;
@@ -482,12 +479,7 @@
if (!Move(rcWindow, true, true))
return false;
-#ifdef PDF_ENABLE_XFA
m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), 0);
- if (!thisObserved)
- return false;
-#endif // PDF_ENABLE_XFA
-
return !!thisObserved;
}
@@ -502,14 +494,12 @@
switch (nChar) {
case FWL_VKEY_Up:
if (m_pList->GetCurSel() > 0) {
-#ifdef PDF_ENABLE_XFA
if (m_pFillerNotify) {
if (m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), nFlag))
return false;
if (m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), nFlag))
return false;
}
-#endif // PDF_ENABLE_XFA
if (m_pList->IsMovementKey(nChar)) {
if (m_pList->OnMovementKeyDown(nChar, nFlag))
return false;
@@ -519,14 +509,12 @@
return true;
case FWL_VKEY_Down:
if (m_pList->GetCurSel() < m_pList->GetCount() - 1) {
-#ifdef PDF_ENABLE_XFA
if (m_pFillerNotify) {
if (m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), nFlag))
return false;
if (m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), nFlag))
return false;
}
-#endif // PDF_ENABLE_XFA
if (m_pList->IsMovementKey(nChar)) {
if (m_pList->OnMovementKeyDown(nChar, nFlag))
return false;
@@ -553,14 +541,12 @@
if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
return m_pEdit->OnChar(nChar, nFlag);
-#ifdef PDF_ENABLE_XFA
if (m_pFillerNotify) {
if (m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), nFlag))
return false;
if (m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), nFlag))
return false;
}
-#endif // PDF_ENABLE_XFA
if (!m_pList->IsChar(nChar, nFlag))
return false;
return m_pList->OnCharNotify(nChar, nFlag);
diff --git a/fpdfsdk/pwl/cpwl_edit.h b/fpdfsdk/pwl/cpwl_edit.h
index 9848676..1de382e 100644
--- a/fpdfsdk/pwl/cpwl_edit.h
+++ b/fpdfsdk/pwl/cpwl_edit.h
@@ -28,6 +28,7 @@
float fPopupMax,
bool* bBottom,
float* fPopupRet) = 0;
+
virtual std::pair<bool, bool> OnBeforeKeyStroke(
const IPWL_SystemHandler::PerWindowData* pAttached,
WideString& strChange,
@@ -37,14 +38,13 @@
bool bKeyDown,
uint32_t nFlag) = 0;
-#ifdef PDF_ENABLE_XFA
virtual bool OnPopupPreOpen(
const IPWL_SystemHandler::PerWindowData* pAttached,
uint32_t nFlag) = 0;
+
virtual bool OnPopupPostOpen(
const IPWL_SystemHandler::PerWindowData* pAttached,
uint32_t nFlag) = 0;
-#endif // PDF_ENABLE_XFA
};
class CPWL_Edit final : public CPWL_EditCtrl {