summaryrefslogtreecommitdiff
path: root/fxjs/xfa/cjx_treelist.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-12-11 22:01:08 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-11 22:01:08 +0000
commitcb22f9ad9265f40b1104ed2b09488ccc6ec9e5aa (patch)
tree4aaa14dfb0528268fb9a9a94a4cac82df1af4602 /fxjs/xfa/cjx_treelist.cpp
parent731526e3b9f32ceac1cdac600fe3ecd55a0bc9b5 (diff)
downloadpdfium-cb22f9ad9265f40b1104ed2b09488ccc6ec9e5aa.tar.xz
[xfa] Refactor CJX method signatures.
This CL changes the CJX methods from void (*)(CFXJSE_Arguments*) to CJS_Return (*)(CJS_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) which is closer to how CJS works in practice. Change-Id: I3a3129268acfe4262dfeb04179919ed19f6c24e1 Reviewed-on: https://pdfium-review.googlesource.com/20491 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/xfa/cjx_treelist.cpp')
-rw-r--r--fxjs/xfa/cjx_treelist.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/fxjs/xfa/cjx_treelist.cpp b/fxjs/xfa/cjx_treelist.cpp
index f82f30db29..bb9e4167f8 100644
--- a/fxjs/xfa/cjx_treelist.cpp
+++ b/fxjs/xfa/cjx_treelist.cpp
@@ -6,9 +6,11 @@
#include "fxjs/xfa/cjx_treelist.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_treelist.h"
@@ -27,19 +29,21 @@ CXFA_TreeList* CJX_TreeList::GetXFATreeList() {
return static_cast<CXFA_TreeList*>(GetXFAObject());
}
-void CJX_TreeList::namedItem(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 1) {
- ThrowParamCountMismatchException(L"namedItem");
- return;
- }
+CJS_Return CJX_TreeList::namedItem(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- ByteString szName = pArguments->GetUTF8String(0);
CXFA_Node* pNode = GetXFATreeList()->NamedItem(
- WideString::FromUTF8(szName.AsStringView()).AsStringView());
+ runtime->ToWideString(params[0]).AsStringView());
if (!pNode)
- return;
+ return CJS_Return(true);
+
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode));
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}