diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-10-18 21:39:40 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-18 21:39:40 +0000 |
commit | 0e5bab1b8402b65fa09a36a2b141bbf22291f822 (patch) | |
tree | e6d714f10fc9c552ea043073d17047f969f28f13 /fxjs/cjs_app.cpp | |
parent | ae2aec8712aa4c52454737467869b9d256baa05f (diff) | |
download | pdfium-0e5bab1b8402b65fa09a36a2b141bbf22291f822.tar.xz |
Remove PrintParams object.
The only way to theoretically get one is via doc.getPrintParams(),
and it always returns in error.
Even if one were returend to JS, there aren't any methods/callbacks
to change its properties.
Even if there were methods to change its properties, the information
it stores doesn't align with what is in the JS spec for this object.
Even if it were aligned with the JS spec, the way we check for its
presence as the ninth parameter in CJS_Document::print() doesn't
match the way its use is documented in the spec as the sole
first parameter.
Instead implement the older, simpler behaviour as spec'd prior to
6.0, and toss this enhancement altogether.
Move function to check the result of ExpandKeywordParams() to
js_define.h so other files can use it. Update comment in that
file to remove reference to deprecated enum.
Expand test for API and introduce callback to log parameters.
Change-Id: I047e2be0d2afbad91d6b58c6c74bbea083fed330
Reviewed-on: https://pdfium-review.googlesource.com/c/44271
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fxjs/cjs_app.cpp')
-rw-r--r-- | fxjs/cjs_app.cpp | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp index e217753062..f279250fb0 100644 --- a/fxjs/cjs_app.cpp +++ b/fxjs/cjs_app.cpp @@ -21,17 +21,6 @@ #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" #endif // PDF_ENABLE_XFA -namespace { - -bool IsTypeKnown(v8::Local<v8::Value> value) { - return !value.IsEmpty() && - (value->IsString() || value->IsNumber() || value->IsBoolean() || - value->IsDate() || value->IsObject() || value->IsNull() || - value->IsUndefined()); -} - -} // namespace - #define JS_STR_VIEWERTYPE L"pdfium" #define JS_STR_VIEWERVARIATION L"Full" #define JS_STR_PLATFORM L"WIN" @@ -237,7 +226,7 @@ CJS_Result CJS_App::alert(CJS_Runtime* pRuntime, std::vector<v8::Local<v8::Value>> newParams = ExpandKeywordParams( pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle"); - if (!IsTypeKnown(newParams[0])) + if (!IsExpandedParamKnown(newParams[0])) return CJS_Result::Failure(JSMessage::kParamError); CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv(); @@ -260,15 +249,15 @@ CJS_Result CJS_App::alert(CJS_Runtime* pRuntime, } int iIcon = JSPLATFORM_ALERT_ICON_DEFAULT; - if (IsTypeKnown(newParams[1])) + if (IsExpandedParamKnown(newParams[1])) iIcon = pRuntime->ToInt32(newParams[1]); int iType = JSPLATFORM_ALERT_BUTTON_DEFAULT; - if (IsTypeKnown(newParams[2])) + if (IsExpandedParamKnown(newParams[2])) iType = pRuntime->ToInt32(newParams[2]); WideString swTitle; - if (IsTypeKnown(newParams[3])) + if (IsExpandedParamKnown(newParams[3])) swTitle = pRuntime->ToWideString(newParams[3]); else swTitle = JSGetStringFromID(JSMessage::kAlert); @@ -288,7 +277,7 @@ CJS_Result CJS_App::beep(CJS_Runtime* pRuntime, return CJS_Result::Failure(JSMessage::kParamError); int type = JSPLATFORM_BEEP_DEFAULT; - if (IsTypeKnown(params[0])) + if (IsExpandedParamKnown(params[0])) type = pRuntime->ToInt32(params[0]); pRuntime->GetFormFillEnv()->JS_appBeep(type); @@ -448,12 +437,12 @@ CJS_Result CJS_App::mailMsg(CJS_Runtime* pRuntime, ExpandKeywordParams(pRuntime, params, 6, L"bUI", L"cTo", L"cCc", L"cBcc", L"cSubject", L"cMsg"); - if (!IsTypeKnown(newParams[0])) + if (!IsExpandedParamKnown(newParams[0])) return CJS_Result::Failure(JSMessage::kParamError); bool bUI = pRuntime->ToBoolean(newParams[0]); WideString cTo; - if (IsTypeKnown(newParams[1])) { + if (IsExpandedParamKnown(newParams[1])) { cTo = pRuntime->ToWideString(newParams[1]); } else { // cTo parameter required when UI not invoked. @@ -462,19 +451,19 @@ CJS_Result CJS_App::mailMsg(CJS_Runtime* pRuntime, } WideString cCc; - if (IsTypeKnown(newParams[2])) + if (IsExpandedParamKnown(newParams[2])) cCc = pRuntime->ToWideString(newParams[2]); WideString cBcc; - if (IsTypeKnown(newParams[3])) + if (IsExpandedParamKnown(newParams[3])) cBcc = pRuntime->ToWideString(newParams[3]); WideString cSubject; - if (IsTypeKnown(newParams[4])) + if (IsExpandedParamKnown(newParams[4])) cSubject = pRuntime->ToWideString(newParams[4]); WideString cMsg; - if (IsTypeKnown(newParams[5])) + if (IsExpandedParamKnown(newParams[5])) cMsg = pRuntime->ToWideString(newParams[5]); pRuntime->BeginBlock(); @@ -546,24 +535,24 @@ CJS_Result CJS_App::response(CJS_Runtime* pRuntime, ExpandKeywordParams(pRuntime, params, 5, L"cQuestion", L"cTitle", L"cDefault", L"bPassword", L"cLabel"); - if (!IsTypeKnown(newParams[0])) + if (!IsExpandedParamKnown(newParams[0])) return CJS_Result::Failure(JSMessage::kParamError); WideString swQuestion = pRuntime->ToWideString(newParams[0]); WideString swTitle = L"PDF"; - if (IsTypeKnown(newParams[1])) + if (IsExpandedParamKnown(newParams[1])) swTitle = pRuntime->ToWideString(newParams[1]); WideString swDefault; - if (IsTypeKnown(newParams[2])) + if (IsExpandedParamKnown(newParams[2])) swDefault = pRuntime->ToWideString(newParams[2]); bool bPassword = false; - if (IsTypeKnown(newParams[3])) + if (IsExpandedParamKnown(newParams[3])) bPassword = pRuntime->ToBoolean(newParams[3]); WideString swLabel; - if (IsTypeKnown(newParams[4])) + if (IsExpandedParamKnown(newParams[4])) swLabel = pRuntime->ToWideString(newParams[4]); const int MAX_INPUT_BYTES = 2048; |