Follow up to removing JS alert/beep magic numbers
Cleanup CL to address some comments on
https://pdfium-review.googlesource.com/c/pdfium/+/35730 that appeared
after I sent it to the CQ.
Change-Id: I7d5539101547a79d6fc3edf45720b60a1112e2e5
Reviewed-on: https://pdfium-review.googlesource.com/35951
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index d7b3bed..f2bfff6 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -36,18 +36,24 @@
extern int GetLastError();
#endif
-#define IS_VALID_ALERT_BUTTON(type) \
- ((type) == JSPLATFORM_ALERT_BUTTON_OK || \
- (type) == JSPLATFORM_ALERT_BUTTON_OKCANCEL || \
- (type) == JSPLATFORM_ALERT_BUTTON_YESNO || \
- (type) == JSPLATFORM_ALERT_BUTTON_YESNOCANCEL)
+namespace {
-#define IS_VALID_ALERT_ICON(type) \
- ((type) == JSPLATFORM_ALERT_ICON_ERROR || \
- (type) == JSPLATFORM_ALERT_ICON_WARNING || \
- (type) == JSPLATFORM_ALERT_ICON_QUESTION || \
- (type) == JSPLATFORM_ALERT_ICON_STATUS || \
- (type) == JSPLATFORM_ALERT_ICON_ASTERISK)
+bool IsValidAlertButton(int type) {
+ return type == JSPLATFORM_ALERT_BUTTON_OK ||
+ type == JSPLATFORM_ALERT_BUTTON_OKCANCEL ||
+ type == JSPLATFORM_ALERT_BUTTON_YESNO ||
+ type == JSPLATFORM_ALERT_BUTTON_YESNOCANCEL;
+}
+
+bool IsValidAlertIcon(int type) {
+ return type == JSPLATFORM_ALERT_ICON_ERROR ||
+ type == JSPLATFORM_ALERT_ICON_WARNING ||
+ type == JSPLATFORM_ALERT_ICON_QUESTION ||
+ type == JSPLATFORM_ALERT_ICON_STATUS ||
+ type == JSPLATFORM_ALERT_ICON_ASTERISK;
+}
+
+} // namespace
CPDFXFA_Context::CPDFXFA_Context(CPDF_Document* pPDFDoc)
: m_pPDFDoc(pPDFDoc),
@@ -260,10 +266,9 @@
if (!m_pFormFillEnv || m_nLoadStatus != FXFA_LOADSTATUS_LOADED)
return -1;
- int iconType = IS_VALID_ALERT_ICON(dwIconType)
- ? dwIconType
- : JSPLATFORM_ALERT_ICON_DEFAULT;
- int iButtonType = IS_VALID_ALERT_BUTTON(dwButtonType)
+ int iconType =
+ IsValidAlertIcon(dwIconType) ? dwIconType : JSPLATFORM_ALERT_ICON_DEFAULT;
+ int iButtonType = IsValidAlertButton(dwButtonType)
? dwButtonType
: JSPLATFORM_ALERT_BUTTON_DEFAULT;
return m_pFormFillEnv->JS_appAlert(wsMessage, wsTitle, iButtonType, iconType);
diff --git a/public/fpdf_formfill.h b/public/fpdf_formfill.h
index 915c07a..0bc08ec 100644
--- a/public/fpdf_formfill.h
+++ b/public/fpdf_formfill.h
@@ -76,7 +76,7 @@
* JSPLATFORM_ALERT_ICON_* above .
*
* Return Value:
- * Option selected by user in dialogue, see see
+ * Option selected by user in dialogue, see
* JSPLATFORM_ALERT_RETURN_* above.
*/
int (*app_alert)(struct _IPDF_JsPlatform* pThis,