summaryrefslogtreecommitdiff
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
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>
-rw-r--r--fxjs/CJX_Define.h30
-rw-r--r--fxjs/cfxjse_class.cpp25
-rw-r--r--fxjs/cfxjse_engine.cpp51
-rw-r--r--fxjs/cfxjse_engine.h15
-rw-r--r--fxjs/cfxjse_formcalc_context.cpp1
-rw-r--r--fxjs/cfxjse_resolveprocessor.cpp2
-rw-r--r--fxjs/cjs_v8.cpp42
-rw-r--r--fxjs/cjs_v8.h11
-rw-r--r--fxjs/cjx_datawindow.cpp27
-rw-r--r--fxjs/cjx_eventpseudomodel.cpp25
-rw-r--r--fxjs/cjx_hostpseudomodel.cpp477
-rw-r--r--fxjs/cjx_hostpseudomodel.h4
-rw-r--r--fxjs/cjx_layoutpseudomodel.cpp285
-rw-r--r--fxjs/cjx_layoutpseudomodel.h11
-rw-r--r--fxjs/cjx_logpseudomodel.cpp33
-rw-r--r--fxjs/cjx_node.cpp233
-rw-r--r--fxjs/cjx_object.cpp12
-rw-r--r--fxjs/cjx_object.h22
-rw-r--r--fxjs/cjx_signaturepseudomodel.cpp64
-rw-r--r--fxjs/fxjse.h6
-rw-r--r--fxjs/js_resources.cpp2
-rw-r--r--fxjs/js_resources.h3
-rw-r--r--fxjs/xfa/cjx_container.cpp18
-rw-r--r--fxjs/xfa/cjx_content.cpp1
-rw-r--r--fxjs/xfa/cjx_delta.cpp12
-rw-r--r--fxjs/xfa/cjx_desc.cpp16
-rw-r--r--fxjs/xfa/cjx_exclgroup.cpp116
-rw-r--r--fxjs/xfa/cjx_field.cpp281
-rw-r--r--fxjs/xfa/cjx_form.cpp110
-rw-r--r--fxjs/xfa/cjx_instancemanager.cpp171
-rw-r--r--fxjs/xfa/cjx_list.cpp91
-rw-r--r--fxjs/xfa/cjx_manifest.cpp20
-rw-r--r--fxjs/xfa/cjx_model.cpp101
-rw-r--r--fxjs/xfa/cjx_packet.cpp62
-rw-r--r--fxjs/xfa/cjx_source.cpp146
-rw-r--r--fxjs/xfa/cjx_subform.cpp74
-rw-r--r--fxjs/xfa/cjx_template.cpp84
-rw-r--r--fxjs/xfa/cjx_textnode.cpp1
-rw-r--r--fxjs/xfa/cjx_tree.cpp91
-rw-r--r--fxjs/xfa/cjx_treelist.cpp28
-rw-r--r--fxjs/xfa/cjx_wsdlconnection.cpp17
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp2
-rw-r--r--xfa/fxfa/fxfa_basic.h10
-rw-r--r--xfa/fxfa/parser/cscript_datawindow.cpp1
-rw-r--r--xfa/fxfa/parser/cscript_eventpseudomodel.cpp1
-rw-r--r--xfa/fxfa/parser/cscript_hostpseudomodel.cpp1
-rw-r--r--xfa/fxfa/parser/cscript_layoutpseudomodel.cpp1
-rw-r--r--xfa/fxfa/parser/cscript_logpseudomodel.cpp1
-rw-r--r--xfa/fxfa/parser/cscript_signaturepseudomodel.cpp1
49 files changed, 1438 insertions, 1401 deletions
diff --git a/fxjs/CJX_Define.h b/fxjs/CJX_Define.h
index 3d8a84b7ac..070e7d7557 100644
--- a/fxjs/CJX_Define.h
+++ b/fxjs/CJX_Define.h
@@ -7,18 +7,28 @@
#ifndef FXJS_CJX_DEFINE_H_
#define FXJS_CJX_DEFINE_H_
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
-template <class C, void (C::*M)(CFXJSE_Arguments* args)>
-void JSMethod(C* node, CFXJSE_Arguments* args) {
- (node->*M)(args);
+#include "fxjs/cjs_return.h"
+#include "fxjs/cjs_v8.h"
+
+template <class C,
+ CJS_Return (C::*M)(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params)>
+CJS_Return JSMethod(C* node,
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return (node->*M)(runtime, params);
}
-#define JS_METHOD(method_name, class_name) \
- static void method_name##_static(CJX_Object* node, CFXJSE_Arguments* args) { \
- JSMethod<class_name, &class_name::method_name>( \
- static_cast<class_name*>(node), args); \
- } \
- void method_name(CFXJSE_Arguments* pArguments)
+#define JS_METHOD(method_name, class_name) \
+ static CJS_Return method_name##_static( \
+ CJX_Object* node, CJS_V8* runtime, \
+ const std::vector<v8::Local<v8::Value>>& params) { \
+ return JSMethod<class_name, &class_name::method_name>( \
+ static_cast<class_name*>(node), runtime, params); \
+ } \
+ CJS_Return method_name(CJS_V8* runtime, \
+ const std::vector<v8::Local<v8::Value>>& params)
#endif // FXJS_CJX_DEFINE_H_
diff --git a/fxjs/cfxjse_class.cpp b/fxjs/cfxjse_class.cpp
index 09976d1aa5..9515ef4b74 100644
--- a/fxjs/cfxjse_class.cpp
+++ b/fxjs/cfxjse_class.cpp
@@ -12,6 +12,8 @@
#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_context.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/cjs_return.h"
+#include "fxjs/js_resources.h"
#include "third_party/base/ptr_util.h"
namespace {
@@ -78,15 +80,21 @@ void DynPropGetterAdapter_MethodCallback(
v8::Local<v8::String> hPropName =
hCallBackInfo->GetInternalField(1).As<v8::String>();
ASSERT(lpClass && !hPropName.IsEmpty());
+
v8::String::Utf8Value szPropName(hPropName);
- ByteStringView szFxPropName = *szPropName;
- auto lpThisValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
- lpThisValue->ForceSetValue(info.Holder());
- auto lpRetValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
- CFXJSE_Arguments impl(&info, lpRetValue.get());
- lpClass->dynMethodCall(lpThisValue.get(), szFxPropName, impl);
- if (!lpRetValue->DirectGetValue().IsEmpty())
- info.GetReturnValue().Set(lpRetValue->DirectGetValue());
+ WideString szFxPropName = WideString::FromUTF8(*szPropName);
+
+ CJS_Return result = lpClass->dynMethodCall(info, szFxPropName);
+ if (result.HasError()) {
+ WideString err = JSFormatErrorString(*szPropName, "", result.Error());
+ v8::MaybeLocal<v8::String> str = v8::String::NewFromUtf8(
+ info.GetIsolate(), ByteString::FromUnicode(err).c_str(),
+ v8::NewStringType::kNormal);
+ info.GetIsolate()->ThrowException(str.ToLocalChecked());
+ return;
+ }
+ if (result.HasReturn())
+ info.GetReturnValue().Set(result.Return());
}
void DynPropGetterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
@@ -94,6 +102,7 @@ void DynPropGetterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
const ByteStringView& szPropName,
CFXJSE_Value* pValue) {
ASSERT(lpClass);
+
int32_t nPropType =
lpClass->dynPropTypeGetter == nullptr
? FXJSE_ClassPropType_Property
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp
index 4f086e22e2..9d37f3e409 100644
--- a/fxjs/cfxjse_engine.cpp
+++ b/fxjs/cfxjse_engine.cpp
@@ -11,7 +11,6 @@
#include "core/fxcrt/autorestorer.h"
#include "core/fxcrt/cfx_widetextbuf.h"
#include "core/fxcrt/fx_extension.h"
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_class.h"
#include "fxjs/cfxjse_resolveprocessor.h"
#include "fxjs/cfxjse_value.h"
@@ -70,6 +69,19 @@ CXFA_ThisProxy* ToThisProxy(CFXJSE_Value* pValue, CFXJSE_Class* pClass) {
} // namespace
+// static
+CXFA_Object* CFXJSE_Engine::ToObject(
+ const v8::FunctionCallbackInfo<v8::Value>& info) {
+ if (!info.Holder()->IsObject())
+ return nullptr;
+
+ CFXJSE_HostObject* hostObj =
+ FXJSE_RetrieveObjectBinding(info.Holder().As<v8::Object>(), nullptr);
+ if (!hostObj || hostObj->type() != CFXJSE_HostObject::kXFA)
+ return nullptr;
+ return static_cast<CXFA_Object*>(hostObj);
+}
+
// static.
CXFA_Object* CFXJSE_Engine::ToObject(CFXJSE_Value* pValue,
CFXJSE_Class* pClass) {
@@ -80,11 +92,11 @@ CXFA_Object* CFXJSE_Engine::ToObject(CFXJSE_Value* pValue,
}
CFXJSE_Engine::CFXJSE_Engine(CXFA_Document* pDocument, v8::Isolate* pIsolate)
- : m_pDocument(pDocument),
+ : CJS_V8(pIsolate),
+ m_pDocument(pDocument),
m_JsContext(CFXJSE_Context::Create(pIsolate,
&GlobalClassDescriptor,
pDocument->GetRoot())),
- m_pIsolate(pIsolate),
m_pJsClass(nullptr),
m_eScriptType(CXFA_ScriptData::Type::Unknown),
m_pScriptNodeArray(nullptr),
@@ -115,7 +127,7 @@ bool CFXJSE_Engine::RunScript(CXFA_ScriptData::Type eScriptType,
if (eScriptType == CXFA_ScriptData::Type::Formcalc) {
if (!m_FM2JSContext) {
m_FM2JSContext = pdfium::MakeUnique<CFXJSE_FormCalcContext>(
- m_pIsolate, m_JsContext.get(), m_pDocument.Get());
+ GetIsolate(), m_JsContext.get(), m_pDocument.Get());
}
CFX_WideTextBuf wsJavaScript;
if (!CFXJSE_FormCalcContext::Translate(wsScript, &wsJavaScript)) {
@@ -384,18 +396,21 @@ int32_t CFXJSE_Engine::NormalPropTypeGetter(CFXJSE_Value* pOriginalValue,
return FXJSE_ClassPropType_Property;
}
-void CFXJSE_Engine::NormalMethodCall(CFXJSE_Value* pThis,
- const ByteStringView& szFuncName,
- CFXJSE_Arguments& args) {
- CXFA_Object* pObject = ToObject(pThis, nullptr);
+CJS_Return CFXJSE_Engine::NormalMethodCall(
+ const v8::FunctionCallbackInfo<v8::Value>& info,
+ const WideString& functionName) {
+ CXFA_Object* pObject = ToObject(info);
if (!pObject)
- return;
+ return CJS_Return(false);
- WideString wsFunName = WideString::FromUTF8(szFuncName);
CFXJSE_Engine* lpScriptContext = pObject->GetDocument()->GetScriptContext();
-
pObject = lpScriptContext->GetVariablesThis(pObject);
- pObject->JSObject()->RunMethod(wsFunName, &args);
+
+ std::vector<v8::Local<v8::Value>> parameters;
+ for (unsigned int i = 0; i < (unsigned int)info.Length(); i++)
+ parameters.push_back(info[i]);
+
+ return pObject->JSObject()->RunMethod(functionName, parameters);
}
bool CFXJSE_Engine::IsStrictScopeInJavaScript() {
@@ -412,7 +427,7 @@ CFXJSE_Context* CFXJSE_Engine::CreateVariablesContext(CXFA_Node* pScriptNode,
return nullptr;
auto pNewContext =
- CFXJSE_Context::Create(m_pIsolate, &VariablesClassDescriptor,
+ CFXJSE_Context::Create(GetIsolate(), &VariablesClassDescriptor,
new CXFA_ThisProxy(pSubform, pScriptNode));
RemoveBuiltInObjs(pNewContext.get());
pNewContext->EnableCompatibleMode();
@@ -455,7 +470,7 @@ bool CFXJSE_Engine::RunVariablesScript(CXFA_Node* pScriptNode) {
return false;
ByteString btScript = wsScript->UTF8Encode();
- auto hRetValue = pdfium::MakeUnique<CFXJSE_Value>(m_pIsolate);
+ auto hRetValue = pdfium::MakeUnique<CFXJSE_Value>(GetIsolate());
CXFA_Node* pThisObject = pParent->GetNodeItem(XFA_NODEITEM_Parent);
CFXJSE_Context* pVariablesContext =
CreateVariablesContext(pScriptNode, pThisObject);
@@ -482,7 +497,7 @@ bool CFXJSE_Engine::QueryVariableValue(CXFA_Node* pScriptNode,
CFXJSE_Context* pVariableContext = it->second.get();
std::unique_ptr<CFXJSE_Value> pObject = pVariableContext->GetGlobalObject();
- auto hVariableValue = pdfium::MakeUnique<CFXJSE_Value>(m_pIsolate);
+ auto hVariableValue = pdfium::MakeUnique<CFXJSE_Value>(GetIsolate());
if (!bGetter) {
pObject->SetObjectOwnProperty(szPropName, pValue);
return true;
@@ -503,7 +518,7 @@ bool CFXJSE_Engine::QueryVariableValue(CXFA_Node* pScriptNode,
void CFXJSE_Engine::RemoveBuiltInObjs(CFXJSE_Context* pContext) const {
static const ByteStringView OBJ_NAME[2] = {"Number", "Date"};
std::unique_ptr<CFXJSE_Value> pObject = pContext->GetGlobalObject();
- auto hProp = pdfium::MakeUnique<CFXJSE_Value>(m_pIsolate);
+ auto hProp = pdfium::MakeUnique<CFXJSE_Value>(GetIsolate());
for (int i = 0; i < 2; ++i) {
if (pObject->GetObjectProperty(OBJ_NAME[i], hProp.get()))
pObject->DeleteObjectProperty(OBJ_NAME[i]);
@@ -610,7 +625,7 @@ bool CFXJSE_Engine::ResolveObjects(CXFA_Object* refObject,
rndFind.m_pScriptAttribute &&
nStart <
pdfium::base::checked_cast<int32_t>(wsExpression.GetLength())) {
- auto pValue = pdfium::MakeUnique<CFXJSE_Value>(m_pIsolate);
+ auto pValue = pdfium::MakeUnique<CFXJSE_Value>(GetIsolate());
CJX_Object* jsObject = rndFind.m_Objects.front()->JSObject();
(jsObject->*(rndFind.m_pScriptAttribute->callback))(
pValue.get(), false, rndFind.m_pScriptAttribute->attribute);
@@ -703,7 +718,7 @@ CFXJSE_Value* CFXJSE_Engine::GetJSValueFromMap(CXFA_Object* pObject) {
if (iter != m_mapObjectToValue.end())
return iter->second.get();
- auto jsValue = pdfium::MakeUnique<CFXJSE_Value>(m_pIsolate);
+ auto jsValue = pdfium::MakeUnique<CFXJSE_Value>(GetIsolate());
jsValue->SetObject(pObject, m_pJsClass);
CFXJSE_Value* pValue = jsValue.get();
diff --git a/fxjs/cfxjse_engine.h b/fxjs/cfxjse_engine.h
index 5310a5c1a5..9541f7b26b 100644
--- a/fxjs/cfxjse_engine.h
+++ b/fxjs/cfxjse_engine.h
@@ -11,8 +11,8 @@
#include <memory>
#include <vector>
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_formcalc_context.h"
+#include "fxjs/cjs_v8.h"
#include "xfa/fxfa/cxfa_eventparam.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
@@ -22,8 +22,9 @@
class CXFA_List;
class CFXJSE_ResolveProcessor;
-class CFXJSE_Engine {
+class CFXJSE_Engine : public CJS_V8 {
public:
+ static CXFA_Object* ToObject(const v8::FunctionCallbackInfo<v8::Value>& info);
static CXFA_Object* ToObject(CFXJSE_Value* pValue, CFXJSE_Class* pClass);
static void GlobalPropertyGetter(CFXJSE_Value* pObject,
const ByteStringView& szPropName,
@@ -37,9 +38,9 @@ class CFXJSE_Engine {
static void NormalPropertySetter(CFXJSE_Value* pObject,
const ByteStringView& szPropName,
CFXJSE_Value* pValue);
- static void NormalMethodCall(CFXJSE_Value* hThis,
- const ByteStringView& szFuncName,
- CFXJSE_Arguments& args);
+ static CJS_Return NormalMethodCall(
+ const v8::FunctionCallbackInfo<v8::Value>& info,
+ const WideString& functionName);
static int32_t NormalPropTypeGetter(CFXJSE_Value* pObject,
const ByteStringView& szPropName,
bool bQueryIn);
@@ -48,7 +49,7 @@ class CFXJSE_Engine {
bool bQueryIn);
explicit CFXJSE_Engine(CXFA_Document* pDocument, v8::Isolate* pIsolate);
- ~CFXJSE_Engine();
+ ~CFXJSE_Engine() override;
void SetEventParam(CXFA_EventParam param) { m_eventParam = param; }
CXFA_EventParam* GetEventParam() { return &m_eventParam; }
@@ -65,7 +66,6 @@ class CFXJSE_Engine {
CFXJSE_Value* GetJSValueFromMap(CXFA_Object* pObject);
void AddToCacheList(std::unique_ptr<CXFA_List> pList);
CXFA_Object* GetThisObject() const { return m_pThisObject; }
- v8::Isolate* GetRuntime() const { return m_pIsolate; }
int32_t GetIndexByName(CXFA_Node* refNode);
int32_t GetIndexByClassName(CXFA_Node* refNode);
@@ -101,7 +101,6 @@ class CFXJSE_Engine {
UnownedPtr<CXFA_Document> const m_pDocument;
std::unique_ptr<CFXJSE_Context> m_JsContext;
- v8::Isolate* m_pIsolate;
CFXJSE_Class* m_pJsClass;
CXFA_ScriptData::Type m_eScriptType;
std::map<CXFA_Object*, std::unique_ptr<CFXJSE_Value>> m_mapObjectToValue;
diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp
index e565c42e46..1777102e06 100644
--- a/fxjs/cfxjse_formcalc_context.cpp
+++ b/fxjs/cfxjse_formcalc_context.cpp
@@ -16,7 +16,6 @@
#include "core/fxcrt/cfx_widetextbuf.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_random.h"
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_class.h"
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
diff --git a/fxjs/cfxjse_resolveprocessor.cpp b/fxjs/cfxjse_resolveprocessor.cpp
index 8e0c6fba1e..9c0121dc52 100644
--- a/fxjs/cfxjse_resolveprocessor.cpp
+++ b/fxjs/cfxjse_resolveprocessor.cpp
@@ -635,7 +635,7 @@ void CFXJSE_ResolveProcessor::DoPredicateFilter(int32_t iCurIndex,
CFXJSE_Engine* pContext = rnd.m_pSC;
wsExpression = wsCondition.Mid(2, wsCondition.GetLength() - 3);
for (int32_t i = iFoundCount - 1; i >= 0; i--) {
- auto pRetValue = pdfium::MakeUnique<CFXJSE_Value>(rnd.m_pSC->GetRuntime());
+ auto pRetValue = pdfium::MakeUnique<CFXJSE_Value>(rnd.m_pSC->GetIsolate());
bool bRet = pContext->RunScript(eLangType, wsExpression.AsStringView(),
pRetValue.get(), rnd.m_Objects[i]);
if (!bRet || !pRetValue->ToBoolean())
diff --git a/fxjs/cjs_v8.cpp b/fxjs/cjs_v8.cpp
index 67f0cb52b1..18bbed606c 100644
--- a/fxjs/cjs_v8.cpp
+++ b/fxjs/cjs_v8.cpp
@@ -6,6 +6,11 @@
#include "fxjs/cjs_v8.h"
+#ifdef PDF_ENABLE_XFA
+#include "fxjs/cfxjse_context.h"
+#include "xfa/fxfa/parser/cxfa_object.h"
+#endif // PDF_ENABLE_XFA
+
CJS_V8::CJS_V8(v8::Isolate* isolate) : m_isolate(isolate) {}
CJS_V8::~CJS_V8() {
@@ -176,6 +181,17 @@ WideString CJS_V8::ToWideString(v8::Local<v8::Value> pValue) {
return WideString::FromUTF8(ByteStringView(*s, s.length()));
}
+ByteString CJS_V8::ToByteString(v8::Local<v8::Value> pValue) {
+ if (pValue.IsEmpty())
+ return ByteString();
+ v8::Local<v8::Context> context = m_isolate->GetCurrentContext();
+ v8::MaybeLocal<v8::String> maybe_string = pValue->ToString(context);
+ if (maybe_string.IsEmpty())
+ return ByteString();
+ v8::String::Utf8Value s(maybe_string.ToLocalChecked());
+ return ByteString(*s);
+}
+
v8::Local<v8::Object> CJS_V8::ToObject(v8::Local<v8::Value> pValue) {
if (pValue.IsEmpty() || !pValue->IsObject())
return v8::Local<v8::Object>();
@@ -197,3 +213,29 @@ void CJS_V8::SetConstArray(const WideString& name, v8::Local<v8::Array> array) {
v8::Local<v8::Array> CJS_V8::GetConstArray(const WideString& name) {
return v8::Local<v8::Array>::New(GetIsolate(), m_ConstArrays[name]);
}
+
+#ifdef PDF_ENABLE_XFA
+CXFA_Object* CJS_V8::ToXFAObject(v8::Local<v8::Value> obj) {
+ ASSERT(!obj.IsEmpty());
+
+ if (!obj->IsObject())
+ return nullptr;
+
+ CFXJSE_HostObject* hostObj =
+ FXJSE_RetrieveObjectBinding(obj.As<v8::Object>(), nullptr);
+ if (!hostObj || hostObj->type() != CFXJSE_HostObject::kXFA)
+ return nullptr;
+ return static_cast<CXFA_Object*>(hostObj);
+}
+
+v8::Local<v8::Value> CJS_V8::NewXFAObject(
+ CXFA_Object* obj,
+ v8::Global<v8::FunctionTemplate>& tmpl) {
+ v8::EscapableHandleScope scope(m_isolate);
+ v8::Local<v8::FunctionTemplate> klass =
+ v8::Local<v8::FunctionTemplate>::New(m_isolate, tmpl);
+ v8::Local<v8::Object> object = klass->InstanceTemplate()->NewInstance();
+ FXJSE_UpdateObjectBinding(object, obj);
+ return scope.Escape(object);
+}
+#endif // PDF_ENABLE_XFA
diff --git a/fxjs/cjs_v8.h b/fxjs/cjs_v8.h
index 9060f019ab..b79d236670 100644
--- a/fxjs/cjs_v8.h
+++ b/fxjs/cjs_v8.h
@@ -17,6 +17,10 @@
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/widestring.h"
+#ifdef PDF_ENABLE_XFA
+class CXFA_Object;
+#endif // PDF_ENABLE_XFA
+
class CJS_V8 {
public:
explicit CJS_V8(v8::Isolate* pIsolate);
@@ -42,9 +46,16 @@ class CJS_V8 {
bool ToBoolean(v8::Local<v8::Value> pValue);
double ToDouble(v8::Local<v8::Value> pValue);
WideString ToWideString(v8::Local<v8::Value> pValue);
+ ByteString ToByteString(v8::Local<v8::Value> pValue);
v8::Local<v8::Object> ToObject(v8::Local<v8::Value> pValue);
v8::Local<v8::Array> ToArray(v8::Local<v8::Value> pValue);
+#ifdef PDF_ENABLE_XFA
+ CXFA_Object* ToXFAObject(v8::Local<v8::Value> obj);
+ v8::Local<v8::Value> NewXFAObject(CXFA_Object* obj,
+ v8::Global<v8::FunctionTemplate>& tmpl);
+#endif // PDF_ENABLE_XFA
+
// Arrays.
unsigned GetArrayLength(v8::Local<v8::Array> pArray);
v8::Local<v8::Value> GetArrayElement(v8::Local<v8::Array> pArray,
diff --git a/fxjs/cjx_datawindow.cpp b/fxjs/cjx_datawindow.cpp
index 0d712bac77..b642356f05 100644
--- a/fxjs/cjx_datawindow.cpp
+++ b/fxjs/cjx_datawindow.cpp
@@ -6,7 +6,8 @@
#include "fxjs/cjx_datawindow.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
#include "xfa/fxfa/parser/cscript_datawindow.h"
@@ -24,13 +25,29 @@ CJX_DataWindow::CJX_DataWindow(CScript_DataWindow* window)
CJX_DataWindow::~CJX_DataWindow() {}
-void CJX_DataWindow::moveCurrentRecord(CFXJSE_Arguments* pArguments) {}
+CJS_Return CJX_DataWindow::moveCurrentRecord(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
+}
-void CJX_DataWindow::record(CFXJSE_Arguments* pArguments) {}
+CJS_Return CJX_DataWindow::record(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
+}
-void CJX_DataWindow::gotoRecord(CFXJSE_Arguments* pArguments) {}
+CJS_Return CJX_DataWindow::gotoRecord(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
+}
-void CJX_DataWindow::isRecordGroup(CFXJSE_Arguments* pArguments) {}
+CJS_Return CJX_DataWindow::isRecordGroup(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
+}
void CJX_DataWindow::RecordsBefore(CFXJSE_Value* pValue,
bool bSetting,
diff --git a/fxjs/cjx_eventpseudomodel.cpp b/fxjs/cjx_eventpseudomodel.cpp
index f78890bc9f..092d39fa28 100644
--- a/fxjs/cjx_eventpseudomodel.cpp
+++ b/fxjs/cjx_eventpseudomodel.cpp
@@ -6,7 +6,8 @@
#include "fxjs/cjx_eventpseudomodel.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
#include "xfa/fxfa/cxfa_eventparam.h"
@@ -150,36 +151,42 @@ void CJX_EventPseudoModel::Target(CFXJSE_Value* pValue,
Property(pValue, XFA_Event::Target, bSetting);
}
-void CJX_EventPseudoModel::emit(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_EventPseudoModel::emit(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return;
+ return CJS_Return(true);
CXFA_EventParam* pEventParam = pScriptContext->GetEventParam();
if (!pEventParam)
- return;
+ return CJS_Return(true);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
CXFA_FFWidgetHandler* pWidgetHandler = pNotify->GetWidgetHandler();
if (!pWidgetHandler)
- return;
+ return CJS_Return(true);
pWidgetHandler->ProcessEvent(pEventParam->m_pTarget, pEventParam);
+ return CJS_Return(true);
}
-void CJX_EventPseudoModel::reset(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_EventPseudoModel::reset(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return;
+ return CJS_Return(true);
CXFA_EventParam* pEventParam = pScriptContext->GetEventParam();
if (!pEventParam)
- return;
+ return CJS_Return(true);
pEventParam->Reset();
+ return CJS_Return(true);
}
void CJX_EventPseudoModel::Property(CFXJSE_Value* pValue,
diff --git a/fxjs/cjx_hostpseudomodel.cpp b/fxjs/cjx_hostpseudomodel.cpp
index 6e0f2f83cb..c4467b8755 100644
--- a/fxjs/cjx_hostpseudomodel.cpp
+++ b/fxjs/cjx_hostpseudomodel.cpp
@@ -7,10 +7,11 @@
#include "fxjs/cjx_hostpseudomodel.h"
#include <memory>
+#include <vector>
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/parser/cscript_hostpseudomodel.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
@@ -19,10 +20,6 @@
namespace {
-CXFA_Node* ToNode(CFXJSE_Value* pValue, CFXJSE_Class* pClass) {
- return static_cast<CXFA_Node*>(pValue->ToHostObject(pClass));
-}
-
int32_t FilterName(const WideStringView& wsExpression,
int32_t nStart,
WideString& wsFilter) {
@@ -249,160 +246,145 @@ void CJX_HostPseudoModel::Name(CFXJSE_Value* pValue,
pNotify->GetAppProvider()->GetAppName().UTF8Encode().AsStringView());
}
-void CJX_HostPseudoModel::gotoURL(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_HostPseudoModel::gotoURL(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return;
+ return CJS_Return(true);
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"gotoURL");
- return;
- }
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
- WideString wsURL;
- if (iLength >= 1) {
- ByteString bsURL = pArguments->GetUTF8String(0);
- wsURL = WideString::FromUTF8(bsURL.AsStringView());
- }
- pNotify->GetDocEnvironment()->GotoURL(hDoc, wsURL);
+ WideString URL = runtime->ToWideString(params[0]);
+ pNotify->GetDocEnvironment()->GotoURL(hDoc, URL);
+ return CJS_Return(true);
}
-void CJX_HostPseudoModel::openList(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_HostPseudoModel::openList(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return;
+ return CJS_Return(true);
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"openList");
- return;
- }
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
CXFA_Node* pNode = nullptr;
- if (iLength >= 1) {
- std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0));
- if (pValue->IsObject()) {
- pNode = ToNode(pValue.get(), nullptr);
- } else if (pValue->IsString()) {
- CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
- if (!pScriptContext)
- return;
+ if (params[0]->IsObject()) {
+ pNode = ToNode(runtime->ToXFAObject(params[0]));
+ } else if (params[0]->IsString()) {
+ CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
+ if (!pScriptContext)
+ return CJS_Return(true);
- CXFA_Object* pObject = pScriptContext->GetThisObject();
- if (!pObject)
- return;
+ CXFA_Object* pObject = pScriptContext->GetThisObject();
+ if (!pObject)
+ return CJS_Return(true);
- uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
- XFA_RESOLVENODE_Siblings;
- XFA_RESOLVENODE_RS resolveNodeRS;
- bool iRet = pScriptContext->ResolveObjects(
- pObject, pValue->ToWideString().AsStringView(), &resolveNodeRS,
- dwFlag, nullptr);
- if (!iRet || !resolveNodeRS.objects.front()->IsNode())
- return;
+ uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
+ XFA_RESOLVENODE_Siblings;
+ XFA_RESOLVENODE_RS resolveNodeRS;
+ bool iRet = pScriptContext->ResolveObjects(
+ pObject, runtime->ToWideString(params[0]).AsStringView(),
+ &resolveNodeRS, dwFlag, nullptr);
+ if (!iRet || !resolveNodeRS.objects.front()->IsNode())
+ return CJS_Return(true);
- pNode = resolveNodeRS.objects.front()->AsNode();
- }
+ pNode = resolveNodeRS.objects.front()->AsNode();
}
CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout();
if (!pDocLayout)
- return;
+ return CJS_Return(true);
CXFA_FFWidget* hWidget =
pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode));
if (!hWidget)
- return;
+ return CJS_Return(true);
pNotify->GetDocEnvironment()->SetFocusWidget(pNotify->GetHDOC(), hWidget);
pNotify->OpenDropDownList(hWidget);
+ return CJS_Return(true);
}
-void CJX_HostPseudoModel::response(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 4) {
- ThrowParamCountMismatchException(L"response");
- return;
- }
+CJS_Return CJX_HostPseudoModel::response(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty() || params.size() > 4)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
- WideString wsQuestion;
- WideString wsTitle;
- WideString wsDefaultAnswer;
- bool bMark = false;
- if (iLength >= 1) {
- ByteString bsQuestion = pArguments->GetUTF8String(0);
- wsQuestion = WideString::FromUTF8(bsQuestion.AsStringView());
- }
- if (iLength >= 2) {
- ByteString bsTitle = pArguments->GetUTF8String(1);
- wsTitle = WideString::FromUTF8(bsTitle.AsStringView());
- }
- if (iLength >= 3) {
- ByteString bsDefaultAnswer = pArguments->GetUTF8String(2);
- wsDefaultAnswer = WideString::FromUTF8(bsDefaultAnswer.AsStringView());
- }
- if (iLength >= 4) {
- bMark = pArguments->GetInt32(3) == 0 ? false : true;
- }
+ WideString question;
+ if (params.size() >= 1)
+ question = runtime->ToWideString(params[0]);
+
+ WideString title;
+ if (params.size() >= 2)
+ title = runtime->ToWideString(params[1]);
+
+ WideString defaultAnswer;
+ if (params.size() >= 3)
+ defaultAnswer = runtime->ToWideString(params[2]);
+
+ bool mark = false;
+ if (params.size() >= 4)
+ mark = runtime->ToInt32(params[3]) != 0;
- WideString wsAnswer = pNotify->GetAppProvider()->Response(
- wsQuestion, wsTitle, wsDefaultAnswer, bMark);
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetString(wsAnswer.UTF8Encode().AsStringView());
+ WideString answer =
+ pNotify->GetAppProvider()->Response(question, title, defaultAnswer, mark);
+ return CJS_Return(runtime->NewString(answer.UTF8Encode().AsStringView()));
}
-void CJX_HostPseudoModel::documentInBatch(CFXJSE_Arguments* pArguments) {
- if (CFXJSE_Value* pValue = pArguments->GetReturnValue())
- pValue->SetInteger(0);
+CJS_Return CJX_HostPseudoModel::documentInBatch(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(runtime->NewNumber(0));
}
-void CJX_HostPseudoModel::resetData(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 0 || iLength > 1) {
- ThrowParamCountMismatchException(L"resetData");
- return;
- }
+CJS_Return CJX_HostPseudoModel::resetData(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() > 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
- WideString wsExpression;
- if (iLength >= 1) {
- ByteString bsExpression = pArguments->GetUTF8String(0);
- wsExpression = WideString::FromUTF8(bsExpression.AsStringView());
- }
- if (wsExpression.IsEmpty()) {
+ WideString expression;
+ if (params.size() >= 1)
+ expression = runtime->ToWideString(params[0]);
+
+ if (expression.IsEmpty()) {
pNotify->ResetData();
- return;
+ return CJS_Return(true);
}
int32_t iStart = 0;
WideString wsName;
CXFA_Node* pNode = nullptr;
- int32_t iExpLength = wsExpression.GetLength();
+ int32_t iExpLength = expression.GetLength();
while (iStart < iExpLength) {
- iStart = FilterName(wsExpression.AsStringView(), iStart, wsName);
+ iStart = FilterName(expression.AsStringView(), iStart, wsName);
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return;
+ return CJS_Return(true);
CXFA_Object* pObject = pScriptContext->GetThisObject();
if (!pObject)
- return;
+ return CJS_Return(true);
uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings;
@@ -417,278 +399,234 @@ void CJX_HostPseudoModel::resetData(CFXJSE_Arguments* pArguments) {
}
if (!pNode)
pNotify->ResetData();
+
+ return CJS_Return(true);
}
-void CJX_HostPseudoModel::beep(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_HostPseudoModel::beep(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return;
+ return CJS_Return(true);
- int32_t iLength = pArguments->GetLength();
- if (iLength < 0 || iLength > 1) {
- ThrowParamCountMismatchException(L"beep");
- return;
- }
+ if (params.size() > 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
uint32_t dwType = 4;
- if (iLength >= 1)
- dwType = pArguments->GetInt32(0);
+ if (params.size() >= 1)
+ dwType = runtime->ToInt32(params[0]);
pNotify->GetAppProvider()->Beep(dwType);
+ return CJS_Return(true);
}
-void CJX_HostPseudoModel::setFocus(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_HostPseudoModel::setFocus(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return;
+ return CJS_Return(true);
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"setFocus");
- return;
- }
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
CXFA_Node* pNode = nullptr;
- if (iLength >= 1) {
- std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0));
- if (pValue->IsObject()) {
- pNode = ToNode(pValue.get(), nullptr);
- } else if (pValue->IsString()) {
+ if (params.size() >= 1) {
+ if (params[0]->IsObject()) {
+ pNode = ToNode(runtime->ToXFAObject(params[0]));
+ } else if (params[0]->IsString()) {
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return;
+ return CJS_Return(true);
CXFA_Object* pObject = pScriptContext->GetThisObject();
if (!pObject)
- return;
+ return CJS_Return(true);
uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings;
XFA_RESOLVENODE_RS resolveNodeRS;
bool iRet = pScriptContext->ResolveObjects(
- pObject, pValue->ToWideString().AsStringView(), &resolveNodeRS,
- dwFlag, nullptr);
+ pObject, runtime->ToWideString(params[0]).AsStringView(),
+ &resolveNodeRS, dwFlag, nullptr);
if (!iRet || !resolveNodeRS.objects.front()->IsNode())
- return;
+ return CJS_Return(true);
pNode = resolveNodeRS.objects.front()->AsNode();
}
}
pNotify->SetFocusWidgetNode(pNode);
+ return CJS_Return(true);
}
-void CJX_HostPseudoModel::getFocus(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_HostPseudoModel::getFocus(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
CXFA_Node* pNode = pNotify->GetFocusWidgetNode();
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()));
}
-void CJX_HostPseudoModel::messageBox(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_HostPseudoModel::messageBox(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return;
+ return CJS_Return(true);
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 4) {
- ThrowParamCountMismatchException(L"messageBox");
- return;
- }
+ if (params.empty() || params.size() > 4)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
-
- WideString wsMessage;
- WideString bsTitle;
- uint32_t dwMessageType = XFA_MBICON_Error;
- uint32_t dwButtonType = XFA_MB_OK;
- if (iLength >= 1) {
- if (!ValidateArgsForMsg(pArguments, 0, wsMessage))
- return;
- }
- if (iLength >= 2) {
- if (!ValidateArgsForMsg(pArguments, 1, bsTitle))
- return;
- }
- if (iLength >= 3) {
- dwMessageType = pArguments->GetInt32(2);
- if (dwMessageType > XFA_MBICON_Status)
- dwMessageType = XFA_MBICON_Error;
- }
- if (iLength >= 4) {
- dwButtonType = pArguments->GetInt32(3);
- if (dwButtonType > XFA_MB_YesNoCancel)
- dwButtonType = XFA_MB_OK;
- }
+ return CJS_Return(true);
- int32_t iValue = pNotify->GetAppProvider()->MsgBox(
- wsMessage, bsTitle, dwMessageType, dwButtonType);
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetInteger(iValue);
-}
+ WideString message;
+ if (params.size() >= 1)
+ message = runtime->ToWideString(params[0]);
-bool CJX_HostPseudoModel::ValidateArgsForMsg(CFXJSE_Arguments* pArguments,
- int32_t iArgIndex,
- WideString& wsValue) {
- if (!pArguments || iArgIndex < 0)
- return false;
+ WideString title;
+ if (params.size() >= 2)
+ title = runtime->ToWideString(params[1]);
- bool bIsJsType = false;
- if (GetDocument()->GetScriptContext()->GetType() ==
- CXFA_ScriptData::Type::Javascript) {
- bIsJsType = true;
+ uint32_t messageType = XFA_MBICON_Error;
+ if (params.size() >= 3) {
+ messageType = runtime->ToInt32(params[2]);
+ if (messageType > XFA_MBICON_Status)
+ messageType = XFA_MBICON_Error;
}
- std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex));
- if (!pValueArg->IsString() && bIsJsType) {
- ThrowArgumentMismatchException();
- return false;
+ uint32_t buttonType = XFA_MB_OK;
+ if (params.size() >= 4) {
+ buttonType = runtime->ToInt32(params[3]);
+ if (buttonType > XFA_MB_YesNoCancel)
+ buttonType = XFA_MB_OK;
}
- wsValue = pValueArg->IsNull() ? L"" : pValueArg->ToWideString();
- return true;
+
+ int32_t iValue = pNotify->GetAppProvider()->MsgBox(message, title,
+ messageType, buttonType);
+ return CJS_Return(runtime->NewNumber(iValue));
}
-void CJX_HostPseudoModel::documentCountInBatch(CFXJSE_Arguments* pArguments) {
- if (CFXJSE_Value* pValue = pArguments->GetReturnValue())
- pValue->SetInteger(0);
+CJS_Return CJX_HostPseudoModel::documentCountInBatch(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(runtime->NewNumber(0));
}
-void CJX_HostPseudoModel::print(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_HostPseudoModel::print(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return;
+ return CJS_Return(true);
- int32_t iLength = pArguments->GetLength();
- if (iLength != 8) {
- ThrowParamCountMismatchException(L"print");
- return;
- }
+ if (params.size() != 8)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
- CXFA_FFDoc* hDoc = pNotify->GetHDOC();
uint32_t dwOptions = 0;
- bool bShowDialog = true;
- if (iLength >= 1)
- bShowDialog = pArguments->GetInt32(0) == 0 ? false : true;
- if (bShowDialog)
+ if (runtime->ToBoolean(params[0]))
dwOptions |= XFA_PRINTOPT_ShowDialog;
-
- int32_t nStartPage = 0;
- if (iLength >= 2)
- nStartPage = pArguments->GetInt32(1);
-
- int32_t nEndPage = 0;
- if (iLength >= 3)
- nEndPage = pArguments->GetInt32(2);
-
- bool bCanCancel = true;
- if (iLength >= 4)
- bCanCancel = pArguments->GetInt32(3) == 0 ? false : true;
- if (bCanCancel)
+ if (runtime->ToBoolean(params[3]))
dwOptions |= XFA_PRINTOPT_CanCancel;
-
- bool bShrinkPage = true;
- if (iLength >= 5)
- bShrinkPage = pArguments->GetInt32(4) == 0 ? false : true;
- if (bShrinkPage)
+ if (runtime->ToBoolean(params[4]))
dwOptions |= XFA_PRINTOPT_ShrinkPage;
-
- bool bAsImage = true;
- if (iLength >= 6)
- bAsImage = pArguments->GetInt32(5) == 0 ? false : true;
- if (bAsImage)
+ if (runtime->ToBoolean(params[5]))
dwOptions |= XFA_PRINTOPT_AsImage;
-
- bool bReverseOrder = true;
- if (iLength >= 7)
- bAsImage = pArguments->GetInt32(5) == 0 ? false : true;
-
- bReverseOrder = pArguments->GetInt32(6) == 0 ? false : true;
- if (bReverseOrder)
+ if (runtime->ToBoolean(params[6]))
dwOptions |= XFA_PRINTOPT_ReverseOrder;
-
- bool bPrintAnnot = true;
- if (iLength >= 8)
- bPrintAnnot = pArguments->GetInt32(7) == 0 ? false : true;
- if (bPrintAnnot)
+ if (runtime->ToBoolean(params[7]))
dwOptions |= XFA_PRINTOPT_PrintAnnot;
- pNotify->GetDocEnvironment()->Print(hDoc, nStartPage, nEndPage, dwOptions);
+ int32_t nStartPage = runtime->ToInt32(params[1]);
+ int32_t nEndPage = runtime->ToInt32(params[2]);
+
+ pNotify->GetDocEnvironment()->Print(pNotify->GetHDOC(), nStartPage, nEndPage,
+ dwOptions);
+ return CJS_Return(true);
}
-void CJX_HostPseudoModel::importData(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 0 || iLength > 1) {
- ThrowParamCountMismatchException(L"importData");
- return;
- }
- // Not implemented.
+CJS_Return CJX_HostPseudoModel::importData(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty() || params.size() > 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+
+ return CJS_Return(true);
}
-void CJX_HostPseudoModel::exportData(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 0 || iLength > 2) {
- ThrowParamCountMismatchException(L"exportData");
- return;
- }
+CJS_Return CJX_HostPseudoModel::exportData(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty() || params.size() > 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
- CXFA_FFDoc* hDoc = pNotify->GetHDOC();
- WideString wsFilePath;
- bool bXDP = true;
- if (iLength >= 1) {
- ByteString bsFilePath = pArguments->GetUTF8String(0);
- wsFilePath = WideString::FromUTF8(bsFilePath.AsStringView());
- }
- if (iLength >= 2)
- bXDP = pArguments->GetInt32(1) == 0 ? false : true;
+ WideString filePath;
+ if (params.size() >= 1)
+ filePath = runtime->ToWideString(params[0]);
+
+ bool XDP = true;
+ if (params.size() >= 2)
+ XDP = runtime->ToBoolean(params[1]);
- pNotify->GetDocEnvironment()->ExportData(hDoc, wsFilePath, bXDP);
+ pNotify->GetDocEnvironment()->ExportData(pNotify->GetHDOC(), filePath, XDP);
+ return CJS_Return(true);
}
-void CJX_HostPseudoModel::pageUp(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_HostPseudoModel::pageUp(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
int32_t nCurPage = pNotify->GetDocEnvironment()->GetCurrentPage(hDoc);
int32_t nNewPage = 0;
if (nCurPage <= 1)
- return;
+ return CJS_Return(true);
nNewPage = nCurPage - 1;
pNotify->GetDocEnvironment()->SetCurrentPage(hDoc, nNewPage);
+ return CJS_Return(true);
}
-void CJX_HostPseudoModel::pageDown(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_HostPseudoModel::pageDown(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
int32_t nCurPage = pNotify->GetDocEnvironment()->GetCurrentPage(hDoc);
int32_t nPageCount = pNotify->GetDocEnvironment()->CountPages(hDoc);
if (!nPageCount || nCurPage == nPageCount)
- return;
+ return CJS_Return(true);
int32_t nNewPage = 0;
if (nCurPage >= nPageCount)
@@ -697,4 +635,5 @@ void CJX_HostPseudoModel::pageDown(CFXJSE_Arguments* pArguments) {
nNewPage = nCurPage + 1;
pNotify->GetDocEnvironment()->SetCurrentPage(hDoc, nNewPage);
+ return CJS_Return(true);
}
diff --git a/fxjs/cjx_hostpseudomodel.h b/fxjs/cjx_hostpseudomodel.h
index d5c90aa87c..e77a37ee6b 100644
--- a/fxjs/cjx_hostpseudomodel.h
+++ b/fxjs/cjx_hostpseudomodel.h
@@ -54,10 +54,6 @@ class CJX_HostPseudoModel : public CJX_Object {
JS_METHOD(setFocus, CJX_HostPseudoModel);
private:
- bool ValidateArgsForMsg(CFXJSE_Arguments* pArguments,
- int32_t iArgIndex,
- WideString& wsValue);
-
static const CJX_MethodSpec MethodSpecs[];
};
diff --git a/fxjs/cjx_layoutpseudomodel.cpp b/fxjs/cjx_layoutpseudomodel.cpp
index cc7c154841..ed43de58f4 100644
--- a/fxjs/cjx_layoutpseudomodel.cpp
+++ b/fxjs/cjx_layoutpseudomodel.cpp
@@ -9,9 +9,9 @@
#include <set>
#include "core/fxcrt/fx_coordinates.h"
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/parser/cscript_layoutpseudomodel.h"
#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
@@ -68,60 +68,40 @@ void CJX_LayoutPseudoModel::Ready(CFXJSE_Value* pValue,
pValue->SetBoolean(iStatus >= 2);
}
-void CJX_LayoutPseudoModel::HWXY(CFXJSE_Arguments* pArguments,
- XFA_LAYOUTMODEL_HWXY layoutModel) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 3) {
- const wchar_t* methodName = nullptr;
- switch (layoutModel) {
- case XFA_LAYOUTMODEL_H:
- methodName = L"h";
- break;
- case XFA_LAYOUTMODEL_W:
- methodName = L"w";
- break;
- case XFA_LAYOUTMODEL_X:
- methodName = L"x";
- break;
- case XFA_LAYOUTMODEL_Y:
- methodName = L"y";
- break;
- }
- ThrowParamCountMismatchException(methodName);
- return;
- }
+CJS_Return CJX_LayoutPseudoModel::HWXY(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params,
+ XFA_LAYOUTMODEL_HWXY layoutModel) {
+ if (params.empty() || params.size() > 3)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
+ CXFA_Node* pNode = ToNode(runtime->ToXFAObject(params[0]));
if (!pNode)
- return;
+ return CJS_Return(true);
- WideString wsUnit(L"pt");
- if (iLength >= 2) {
- ByteString bsUnit = pArguments->GetUTF8String(1);
- if (!bsUnit.IsEmpty())
- wsUnit = WideString::FromUTF8(bsUnit.AsStringView());
+ WideString unit(L"pt");
+ if (params.size() >= 2) {
+ WideString tmp_unit = runtime->ToWideString(params[1]);
+ if (!tmp_unit.IsEmpty())
+ unit = tmp_unit;
}
-
- int32_t iIndex = iLength >= 3 ? pArguments->GetInt32(2) : 0;
+ int32_t iIndex = params.size() >= 3 ? runtime->ToInt32(params[2]) : 0;
CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout();
if (!pDocLayout)
- return;
+ return CJS_Return(true);
CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode);
if (!pLayoutItem)
- return;
+ return CJS_Return(true);
while (iIndex > 0 && pLayoutItem) {
pLayoutItem = pLayoutItem->GetNext();
- iIndex--;
+ --iIndex;
}
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (!pLayoutItem) {
- pValue->SetFloat(0);
- return;
- }
+ if (!pLayoutItem)
+ return CJS_Return(runtime->NewNumber(0.0));
CXFA_Measurement measure;
CFX_RectF rtRect = pLayoutItem->GetRect(true);
@@ -140,33 +120,40 @@ void CJX_LayoutPseudoModel::HWXY(CFXJSE_Arguments* pArguments,
break;
}
- float fValue = measure.ToUnit(
- CXFA_Measurement::GetUnitFromString(wsUnit.AsStringView()));
- fValue = FXSYS_round(fValue * 1000) / 1000.0f;
- pValue->SetFloat(fValue);
+ float fValue =
+ measure.ToUnit(CXFA_Measurement::GetUnitFromString(unit.AsStringView()));
+ return CJS_Return(runtime->NewNumber(FXSYS_round(fValue * 1000) / 1000.0f));
}
-void CJX_LayoutPseudoModel::h(CFXJSE_Arguments* pArguments) {
- HWXY(pArguments, XFA_LAYOUTMODEL_H);
+CJS_Return CJX_LayoutPseudoModel::h(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return HWXY(runtime, params, XFA_LAYOUTMODEL_H);
}
-void CJX_LayoutPseudoModel::w(CFXJSE_Arguments* pArguments) {
- HWXY(pArguments, XFA_LAYOUTMODEL_W);
+CJS_Return CJX_LayoutPseudoModel::w(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return HWXY(runtime, params, XFA_LAYOUTMODEL_W);
}
-void CJX_LayoutPseudoModel::x(CFXJSE_Arguments* pArguments) {
- HWXY(pArguments, XFA_LAYOUTMODEL_X);
+CJS_Return CJX_LayoutPseudoModel::x(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return HWXY(runtime, params, XFA_LAYOUTMODEL_X);
}
-void CJX_LayoutPseudoModel::y(CFXJSE_Arguments* pArguments) {
- HWXY(pArguments, XFA_LAYOUTMODEL_Y);
+CJS_Return CJX_LayoutPseudoModel::y(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return HWXY(runtime, params, XFA_LAYOUTMODEL_Y);
}
-void CJX_LayoutPseudoModel::NumberedPageCount(CFXJSE_Arguments* pArguments,
- bool bNumbered) {
+CJS_Return CJX_LayoutPseudoModel::NumberedPageCount(CJS_V8* runtime,
+ bool bNumbered) {
CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout();
if (!pDocLayout)
- return;
+ return CJS_Return(true);
int32_t iPageCount = 0;
int32_t iPageNum = pDocLayout->CountPages();
@@ -183,46 +170,43 @@ void CJX_LayoutPseudoModel::NumberedPageCount(CFXJSE_Arguments* pArguments,
} else {
iPageCount = iPageNum;
}
-
- pArguments->GetReturnValue()->SetInteger(iPageCount);
+ return CJS_Return(runtime->NewNumber(iPageCount));
}
-void CJX_LayoutPseudoModel::pageCount(CFXJSE_Arguments* pArguments) {
- NumberedPageCount(pArguments, true);
+CJS_Return CJX_LayoutPseudoModel::pageCount(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return NumberedPageCount(runtime, true);
}
-void CJX_LayoutPseudoModel::pageSpan(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"pageSpan");
- return;
- }
+CJS_Return CJX_LayoutPseudoModel::pageSpan(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CXFA_Node* pNode = nullptr;
- if (iLength >= 1)
- pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
+ CXFA_Node* pNode = ToNode(runtime->ToXFAObject(params[0]));
if (!pNode)
- return;
+ return CJS_Return(true);
CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout();
if (!pDocLayout)
- return;
+ return CJS_Return(true);
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode);
- if (!pLayoutItem) {
- pValue->SetInteger(-1);
- return;
- }
+ if (!pLayoutItem)
+ return CJS_Return(runtime->NewNumber(-1));
int32_t iLast = pLayoutItem->GetLast()->GetPage()->GetPageIndex();
int32_t iFirst = pLayoutItem->GetFirst()->GetPage()->GetPageIndex();
int32_t iPageSpan = iLast - iFirst + 1;
- pValue->SetInteger(iPageSpan);
+ return CJS_Return(runtime->NewNumber(iPageSpan));
}
-void CJX_LayoutPseudoModel::page(CFXJSE_Arguments* pArguments) {
- PageInternals(pArguments, false);
+CJS_Return CJX_LayoutPseudoModel::page(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return PageInternals(runtime, params, false);
}
std::vector<CXFA_Node*> CJX_LayoutPseudoModel::GetObjArray(
@@ -359,55 +343,63 @@ std::vector<CXFA_Node*> CJX_LayoutPseudoModel::GetObjArray(
return retArray;
}
-void CJX_LayoutPseudoModel::pageContent(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 3) {
- ThrowParamCountMismatchException(L"pageContent");
- return;
- }
+CJS_Return CJX_LayoutPseudoModel::pageContent(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty() || params.size() > 3)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
int32_t iIndex = 0;
+ if (params.size() >= 1)
+ iIndex = runtime->ToInt32(params[0]);
+
WideString wsType;
- bool bOnPageArea = false;
- if (iLength >= 1)
- iIndex = pArguments->GetInt32(0);
+ if (params.size() >= 2)
+ wsType = runtime->ToWideString(params[1]);
- if (iLength >= 2) {
- ByteString bsType = pArguments->GetUTF8String(1);
- wsType = WideString::FromUTF8(bsType.AsStringView());
- }
- if (iLength >= 3)
- bOnPageArea = pArguments->GetInt32(2) == 0 ? false : true;
+ bool bOnPageArea = false;
+ if (params.size() >= 3)
+ bOnPageArea = runtime->ToBoolean(params[2]);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout();
if (!pDocLayout)
- return;
+ return CJS_Return(true);
auto pArrayNodeList = pdfium::MakeUnique<CXFA_ArrayNodeList>(GetDocument());
pArrayNodeList->SetArrayNodeList(
GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea));
- pArguments->GetReturnValue()->SetObject(
+
+ // TODO(dsinclair): Who owns the array once we release it? Won't this leak?
+ return CJS_Return(runtime->NewXFAObject(
pArrayNodeList.release(),
- GetDocument()->GetScriptContext()->GetJseNormalClass());
+ GetDocument()->GetScriptContext()->GetJseNormalClass()->GetTemplate()));
}
-void CJX_LayoutPseudoModel::absPageCount(CFXJSE_Arguments* pArguments) {
- NumberedPageCount(pArguments, false);
+CJS_Return CJX_LayoutPseudoModel::absPageCount(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return NumberedPageCount(runtime, false);
}
-void CJX_LayoutPseudoModel::absPageCountInBatch(CFXJSE_Arguments* pArguments) {
- pArguments->GetReturnValue()->SetInteger(0);
+CJS_Return CJX_LayoutPseudoModel::absPageCountInBatch(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(runtime->NewNumber(0));
}
-void CJX_LayoutPseudoModel::sheetCountInBatch(CFXJSE_Arguments* pArguments) {
- pArguments->GetReturnValue()->SetInteger(0);
+CJS_Return CJX_LayoutPseudoModel::sheetCountInBatch(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(runtime->NewNumber(0));
}
-void CJX_LayoutPseudoModel::relayout(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_LayoutPseudoModel::relayout(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
CXFA_Node* pRootNode = GetDocument()->GetRoot();
CXFA_Node* pFormRoot = pRootNode->GetFirstChildByClass(XFA_Element::Form);
CXFA_Node* pContentRootNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
@@ -416,67 +408,74 @@ void CJX_LayoutPseudoModel::relayout(CFXJSE_Arguments* pArguments) {
pLayoutProcessor->AddChangedContainer(pContentRootNode);
pLayoutProcessor->SetForceReLayout(true);
+ return CJS_Return(true);
}
-void CJX_LayoutPseudoModel::absPageSpan(CFXJSE_Arguments* pArguments) {
- pageSpan(pArguments);
+CJS_Return CJX_LayoutPseudoModel::absPageSpan(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return pageSpan(runtime, params);
}
-void CJX_LayoutPseudoModel::absPageInBatch(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"absPageInBatch");
- return;
- }
-
- pArguments->GetReturnValue()->SetInteger(0);
+CJS_Return CJX_LayoutPseudoModel::absPageInBatch(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewNumber(0));
}
-void CJX_LayoutPseudoModel::sheetInBatch(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"sheetInBatch");
- return;
- }
-
- pArguments->GetReturnValue()->SetInteger(0);
+CJS_Return CJX_LayoutPseudoModel::sheetInBatch(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewNumber(0));
}
-void CJX_LayoutPseudoModel::sheet(CFXJSE_Arguments* pArguments) {
- PageInternals(pArguments, true);
+CJS_Return CJX_LayoutPseudoModel::sheet(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return PageInternals(runtime, params, true);
}
-void CJX_LayoutPseudoModel::relayoutPageArea(CFXJSE_Arguments* pArguments) {}
+CJS_Return CJX_LayoutPseudoModel::relayoutPageArea(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
+}
-void CJX_LayoutPseudoModel::sheetCount(CFXJSE_Arguments* pArguments) {
- NumberedPageCount(pArguments, false);
+CJS_Return CJX_LayoutPseudoModel::sheetCount(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return NumberedPageCount(runtime, false);
}
-void CJX_LayoutPseudoModel::absPage(CFXJSE_Arguments* pArguments) {
- PageInternals(pArguments, true);
+CJS_Return CJX_LayoutPseudoModel::absPage(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return PageInternals(runtime, params, true);
}
-void CJX_LayoutPseudoModel::PageInternals(CFXJSE_Arguments* pArguments,
- bool bAbsPage) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(bAbsPage ? L"absPage" : L"page");
- return;
- }
+CJS_Return CJX_LayoutPseudoModel::PageInternals(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params,
+ bool bAbsPage) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ CXFA_Node* pNode = ToNode(runtime->ToXFAObject(params[0]));
if (!pNode)
- pValue->SetInteger(0);
+ return CJS_Return(runtime->NewNumber(0));
CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout();
if (!pDocLayout)
- return;
+ return CJS_Return(true);
CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode);
- if (!pLayoutItem) {
- pValue->SetInteger(-1);
- return;
- }
+ if (!pLayoutItem)
+ return CJS_Return(runtime->NewNumber(-1));
int32_t iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex();
- pValue->SetInteger(bAbsPage ? iPage : iPage + 1);
+ return CJS_Return(runtime->NewNumber(bAbsPage ? iPage : iPage + 1));
}
diff --git a/fxjs/cjx_layoutpseudomodel.h b/fxjs/cjx_layoutpseudomodel.h
index 9eba2ac85f..e465d42f8e 100644
--- a/fxjs/cjx_layoutpseudomodel.h
+++ b/fxjs/cjx_layoutpseudomodel.h
@@ -19,7 +19,6 @@ enum XFA_LAYOUTMODEL_HWXY {
XFA_LAYOUTMODEL_Y
};
-class CFXJSE_Arguments;
class CFXJSE_Value;
class CScript_LayoutPseudoModel;
class CXFA_LayoutProcessor;
@@ -53,13 +52,17 @@ class CJX_LayoutPseudoModel : public CJX_Object {
JS_METHOD(y, CJX_LayoutPseudoModel);
private:
- void NumberedPageCount(CFXJSE_Arguments* pArguments, bool bNumbered);
- void HWXY(CFXJSE_Arguments* pArguments, XFA_LAYOUTMODEL_HWXY layoutModel);
+ CJS_Return NumberedPageCount(CJS_V8* runtime, bool bNumbered);
+ CJS_Return HWXY(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params,
+ XFA_LAYOUTMODEL_HWXY layoutModel);
std::vector<CXFA_Node*> GetObjArray(CXFA_LayoutProcessor* pDocLayout,
int32_t iPageNo,
const WideString& wsType,
bool bOnPageArea);
- void PageInternals(CFXJSE_Arguments* pArguments, bool bAbsPage);
+ CJS_Return PageInternals(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params,
+ bool bAbsPage);
static const CJX_MethodSpec MethodSpecs[];
};
diff --git a/fxjs/cjx_logpseudomodel.cpp b/fxjs/cjx_logpseudomodel.cpp
index 759817257d..54713fa83d 100644
--- a/fxjs/cjx_logpseudomodel.cpp
+++ b/fxjs/cjx_logpseudomodel.cpp
@@ -6,7 +6,8 @@
#include "fxjs/cjx_logpseudomodel.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
#include "xfa/fxfa/parser/cscript_logpseudomodel.h"
@@ -25,12 +26,32 @@ CJX_LogPseudoModel::CJX_LogPseudoModel(CScript_LogPseudoModel* model)
CJX_LogPseudoModel::~CJX_LogPseudoModel() {}
-void CJX_LogPseudoModel::message(CFXJSE_Arguments* pArguments) {}
+CJS_Return CJX_LogPseudoModel::message(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
+}
-void CJX_LogPseudoModel::traceEnabled(CFXJSE_Arguments* pArguments) {}
+CJS_Return CJX_LogPseudoModel::traceEnabled(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
+}
-void CJX_LogPseudoModel::traceActivate(CFXJSE_Arguments* pArguments) {}
+CJS_Return CJX_LogPseudoModel::traceActivate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
+}
-void CJX_LogPseudoModel::traceDeactivate(CFXJSE_Arguments* pArguments) {}
+CJS_Return CJX_LogPseudoModel::traceDeactivate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
+}
-void CJX_LogPseudoModel::trace(CFXJSE_Arguments* pArguments) {}
+CJS_Return CJX_LogPseudoModel::trace(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
+}
diff --git a/fxjs/cjx_node.cpp b/fxjs/cjx_node.cpp
index 4a07b31d4a..1c476a2157 100644
--- a/fxjs/cjx_node.cpp
+++ b/fxjs/cjx_node.cpp
@@ -17,8 +17,8 @@
#include "core/fxcrt/xml/cfx_xmlelement.h"
#include "core/fxcrt/xml/cfx_xmlnode.h"
#include "core/fxcrt/xml/cfx_xmltext.h"
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_engine.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
@@ -249,93 +249,81 @@ int32_t CJX_Node::InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom) {
return 0;
}
-void CJX_Node::applyXSL(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"applyXSL");
- return;
- }
+CJS_Return CJX_Node::applyXSL(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
// TODO(weili): check whether we need to implement this, pdfium:501.
+ return CJS_Return(true);
}
-void CJX_Node::assignNode(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 3) {
- ThrowParamCountMismatchException(L"assignNode");
- return;
- }
+CJS_Return CJX_Node::assignNode(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty() || params.size() > 3)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
// TODO(weili): check whether we need to implement this, pdfium:501.
+ return CJS_Return(true);
}
-void CJX_Node::clone(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"clone");
- return;
- }
+CJS_Return CJX_Node::clone(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CXFA_Node* pCloneNode = GetXFANode()->Clone(!!pArguments->GetInt32(0));
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(pCloneNode));
+ CXFA_Node* pCloneNode = GetXFANode()->Clone(runtime->ToBoolean(params[0]));
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pCloneNode);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}
-void CJX_Node::getAttribute(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"getAttribute");
- return;
- }
+CJS_Return CJX_Node::getAttribute(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (!pValue)
- return;
-
- WideString wsExpression =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
- pValue->SetString(
- GetAttribute(wsExpression.AsStringView()).UTF8Encode().AsStringView());
+ WideString expression = runtime->ToWideString(params[0]);
+ return CJS_Return(runtime->NewString(
+ GetAttribute(expression.AsStringView()).UTF8Encode().AsStringView()));
}
-void CJX_Node::getElement(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 2) {
- ThrowParamCountMismatchException(L"getElement");
- return;
- }
+CJS_Return CJX_Node::getElement(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty() || params.size() > 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- WideString wsExpression =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
- int32_t iValue = iLength >= 2 ? pArguments->GetInt32(1) : 0;
+ WideString expression = runtime->ToWideString(params[0]);
+ int32_t iValue = params.size() >= 2 ? runtime->ToInt32(params[1]) : 0;
CXFA_Node* pNode =
- GetProperty(iValue, CXFA_Node::NameToElement(wsExpression), true);
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode));
-}
-
-void CJX_Node::isPropertySpecified(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 3) {
- ThrowParamCountMismatchException(L"isPropertySpecified");
- return;
- }
-
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (!pValue)
- return;
-
- WideString wsExpression =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
- XFA_Attribute attr = CXFA_Node::NameToAttribute(wsExpression.AsStringView());
- if (attr != XFA_Attribute::Unknown && HasAttribute(attr)) {
- pValue->SetBoolean(true);
- return;
- }
-
- bool bParent = iLength < 2 || pArguments->GetInt32(1);
- int32_t iIndex = iLength == 3 ? pArguments->GetInt32(2) : 0;
- XFA_Element eType = CXFA_Node::NameToElement(wsExpression);
+ GetProperty(iValue, CXFA_Node::NameToElement(expression), true);
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
+}
+
+CJS_Return CJX_Node::isPropertySpecified(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty() || params.size() > 3)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+
+ WideString expression = runtime->ToWideString(params[0]);
+ XFA_Attribute attr = CXFA_Node::NameToAttribute(expression.AsStringView());
+ if (attr != XFA_Attribute::Unknown && HasAttribute(attr))
+ return CJS_Return(runtime->NewBoolean(true));
+
+ bool bParent = params.size() < 2 || runtime->ToBoolean(params[1]);
+ int32_t iIndex = params.size() == 3 ? runtime->ToInt32(params[2]) : 0;
+ XFA_Element eType = CXFA_Node::NameToElement(expression);
bool bHas = !!GetProperty(iIndex, eType, true);
if (!bHas && bParent && GetXFANode()->GetParent()) {
// Also check on the parent.
@@ -343,35 +331,33 @@ void CJX_Node::isPropertySpecified(CFXJSE_Arguments* pArguments) {
bHas = jsnode->HasAttribute(attr) ||
!!jsnode->GetProperty(iIndex, eType, true);
}
- pValue->SetBoolean(bHas);
+ return CJS_Return(runtime->NewBoolean(bHas));
}
-void CJX_Node::loadXML(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 3) {
- ThrowParamCountMismatchException(L"loadXML");
- return;
- }
+CJS_Return CJX_Node::loadXML(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty() || params.size() > 3)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- ByteString wsExpression = pArguments->GetUTF8String(0);
- if (wsExpression.IsEmpty())
- return;
+ ByteString expression = runtime->ToByteString(params[0]);
+ if (expression.IsEmpty())
+ return CJS_Return(true);
bool bIgnoreRoot = true;
- if (iLength >= 2)
- bIgnoreRoot = !!pArguments->GetInt32(1);
+ if (params.size() >= 2)
+ bIgnoreRoot = runtime->ToBoolean(params[1]);
bool bOverwrite = 0;
- if (iLength >= 3)
- bOverwrite = !!pArguments->GetInt32(2);
+ if (params.size() >= 3)
+ bOverwrite = runtime->ToBoolean(params[2]);
auto pParser = pdfium::MakeUnique<CXFA_SimpleParser>(GetDocument());
if (!pParser)
- return;
+ return CJS_Return(true);
- CFX_XMLNode* pXMLNode = pParser->ParseXMLData(wsExpression);
+ CFX_XMLNode* pXMLNode = pParser->ParseXMLData(expression);
if (!pXMLNode)
- return;
+ return CJS_Return(true);
if (bIgnoreRoot &&
(pXMLNode->GetType() != FX_XMLNODE_Element ||
@@ -416,7 +402,7 @@ void CJX_Node::loadXML(CFXJSE_Arguments* pArguments) {
pParser->ConstructXFANode(pFakeRoot, pFakeXMLRoot.get());
pFakeRoot = pParser->GetRootNode();
if (!pFakeRoot)
- return;
+ return CJS_Return(true);
if (bOverwrite) {
CXFA_Node* pChild = GetXFANode()->GetNodeItem(XFA_NODEITEM_FirstChild);
@@ -464,41 +450,40 @@ void CJX_Node::loadXML(CFXJSE_Arguments* pArguments) {
pFakeRoot->SetFlag(XFA_NodeFlag_OwnXMLNode, false);
}
pFakeRoot->SetFlag(XFA_NodeFlag_HasRemovedChildren, false);
+
+ return CJS_Return(true);
}
-void CJX_Node::saveFilteredXML(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_Node::saveFilteredXML(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// TODO(weili): Check whether we need to implement this, pdfium:501.
+ return CJS_Return(true);
}
-void CJX_Node::saveXML(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 0 || iLength > 1) {
- ThrowParamCountMismatchException(L"saveXML");
- return;
- }
-
- if (iLength == 1 && pArguments->GetUTF8String(0) != "pretty") {
- ThrowArgumentMismatchException();
- return;
- }
+CJS_Return CJX_Node::saveXML(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() > 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ if (params.size() == 1 && runtime->ToWideString(params[0]) != L"pretty")
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
// TODO(weili): Check whether we need to save pretty print XML, pdfium:501.
WideString bsXMLHeader = L"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
if (GetXFANode()->GetPacketType() != XFA_PacketType::Form &&
GetXFANode()->GetPacketType() != XFA_PacketType::Datasets) {
- pArguments->GetReturnValue()->SetString("");
- return;
+ return CJS_Return(runtime->NewString(""));
}
CFX_XMLNode* pElement = nullptr;
if (GetXFANode()->GetPacketType() == XFA_PacketType::Datasets) {
pElement = GetXFANode()->GetXMLMappingNode();
if (!pElement || pElement->GetType() != FX_XMLNODE_Element) {
- pArguments->GetReturnValue()->SetString(
- bsXMLHeader.UTF8Encode().AsStringView());
- return;
+ return CJS_Return(
+ runtime->NewString(bsXMLHeader.UTF8Encode().AsStringView()));
}
+
XFA_DataExporter_DealWithDataGroupNode(GetXFANode());
}
@@ -513,32 +498,30 @@ void CJX_Node::saveXML(CFXJSE_Arguments* pArguments) {
else
pElement->SaveXMLNode(pStream);
- pArguments->GetReturnValue()->SetString(
- ByteStringView(pMemoryStream->GetBuffer(), pMemoryStream->GetSize()));
+ return CJS_Return(runtime->NewString(
+ ByteStringView(pMemoryStream->GetBuffer(), pMemoryStream->GetSize())));
}
-void CJX_Node::setAttribute(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 2) {
- ThrowParamCountMismatchException(L"setAttribute");
- return;
- }
+CJS_Return CJX_Node::setAttribute(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- WideString wsAttributeValue =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
- WideString wsAttribute =
- WideString::FromUTF8(pArguments->GetUTF8String(1).AsStringView());
- SetAttribute(wsAttribute.AsStringView(), wsAttributeValue.AsStringView(),
- true);
+ WideString attributeValue = runtime->ToWideString(params[0]);
+ WideString attribute = runtime->ToWideString(params[1]);
+ SetAttribute(attribute.AsStringView(), attributeValue.AsStringView(), true);
+ return CJS_Return(true);
}
-void CJX_Node::setElement(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1 && iLength != 2) {
- ThrowParamCountMismatchException(L"setElement");
- return;
- }
+CJS_Return CJX_Node::setElement(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1 && params.size() != 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
// TODO(weili): check whether we need to implement this, pdfium:501.
+ return CJS_Return(true);
}
void CJX_Node::Script_NodeClass_Ns(CFXJSE_Value* pValue,
diff --git a/fxjs/cjx_object.cpp b/fxjs/cjx_object.cpp
index 21eb3c8921..fbbcc00365 100644
--- a/fxjs/cjx_object.cpp
+++ b/fxjs/cjx_object.cpp
@@ -6,12 +6,13 @@
#include "fxjs/cjx_object.h"
-#include <map>
#include <utility>
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/xml/cfx_xmltext.h"
+#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/cjs_return.h"
#include "third_party/base/ptr_util.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/cxfa_ffwidget.h"
@@ -103,11 +104,14 @@ bool CJX_Object::HasMethod(const WideString& func) const {
return pdfium::ContainsKey(method_specs_, func.UTF8Encode());
}
-void CJX_Object::RunMethod(const WideString& func, CFXJSE_Arguments* args) {
+CJS_Return CJX_Object::RunMethod(
+ const WideString& func,
+ const std::vector<v8::Local<v8::Value>>& params) {
auto it = method_specs_.find(func.UTF8Encode());
if (it == method_specs_.end())
- return;
- it->second(this, args);
+ return CJS_Return(false);
+ return it->second(this, GetXFAObject()->GetDocument()->GetScriptContext(),
+ params);
}
void CJX_Object::ThrowInvalidPropertyException() const {
diff --git a/fxjs/cjx_object.h b/fxjs/cjx_object.h
index c945c1e832..fb6251e224 100644
--- a/fxjs/cjx_object.h
+++ b/fxjs/cjx_object.h
@@ -9,14 +9,25 @@
#include <map>
#include <memory>
+#include <vector>
#include "core/fxcrt/unowned_ptr.h"
#include "core/fxcrt/widestring.h"
#include "core/fxcrt/xml/cfx_xmlelement.h"
+#include "third_party/base/optional.h"
#include "xfa/fxfa/fxfa_basic.h"
-typedef void (*CJX_MethodCall)(CJX_Object* obj, CFXJSE_Arguments* args);
+class CFXJSE_Value;
+class CJS_V8;
+class CXFA_CalcData;
+class CXFA_Document;
+class CXFA_Object;
+struct XFA_MAPMODULEDATA;
+typedef CJS_Return (*CJX_MethodCall)(
+ CJX_Object* obj,
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params);
struct CJX_MethodSpec {
const char* pName;
CJX_MethodCall pMethodCall;
@@ -30,12 +41,6 @@ struct XFA_MAPDATABLOCKCALLBACKINFO {
PD_CALLBACK_DUPLICATEDATA pCopy;
};
-class CFXJSE_Value;
-class CXFA_CalcData;
-class CXFA_Document;
-class CXFA_Object;
-struct XFA_MAPMODULEDATA;
-
class CJX_Object {
public:
virtual ~CJX_Object();
@@ -46,7 +51,8 @@ class CJX_Object {
CXFA_Document* GetDocument() const;
bool HasMethod(const WideString& func) const;
- void RunMethod(const WideString& func, CFXJSE_Arguments* args);
+ CJS_Return RunMethod(const WideString& func,
+ const std::vector<v8::Local<v8::Value>>& params);
bool HasAttribute(XFA_Attribute eAttr);
bool SetAttribute(XFA_Attribute eAttr,
diff --git a/fxjs/cjx_signaturepseudomodel.cpp b/fxjs/cjx_signaturepseudomodel.cpp
index b50e5dc9ab..900116bccf 100644
--- a/fxjs/cjx_signaturepseudomodel.cpp
+++ b/fxjs/cjx_signaturepseudomodel.cpp
@@ -6,8 +6,10 @@
#include "fxjs/cjx_signaturepseudomodel.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cscript_signaturepseudomodel.h"
const CJX_MethodSpec CJX_SignaturePseudoModel::MethodSpecs[] = {
@@ -25,46 +27,34 @@ CJX_SignaturePseudoModel::CJX_SignaturePseudoModel(
CJX_SignaturePseudoModel::~CJX_SignaturePseudoModel() {}
-void CJX_SignaturePseudoModel::verifySignature(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 4) {
- ThrowParamCountMismatchException(L"verify");
- return;
- }
-
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetInteger(0);
+CJS_Return CJX_SignaturePseudoModel::verifySignature(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty() || params.size() > 4)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewNumber(0));
}
-void CJX_SignaturePseudoModel::sign(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 3 || iLength > 7) {
- ThrowParamCountMismatchException(L"sign");
- return;
- }
-
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetBoolean(false);
+CJS_Return CJX_SignaturePseudoModel::sign(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() < 3 || params.size() > 7)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewBoolean(false));
}
-void CJX_SignaturePseudoModel::enumerate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"enumerate");
- return;
- }
- return;
+CJS_Return CJX_SignaturePseudoModel::enumerate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_SignaturePseudoModel::clear(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 2) {
- ThrowParamCountMismatchException(L"clear");
- return;
- }
-
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetBoolean(false);
+CJS_Return CJX_SignaturePseudoModel::clear(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty() || params.size() > 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewBoolean(false));
}
diff --git a/fxjs/fxjse.h b/fxjs/fxjse.h
index df1dff6243..873fcf50d2 100644
--- a/fxjs/fxjse.h
+++ b/fxjs/fxjse.h
@@ -13,6 +13,7 @@
class CFXJSE_Arguments;
class CFXJSE_Value;
+class CJS_Return;
// C++ object which is retrieved from v8 object's slot.
class CFXJSE_HostObject {
@@ -30,6 +31,9 @@ class CFXJSE_HostObject {
Type type_;
};
+typedef CJS_Return (*FXJSE_MethodCallback)(
+ const v8::FunctionCallbackInfo<v8::Value>& info,
+ const WideString& functionName);
typedef void (*FXJSE_FuncCallback)(CFXJSE_Value* pThis,
const ByteStringView& szFuncName,
CFXJSE_Arguments& args);
@@ -58,7 +62,7 @@ struct FXJSE_CLASS_DESCRIPTOR {
FXJSE_PropTypeGetter dynPropTypeGetter;
FXJSE_PropAccessor dynPropGetter;
FXJSE_PropAccessor dynPropSetter;
- FXJSE_FuncCallback dynMethodCall;
+ FXJSE_MethodCallback dynMethodCall;
};
void FXJSE_ThrowMessage(const ByteStringView& utf8Message);
diff --git a/fxjs/js_resources.cpp b/fxjs/js_resources.cpp
index b23103ab76..bfffbc3714 100644
--- a/fxjs/js_resources.cpp
+++ b/fxjs/js_resources.cpp
@@ -49,6 +49,8 @@ WideString JSGetStringFromID(JSMessage msg) {
return L"Permission denied.";
case JSMessage::kBadObjectError:
return L"Object no longer exists.";
+ case JSMessage::kTooManyOccurances:
+ return L"Too many occurances";
}
NOTREACHED();
return L"";
diff --git a/fxjs/js_resources.h b/fxjs/js_resources.h
index 728ec22126..0b664c997c 100644
--- a/fxjs/js_resources.h
+++ b/fxjs/js_resources.h
@@ -29,7 +29,8 @@ enum class JSMessage {
kTypeError,
kValueError,
kPermissionError,
- kBadObjectError
+ kBadObjectError,
+ kTooManyOccurances
};
WideString JSGetStringFromID(JSMessage msg);
diff --git a/fxjs/xfa/cjx_container.cpp b/fxjs/xfa/cjx_container.cpp
index 517fb86f98..a5d7921090 100644
--- a/fxjs/xfa/cjx_container.cpp
+++ b/fxjs/xfa/cjx_container.cpp
@@ -6,7 +6,8 @@
#include "fxjs/xfa/cjx_container.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
@@ -24,10 +25,17 @@ CJX_Container::CJX_Container(CXFA_Node* node) : CJX_Node(node) {
CJX_Container::~CJX_Container() {}
-void CJX_Container::getDelta(CFXJSE_Arguments* pArguments) {}
+CJS_Return CJX_Container::getDelta(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
+}
-void CJX_Container::getDeltas(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_Container::getDeltas(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(GetDocument());
- pArguments->GetReturnValue()->SetObject(
- pFormNodes, GetDocument()->GetScriptContext()->GetJseNormalClass());
+ return CJS_Return(runtime->NewXFAObject(
+ pFormNodes,
+ GetDocument()->GetScriptContext()->GetJseNormalClass()->GetTemplate()));
}
diff --git a/fxjs/xfa/cjx_content.cpp b/fxjs/xfa/cjx_content.cpp
index 87ddf63d86..dd25829a67 100644
--- a/fxjs/xfa/cjx_content.cpp
+++ b/fxjs/xfa/cjx_content.cpp
@@ -6,7 +6,6 @@
#include "fxjs/xfa/cjx_content.h"
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_value.h"
#include "xfa/fxfa/parser/cxfa_object.h"
diff --git a/fxjs/xfa/cjx_delta.cpp b/fxjs/xfa/cjx_delta.cpp
index b661ae9ffd..1dfad24319 100644
--- a/fxjs/xfa/cjx_delta.cpp
+++ b/fxjs/xfa/cjx_delta.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_delta.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_delta.h"
const CJX_MethodSpec CJX_Delta::MethodSpecs[] = {{"restore", restore_static},
@@ -19,7 +21,9 @@ CJX_Delta::CJX_Delta(CXFA_Delta* delta) : CJX_Object(delta) {
CJX_Delta::~CJX_Delta() {}
-void CJX_Delta::restore(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"restore");
+CJS_Return CJX_Delta::restore(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
diff --git a/fxjs/xfa/cjx_desc.cpp b/fxjs/xfa/cjx_desc.cpp
index 4efd1dde0e..7ff58a774a 100644
--- a/fxjs/xfa/cjx_desc.cpp
+++ b/fxjs/xfa/cjx_desc.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_desc.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_desc.h"
const CJX_MethodSpec CJX_Desc::MethodSpecs[] = {{"metadata", metadata_static},
@@ -19,11 +21,9 @@ CJX_Desc::CJX_Desc(CXFA_Desc* desc) : CJX_Node(desc) {
CJX_Desc::~CJX_Desc() {}
-void CJX_Desc::metadata(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 0 && argc != 1) {
- ThrowParamCountMismatchException(L"metadata");
- return;
- }
- pArguments->GetReturnValue()->SetString("");
+CJS_Return CJX_Desc::metadata(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 0 && params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewString(""));
}
diff --git a/fxjs/xfa/cjx_exclgroup.cpp b/fxjs/xfa/cjx_exclgroup.cpp
index c84ec94793..6317736ffa 100644
--- a/fxjs/xfa/cjx_exclgroup.cpp
+++ b/fxjs/xfa/cjx_exclgroup.cpp
@@ -6,9 +6,11 @@
#include "fxjs/xfa/cjx_exclgroup.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/cxfa_eventparam.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/fxfa.h"
@@ -30,89 +32,79 @@ CJX_ExclGroup::CJX_ExclGroup(CXFA_ExclGroup* group) : CJX_Node(group) {
CJX_ExclGroup::~CJX_ExclGroup() {}
-void CJX_ExclGroup::execEvent(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"execEvent");
- return;
- }
+CJS_Return CJX_ExclGroup::execEvent(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- ByteString eventString = pArguments->GetUTF8String(0);
- execSingleEventByName(
- WideString::FromUTF8(eventString.AsStringView()).AsStringView(),
- XFA_Element::ExclGroup);
+ execSingleEventByName(runtime->ToWideString(params[0]).AsStringView(),
+ XFA_Element::ExclGroup);
+ return CJS_Return(true);
}
-void CJX_ExclGroup::execInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
+CJS_Return CJX_ExclGroup::execInitialize(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+ if (pNotify)
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+ return CJS_Return(true);
}
-void CJX_ExclGroup::execCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
+CJS_Return CJX_ExclGroup::execCalculate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+ if (pNotify)
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+ return CJS_Return(true);
}
-void CJX_ExclGroup::execValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
+CJS_Return CJX_ExclGroup::execValidate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
+ CXFA_FFNotify* notify = GetDocument()->GetNotify();
+ if (!notify)
+ return CJS_Return(runtime->NewBoolean(false));
- int32_t iRet =
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ int32_t iRet = notify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate);
+ return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
-void CJX_ExclGroup::selectedMember(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc < 0 || argc > 1) {
- ThrowParamCountMismatchException(L"selectedMember");
- return;
- }
+CJS_Return CJX_ExclGroup::selectedMember(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
+ if (!pWidgetData)
+ return CJS_Return(runtime->NewNull());
CXFA_Node* pReturnNode = nullptr;
- if (argc == 0) {
+ if (params.empty()) {
pReturnNode = pWidgetData->GetSelectedMember();
} else {
- ByteString szName;
- szName = pArguments->GetUTF8String(0);
pReturnNode = pWidgetData->SetSelectedMember(
- WideString::FromUTF8(szName.AsStringView()).AsStringView(), true);
- }
- if (!pReturnNode) {
- pArguments->GetReturnValue()->SetNull();
- return;
+ runtime->ToWideString(params[0]).AsStringView(), true);
}
+ if (!pReturnNode)
+ return CJS_Return(runtime->NewNull());
+
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pReturnNode);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(pReturnNode));
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp
index f0dbc78c78..d2cffbc983 100644
--- a/fxjs/xfa/cjx_field.cpp
+++ b/fxjs/xfa/cjx_field.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_field.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/cxfa_eventparam.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/fxfa.h"
@@ -36,228 +38,199 @@ CJX_Field::CJX_Field(CXFA_Field* field) : CJX_Container(field) {
CJX_Field::~CJX_Field() {}
-void CJX_Field::clearItems(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_Field::clearItems(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
- if (!pWidgetData)
- return;
-
- pWidgetData->DeleteItem(-1, true, false);
+ if (pWidgetData)
+ pWidgetData->DeleteItem(-1, true, false);
+ return CJS_Return(true);
}
-void CJX_Field::execEvent(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"execEvent");
- return;
- }
+CJS_Return CJX_Field::execEvent(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- ByteString eventString = pArguments->GetUTF8String(0);
- int32_t iRet = execSingleEventByName(
- WideString::FromUTF8(eventString.AsStringView()).AsStringView(),
- XFA_Element::Field);
- if (eventString != "validate")
- return;
+ WideString eventString = runtime->ToWideString(params[0]);
+ int32_t iRet =
+ execSingleEventByName(eventString.AsStringView(), XFA_Element::Field);
+ if (eventString != L"validate")
+ return CJS_Return(true);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
-void CJX_Field::execInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
+CJS_Return CJX_Field::execInitialize(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false,
- false);
+ if (pNotify) {
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false,
+ false);
+ }
+ return CJS_Return(true);
}
-void CJX_Field::deleteItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"deleteItem");
- return;
- }
+CJS_Return CJX_Field::deleteItem(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
if (!pWidgetData)
- return;
+ return CJS_Return(true);
- int32_t iIndex = pArguments->GetInt32(0);
- bool bValue = pWidgetData->DeleteItem(iIndex, true, true);
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetBoolean(bValue);
+ bool bValue =
+ pWidgetData->DeleteItem(runtime->ToInt32(params[0]), true, true);
+ return CJS_Return(runtime->NewBoolean(bValue));
}
-void CJX_Field::getSaveItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"getSaveItem");
- return;
- }
+CJS_Return CJX_Field::getSaveItem(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- int32_t iIndex = pArguments->GetInt32(0);
- if (iIndex < 0) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
+ int32_t iIndex = runtime->ToInt32(params[0]);
+ if (iIndex < 0)
+ return CJS_Return(runtime->NewNull());
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
+ if (!pWidgetData)
+ return CJS_Return(runtime->NewNull());
pdfium::Optional<WideString> value =
pWidgetData->GetChoiceListItem(iIndex, true);
- if (!value) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
- pArguments->GetReturnValue()->SetString(value->UTF8Encode().AsStringView());
+ if (!value)
+ return CJS_Return(runtime->NewNull());
+
+ return CJS_Return(runtime->NewString(value->UTF8Encode().AsStringView()));
}
-void CJX_Field::boundItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"boundItem");
- return;
- }
+CJS_Return CJX_Field::boundItem(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
if (!pWidgetData)
- return;
-
- ByteString bsValue = pArguments->GetUTF8String(0);
- WideString wsValue = WideString::FromUTF8(bsValue.AsStringView());
- WideString wsBoundValue = pWidgetData->GetItemValue(wsValue.AsStringView());
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetString(wsBoundValue.UTF8Encode().AsStringView());
+ return CJS_Return(true);
+
+ WideString value = runtime->ToWideString(params[0]);
+ WideString boundValue = pWidgetData->GetItemValue(value.AsStringView());
+ return CJS_Return(runtime->NewString(boundValue.UTF8Encode().AsStringView()));
}
-void CJX_Field::getItemState(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"getItemState");
- return;
- }
+CJS_Return CJX_Field::getItemState(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
if (!pWidgetData)
- return;
+ return CJS_Return(true);
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetBoolean(pWidgetData->GetItemState(pArguments->GetInt32(0)));
+ int32_t state = pWidgetData->GetItemState(runtime->ToInt32(params[0]));
+ return CJS_Return(runtime->NewBoolean(state != 0));
}
-void CJX_Field::execCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
+CJS_Return CJX_Field::execCalculate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false,
- false);
+ if (pNotify) {
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false,
+ false);
+ }
+ return CJS_Return(true);
}
-void CJX_Field::getDisplayItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"getDisplayItem");
- return;
- }
+CJS_Return CJX_Field::getDisplayItem(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- int32_t iIndex = pArguments->GetInt32(0);
- if (iIndex < 0) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
+ int32_t iIndex = runtime->ToInt32(params[0]);
+ if (iIndex < 0)
+ return CJS_Return(runtime->NewNull());
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
+ if (!pWidgetData)
+ return CJS_Return(runtime->NewNull());
pdfium::Optional<WideString> value =
pWidgetData->GetChoiceListItem(iIndex, false);
- if (!value) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
- pArguments->GetReturnValue()->SetString(value->UTF8Encode().AsStringView());
+ if (!value)
+ return CJS_Return(runtime->NewNull());
+
+ return CJS_Return(runtime->NewString(value->UTF8Encode().AsStringView()));
}
-void CJX_Field::setItemState(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 2) {
- ThrowParamCountMismatchException(L"setItemState");
- return;
- }
+CJS_Return CJX_Field::setItemState(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
if (!pWidgetData)
- return;
+ return CJS_Return(true);
- int32_t iIndex = pArguments->GetInt32(0);
- if (pArguments->GetInt32(1) != 0) {
+ int32_t iIndex = runtime->ToInt32(params[0]);
+ if (runtime->ToInt32(params[1]) != 0) {
pWidgetData->SetItemState(iIndex, true, true, true, true);
- return;
+ return CJS_Return(true);
}
-
if (pWidgetData->GetItemState(iIndex))
pWidgetData->SetItemState(iIndex, false, true, true, true);
+
+ return CJS_Return(true);
}
-void CJX_Field::addItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 2) {
- ThrowParamCountMismatchException(L"addItem");
- return;
- }
+CJS_Return CJX_Field::addItem(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1 && params.size() != 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
if (!pWidgetData)
- return;
+ return CJS_Return(true);
- WideString wsLabel;
- if (iLength >= 1) {
- ByteString bsLabel = pArguments->GetUTF8String(0);
- wsLabel = WideString::FromUTF8(bsLabel.AsStringView());
- }
+ WideString label;
+ if (params.size() >= 1)
+ label = runtime->ToWideString(params[0]);
- WideString wsValue;
- if (iLength >= 2) {
- ByteString bsValue = pArguments->GetUTF8String(1);
- wsValue = WideString::FromUTF8(bsValue.AsStringView());
- }
+ WideString value;
+ if (params.size() >= 2)
+ value = runtime->ToWideString(params[1]);
- pWidgetData->InsertItem(wsLabel, wsValue, true);
+ pWidgetData->InsertItem(label, value, true);
+ return CJS_Return(true);
}
-void CJX_Field::execValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
+CJS_Return CJX_Field::execValidate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
+ if (!pNotify)
+ return CJS_Return(runtime->NewBoolean(false));
int32_t iRet = pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate,
false, false);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
diff --git a/fxjs/xfa/cjx_form.cpp b/fxjs/xfa/cjx_form.cpp
index 106910c6c1..22a7db2135 100644
--- a/fxjs/xfa/cjx_form.cpp
+++ b/fxjs/xfa/cjx_form.cpp
@@ -8,9 +8,9 @@
#include <vector>
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/cxfa_eventparam.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
@@ -32,97 +32,93 @@ CJX_Form::CJX_Form(CXFA_Form* form) : CJX_Model(form) {
CJX_Form::~CJX_Form() {}
-void CJX_Form::formNodes(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"formNodes");
- return;
- }
+CJS_Return CJX_Form::formNodes(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CXFA_Node* pDataNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- if (!pDataNode) {
- ThrowArgumentMismatchException();
- return;
- }
+ CXFA_Node* pDataNode = ToNode(runtime->ToXFAObject(params[0]));
+ if (!pDataNode)
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
std::vector<CXFA_Node*> formItems;
CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(GetDocument());
pFormNodes->SetArrayNodeList(formItems);
- pArguments->GetReturnValue()->SetObject(
- pFormNodes, GetDocument()->GetScriptContext()->GetJseNormalClass());
+
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pFormNodes);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}
-void CJX_Form::remerge(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"remerge");
- return;
- }
+CJS_Return CJX_Form::remerge(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
GetDocument()->DoDataRemerge(true);
+ return CJS_Return(true);
}
-void CJX_Form::execInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
+CJS_Return CJX_Form::execInitialize(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+ if (pNotify)
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+ return CJS_Return(true);
}
-void CJX_Form::recalculate(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_Form::recalculate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
CXFA_EventParam* pEventParam =
GetDocument()->GetScriptContext()->GetEventParam();
if (pEventParam->m_eType == XFA_EVENT_Calculate ||
pEventParam->m_eType == XFA_EVENT_InitCalculate) {
- return;
- }
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"recalculate");
- return;
+ return CJS_Return(true);
}
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
- if (pArguments->GetInt32(0) != 0)
- return;
+ if (!pNotify || runtime->ToInt32(params[0]) != 0)
+ return CJS_Return(true);
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate);
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Ready, true);
+ return CJS_Return(true);
}
-void CJX_Form::execCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
+CJS_Return CJX_Form::execCalculate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+ if (pNotify)
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+ return CJS_Return(true);
}
-void CJX_Form::execValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
+CJS_Return CJX_Form::execValidate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 0)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
+ if (!pNotify)
+ return CJS_Return(runtime->NewBoolean(false));
int32_t iRet =
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
diff --git a/fxjs/xfa/cjx_instancemanager.cpp b/fxjs/xfa/cjx_instancemanager.cpp
index da8422ea35..19c6d72cc3 100644
--- a/fxjs/xfa/cjx_instancemanager.cpp
+++ b/fxjs/xfa/cjx_instancemanager.cpp
@@ -6,9 +6,11 @@
#include "fxjs/xfa/cjx_instancemanager.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/cxfa_ffnotify.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_instancemanager.h"
@@ -30,18 +32,19 @@ CJX_InstanceManager::CJX_InstanceManager(CXFA_InstanceManager* mgr)
CJX_InstanceManager::~CJX_InstanceManager() {}
-void CJX_InstanceManager::moveInstance(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 2) {
- pArguments->GetReturnValue()->SetUndefined();
- return;
- }
+CJS_Return CJX_InstanceManager::moveInstance(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- int32_t iFrom = pArguments->GetInt32(0);
- int32_t iTo = pArguments->GetInt32(1);
+ int32_t iFrom = runtime->ToInt32(params[0]);
+ int32_t iTo = runtime->ToInt32(params[1]);
InstanceManager_MoveInstance(iTo, iFrom);
+
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
CXFA_Node* pToInstance = GetXFANode()->GetItem(iTo);
if (pToInstance && pToInstance->GetElementType() == XFA_Element::Subform)
@@ -52,29 +55,28 @@ void CJX_InstanceManager::moveInstance(CFXJSE_Arguments* pArguments) {
pFromInstance->GetElementType() == XFA_Element::Subform) {
pNotify->RunSubformIndexChange(pFromInstance);
}
+
+ return CJS_Return(true);
}
-void CJX_InstanceManager::removeInstance(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- pArguments->GetReturnValue()->SetUndefined();
- return;
- }
+CJS_Return CJX_InstanceManager::removeInstance(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- int32_t iIndex = pArguments->GetInt32(0);
+ int32_t iIndex = runtime->ToInt32(params[0]);
int32_t iCount = GetXFANode()->GetCount();
- if (iIndex < 0 || iIndex >= iCount) {
- ThrowIndexOutOfBoundsException();
- return;
- }
+ if (iIndex < 0 || iIndex >= iCount)
+ return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
int32_t iMin = CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMin();
- if (iCount - 1 < iMin) {
- ThrowTooManyOccurancesException(L"min");
- return;
- }
+ if (iCount - 1 < iMin)
+ return CJS_Return(JSGetStringFromID(JSMessage::kTooManyOccurances));
CXFA_Node* pRemoveInstance = GetXFANode()->GetItem(iIndex);
GetXFANode()->RemoveItem(pRemoveInstance, true);
+
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (pNotify) {
for (int32_t i = iIndex; i < iCount - 1; i++) {
@@ -86,95 +88,96 @@ void CJX_InstanceManager::removeInstance(CFXJSE_Arguments* pArguments) {
}
}
CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
- if (!pLayoutPro)
- return;
-
- pLayoutPro->AddChangedContainer(
- ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+ if (pLayoutPro) {
+ pLayoutPro->AddChangedContainer(
+ ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+ }
+ return CJS_Return(true);
}
-void CJX_InstanceManager::setInstances(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- pArguments->GetReturnValue()->SetUndefined();
- return;
- }
+CJS_Return CJX_InstanceManager::setInstances(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- int32_t iDesired = pArguments->GetInt32(0);
- InstanceManager_SetInstances(iDesired);
+ InstanceManager_SetInstances(runtime->ToInt32(params[0]));
+ return CJS_Return(true);
}
-void CJX_InstanceManager::addInstance(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 0 && argc != 1) {
- ThrowParamCountMismatchException(L"addInstance");
- return;
- }
+CJS_Return CJX_InstanceManager::addInstance(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty() && params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
bool fFlags = true;
- if (argc == 1)
- fFlags = pArguments->GetInt32(0) == 0 ? false : true;
+ if (params.size() == 1)
+ fFlags = runtime->ToBoolean(params[0]);
int32_t iCount = GetXFANode()->GetCount();
int32_t iMax = CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMax();
- if (iMax >= 0 && iCount >= iMax) {
- ThrowTooManyOccurancesException(L"max");
- return;
- }
+ if (iMax >= 0 && iCount >= iMax)
+ return CJS_Return(JSGetStringFromID(JSMessage::kTooManyOccurances));
CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(fFlags);
GetXFANode()->InsertItem(pNewInstance, iCount, iCount, false);
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance));
+
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
+ if (pNotify) {
+ pNotify->RunNodeInitialize(pNewInstance);
- pNotify->RunNodeInitialize(pNewInstance);
- CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
- if (!pLayoutPro)
- return;
+ CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
+ if (pLayoutPro) {
+ pLayoutPro->AddChangedContainer(
+ ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+ }
+ }
- pLayoutPro->AddChangedContainer(
- ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
+
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}
-void CJX_InstanceManager::insertInstance(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 1 && argc != 2) {
- ThrowParamCountMismatchException(L"insertInstance");
- return;
- }
+CJS_Return CJX_InstanceManager::insertInstance(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1 && params.size() != 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- int32_t iIndex = pArguments->GetInt32(0);
+ int32_t iIndex = runtime->ToInt32(params[0]);
bool bBind = false;
- if (argc == 2)
- bBind = pArguments->GetInt32(1) == 0 ? false : true;
+ if (params.size() == 2)
+ bBind = runtime->ToBoolean(params[1]);
int32_t iCount = GetXFANode()->GetCount();
- if (iIndex < 0 || iIndex > iCount) {
- ThrowIndexOutOfBoundsException();
- return;
- }
+ if (iIndex < 0 || iIndex > iCount)
+ return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
int32_t iMax = CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMax();
- if (iMax >= 0 && iCount >= iMax) {
- ThrowTooManyOccurancesException(L"max");
- return;
- }
+ if (iMax >= 0 && iCount >= iMax)
+ return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(bBind);
GetXFANode()->InsertItem(pNewInstance, iIndex, iCount, true);
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance));
+
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
+ if (pNotify) {
+ pNotify->RunNodeInitialize(pNewInstance);
+ CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
+ if (pLayoutPro) {
+ pLayoutPro->AddChangedContainer(
+ ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+ }
+ }
- pNotify->RunNodeInitialize(pNewInstance);
- CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
- if (!pLayoutPro)
- return;
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
- pLayoutPro->AddChangedContainer(
- ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}
diff --git a/fxjs/xfa/cjx_list.cpp b/fxjs/xfa/cjx_list.cpp
index 34cf9da7a5..84bdf7bd07 100644
--- a/fxjs/xfa/cjx_list.cpp
+++ b/fxjs/xfa/cjx_list.cpp
@@ -6,9 +6,11 @@
#include "fxjs/xfa/cjx_list.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_list.h"
#include "xfa/fxfa/parser/cxfa_node.h"
@@ -29,67 +31,58 @@ CXFA_List* CJX_List::GetXFAList() {
return static_cast<CXFA_List*>(GetXFAObject());
}
-void CJX_List::append(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 1) {
- ThrowParamCountMismatchException(L"append");
- return;
- }
+CJS_Return CJX_List::append(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+
+ auto* pNode = ToNode(runtime->ToXFAObject(params[0]));
+ if (!pNode)
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
- auto* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- if (!pNode) {
- ThrowArgumentMismatchException();
- return;
- }
GetXFAList()->Append(pNode);
+ return CJS_Return(true);
}
-void CJX_List::insert(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 2) {
- ThrowParamCountMismatchException(L"insert");
- return;
- }
+CJS_Return CJX_List::insert(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- auto* pNewNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- auto* pBeforeNode = static_cast<CXFA_Node*>(pArguments->GetObject(1));
- if (!pNewNode) {
- ThrowArgumentMismatchException();
- return;
- }
+ auto* pNewNode = ToNode(runtime->ToXFAObject(params[0]));
+ if (!pNewNode)
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
+
+ auto* pBeforeNode = ToNode(runtime->ToXFAObject(params[1]));
GetXFAList()->Insert(pNewNode, pBeforeNode);
+ return CJS_Return(true);
}
-void CJX_List::remove(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 1) {
- ThrowParamCountMismatchException(L"remove");
- return;
- }
+CJS_Return CJX_List::remove(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+
+ auto* pNode = ToNode(runtime->ToXFAObject(params[0]));
+ if (!pNode)
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
- auto* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- if (!pNode) {
- ThrowArgumentMismatchException();
- return;
- }
GetXFAList()->Remove(pNode);
+ return CJS_Return(true);
}
-void CJX_List::item(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 1) {
- ThrowParamCountMismatchException(L"item");
- return;
- }
+CJS_Return CJX_List::item(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- int32_t iIndex = pArguments->GetInt32(0);
- if (iIndex < 0 || iIndex >= GetXFAList()->GetLength()) {
- ThrowIndexOutOfBoundsException();
- return;
- }
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(
- GetXFAList()->Item(iIndex)));
+ int32_t iIndex = runtime->ToInt32(params[0]);
+ if (iIndex < 0 || iIndex >= GetXFAList()->GetLength())
+ return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
+
+ return CJS_Return(runtime->NewXFAObject(
+ GetXFAList()->Item(iIndex),
+ GetDocument()->GetScriptContext()->GetJseNormalClass()->GetTemplate()));
}
void CJX_List::length(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_manifest.cpp b/fxjs/xfa/cjx_manifest.cpp
index 066ba29e15..6d5da2c60e 100644
--- a/fxjs/xfa/cjx_manifest.cpp
+++ b/fxjs/xfa/cjx_manifest.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_manifest.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_manifest.h"
const CJX_MethodSpec CJX_Manifest::MethodSpecs[] = {
@@ -20,16 +22,12 @@ CJX_Manifest::CJX_Manifest(CXFA_Manifest* manifest) : CJX_Node(manifest) {
CJX_Manifest::~CJX_Manifest() {}
-void CJX_Manifest::evaluate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"evaluate");
- return;
- }
+CJS_Return CJX_Manifest::evaluate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+ return CJS_Return(runtime->NewBoolean(!!pWidgetData));
}
diff --git a/fxjs/xfa/cjx_model.cpp b/fxjs/xfa/cjx_model.cpp
index cd738b0018..65084162fb 100644
--- a/fxjs/xfa/cjx_model.cpp
+++ b/fxjs/xfa/cjx_model.cpp
@@ -6,9 +6,11 @@
#include "fxjs/xfa/cjx_model.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_delta.h"
#include "xfa/fxfa/parser/cxfa_document.h"
@@ -24,71 +26,60 @@ CJX_Model::CJX_Model(CXFA_Node* node) : CJX_Node(node) {
CJX_Model::~CJX_Model() {}
-void CJX_Model::clearErrorList(CFXJSE_Arguments* pArguments) {}
+CJS_Return CJX_Model::clearErrorList(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
+}
-void CJX_Model::createNode(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc <= 0 || argc >= 4) {
- ThrowParamCountMismatchException(L"createNode");
- return;
- }
+CJS_Return CJX_Model::createNode(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty() || params.size() > 3)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- WideString strName;
- WideString strNameSpace;
- if (argc > 1) {
- ByteString bsName = pArguments->GetUTF8String(1);
- strName = WideString::FromUTF8(bsName.AsStringView());
- if (argc == 3) {
- ByteString bsNameSpace = pArguments->GetUTF8String(2);
- strNameSpace = WideString::FromUTF8(bsNameSpace.AsStringView());
- }
- }
+ WideString name;
+ if (params.size() > 1)
+ name = runtime->ToWideString(params[1]);
+
+ WideString nameSpace;
+ if (params.size() == 3)
+ nameSpace = runtime->ToWideString(params[2]);
- ByteString bsTagName = pArguments->GetUTF8String(0);
- WideString strTagName = WideString::FromUTF8(bsTagName.AsStringView());
- XFA_Element eType = CXFA_Node::NameToElement(strTagName);
+ WideString tagName = runtime->ToWideString(params[0]);
+ XFA_Element eType = CXFA_Node::NameToElement(tagName);
CXFA_Node* pNewNode = GetXFANode()->CreateSamePacketNode(eType);
- if (!pNewNode) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
+ if (!pNewNode)
+ return CJS_Return(runtime->NewNull());
- if (strName.IsEmpty()) {
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewNode));
- return;
- }
+ if (!name.IsEmpty()) {
+ if (!pNewNode->HasAttribute(XFA_Attribute::Name))
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- if (!pNewNode->HasAttribute(XFA_Attribute::Name)) {
- ThrowMissingPropertyException(strTagName, L"name");
- return;
+ pNewNode->JSNode()->SetAttribute(XFA_Attribute::Name, name.AsStringView(),
+ true);
+ if (pNewNode->GetPacketType() == XFA_PacketType::Datasets)
+ pNewNode->CreateXMLMappingNode();
}
- pNewNode->JSNode()->SetAttribute(XFA_Attribute::Name, strName.AsStringView(),
- true);
- if (pNewNode->GetPacketType() == XFA_PacketType::Datasets)
- pNewNode->CreateXMLMappingNode();
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewNode);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewNode));
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}
-void CJX_Model::isCompatibleNS(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1) {
- ThrowParamCountMismatchException(L"isCompatibleNS");
- return;
- }
-
- WideString wsNameSpace;
- if (iLength >= 1) {
- ByteString bsNameSpace = pArguments->GetUTF8String(0);
- wsNameSpace = WideString::FromUTF8(bsNameSpace.AsStringView());
- }
+CJS_Return CJX_Model::isCompatibleNS(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (!pValue)
- return;
+ WideString nameSpace;
+ if (params.size() >= 1)
+ nameSpace = runtime->ToWideString(params[0]);
- pValue->SetBoolean(TryNamespace().value_or(WideString()) == wsNameSpace);
+ return CJS_Return(
+ runtime->NewBoolean(TryNamespace().value_or(WideString()) == nameSpace));
}
diff --git a/fxjs/xfa/cjx_packet.cpp b/fxjs/xfa/cjx_packet.cpp
index b1424d27e7..0040951ac3 100644
--- a/fxjs/xfa/cjx_packet.cpp
+++ b/fxjs/xfa/cjx_packet.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_packet.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_packet.h"
const CJX_MethodSpec CJX_Packet::MethodSpecs[] = {
@@ -22,54 +24,48 @@ CJX_Packet::CJX_Packet(CXFA_Packet* packet) : CJX_Node(packet) {
CJX_Packet::~CJX_Packet() {}
-void CJX_Packet::getAttribute(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"getAttribute");
- return;
- }
+CJS_Return CJX_Packet::getAttribute(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- WideString wsAttributeValue;
+ WideString attributeValue;
CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode();
if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) {
- ByteString bsAttributeName = pArguments->GetUTF8String(0);
- wsAttributeValue = static_cast<CFX_XMLElement*>(pXMLNode)->GetString(
- WideString::FromUTF8(bsAttributeName.AsStringView()).c_str());
+ attributeValue = static_cast<CFX_XMLElement*>(pXMLNode)->GetString(
+ runtime->ToWideString(params[0]).c_str());
}
-
- pArguments->GetReturnValue()->SetString(
- wsAttributeValue.UTF8Encode().AsStringView());
+ return CJS_Return(
+ runtime->NewString(attributeValue.UTF8Encode().AsStringView()));
}
-void CJX_Packet::setAttribute(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 2) {
- ThrowParamCountMismatchException(L"setAttribute");
- return;
- }
+CJS_Return CJX_Packet::setAttribute(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode();
if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) {
- ByteString bsValue = pArguments->GetUTF8String(0);
- ByteString bsName = pArguments->GetUTF8String(1);
static_cast<CFX_XMLElement*>(pXMLNode)->SetString(
- WideString::FromUTF8(bsName.AsStringView()),
- WideString::FromUTF8(bsValue.AsStringView()));
+ runtime->ToWideString(params[1]), runtime->ToWideString(params[0]));
}
- pArguments->GetReturnValue()->SetNull();
+ return CJS_Return(runtime->NewNull());
}
-void CJX_Packet::removeAttribute(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"removeAttribute");
- return;
- }
+CJS_Return CJX_Packet::removeAttribute(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode();
if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) {
- ByteString bsName = pArguments->GetUTF8String(0);
- WideString wsName = WideString::FromUTF8(bsName.AsStringView());
+ WideString name = runtime->ToWideString(params[0]);
CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLNode);
- if (pXMLElement->HasAttribute(wsName.c_str()))
- pXMLElement->RemoveAttribute(wsName.c_str());
+ if (pXMLElement->HasAttribute(name.c_str()))
+ pXMLElement->RemoveAttribute(name.c_str());
}
- pArguments->GetReturnValue()->SetNull();
+ return CJS_Return(runtime->NewNull());
}
diff --git a/fxjs/xfa/cjx_source.cpp b/fxjs/xfa/cjx_source.cpp
index 3197231811..17512b3e63 100644
--- a/fxjs/xfa/cjx_source.cpp
+++ b/fxjs/xfa/cjx_source.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_source.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_source.h"
const CJX_MethodSpec CJX_Source::MethodSpecs[] = {
@@ -36,87 +38,127 @@ CJX_Source::CJX_Source(CXFA_Source* src) : CJX_Node(src) {
CJX_Source::~CJX_Source() {}
-void CJX_Source::next(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"next");
+CJS_Return CJX_Source::next(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::cancelBatch(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"cancelBatch");
+CJS_Return CJX_Source::cancelBatch(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::first(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"first");
+CJS_Return CJX_Source::first(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::updateBatch(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"updateBatch");
+CJS_Return CJX_Source::updateBatch(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::previous(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"previous");
+CJS_Return CJX_Source::previous(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::isBOF(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"isBOF");
+CJS_Return CJX_Source::isBOF(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::isEOF(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"isEOF");
+CJS_Return CJX_Source::isEOF(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::cancel(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"cancel");
+CJS_Return CJX_Source::cancel(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::update(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"update");
+CJS_Return CJX_Source::update(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::open(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"open");
+CJS_Return CJX_Source::open(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::deleteItem(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"delete");
+CJS_Return CJX_Source::deleteItem(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::addNew(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"addNew");
+CJS_Return CJX_Source::addNew(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::requery(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"requery");
+CJS_Return CJX_Source::requery(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::resync(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"resync");
+CJS_Return CJX_Source::resync(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::close(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"close");
+CJS_Return CJX_Source::close(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::last(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"last");
+CJS_Return CJX_Source::last(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::hasDataChanged(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"hasDataChanged");
+CJS_Return CJX_Source::hasDataChanged(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
diff --git a/fxjs/xfa/cjx_subform.cpp b/fxjs/xfa/cjx_subform.cpp
index 32de182e7b..a7e1d2a587 100644
--- a/fxjs/xfa/cjx_subform.cpp
+++ b/fxjs/xfa/cjx_subform.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_subform.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/cxfa_eventparam.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/fxfa.h"
@@ -27,58 +29,52 @@ CJX_Subform::CJX_Subform(CXFA_Node* node) : CJX_Container(node) {
CJX_Subform::~CJX_Subform() {}
-void CJX_Subform::execEvent(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"execEvent");
- return;
- }
+CJS_Return CJX_Subform::execEvent(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- ByteString eventString = pArguments->GetUTF8String(0);
- execSingleEventByName(
- WideString::FromUTF8(eventString.AsStringView()).AsStringView(),
- XFA_Element::Subform);
+ execSingleEventByName(runtime->ToWideString(params[0]).AsStringView(),
+ XFA_Element::Subform);
+ return CJS_Return(true);
}
-void CJX_Subform::execInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
+CJS_Return CJX_Subform::execInitialize(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+ if (pNotify)
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+ return CJS_Return(true);
}
-void CJX_Subform::execCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
+CJS_Return CJX_Subform::execCalculate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+ if (pNotify)
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+ return CJS_Return(true);
}
-void CJX_Subform::execValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
+CJS_Return CJX_Subform::execValidate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
+ if (!pNotify)
+ return CJS_Return(runtime->NewBoolean(false));
int32_t iRet =
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
diff --git a/fxjs/xfa/cjx_template.cpp b/fxjs/xfa/cjx_template.cpp
index 99db4ea69a..48507c3494 100644
--- a/fxjs/xfa/cjx_template.cpp
+++ b/fxjs/xfa/cjx_template.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_template.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_template.h"
@@ -26,62 +28,56 @@ CJX_Template::CJX_Template(CXFA_Template* tmpl) : CJX_Model(tmpl) {
CJX_Template::~CJX_Template() {}
-void CJX_Template::formNodes(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"formNodes");
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+CJS_Return CJX_Template::formNodes(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewBoolean(true));
}
-void CJX_Template::remerge(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"remerge");
- return;
- }
+CJS_Return CJX_Template::remerge(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+
GetDocument()->DoDataRemerge(true);
+ return CJS_Return(true);
}
-void CJX_Template::execInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
+CJS_Return CJX_Template::execInitialize(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+ return CJS_Return(runtime->NewBoolean(!!pWidgetData));
}
-void CJX_Template::recalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"recalculate");
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+CJS_Return CJX_Template::recalculate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewBoolean(true));
}
-void CJX_Template::execCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
+CJS_Return CJX_Template::execCalculate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+ return CJS_Return(runtime->NewBoolean(!!pWidgetData));
}
-void CJX_Template::execValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(!!GetXFANode()->GetWidgetData());
+CJS_Return CJX_Template::execValidate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewBoolean(!!GetXFANode()->GetWidgetData()));
}
diff --git a/fxjs/xfa/cjx_textnode.cpp b/fxjs/xfa/cjx_textnode.cpp
index 4ebf3ce472..604682f2ee 100644
--- a/fxjs/xfa/cjx_textnode.cpp
+++ b/fxjs/xfa/cjx_textnode.cpp
@@ -6,7 +6,6 @@
#include "fxjs/xfa/cjx_textnode.h"
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_value.h"
#include "xfa/fxfa/parser/cxfa_node.h"
diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp
index 69cbfa0652..6c5e5abd89 100644
--- a/fxjs/xfa/cjx_tree.cpp
+++ b/fxjs/xfa/cjx_tree.cpp
@@ -6,9 +6,11 @@
#include "fxjs/xfa/cjx_tree.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "third_party/base/ptr_util.h"
#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
#include "xfa/fxfa/parser/cxfa_attachnodelist.h"
@@ -28,73 +30,76 @@ CJX_Tree::CJX_Tree(CXFA_Object* obj) : CJX_Object(obj) {
CJX_Tree::~CJX_Tree() {}
-void CJX_Tree::resolveNode(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"resolveNode");
- return;
- }
- WideString wsExpression =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
+CJS_Return CJX_Tree::resolveNode(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+
+ WideString expression = runtime->ToWideString(params[0]);
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return;
+ return CJS_Return(true);
+
CXFA_Object* refNode = GetXFAObject();
if (refNode->GetElementType() == XFA_Element::Xfa)
refNode = pScriptContext->GetThisObject();
+
uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings;
XFA_RESOLVENODE_RS resolveNodeRS;
if (!pScriptContext->ResolveObjects(ToNode(refNode),
- wsExpression.AsStringView(),
- &resolveNodeRS, dwFlag, nullptr)) {
- pArguments->GetReturnValue()->SetNull();
- return;
+ expression.AsStringView(), &resolveNodeRS,
+ dwFlag, nullptr)) {
+ return CJS_Return(runtime->NewNull());
}
+
if (resolveNodeRS.dwFlags == XFA_ResolveNode_RSType_Nodes) {
CXFA_Object* pObject = resolveNodeRS.objects.front();
- pArguments->GetReturnValue()->Assign(
- pScriptContext->GetJSValueFromMap(pObject));
- } else {
- const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo =
- resolveNodeRS.pScriptAttribute;
- if (lpAttributeInfo &&
- lpAttributeInfo->eValueType == XFA_ScriptType::Object) {
- auto pValue =
- pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetRuntime());
- CJX_Object* jsObject = resolveNodeRS.objects.front()->JSObject();
- (jsObject->*(lpAttributeInfo->callback))(pValue.get(), false,
- lpAttributeInfo->attribute);
- pArguments->GetReturnValue()->Assign(pValue.get());
- } else {
- pArguments->GetReturnValue()->SetNull();
- }
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pObject);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
+
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}
-}
-void CJX_Tree::resolveNodes(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"resolveNodes");
- return;
+ const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo =
+ resolveNodeRS.pScriptAttribute;
+ if (!lpAttributeInfo ||
+ lpAttributeInfo->eValueType != XFA_ScriptType::Object) {
+ return CJS_Return(runtime->NewNull());
}
- WideString wsExpression =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (!pValue)
- return;
+ auto pValue = pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetIsolate());
+ CJX_Object* jsObject = resolveNodeRS.objects.front()->JSObject();
+ (jsObject->*(lpAttributeInfo->callback))(pValue.get(), false,
+ lpAttributeInfo->attribute);
+ return CJS_Return(pValue->DirectGetValue().Get(runtime->GetIsolate()));
+}
+
+CJS_Return CJX_Tree::resolveNodes(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_Object* refNode = GetXFAObject();
if (refNode->GetElementType() == XFA_Element::Xfa)
refNode = GetDocument()->GetScriptContext()->GetThisObject();
- ResolveNodeList(pValue, wsExpression,
+ CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
+ if (!pScriptContext)
+ return CJS_Return(true);
+
+ auto pValue = pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetIsolate());
+ ResolveNodeList(pValue.get(), runtime->ToWideString(params[0]),
XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings,
ToNode(refNode));
+ return CJS_Return(pValue->DirectGetValue().Get(runtime->GetIsolate()));
}
void CJX_Tree::all(CFXJSE_Value* pValue,
@@ -215,7 +220,7 @@ void CJX_Tree::ResolveNodeList(CFXJSE_Value* pValue,
resolveNodeRS.pScriptAttribute->eValueType == XFA_ScriptType::Object) {
for (CXFA_Object* pObject : resolveNodeRS.objects) {
auto pValue =
- pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetRuntime());
+ pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetIsolate());
CJX_Object* jsObject = pObject->JSObject();
(jsObject->*(resolveNodeRS.pScriptAttribute->callback))(
pValue.get(), false, resolveNodeRS.pScriptAttribute->attribute);
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()));
}
diff --git a/fxjs/xfa/cjx_wsdlconnection.cpp b/fxjs/xfa/cjx_wsdlconnection.cpp
index 8a684f4341..a1d673fae5 100644
--- a/fxjs/xfa/cjx_wsdlconnection.cpp
+++ b/fxjs/xfa/cjx_wsdlconnection.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_wsdlconnection.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_wsdlconnection.h"
const CJX_MethodSpec CJX_WsdlConnection::MethodSpecs[] = {
@@ -21,11 +23,10 @@ CJX_WsdlConnection::CJX_WsdlConnection(CXFA_WsdlConnection* connection)
CJX_WsdlConnection::~CJX_WsdlConnection() {}
-void CJX_WsdlConnection::execute(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 0 && argc != 1) {
- ThrowParamCountMismatchException(L"execute");
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(false);
+CJS_Return CJX_WsdlConnection::execute(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty() && params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewBoolean(false));
}
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index ef5904c946..86d1da5ed4 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -607,7 +607,7 @@ std::pair<int32_t, bool> CXFA_WidgetAcc::ExecuteBoolScript(
pContext->SetNodesOfRunScript(&refNodes);
}
- auto pTmpRetValue = pdfium::MakeUnique<CFXJSE_Value>(pContext->GetRuntime());
+ auto pTmpRetValue = pdfium::MakeUnique<CFXJSE_Value>(pContext->GetIsolate());
++m_nRecursionDepth;
bool bRet = pContext->RunScript(eScriptType, wsExpression.AsStringView(),
pTmpRetValue.get(), m_pNode);
diff --git a/xfa/fxfa/fxfa_basic.h b/xfa/fxfa/fxfa_basic.h
index b5acd2df40..96b483d978 100644
--- a/xfa/fxfa/fxfa_basic.h
+++ b/xfa/fxfa/fxfa_basic.h
@@ -7,10 +7,8 @@
#ifndef XFA_FXFA_FXFA_BASIC_H_
#define XFA_FXFA_FXFA_BASIC_H_
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/fxjse.h"
-class CFXJSE_Arguments;
class CJX_Object;
class CXFA_Measurement;
enum class XFA_ObjectType;
@@ -966,14 +964,6 @@ enum class XFA_Unit : uint8_t {
Unknown = 255,
};
-typedef void (CJX_Object::*XFA_METHOD_CALLBACK)(CFXJSE_Arguments* pArguments);
-
-struct XFA_METHODINFO {
- uint32_t uHash;
- const wchar_t* pName;
- XFA_METHOD_CALLBACK callback;
-};
-
typedef void (CJX_Object::*XFA_ATTRIBUTE_CALLBACK)(CFXJSE_Value* pValue,
bool bSetting,
XFA_Attribute eAttribute);
diff --git a/xfa/fxfa/parser/cscript_datawindow.cpp b/xfa/fxfa/parser/cscript_datawindow.cpp
index e8ffdaa114..25ad589fe5 100644
--- a/xfa/fxfa/parser/cscript_datawindow.cpp
+++ b/xfa/fxfa/parser/cscript_datawindow.cpp
@@ -6,7 +6,6 @@
#include "xfa/fxfa/parser/cscript_datawindow.h"
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cjx_datawindow.h"
#include "third_party/base/ptr_util.h"
#include "xfa/fxfa/parser/cxfa_document.h"
diff --git a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp
index c09ba76c47..8f4e049a4f 100644
--- a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp
@@ -6,7 +6,6 @@
#include "xfa/fxfa/parser/cscript_eventpseudomodel.h"
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cjx_object.h"
#include "third_party/base/ptr_util.h"
diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp
index 9ca3828961..8122aa32f7 100644
--- a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp
@@ -6,7 +6,6 @@
#include "xfa/fxfa/parser/cscript_hostpseudomodel.h"
-#include "fxjs/cfxjse_arguments.h"
#include "third_party/base/ptr_util.h"
CScript_HostPseudoModel::CScript_HostPseudoModel(CXFA_Document* pDocument)
diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
index 675e79531e..73033d5bea 100644
--- a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
@@ -6,7 +6,6 @@
#include "xfa/fxfa/parser/cscript_layoutpseudomodel.h"
-#include "fxjs/cfxjse_arguments.h"
#include "third_party/base/ptr_util.h"
CScript_LayoutPseudoModel::CScript_LayoutPseudoModel(CXFA_Document* pDocument)
diff --git a/xfa/fxfa/parser/cscript_logpseudomodel.cpp b/xfa/fxfa/parser/cscript_logpseudomodel.cpp
index 7a9c410aba..1c2d80204c 100644
--- a/xfa/fxfa/parser/cscript_logpseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_logpseudomodel.cpp
@@ -6,7 +6,6 @@
#include "xfa/fxfa/parser/cscript_logpseudomodel.h"
-#include "fxjs/cfxjse_arguments.h"
#include "third_party/base/ptr_util.h"
CScript_LogPseudoModel::CScript_LogPseudoModel(CXFA_Document* pDocument)
diff --git a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp
index a8a67429be..c5f4e6425f 100644
--- a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp
@@ -6,7 +6,6 @@
#include "xfa/fxfa/parser/cscript_signaturepseudomodel.h"
-#include "fxjs/cfxjse_arguments.h"
#include "third_party/base/ptr_util.h"
CScript_SignaturePseudoModel::CScript_SignaturePseudoModel(