Remove SetFillerNotify() from CWPL_Wnd sub-classes
Previous CL shows it is redundant. Avoid conditionals since we
know it is set in the CPWL_Wnd itself at creation.
Change-Id: If0bca94fee8889f4b8bebde6c4f9d67d340c88d6
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/93611
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 531e17b..79de664 100644
--- a/fpdfsdk/formfiller/cffl_combobox.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -46,7 +46,6 @@
static_cast<CFFL_PerWindowData*>(pAttachedData.get())->SetFormField(this);
auto pWnd = std::make_unique<CPWL_ComboBox>(cp, std::move(pAttachedData));
pWnd->Realize();
- pWnd->SetFillerNotify(m_pFormFiller.Get());
int32_t nCurSel = m_pWidget->GetSelectedIndex(0);
WideString swText;
diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp
index 809c5cc..96b4aea 100644
--- a/fpdfsdk/formfiller/cffl_listbox.cpp
+++ b/fpdfsdk/formfiller/cffl_listbox.cpp
@@ -45,7 +45,6 @@
static_cast<CFFL_PerWindowData*>(pAttachedData.get())->SetFormField(this);
auto pWnd = std::make_unique<CPWL_ListBox>(cp, std::move(pAttachedData));
pWnd->Realize();
- pWnd->SetFillerNotify(m_pFormFiller.Get());
for (int32_t i = 0, sz = m_pWidget->CountOptions(); i < sz; i++)
pWnd->AddString(m_pWidget->GetOptionLabel(i));
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index 8c9e002..da46bcb 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -89,7 +89,6 @@
static_cast<CFFL_PerWindowData*>(pAttachedData.get())->SetFormField(this);
auto pWnd = std::make_unique<CPWL_Edit>(cp, std::move(pAttachedData));
pWnd->Realize();
- pWnd->SetFillerNotify(m_pFormFiller.Get());
int32_t nMaxLen = m_pWidget->GetMaxLen();
WideString swValue = m_pWidget->GetValue();
diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp
index 37127e7..6f89e7d 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box.cpp
@@ -296,11 +296,8 @@
return Move(m_rcOldWindow, true, true);
}
- if (!m_pFillerNotify)
- return true;
-
ObservedPtr<CPWL_ComboBox> thisObserved(this);
- if (m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), {}))
+ if (GetFillerNotify()->OnPopupPreOpen(GetAttachedData(), {}))
return !!thisObserved;
if (!thisObserved)
return false;
@@ -313,8 +310,8 @@
bool bBottom;
float fPopupRet;
- m_pFillerNotify->QueryWherePopup(GetAttachedData(), fPopupMin, fPopupMax,
- &bBottom, &fPopupRet);
+ GetFillerNotify()->QueryWherePopup(GetAttachedData(), fPopupMin, fPopupMax,
+ &bBottom, &fPopupRet);
if (!FXSYS_IsFloatBigger(fPopupRet, 0.0f))
return true;
@@ -331,7 +328,7 @@
if (!Move(rcWindow, true, true))
return false;
- m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), {});
+ GetFillerNotify()->OnPopupPostOpen(GetAttachedData(), {});
return !!thisObserved;
}
@@ -347,12 +344,10 @@
switch (nKeyCode) {
case FWL_VKEY_Up:
if (m_pList->GetCurSel() > 0) {
- if (m_pFillerNotify) {
- if (m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), nFlag))
- return false;
- if (m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), nFlag))
- return false;
- }
+ if (GetFillerNotify()->OnPopupPreOpen(GetAttachedData(), nFlag))
+ return false;
+ if (GetFillerNotify()->OnPopupPostOpen(GetAttachedData(), nFlag))
+ return false;
if (m_pList->IsMovementKey(nKeyCode)) {
if (m_pList->OnMovementKeyDown(nKeyCode, nFlag))
return false;
@@ -362,12 +357,10 @@
return true;
case FWL_VKEY_Down:
if (m_pList->GetCurSel() < m_pList->GetCount() - 1) {
- if (m_pFillerNotify) {
- if (m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), nFlag))
- return false;
- if (m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), nFlag))
- return false;
- }
+ if (GetFillerNotify()->OnPopupPreOpen(GetAttachedData(), nFlag))
+ return false;
+ if (GetFillerNotify()->OnPopupPostOpen(GetAttachedData(), nFlag))
+ return false;
if (m_pList->IsMovementKey(nKeyCode)) {
if (m_pList->OnMovementKeyDown(nKeyCode, nFlag))
return false;
@@ -418,12 +411,10 @@
if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
return m_pEdit->OnChar(nChar, nFlag);
- if (m_pFillerNotify) {
- if (m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), nFlag))
- return false;
- if (m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), nFlag))
- return false;
- }
+ if (GetFillerNotify()->OnPopupPreOpen(GetAttachedData(), nFlag))
+ return false;
+ if (GetFillerNotify()->OnPopupPostOpen(GetAttachedData(), nFlag))
+ return false;
if (!m_pList->IsChar(nChar, nFlag))
return false;
return m_pList->OnCharNotify(nChar, nFlag);
@@ -459,14 +450,3 @@
m_pEdit->SelectAllText();
m_nSelectItem = m_pList->GetCurSel();
}
-
-void CPWL_ComboBox::SetFillerNotify(IPWL_FillerNotify* pNotify) {
- CHECK_EQ(pNotify, GetCreationParams()->pFillerNotify);
- m_pFillerNotify = pNotify;
-
- if (m_pEdit)
- m_pEdit->SetFillerNotify(pNotify);
-
- if (m_pList)
- m_pList->SetFillerNotify(pNotify);
-}
diff --git a/fpdfsdk/pwl/cpwl_combo_box.h b/fpdfsdk/pwl/cpwl_combo_box.h
index 89ae9cb..0d13b40 100644
--- a/fpdfsdk/pwl/cpwl_combo_box.h
+++ b/fpdfsdk/pwl/cpwl_combo_box.h
@@ -47,8 +47,6 @@
bool Undo() override;
bool Redo() override;
- void SetFillerNotify(IPWL_FillerNotify* pNotify);
-
void SetText(const WideString& text);
void AddString(const WideString& str);
int32_t GetSelect() const;
@@ -75,7 +73,6 @@
bool m_bPopup = false;
bool m_bBottom = true;
int32_t m_nSelectItem = -1;
- UnownedPtr<IPWL_FillerNotify> m_pFillerNotify;
};
#endif // FPDFSDK_PWL_CPWL_COMBO_BOX_H_
diff --git a/fpdfsdk/pwl/cpwl_edit.cpp b/fpdfsdk/pwl/cpwl_edit.cpp
index 0a040de..5e8399a 100644
--- a/fpdfsdk/pwl/cpwl_edit.cpp
+++ b/fpdfsdk/pwl/cpwl_edit.cpp
@@ -331,33 +331,31 @@
return true;
if (nKeyCode == FWL_VKEY_Delete) {
- if (m_pFillerNotify) {
- WideString strChange;
- WideString strChangeEx;
+ WideString strChange;
+ WideString strChangeEx;
- int nSelStart;
- int nSelEnd;
- std::tie(nSelStart, nSelEnd) = GetSelection();
+ int nSelStart;
+ int nSelEnd;
+ std::tie(nSelStart, nSelEnd) = GetSelection();
- if (nSelStart == nSelEnd)
- nSelEnd = nSelStart + 1;
+ if (nSelStart == nSelEnd)
+ nSelEnd = nSelStart + 1;
- ObservedPtr<CPWL_Wnd> thisObserved(this);
+ ObservedPtr<CPWL_Wnd> thisObserved(this);
- bool bRC;
- bool bExit;
- std::tie(bRC, bExit) = m_pFillerNotify->OnBeforeKeyStroke(
- GetAttachedData(), strChange, strChangeEx, nSelStart, nSelEnd, true,
- nFlag);
+ bool bRC;
+ bool bExit;
+ std::tie(bRC, bExit) = GetFillerNotify()->OnBeforeKeyStroke(
+ GetAttachedData(), strChange, strChangeEx, nSelStart, nSelEnd, true,
+ nFlag);
- if (!thisObserved)
- return false;
+ if (!thisObserved)
+ return false;
- if (!bRC)
- return false;
- if (bExit)
- return false;
- }
+ if (!bRC)
+ return false;
+ if (bExit)
+ return false;
}
bool bRet = OnKeyDownInternal(nKeyCode, nFlag);
@@ -407,35 +405,32 @@
bool bExit = false;
if (!IsCTRLKeyDown(nFlag)) {
- if (m_pFillerNotify) {
- WideString swChange;
+ WideString swChange;
+ int nSelStart;
+ int nSelEnd;
+ std::tie(nSelStart, nSelEnd) = GetSelection();
- int nSelStart;
- int nSelEnd;
- std::tie(nSelStart, nSelEnd) = GetSelection();
-
- switch (nChar) {
- case pdfium::ascii::kBackspace:
- if (nSelStart == nSelEnd)
- nSelStart = nSelEnd - 1;
- break;
- case pdfium::ascii::kReturn:
- break;
- default:
- swChange += nChar;
- break;
- }
-
- ObservedPtr<CPWL_Wnd> thisObserved(this);
-
- WideString strChangeEx;
- std::tie(bRC, bExit) = m_pFillerNotify->OnBeforeKeyStroke(
- GetAttachedData(), swChange, strChangeEx, nSelStart, nSelEnd, true,
- nFlag);
-
- if (!thisObserved)
- return false;
+ switch (nChar) {
+ case pdfium::ascii::kBackspace:
+ if (nSelStart == nSelEnd)
+ nSelStart = nSelEnd - 1;
+ break;
+ case pdfium::ascii::kReturn:
+ break;
+ default:
+ swChange += nChar;
+ break;
}
+
+ ObservedPtr<CPWL_Wnd> thisObserved(this);
+
+ WideString strChangeEx;
+ std::tie(bRC, bExit) = GetFillerNotify()->OnBeforeKeyStroke(
+ GetAttachedData(), swChange, strChangeEx, nSelStart, nSelEnd, true,
+ nFlag);
+
+ if (!thisObserved)
+ return false;
}
if (!bRC)
diff --git a/fpdfsdk/pwl/cpwl_edit.h b/fpdfsdk/pwl/cpwl_edit.h
index 845f338..95474d5 100644
--- a/fpdfsdk/pwl/cpwl_edit.h
+++ b/fpdfsdk/pwl/cpwl_edit.h
@@ -16,7 +16,6 @@
#include "core/fxcrt/widestring.h"
#include "fpdfsdk/pwl/cpwl_wnd.h"
#include "fpdfsdk/pwl/ipwl_fillernotify.h"
-#include "third_party/base/check_op.h"
class CPDF_Font;
class CPWL_Caret;
@@ -96,11 +95,6 @@
const CFX_FloatRect& rcPlate,
int32_t nCharArray);
- void SetFillerNotify(IPWL_FillerNotify* pNotify) {
- CHECK_EQ(pNotify, GetCreationParams()->pFillerNotify);
- m_pFillerNotify = pNotify;
- }
-
bool SetCaret(bool bVisible,
const CFX_PointF& ptHead,
const CFX_PointF& ptFoot);
@@ -137,7 +131,6 @@
CFX_FloatRect m_rcOldWindow;
std::unique_ptr<CPWL_EditImpl> const m_pEditImpl;
UnownedPtr<CPWL_Caret> m_pCaret;
- UnownedPtr<IPWL_FillerNotify> m_pFillerNotify;
};
#endif // FPDFSDK_PWL_CPWL_EDIT_H_
diff --git a/fpdfsdk/pwl/cpwl_list_box.cpp b/fpdfsdk/pwl/cpwl_list_box.cpp
index 04bd460..534ec8b 100644
--- a/fpdfsdk/pwl/cpwl_list_box.cpp
+++ b/fpdfsdk/pwl/cpwl_list_box.cpp
@@ -204,9 +204,6 @@
bool CPWL_ListBox::OnNotifySelectionChanged(bool bKeyDown,
Mask<FWL_EVENTFLAG> nFlag) {
- if (!m_pFillerNotify)
- return false;
-
ObservedPtr<CPWL_Wnd> thisObserved(this);
WideString swChange = GetText();
@@ -215,7 +212,7 @@
int nSelEnd = pdfium::base::checked_cast<int>(swChange.GetLength());
bool bRC;
bool bExit;
- std::tie(bRC, bExit) = m_pFillerNotify->OnBeforeKeyStroke(
+ std::tie(bRC, bExit) = GetFillerNotify()->OnBeforeKeyStroke(
GetAttachedData(), swChange, strChangeEx, nSelStart, nSelEnd, bKeyDown,
nFlag);
diff --git a/fpdfsdk/pwl/cpwl_list_box.h b/fpdfsdk/pwl/cpwl_list_box.h
index f0df413..7a10681 100644
--- a/fpdfsdk/pwl/cpwl_list_box.h
+++ b/fpdfsdk/pwl/cpwl_list_box.h
@@ -12,7 +12,6 @@
#include "core/fxcrt/unowned_ptr.h"
#include "fpdfsdk/pwl/cpwl_list_ctrl.h"
#include "fpdfsdk/pwl/cpwl_wnd.h"
-#include "third_party/base/check_op.h"
class IPWL_FillerNotify;
@@ -76,16 +75,10 @@
float GetFirstHeight() const;
CFX_FloatRect GetListRect() const;
- void SetFillerNotify(IPWL_FillerNotify* pNotify) {
- CHECK_EQ(pNotify, GetCreationParams()->pFillerNotify);
- m_pFillerNotify = pNotify;
- }
-
protected:
bool m_bMouseDown = false;
bool m_bHoverSel = false;
std::unique_ptr<CPWL_ListCtrl> m_pListCtrl;
- UnownedPtr<IPWL_FillerNotify> m_pFillerNotify;
};
#endif // FPDFSDK_PWL_CPWL_LIST_BOX_H_