summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/app.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-26 09:28:59 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-26 17:14:48 +0000
commit3a1ba8efdbfffad723646dd878e6ca511f9f75bd (patch)
tree3d025f32729479faa9628668cac0654f13e45a37 /fpdfsdk/javascript/app.cpp
parent8b6acddd1e25dd48582f954ea9e67861dbd4f50f (diff)
downloadpdfium-3a1ba8efdbfffad723646dd878e6ca511f9f75bd.tar.xz
Remove CJS_Array
This CL removes the CJS_Array wrapper and uses the v8 objects directly. Change-Id: I904f76e59e27d65db4b4d0bbd503fddb3e8cfc6f Reviewed-on: https://pdfium-review.googlesource.com/16830 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/app.cpp')
-rw-r--r--fpdfsdk/javascript/app.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index e65ec2d0b6..1d78c1df53 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -224,15 +224,13 @@ CJS_Return app::get_active_docs(CJS_Runtime* pRuntime) {
if (CFXJS_Engine::GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID)
pJSDocument = static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj));
- CJS_Array aDocs;
- aDocs.SetElement(pRuntime, 0,
- pJSDocument ? v8::Local<v8::Value>(pJSDocument->ToV8Object())
- : v8::Local<v8::Value>());
- if (aDocs.GetLength(pRuntime) > 0) {
- if (aDocs.ToV8Value().IsEmpty())
- return CJS_Return(pRuntime->NewArray());
- return CJS_Return(aDocs.ToV8Value());
- }
+ v8::Local<v8::Array> aDocs = pRuntime->NewArray();
+ pRuntime->PutArrayElement(
+ aDocs, 0,
+ pJSDocument ? v8::Local<v8::Value>(pJSDocument->ToV8Object())
+ : v8::Local<v8::Value>());
+ if (pRuntime->GetArrayLength(aDocs) > 0)
+ return CJS_Return(aDocs);
return CJS_Return(pRuntime->NewUndefined());
}
@@ -361,13 +359,13 @@ CJS_Return app::alert(CJS_Runtime* pRuntime,
WideString swMsg;
if (newParams[0]->IsArray()) {
- CJS_Array carray(pRuntime->ToArray(newParams[0]));
+ v8::Local<v8::Array> carray = pRuntime->ToArray(newParams[0]);
swMsg = L"[";
- for (int i = 0; i < carray.GetLength(pRuntime); ++i) {
+ for (size_t i = 0; i < pRuntime->GetArrayLength(carray); ++i) {
if (i)
swMsg += L", ";
- swMsg += pRuntime->ToWideString(carray.GetElement(pRuntime, i));
+ swMsg += pRuntime->ToWideString(pRuntime->GetArrayElement(carray, i));
}
swMsg += L"]";
} else {