summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/Document.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-24 15:15:27 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-24 19:28:02 +0000
commit3cac3602f24f56413cc2ca312731675fc080b7ef (patch)
treecc5741593ce51f41276be2f8a1826bf452a7841c /fpdfsdk/javascript/Document.cpp
parent1b2a18ec4ed99fc2ac56b5fde230bc2b348d9725 (diff)
downloadpdfium-3cac3602f24f56413cc2ca312731675fc080b7ef.tar.xz
Remove GetType from CJS_Value
This CL removes the GetType method from CJS_Value and, instead, retrieves the value from the v8 object directly. Change-Id: Ia8390f3ead163c09a39cae493e75fccdd41a0961 Reviewed-on: https://pdfium-review.googlesource.com/16615 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/Document.cpp')
-rw-r--r--fpdfsdk/javascript/Document.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 68023d02b0..22fe8b4c80 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -447,7 +447,7 @@ bool Document::print(CJS_Runtime* pRuntime,
bool bAnnotations = false;
int nlength = params.size();
if (nlength == 9) {
- if (params[8].GetType() == CJS_Value::VT_object) {
+ if (params[8].ToV8Value()->IsObject()) {
v8::Local<v8::Object> pObj = pRuntime->ToObject(params[8].ToV8Value());
if (CFXJS_Engine::GetObjDefnID(pObj) ==
CJS_PrintParamsObj::g_nObjDefnID) {
@@ -584,14 +584,10 @@ bool Document::resetForm(CJS_Runtime* pRuntime,
return true;
}
- switch (params[0].GetType()) {
- default:
- aName = CJS_Array(pRuntime->ToArray(params[0].ToV8Value()));
- break;
- case CJS_Value::VT_string:
- aName.SetElement(pRuntime, 0, params[0]);
- break;
- }
+ if (params[0].ToV8Value()->IsString())
+ aName.SetElement(pRuntime, 0, params[0]);
+ else
+ aName = CJS_Array(pRuntime->ToArray(params[0].ToV8Value()));
std::vector<CPDF_FormField*> aFields;
for (int i = 0, isz = aName.GetLength(pRuntime); i < isz; ++i) {
@@ -643,7 +639,7 @@ bool Document::submitForm(CJS_Runtime* pRuntime,
bool bFDF = true;
bool bEmpty = false;
CJS_Value v(params[0]);
- if (v.GetType() == CJS_Value::VT_string) {
+ if (v.ToV8Value()->IsString()) {
strURL = pRuntime->ToWideString(params[0].ToV8Value());
if (nSize > 1)
bFDF = pRuntime->ToBoolean(params[1].ToV8Value());
@@ -651,7 +647,7 @@ bool Document::submitForm(CJS_Runtime* pRuntime,
bEmpty = pRuntime->ToBoolean(params[2].ToV8Value());
if (nSize > 3)
aFields = CJS_Array(pRuntime->ToArray(params[3].ToV8Value()));
- } else if (v.GetType() == CJS_Value::VT_object) {
+ } else if (v.ToV8Value()->IsObject()) {
v8::Local<v8::Object> pObj = pRuntime->ToObject(params[0].ToV8Value());
v8::Local<v8::Value> pValue = pRuntime->GetObjectProperty(pObj, L"cURL");
if (!pValue.IsEmpty())
@@ -737,7 +733,7 @@ bool Document::mailDoc(CJS_Runtime* pRuntime,
if (params.size() >= 6)
cMsg = pRuntime->ToWideString(params[5].ToV8Value());
- if (params.size() >= 1 && params[0].GetType() == CJS_Value::VT_object) {
+ if (params.size() >= 1 && params[0].ToV8Value()->IsObject()) {
v8::Local<v8::Object> pObj = pRuntime->ToObject(params[0].ToV8Value());
bUI = pRuntime->ToBoolean(pRuntime->GetObjectProperty(pObj, L"bUI"));
cTo = pRuntime->ToWideString(pRuntime->GetObjectProperty(pObj, L"cTo"));
@@ -1371,7 +1367,7 @@ bool Document::addIcon(CJS_Runtime* pRuntime,
}
WideString swIconName = pRuntime->ToWideString(params[0].ToV8Value());
- if (params[1].GetType() != CJS_Value::VT_object) {
+ if (!params[1].ToV8Value()->IsObject()) {
sError = JSGetStringFromID(IDS_STRING_JSTYPEERROR);
return false;
}