From 507fb4ed09d5fbc92fafdfe405d79d44d11a4664 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Thu, 8 Mar 2018 15:14:09 +0000 Subject: Convert Before{Selection|Value}Change to return a bool Both of these IPDF_FormNotify methods return {-1, 0, 1} but all callsites only care about < 0 and >= 0. Convert to return a bool that treats the 0 and 1 case as the same. This also makse sense in terms of the API because false means validation failure. The case where 0 was used was a place holder for we didn't try for this field type, which also implicitly means validation passed. Change-Id: I0950c678191b83caffd755d4a87b2f0efee71c89 Reviewed-on: https://pdfium-review.googlesource.com/28192 Commit-Queue: Ryan Harrison Reviewed-by: Ryan Harrison --- core/fpdfdoc/cpdf_formfield.cpp | 4 ++-- core/fpdfdoc/cpdf_interform.cpp | 4 ++-- core/fpdfdoc/ipdf_formnotify.h | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'core') diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp index 686054f9f1..679acd1dc8 100644 --- a/core/fpdfdoc/cpdf_formfield.cpp +++ b/core/fpdfdoc/cpdf_formfield.cpp @@ -928,7 +928,7 @@ void CPDF_FormField::LoadDA() { bool CPDF_FormField::NotifyBeforeSelectionChange(const WideString& value) { if (!m_pForm->GetFormNotify()) return true; - return m_pForm->GetFormNotify()->BeforeSelectionChange(this, value) >= 0; + return m_pForm->GetFormNotify()->BeforeSelectionChange(this, value); } void CPDF_FormField::NotifyAfterSelectionChange() { @@ -940,7 +940,7 @@ void CPDF_FormField::NotifyAfterSelectionChange() { bool CPDF_FormField::NotifyBeforeValueChange(const WideString& value) { if (!m_pForm->GetFormNotify()) return true; - return m_pForm->GetFormNotify()->BeforeValueChange(this, value) >= 0; + return m_pForm->GetFormNotify()->BeforeValueChange(this, value); } void CPDF_FormField::NotifyAfterValueChange() { diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp index c8440eac00..2fbc3aa32a 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -1203,11 +1203,11 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, FormFieldType fieldType = pField->GetFieldType(); if (bNotify && m_pFormNotify) { if (fieldType == FormFieldType::kListBox) { - if (m_pFormNotify->BeforeSelectionChange(pField, csWValue) < 0) + if (!m_pFormNotify->BeforeSelectionChange(pField, csWValue)) return; } else if (fieldType == FormFieldType::kComboBox || fieldType == FormFieldType::kTextField) { - if (m_pFormNotify->BeforeValueChange(pField, csWValue) < 0) + if (!m_pFormNotify->BeforeValueChange(pField, csWValue)) return; } } diff --git a/core/fpdfdoc/ipdf_formnotify.h b/core/fpdfdoc/ipdf_formnotify.h index 10a97a0d88..053ca12a41 100644 --- a/core/fpdfdoc/ipdf_formnotify.h +++ b/core/fpdfdoc/ipdf_formnotify.h @@ -16,12 +16,12 @@ class IPDF_FormNotify { public: virtual ~IPDF_FormNotify() {} - virtual int BeforeValueChange(CPDF_FormField* pField, - const WideString& csValue) = 0; + virtual bool BeforeValueChange(CPDF_FormField* pField, + const WideString& csValue) = 0; virtual void AfterValueChange(CPDF_FormField* pField) = 0; - virtual int BeforeSelectionChange(CPDF_FormField* pField, - const WideString& csValue) = 0; + virtual bool BeforeSelectionChange(CPDF_FormField* pField, + const WideString& csValue) = 0; virtual void AfterSelectionChange(CPDF_FormField* pField) = 0; virtual void AfterCheckedStatusChange(CPDF_FormField* pField) = 0; -- cgit v1.2.3