Merge CPWL_Wnd::FocusHandlerIface into ProviderIface.
The focus handler method is simply one that few provider implementors
actually provide, but having a no-op stub for most beats having a
separate interface for these.
-- we'll pick better names in a follow-up.
Change-Id: I81c28daf78426321778b6db007c72606f4ef78aa
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/93551
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp
index 79de664..cc2b8f6 100644
--- a/fpdfsdk/formfiller/cffl_combobox.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -21,9 +21,6 @@
: CFFL_TextObject(pFormFiller, pWidget) {}
CFFL_ComboBox::~CFFL_ComboBox() {
- for (const auto& it : m_Maps)
- it.second->InvalidateFocusHandler(this);
-
// See comment in cffl_formfiller.h.
// The font map should be stored somewhere more appropriate so it will live
// until the PWL_Edit is done with it. pdfium:566
@@ -36,7 +33,6 @@
cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT;
cp.pFontMap = GetOrCreateFontMap();
- cp.pFocusHandler = this;
return cp;
}
@@ -236,7 +232,7 @@
}
#endif // PDF_ENABLE_XFA
-void CFFL_ComboBox::OnSetFocus(CPWL_Edit* pEdit) {
+void CFFL_ComboBox::OnSetFocusForEdit(CPWL_Edit* pEdit) {
pEdit->SetCharSet(FX_Charset::kChineseSimplified);
pEdit->SetReadyToInput();
m_pFormFiller->GetCallbackIface()->OnSetFieldInputFocus(pEdit->GetText());
diff --git a/fpdfsdk/formfiller/cffl_combobox.h b/fpdfsdk/formfiller/cffl_combobox.h
index 7df16ad..724e6ac 100644
--- a/fpdfsdk/formfiller/cffl_combobox.h
+++ b/fpdfsdk/formfiller/cffl_combobox.h
@@ -21,8 +21,7 @@
WideString sValue;
};
-class CFFL_ComboBox final : public CFFL_TextObject,
- public CPWL_Wnd::FocusHandlerIface {
+class CFFL_ComboBox final : public CFFL_TextObject {
public:
CFFL_ComboBox(CFFL_InteractiveFormFiller* pFormFiller,
CPDFSDK_Widget* pWidget);
@@ -53,8 +52,8 @@
bool IsFieldFull(const CPDFSDK_PageView* pPageView) override;
#endif
- // CPWL_Wnd::FocusHandlerIface:
- void OnSetFocus(CPWL_Edit* pEdit) override;
+ // CPWL_Wnd::ProviderIface:
+ void OnSetFocusForEdit(CPWL_Edit* pEdit) override;
private:
WideString GetSelectExportText();
diff --git a/fpdfsdk/formfiller/cffl_formfield.cpp b/fpdfsdk/formfiller/cffl_formfield.cpp
index 19f0c67..97b5bd0 100644
--- a/fpdfsdk/formfiller/cffl_formfield.cpp
+++ b/fpdfsdk/formfiller/cffl_formfield.cpp
@@ -395,6 +395,10 @@
return GetCurMatrix() * pPageView->GetCurrentMatrix();
}
+void CFFL_FormField::OnSetFocusForEdit(CPWL_Edit* pEdit) {
+ // Only sub-classes might have a subordinate edit to focus.
+}
+
CFX_Matrix CFFL_FormField::GetCurMatrix() {
CFX_Matrix mt;
CFX_FloatRect rcDA = m_pWidget->GetPDFAnnot()->GetRect();
diff --git a/fpdfsdk/formfiller/cffl_formfield.h b/fpdfsdk/formfiller/cffl_formfield.h
index eb5bbad..a9479f8 100644
--- a/fpdfsdk/formfiller/cffl_formfield.h
+++ b/fpdfsdk/formfiller/cffl_formfield.h
@@ -94,6 +94,7 @@
// CPWL_Wnd::ProviderIface:
CFX_Matrix GetWindowMatrix(
const IPWL_FillerNotify::PerWindowData* pAttached) override;
+ void OnSetFocusForEdit(CPWL_Edit* pEdit) override;
virtual void GetActionData(const CPDFSDK_PageView* pPageView,
CPDF_AAction::AActionType type,
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index da46bcb..5ae3e94 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -33,9 +33,6 @@
: CFFL_TextObject(pFormFiller, pWidget) {}
CFFL_TextField::~CFFL_TextField() {
- for (const auto& it : m_Maps)
- it.second->InvalidateFocusHandler(this);
-
// See comment in cffl_formfiller.h.
// The font map should be stored somewhere more appropriate so it will live
// until the PWL_Edit is done with it. pdfium:566
@@ -79,7 +76,6 @@
break;
}
cp.pFontMap = GetOrCreateFontMap();
- cp.pFocusHandler = this;
return cp;
}
@@ -241,7 +237,7 @@
}
#endif // PDF_ENABLE_XFA
-void CFFL_TextField::OnSetFocus(CPWL_Edit* pEdit) {
+void CFFL_TextField::OnSetFocusForEdit(CPWL_Edit* pEdit) {
pEdit->SetCharSet(FX_Charset::kChineseSimplified);
pEdit->SetReadyToInput();
m_pFormFiller->GetCallbackIface()->OnSetFieldInputFocus(pEdit->GetText());
diff --git a/fpdfsdk/formfiller/cffl_textfield.h b/fpdfsdk/formfiller/cffl_textfield.h
index 91821e1..9ce8a8c 100644
--- a/fpdfsdk/formfiller/cffl_textfield.h
+++ b/fpdfsdk/formfiller/cffl_textfield.h
@@ -19,8 +19,7 @@
WideString sValue;
};
-class CFFL_TextField final : public CFFL_TextObject,
- public CPWL_Wnd::FocusHandlerIface {
+class CFFL_TextField final : public CFFL_TextObject {
public:
CFFL_TextField(CFFL_InteractiveFormFiller* pFormFiller,
CPDFSDK_Widget* pWidget);
@@ -49,8 +48,8 @@
bool IsFieldFull(const CPDFSDK_PageView* pPageView) override;
#endif
- // CPWL_Wnd::FocusHandlerIface:
- void OnSetFocus(CPWL_Edit* pEdit) override;
+ // CPWL_Wnd::ProviderIface:
+ void OnSetFocusForEdit(CPWL_Edit* pEdit) override;
private:
CPWL_Edit* GetPWLEdit(const CPDFSDK_PageView* pPageView) const;
diff --git a/fpdfsdk/pwl/cpwl_edit.cpp b/fpdfsdk/pwl/cpwl_edit.cpp
index 5e8399a..3936a30 100644
--- a/fpdfsdk/pwl/cpwl_edit.cpp
+++ b/fpdfsdk/pwl/cpwl_edit.cpp
@@ -223,8 +223,9 @@
return;
if (!IsReadOnly()) {
- if (CPWL_Wnd::FocusHandlerIface* pFocusHandler = GetFocusHandler()) {
- pFocusHandler->OnSetFocus(this);
+ CPWL_Wnd::ProviderIface* pProvider = GetProvider();
+ if (pProvider) {
+ pProvider->OnSetFocusForEdit(this);
if (!observed_ptr)
return;
}
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp
index da92cd7..62a4f57 100644
--- a/fpdfsdk/pwl/cpwl_wnd.cpp
+++ b/fpdfsdk/pwl/cpwl_wnd.cpp
@@ -176,11 +176,6 @@
void CPWL_Wnd::OnDestroy() {}
-void CPWL_Wnd::InvalidateFocusHandler(FocusHandlerIface* handler) {
- if (m_CreationParams.pFocusHandler == handler)
- m_CreationParams.pFocusHandler = nullptr;
-}
-
void CPWL_Wnd::InvalidateProvider(ProviderIface* provider) {
if (m_CreationParams.pProvider.Get() == provider)
m_CreationParams.pProvider.Reset();
diff --git a/fpdfsdk/pwl/cpwl_wnd.h b/fpdfsdk/pwl/cpwl_wnd.h
index 34151b6..5a7a644 100644
--- a/fpdfsdk/pwl/cpwl_wnd.h
+++ b/fpdfsdk/pwl/cpwl_wnd.h
@@ -86,12 +86,8 @@
// get a matrix which map user space to CWnd client space
virtual CFX_Matrix GetWindowMatrix(
const IPWL_FillerNotify::PerWindowData* pAttached) = 0;
- };
- class FocusHandlerIface {
- public:
- virtual ~FocusHandlerIface() = default;
- virtual void OnSetFocus(CPWL_Edit* pEdit) = 0;
+ virtual void OnSetFocusForEdit(CPWL_Edit* pEdit) = 0;
};
// Caller-provided options for window creation.
@@ -111,7 +107,6 @@
ObservedPtr<ProviderIface> pProvider;
// Optional:
- UnownedPtr<FocusHandlerIface> pFocusHandler;
uint32_t dwFlags = 0;
CFX_Color sBackgroundColor;
BorderStyle nBorderStyle = BorderStyle::kSolid;
@@ -191,7 +186,6 @@
void Destroy();
bool Move(const CFX_FloatRect& rcNew, bool bReset, bool bRefresh);
- void InvalidateFocusHandler(FocusHandlerIface* handler);
void InvalidateProvider(ProviderIface* provider);
void SetCapture();
void ReleaseCapture();
@@ -237,9 +231,6 @@
ProviderIface* GetProvider() const {
return m_CreationParams.pProvider.Get();
}
- FocusHandlerIface* GetFocusHandler() const {
- return m_CreationParams.pFocusHandler.Get();
- }
int32_t GetTransparency();
void SetTransparency(int32_t nTransparency);