summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-06 16:40:21 -0700
committerLei Zhang <thestig@chromium.org>2015-10-06 16:40:21 -0700
commit38340f322974fc372025f39d6b8d89c520758cd2 (patch)
treec6c9718ccebfc035eeda548ae7f4f0cb9ef4059e
parentb8a074711108baf04017d86207e08c19ff327d8e (diff)
downloadpdfium-38340f322974fc372025f39d6b8d89c520758cd2.tar.xz
Merge to M47: Do not call into formfiller code with a NULL PageView.
BUG=537173 TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1376093002 . (cherry picked from commit ac67d4765a8ac36cd00c9fc8b6f2b80a3e1cff72) Review URL: https://codereview.chromium.org/1386273003 .
-rw-r--r--fpdfsdk/include/formfiller/FFL_FormFiller.h4
-rw-r--r--fpdfsdk/src/formfiller/FFL_FormFiller.cpp21
-rw-r--r--fpdfsdk/src/formfiller/FFL_IFormFiller.cpp5
3 files changed, 14 insertions, 16 deletions
diff --git a/fpdfsdk/include/formfiller/FFL_FormFiller.h b/fpdfsdk/include/formfiller/FFL_FormFiller.h
index 799154cedd..35b4bdf59b 100644
--- a/fpdfsdk/include/formfiller/FFL_FormFiller.h
+++ b/fpdfsdk/include/formfiller/FFL_FormFiller.h
@@ -76,8 +76,8 @@ class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler {
FX_UINT nFlags);
virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags);
- FX_BOOL SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag);
- FX_BOOL KillFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag);
+ void SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag);
+ void KillFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag);
// CPWL_TimerHandler
void TimerProc() override;
diff --git a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
index 80e1b0e887..1bd2944636 100644
--- a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
@@ -242,8 +242,7 @@ FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot,
return FALSE;
}
-FX_BOOL CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot,
- FX_UINT nFlag) {
+void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
CPDF_Page* pPage = pWidget->GetPDFPage();
CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument();
@@ -254,31 +253,31 @@ FX_BOOL CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot,
m_bValid = TRUE;
FX_RECT rcRect = GetViewBBox(pPageView, pAnnot);
InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom);
- return TRUE;
}
-FX_BOOL CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot,
- FX_UINT nFlag) {
+void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
if (!IsValid())
- return TRUE;
+ return;
CPDFSDK_PageView* pPageView = GetCurPageView();
+ if (!pPageView)
+ return;
+
CommitData(pPageView, nFlag);
if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE))
pWnd->KillFocus();
+ FX_BOOL bDestroyPDFWindow;
switch (m_pWidget->GetFieldType()) {
case FIELDTYPE_PUSHBUTTON:
case FIELDTYPE_CHECKBOX:
case FIELDTYPE_RADIOBUTTON:
- EscapeFiller(pPageView, TRUE);
- break;
+ bDestroyPDFWindow = TRUE;
default:
- EscapeFiller(pPageView, FALSE);
- break;
+ bDestroyPDFWindow = FALSE;
}
- return TRUE;
+ EscapeFiller(pPageView, bDestroyPDFWindow);
}
FX_BOOL CFFL_FormFiller::IsValid() const {
diff --git a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
index f8f8c6a943..69ff93280e 100644
--- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
@@ -459,7 +459,7 @@ FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
}
if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE))
- return pFormFiller->SetFocusForAnnot(pAnnot, nFlag);
+ pFormFiller->SetFocusForAnnot(pAnnot, nFlag);
return TRUE;
}
@@ -470,8 +470,7 @@ FX_BOOL CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
- if (!pFormFiller->KillFocusForAnnot(pAnnot, nFlag))
- return FALSE;
+ pFormFiller->KillFocusForAnnot(pAnnot, nFlag);
if (!m_bNotifying) {
CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;