diff options
author | Ryan Harrison <rharrison@chromium.org> | 2018-06-22 19:15:05 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-22 19:15:05 +0000 |
commit | 8b8031dc46c892e3cb67535f2540bb863648ed3b (patch) | |
tree | 44bfd8068c90ee3ae2e9db9e061d271fa27e2017 /fpdfsdk | |
parent | 9fff1c76c1083a5cc0543911811e36007a38aa3a (diff) | |
download | pdfium-8b8031dc46c892e3cb67535f2540bb863648ed3b.tar.xz |
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>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_context.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp index d7b3bed849..f2bfff6fa6 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp @@ -36,18 +36,24 @@ extern void SetLastError(int err); 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) - -#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) +namespace { + +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 @@ int32_t CPDFXFA_Context::MsgBox(const WideString& wsMessage, 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); |