summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-06-02 00:45:14 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-06-02 18:31:20 +0000
commit4f34c64914be17966f2d91591921dec635582061 (patch)
tree762d9af8dd0aaeb084a007e6133418e56f6a7605
parentdd29c258fbf7838ddd0ee99361beb4c2da8dce7f (diff)
downloadpdfium-4f34c64914be17966f2d91591921dec635582061.tar.xz
Clean up CFFL formfiller classes.
- Consolidate assertions for m_pFormFillEnv. - Remove check for m_pFormFillEnv being NULL. - Pass in a CPDFSDK_Widget* instead of an Annot* and then casting. - Remove unused LoadPopupMenuString() method. Change-Id: Ic22e75c9e41eb54002be812945a3ee80debeca8b Reviewed-on: https://pdfium-review.googlesource.com/6232 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--fpdfsdk/formfiller/cffl_combobox.cpp6
-rw-r--r--fpdfsdk/formfiller/cffl_combobox.h2
-rw-r--r--fpdfsdk/formfiller/cffl_formfiller.cpp21
-rw-r--r--fpdfsdk/formfiller/cffl_formfiller.h8
-rw-r--r--fpdfsdk/formfiller/cffl_interactiveformfiller.cpp3
-rw-r--r--fpdfsdk/formfiller/cffl_listbox.cpp2
-rw-r--r--fpdfsdk/formfiller/cffl_listbox.h2
-rw-r--r--fpdfsdk/formfiller/cffl_pushbutton.cpp4
-rw-r--r--fpdfsdk/formfiller/cffl_pushbutton.h2
-rw-r--r--fpdfsdk/formfiller/cffl_radiobutton.cpp2
-rw-r--r--fpdfsdk/formfiller/cffl_radiobutton.h2
-rw-r--r--fpdfsdk/formfiller/cffl_textfield.cpp5
-rw-r--r--fpdfsdk/formfiller/cffl_textfield.h2
-rw-r--r--fpdfsdk/pdfwindow/PWL_Wnd.h11
14 files changed, 24 insertions, 48 deletions
diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp
index 4f9ffff5af..8e4efc453a 100644
--- a/fpdfsdk/formfiller/cffl_combobox.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -16,8 +16,8 @@
#include "third_party/base/ptr_util.h"
CFFL_ComboBox::CFFL_ComboBox(CPDFSDK_FormFillEnvironment* pApp,
- CPDFSDK_Annot* pAnnot)
- : CFFL_FormFiller(pApp, pAnnot) {
+ CPDFSDK_Widget* pWidget)
+ : CFFL_FormFiller(pApp, pWidget) {
m_State.nIndex = 0;
m_State.nStart = 0;
m_State.nEnd = 0;
@@ -258,8 +258,6 @@ bool CFFL_ComboBox::IsFieldFull(CPDFSDK_PageView* pPageView) {
#endif // PDF_ENABLE_XFA
void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) {
- ASSERT(m_pFormFillEnv);
-
if (pWnd->GetClassName() != PWL_CLASSNAME_EDIT)
return;
diff --git a/fpdfsdk/formfiller/cffl_combobox.h b/fpdfsdk/formfiller/cffl_combobox.h
index e3e7e3b1e9..be14d8beec 100644
--- a/fpdfsdk/formfiller/cffl_combobox.h
+++ b/fpdfsdk/formfiller/cffl_combobox.h
@@ -23,7 +23,7 @@ struct FFL_ComboBoxState {
class CFFL_ComboBox : public CFFL_FormFiller, public IPWL_FocusHandler {
public:
- CFFL_ComboBox(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Annot* pWidget);
+ CFFL_ComboBox(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Widget* pWidget);
~CFFL_ComboBox() override;
// CFFL_FormFiller:
diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp
index b104d67b6d..f15efd2462 100644
--- a/fpdfsdk/formfiller/cffl_formfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_formfiller.cpp
@@ -22,9 +22,9 @@
#define FFL_HINT_ELAPSE 800
CFFL_FormFiller::CFFL_FormFiller(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- CPDFSDK_Annot* pAnnot)
- : m_pFormFillEnv(pFormFillEnv), m_pAnnot(pAnnot), m_bValid(false) {
- m_pWidget = static_cast<CPDFSDK_Widget*>(pAnnot);
+ CPDFSDK_Widget* pWidget)
+ : m_pFormFillEnv(pFormFillEnv), m_pWidget(pWidget), m_bValid(false) {
+ ASSERT(m_pFormFillEnv);
}
CFFL_FormFiller::~CFFL_FormFiller() {
@@ -282,8 +282,6 @@ bool CFFL_FormFiller::IsValid() const {
}
PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() {
- ASSERT(m_pFormFillEnv);
-
PWL_CREATEPARAM cp;
cp.pParentWnd = nullptr;
cp.pProvider.Reset(this);
@@ -422,12 +420,6 @@ CFX_Matrix CFFL_FormFiller::GetCurMatrix() {
return mt;
}
-CFX_WideString CFFL_FormFiller::LoadPopupMenuString(int nIndex) {
- ASSERT(m_pFormFillEnv);
-
- return L"";
-}
-
CFX_FloatRect CFFL_FormFiller::GetPDFWindowRect() const {
CFX_FloatRect rectAnnot = m_pWidget->GetPDFAnnot()->GetRect();
@@ -440,8 +432,8 @@ CFX_FloatRect CFFL_FormFiller::GetPDFWindowRect() const {
}
CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView(bool renew) {
- UnderlyingPageType* pPage = m_pAnnot->GetUnderlyingPage();
- return m_pFormFillEnv ? m_pFormFillEnv->GetPageView(pPage, renew) : nullptr;
+ UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage();
+ return m_pFormFillEnv->GetPageView(pPage, renew);
}
CFX_FloatRect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) {
@@ -585,7 +577,7 @@ void CFFL_FormFiller::InvalidateRect(const FX_RECT& rect) {
}
CFFL_Button::CFFL_Button(CPDFSDK_FormFillEnvironment* pApp,
- CPDFSDK_Annot* pWidget)
+ CPDFSDK_Widget* pWidget)
: CFFL_FormFiller(pApp, pWidget), m_bMouseIn(false), m_bMouseDown(false) {}
CFFL_Button::~CFFL_Button() {}
@@ -636,7 +628,6 @@ bool CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
uint32_t nFlags,
const CFX_PointF& point) {
- ASSERT(m_pFormFillEnv);
return true;
}
diff --git a/fpdfsdk/formfiller/cffl_formfiller.h b/fpdfsdk/formfiller/cffl_formfiller.h
index 7704b5fe29..445e86fb3c 100644
--- a/fpdfsdk/formfiller/cffl_formfiller.h
+++ b/fpdfsdk/formfiller/cffl_formfiller.h
@@ -22,7 +22,7 @@ class CPDFSDK_Widget;
class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler {
public:
CFFL_FormFiller(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- CPDFSDK_Annot* pAnnot);
+ CPDFSDK_Widget* pWidget);
~CFFL_FormFiller() override;
virtual FX_RECT GetViewBBox(CPDFSDK_PageView* pPageView,
@@ -83,7 +83,6 @@ class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler {
// IPWL_Provider
CFX_Matrix GetWindowMatrix(void* pAttachedData) override;
- CFX_WideString LoadPopupMenuString(int nIndex) override;
virtual void GetActionData(CPDFSDK_PageView* pPageView,
CPDF_AAction::AActionType type,
@@ -139,7 +138,7 @@ class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler {
void SetChangeMark();
virtual void InvalidateRect(const FX_RECT& rect);
- CPDFSDK_Annot* GetSDKAnnot() { return m_pAnnot.Get(); }
+ CPDFSDK_Annot* GetSDKAnnot() { return m_pWidget.Get(); }
protected:
using CFFL_PageView2PDFWindow = std::map<CPDFSDK_PageView*, CPWL_Wnd*>;
@@ -154,7 +153,6 @@ class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler {
CFX_UnownedPtr<CPDFSDK_FormFillEnvironment> const m_pFormFillEnv;
CFX_UnownedPtr<CPDFSDK_Widget> m_pWidget;
- CFX_UnownedPtr<CPDFSDK_Annot> m_pAnnot;
bool m_bValid;
CFFL_PageView2PDFWindow m_Maps;
CFX_PointF m_ptOldPos;
@@ -163,7 +161,7 @@ class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler {
class CFFL_Button : public CFFL_FormFiller {
public:
CFFL_Button(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- CPDFSDK_Annot* pWidget);
+ CPDFSDK_Widget* pWidget);
~CFFL_Button() override;
// CFFL_FormFiller
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
index 491186e39c..2c75225283 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
@@ -478,7 +478,8 @@ CFFL_FormFiller* CFFL_InteractiveFormFiller::GetFormFiller(
if (!bRegister)
return nullptr;
- CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
+ // TODO(thestig): How do we know |pAnnot| is a CPDFSDK_Widget?
+ CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot);
int nFieldType = pWidget->GetFieldType();
CFFL_FormFiller* pFormFiller;
switch (nFieldType) {
diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp
index 617af13d95..55c0f3f2aa 100644
--- a/fpdfsdk/formfiller/cffl_listbox.cpp
+++ b/fpdfsdk/formfiller/cffl_listbox.cpp
@@ -18,7 +18,7 @@
#define FFL_DEFAULTLISTBOXFONTSIZE 12.0f
CFFL_ListBox::CFFL_ListBox(CPDFSDK_FormFillEnvironment* pApp,
- CPDFSDK_Annot* pWidget)
+ CPDFSDK_Widget* pWidget)
: CFFL_FormFiller(pApp, pWidget) {}
CFFL_ListBox::~CFFL_ListBox() {}
diff --git a/fpdfsdk/formfiller/cffl_listbox.h b/fpdfsdk/formfiller/cffl_listbox.h
index 1ad269ec8e..7c2713ca0f 100644
--- a/fpdfsdk/formfiller/cffl_listbox.h
+++ b/fpdfsdk/formfiller/cffl_listbox.h
@@ -17,7 +17,7 @@ class CBA_FontMap;
class CFFL_ListBox : public CFFL_FormFiller {
public:
- CFFL_ListBox(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Annot* pWidget);
+ CFFL_ListBox(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Widget* pWidget);
~CFFL_ListBox() override;
// CFFL_FormFiller
diff --git a/fpdfsdk/formfiller/cffl_pushbutton.cpp b/fpdfsdk/formfiller/cffl_pushbutton.cpp
index e7d03a61bb..15e15f597b 100644
--- a/fpdfsdk/formfiller/cffl_pushbutton.cpp
+++ b/fpdfsdk/formfiller/cffl_pushbutton.cpp
@@ -10,8 +10,8 @@
#include "fpdfsdk/pdfwindow/PWL_SpecialButton.h"
CFFL_PushButton::CFFL_PushButton(CPDFSDK_FormFillEnvironment* pApp,
- CPDFSDK_Annot* pAnnot)
- : CFFL_Button(pApp, pAnnot) {}
+ CPDFSDK_Widget* pWidget)
+ : CFFL_Button(pApp, pWidget) {}
CFFL_PushButton::~CFFL_PushButton() {}
diff --git a/fpdfsdk/formfiller/cffl_pushbutton.h b/fpdfsdk/formfiller/cffl_pushbutton.h
index c634c263e5..334abc27ad 100644
--- a/fpdfsdk/formfiller/cffl_pushbutton.h
+++ b/fpdfsdk/formfiller/cffl_pushbutton.h
@@ -11,7 +11,7 @@
class CFFL_PushButton : public CFFL_Button {
public:
- CFFL_PushButton(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Annot* pAnnot);
+ CFFL_PushButton(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Widget* pWidget);
~CFFL_PushButton() override;
// CFFL_Button
diff --git a/fpdfsdk/formfiller/cffl_radiobutton.cpp b/fpdfsdk/formfiller/cffl_radiobutton.cpp
index e594d69443..e264a3bf4d 100644
--- a/fpdfsdk/formfiller/cffl_radiobutton.cpp
+++ b/fpdfsdk/formfiller/cffl_radiobutton.cpp
@@ -13,7 +13,7 @@
#include "public/fpdf_fwlevent.h"
CFFL_RadioButton::CFFL_RadioButton(CPDFSDK_FormFillEnvironment* pApp,
- CPDFSDK_Annot* pWidget)
+ CPDFSDK_Widget* pWidget)
: CFFL_Button(pApp, pWidget) {}
CFFL_RadioButton::~CFFL_RadioButton() {}
diff --git a/fpdfsdk/formfiller/cffl_radiobutton.h b/fpdfsdk/formfiller/cffl_radiobutton.h
index 21710bac8d..905fc1b016 100644
--- a/fpdfsdk/formfiller/cffl_radiobutton.h
+++ b/fpdfsdk/formfiller/cffl_radiobutton.h
@@ -11,7 +11,7 @@
class CFFL_RadioButton : public CFFL_Button {
public:
- CFFL_RadioButton(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Annot* pAnnot);
+ CFFL_RadioButton(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Widget* pWidget);
~CFFL_RadioButton() override;
// CFFL_Button
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index 1090f8a251..c34bf3e54e 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -13,8 +13,8 @@
#include "third_party/base/ptr_util.h"
CFFL_TextField::CFFL_TextField(CPDFSDK_FormFillEnvironment* pApp,
- CPDFSDK_Annot* pAnnot)
- : CFFL_FormFiller(pApp, pAnnot) {}
+ CPDFSDK_Widget* pWidget)
+ : CFFL_FormFiller(pApp, pWidget) {}
CFFL_TextField::~CFFL_TextField() {
for (const auto& it : m_Maps)
@@ -258,7 +258,6 @@ bool CFFL_TextField::IsFieldFull(CPDFSDK_PageView* pPageView) {
#endif // PDF_ENABLE_XFA
void CFFL_TextField::OnSetFocus(CPWL_Wnd* pWnd) {
- ASSERT(m_pFormFillEnv);
if (pWnd->GetClassName() != PWL_CLASSNAME_EDIT)
return;
diff --git a/fpdfsdk/formfiller/cffl_textfield.h b/fpdfsdk/formfiller/cffl_textfield.h
index 43b0da9ba4..cde477a392 100644
--- a/fpdfsdk/formfiller/cffl_textfield.h
+++ b/fpdfsdk/formfiller/cffl_textfield.h
@@ -27,7 +27,7 @@ struct FFL_TextFieldState {
class CFFL_TextField : public CFFL_FormFiller, public IPWL_FocusHandler {
public:
- CFFL_TextField(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Annot* pAnnot);
+ CFFL_TextField(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Widget* pWidget);
~CFFL_TextField() override;
// CFFL_FormFiller:
diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.h b/fpdfsdk/pdfwindow/PWL_Wnd.h
index 59de290653..e3b79179c9 100644
--- a/fpdfsdk/pdfwindow/PWL_Wnd.h
+++ b/fpdfsdk/pdfwindow/PWL_Wnd.h
@@ -145,17 +145,6 @@ class IPWL_Provider : public CFX_Observable<IPWL_Provider> {
// get a matrix which map user space to CWnd client space
virtual CFX_Matrix GetWindowMatrix(void* pAttachedData) = 0;
-
- /*
- 0 L"&Undo\tCtrl+Z"
- 1 L"&Redo\tCtrl+Shift+Z"
- 2 L"Cu&t\tCtrl+X"
- 3 L"&Copy\tCtrl+C"
- 4 L"&Paste\tCtrl+V"
- 5 L"&Delete"
- 6 L"&Select All\tCtrl+A"
- */
- virtual CFX_WideString LoadPopupMenuString(int32_t nIndex) = 0;
};
class IPWL_FocusHandler {