diff options
author | Ryan Harrison <rharrison@chromium.org> | 2018-06-21 21:09:54 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-21 21:09:54 +0000 |
commit | c3cc2ab66d3d8f52dea8083abb6775115e17af7d (patch) | |
tree | 227eb764e7ee1f674f9ac992ec6620e4e57e2b01 /fxjs/cjs_app.cpp | |
parent | aaaf9877478d7add8a74b4db74d97ca19ce1c47e (diff) | |
download | pdfium-c3cc2ab66d3d8f52dea8083abb6775115e17af7d.tar.xz |
Clean up constant values for JS alert and beep
Define constant values in the public API for the valid values of alert
button type, alert icon type, and beep type. Replace various magic
numbers through out the code base using these values. Also replace the
XFA specific versions with an enum class that is guaranteed to have the
same values, instead of #defines that just happen to.
This CL does not attempt to add error checking on these values, since
it currently doesn't exist so adding it may cause regressions.
Change-Id: Ief3aee2a4ad419691c18fc1dba8b984ad222141b
Reviewed-on: https://pdfium-review.googlesource.com/35730
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/cjs_app.cpp')
-rw-r--r-- | fxjs/cjs_app.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp index 36a1212715..f52d7e9230 100644 --- a/fxjs/cjs_app.cpp +++ b/fxjs/cjs_app.cpp @@ -254,11 +254,11 @@ CJS_Return CJS_App::alert(CJS_Runtime* pRuntime, swMsg = pRuntime->ToWideString(newParams[0]); } - int iIcon = 0; + int iIcon = JSPLATFORM_ALERT_ICON_DEFAULT; if (IsTypeKnown(newParams[1])) iIcon = pRuntime->ToInt32(newParams[1]); - int iType = 0; + int iType = JSPLATFORM_ALERT_BUTTON_DEFAULT; if (IsTypeKnown(newParams[2])) iType = pRuntime->ToInt32(newParams[2]); @@ -282,7 +282,11 @@ CJS_Return CJS_App::beep(CJS_Runtime* pRuntime, if (params.size() != 1) return CJS_Return(JSMessage::kParamError); - pRuntime->GetFormFillEnv()->JS_appBeep(pRuntime->ToInt32(params[0])); + int type = JSPLATFORM_BEEP_DEFAULT; + if (IsTypeKnown(params[0])) + type = pRuntime->ToInt32(params[0]); + + pRuntime->GetFormFillEnv()->JS_appBeep(type); return CJS_Return(); } |