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 <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index 94c9b23..57f3a6e 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -622,16 +622,14 @@
return fields;
}
-int CPDFSDK_InterForm::BeforeValueChange(CPDF_FormField* pField,
- const WideString& csValue) {
+bool CPDFSDK_InterForm::BeforeValueChange(CPDF_FormField* pField,
+ const WideString& csValue) {
FormFieldType fieldType = pField->GetFieldType();
if (!IsFormFieldTypeComboOrText(fieldType))
- return 0;
+ return true;
if (!OnKeyStrokeCommit(pField, csValue))
- return -1;
- if (!OnValidate(pField, csValue))
- return -1;
- return 1;
+ return false;
+ return OnValidate(pField, csValue);
}
void CPDFSDK_InterForm::AfterValueChange(CPDF_FormField* pField) {
@@ -650,15 +648,13 @@
UpdateField(pField);
}
-int CPDFSDK_InterForm::BeforeSelectionChange(CPDF_FormField* pField,
- const WideString& csValue) {
+bool CPDFSDK_InterForm::BeforeSelectionChange(CPDF_FormField* pField,
+ const WideString& csValue) {
if (pField->GetFieldType() != FormFieldType::kListBox)
- return 0;
+ return true;
if (!OnKeyStrokeCommit(pField, csValue))
- return -1;
- if (!OnValidate(pField, csValue))
- return -1;
- return 1;
+ return false;
+ return OnValidate(pField, csValue);
}
void CPDFSDK_InterForm::AfterSelectionChange(CPDF_FormField* pField) {