summaryrefslogtreecommitdiff
path: root/fxjs/xfa
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-08-17 16:44:50 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-17 16:44:50 +0000
commit20736f7f5884cf1e2827543c92b6e47f8282aeaf (patch)
tree9a0f3cbd9262d1676f70ab02c3fa5b4e0acaa03a /fxjs/xfa
parent21068062a038db72b5ee40512fe638acbdd17c3d (diff)
downloadpdfium-20736f7f5884cf1e2827543c92b6e47f8282aeaf.tar.xz
Introduce safer CJS_Return::Success() and Failure().
Avoid the possibility of ever re-introducing the issue noticed last week. Remove some redundant JSGetStringFromID() calls. Change-Id: I56687c2191bd72e378f747083f34080e50cbe490 Reviewed-on: https://pdfium-review.googlesource.com/40490 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/xfa')
-rw-r--r--fxjs/xfa/cjx_container.cpp8
-rw-r--r--fxjs/xfa/cjx_datawindow.cpp8
-rw-r--r--fxjs/xfa/cjx_delta.cpp5
-rw-r--r--fxjs/xfa/cjx_desc.cpp5
-rw-r--r--fxjs/xfa/cjx_eventpseudomodel.cpp19
-rw-r--r--fxjs/xfa/cjx_exclgroup.cpp29
-rw-r--r--fxjs/xfa/cjx_field.cpp77
-rw-r--r--fxjs/xfa/cjx_form.cpp35
-rw-r--r--fxjs/xfa/cjx_hostpseudomodel.cpp118
-rw-r--r--fxjs/xfa/cjx_instancemanager.cpp54
-rw-r--r--fxjs/xfa/cjx_layoutpseudomodel.cpp63
-rw-r--r--fxjs/xfa/cjx_list.cpp24
-rw-r--r--fxjs/xfa/cjx_logpseudomodel.cpp10
-rw-r--r--fxjs/xfa/cjx_manifest.cpp5
-rw-r--r--fxjs/xfa/cjx_model.cpp17
-rw-r--r--fxjs/xfa/cjx_node.cpp72
-rw-r--r--fxjs/xfa/cjx_object.cpp2
-rw-r--r--fxjs/xfa/cjx_packet.cpp12
-rw-r--r--fxjs/xfa/cjx_signaturepseudomodel.cpp20
-rw-r--r--fxjs/xfa/cjx_source.cpp85
-rw-r--r--fxjs/xfa/cjx_subform.cpp18
-rw-r--r--fxjs/xfa/cjx_template.cpp32
-rw-r--r--fxjs/xfa/cjx_tree.cpp23
-rw-r--r--fxjs/xfa/cjx_treelist.cpp9
-rw-r--r--fxjs/xfa/cjx_wsdlconnection.cpp5
25 files changed, 403 insertions, 352 deletions
diff --git a/fxjs/xfa/cjx_container.cpp b/fxjs/xfa/cjx_container.cpp
index a04fccfee0..ddf5ba12ef 100644
--- a/fxjs/xfa/cjx_container.cpp
+++ b/fxjs/xfa/cjx_container.cpp
@@ -27,14 +27,14 @@ CJX_Container::~CJX_Container() {}
CJS_Return CJX_Container::getDelta(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Container::getDeltas(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(GetDocument());
- return CJS_Return(static_cast<CFXJSE_Engine*>(runtime)->NewXFAObject(
- pFormNodes,
+ auto* pEngine = static_cast<CFXJSE_Engine*>(runtime);
+ return CJS_Return::Success(pEngine->NewXFAObject(
+ new CXFA_ArrayNodeList(GetDocument()),
GetDocument()->GetScriptContext()->GetJseNormalClass()->GetTemplate()));
}
diff --git a/fxjs/xfa/cjx_datawindow.cpp b/fxjs/xfa/cjx_datawindow.cpp
index 01a35f0ec8..b03e24161d 100644
--- a/fxjs/xfa/cjx_datawindow.cpp
+++ b/fxjs/xfa/cjx_datawindow.cpp
@@ -27,25 +27,25 @@ CJX_DataWindow::~CJX_DataWindow() {}
CJS_Return CJX_DataWindow::moveCurrentRecord(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_DataWindow::record(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_DataWindow::gotoRecord(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_DataWindow::isRecordGroup(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
void CJX_DataWindow::recordsBefore(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_delta.cpp b/fxjs/xfa/cjx_delta.cpp
index c87ff3507f..791fd213df 100644
--- a/fxjs/xfa/cjx_delta.cpp
+++ b/fxjs/xfa/cjx_delta.cpp
@@ -23,8 +23,9 @@ CJX_Delta::~CJX_Delta() {}
CJS_Return CJX_Delta::restore(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
void CJX_Delta::currentValue(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_desc.cpp b/fxjs/xfa/cjx_desc.cpp
index aa8ee2961b..03379cedbc 100644
--- a/fxjs/xfa/cjx_desc.cpp
+++ b/fxjs/xfa/cjx_desc.cpp
@@ -23,8 +23,9 @@ CJX_Desc::~CJX_Desc() {}
CJS_Return CJX_Desc::metadata(CFX_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(""));
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success(runtime->NewString(""));
}
void CJX_Desc::use(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_eventpseudomodel.cpp b/fxjs/xfa/cjx_eventpseudomodel.cpp
index a1457432f9..3adf1e39a8 100644
--- a/fxjs/xfa/cjx_eventpseudomodel.cpp
+++ b/fxjs/xfa/cjx_eventpseudomodel.cpp
@@ -174,22 +174,22 @@ CJS_Return CJX_EventPseudoModel::emit(
const std::vector<v8::Local<v8::Value>>& params) {
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_EventParam* pEventParam = pScriptContext->GetEventParam();
if (!pEventParam)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_FFWidgetHandler* pWidgetHandler = pNotify->GetWidgetHandler();
if (!pWidgetHandler)
- return CJS_Return();
+ return CJS_Return::Success();
pWidgetHandler->ProcessEvent(pEventParam->m_pTarget.Get(), pEventParam);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_EventPseudoModel::reset(
@@ -197,14 +197,13 @@ CJS_Return CJX_EventPseudoModel::reset(
const std::vector<v8::Local<v8::Value>>& params) {
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_EventParam* pEventParam = pScriptContext->GetEventParam();
- if (!pEventParam)
- return CJS_Return();
+ if (pEventParam)
+ pEventParam->Reset();
- pEventParam->Reset();
- return CJS_Return();
+ return CJS_Return::Success();
}
void CJX_EventPseudoModel::Property(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_exclgroup.cpp b/fxjs/xfa/cjx_exclgroup.cpp
index 0de0ef00fd..3a7f9dd2fb 100644
--- a/fxjs/xfa/cjx_exclgroup.cpp
+++ b/fxjs/xfa/cjx_exclgroup.cpp
@@ -34,63 +34,63 @@ CJS_Return CJX_ExclGroup::execEvent(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
execSingleEventByName(runtime->ToWideString(params[0]).AsStringView(),
XFA_Element::ExclGroup);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_ExclGroup::execInitialize(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (pNotify)
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false,
true);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_ExclGroup::execCalculate(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (pNotify)
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false,
true);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_ExclGroup::execValidate(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* notify = GetDocument()->GetNotify();
if (!notify)
- return CJS_Return(runtime->NewBoolean(false));
+ return CJS_Return::Success(runtime->NewBoolean(false));
int32_t iRet = notify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate,
false, true);
- return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
+ return CJS_Return::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
CJS_Return CJX_ExclGroup::selectedMember(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_Node* node = GetXFANode();
if (!node->IsWidgetReady())
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
CXFA_Node* pReturnNode = nullptr;
if (params.empty()) {
@@ -100,14 +100,15 @@ CJS_Return CJX_ExclGroup::selectedMember(
runtime->ToWideString(params[0]).AsStringView(), true);
}
if (!pReturnNode)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
CFXJSE_Value* value =
GetDocument()->GetScriptContext()->GetJSValueFromMap(pReturnNode);
if (!value)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
- return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
+ return CJS_Return::Success(
+ value->DirectGetValue().Get(runtime->GetIsolate()));
}
void CJX_ExclGroup::defaultValue(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp
index d05e017b7e..c1210b9808 100644
--- a/fxjs/xfa/cjx_field.cpp
+++ b/fxjs/xfa/cjx_field.cpp
@@ -44,166 +44,169 @@ CJS_Return CJX_Field::clearItems(
CXFA_Node* node = GetXFANode();
if (node->IsWidgetReady())
node->DeleteItem(-1, true, false);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Field::execEvent(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString eventString = runtime->ToWideString(params[0]);
int32_t iRet =
execSingleEventByName(eventString.AsStringView(), XFA_Element::Field);
if (eventString != L"validate")
- return CJS_Return();
+ return CJS_Return::Success();
- return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
+ return CJS_Return::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
CJS_Return CJX_Field::execInitialize(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (pNotify) {
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false,
false);
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Field::deleteItem(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_Node* node = GetXFANode();
if (!node->IsWidgetReady())
- return CJS_Return();
+ return CJS_Return::Success();
bool bValue = node->DeleteItem(runtime->ToInt32(params[0]), true, true);
- return CJS_Return(runtime->NewBoolean(bValue));
+ return CJS_Return::Success(runtime->NewBoolean(bValue));
}
CJS_Return CJX_Field::getSaveItem(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
int32_t iIndex = runtime->ToInt32(params[0]);
if (iIndex < 0)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
CXFA_Node* node = GetXFANode();
if (!node->IsWidgetReady())
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
Optional<WideString> value = node->GetChoiceListItem(iIndex, true);
if (!value)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
- return CJS_Return(runtime->NewString(value->UTF8Encode().AsStringView()));
+ return CJS_Return::Success(
+ runtime->NewString(value->UTF8Encode().AsStringView()));
}
CJS_Return CJX_Field::boundItem(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_Node* node = GetXFANode();
if (!node->IsWidgetReady())
- return CJS_Return();
+ return CJS_Return::Success();
WideString value = runtime->ToWideString(params[0]);
WideString boundValue = node->GetItemValue(value.AsStringView());
- return CJS_Return(runtime->NewString(boundValue.UTF8Encode().AsStringView()));
+ return CJS_Return::Success(
+ runtime->NewString(boundValue.UTF8Encode().AsStringView()));
}
CJS_Return CJX_Field::getItemState(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_Node* node = GetXFANode();
if (!node->IsWidgetReady())
- return CJS_Return();
+ return CJS_Return::Success();
int32_t state = node->GetItemState(runtime->ToInt32(params[0]));
- return CJS_Return(runtime->NewBoolean(state != 0));
+ return CJS_Return::Success(runtime->NewBoolean(state != 0));
}
CJS_Return CJX_Field::execCalculate(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (pNotify) {
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false,
false);
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Field::getDisplayItem(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
int32_t iIndex = runtime->ToInt32(params[0]);
if (iIndex < 0)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
CXFA_Node* node = GetXFANode();
if (!node->IsWidgetReady())
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
Optional<WideString> value = node->GetChoiceListItem(iIndex, false);
if (!value)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
- return CJS_Return(runtime->NewString(value->UTF8Encode().AsStringView()));
+ return CJS_Return::Success(
+ runtime->NewString(value->UTF8Encode().AsStringView()));
}
CJS_Return CJX_Field::setItemState(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_Node* node = GetXFANode();
if (!node->IsWidgetReady())
- return CJS_Return();
+ return CJS_Return::Success();
int32_t iIndex = runtime->ToInt32(params[0]);
if (runtime->ToInt32(params[1]) != 0) {
node->SetItemState(iIndex, true, true, true, true);
- return CJS_Return();
+ return CJS_Return::Success();
}
if (node->GetItemState(iIndex))
node->SetItemState(iIndex, false, true, true, true);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Field::addItem(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1 && params.size() != 2)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_Node* node = GetXFANode();
if (!node->IsWidgetReady())
- return CJS_Return();
+ return CJS_Return::Success();
WideString label;
if (params.size() >= 1)
@@ -214,22 +217,22 @@ CJS_Return CJX_Field::addItem(CFX_V8* runtime,
value = runtime->ToWideString(params[1]);
node->InsertItem(label, value, true);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Field::execValidate(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return(runtime->NewBoolean(false));
+ return CJS_Return::Success(runtime->NewBoolean(false));
int32_t iRet = pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate,
false, false);
- return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
+ return CJS_Return::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
void CJX_Field::defaultValue(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_form.cpp b/fxjs/xfa/cjx_form.cpp
index e1441b01ec..3bbdb72bfb 100644
--- a/fxjs/xfa/cjx_form.cpp
+++ b/fxjs/xfa/cjx_form.cpp
@@ -35,12 +35,12 @@ CJS_Return CJX_Form::formNodes(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_Node* pDataNode =
ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0]));
if (!pDataNode)
- return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
+ return CJS_Return::Failure(JSMessage::kValueError);
std::vector<CXFA_Node*> formItems;
CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(GetDocument());
@@ -49,30 +49,31 @@ CJS_Return CJX_Form::formNodes(
CFXJSE_Value* value =
GetDocument()->GetScriptContext()->GetJSValueFromMap(pFormNodes);
if (!value)
- return CJS_Return(runtime->NewNull());
- return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
+ return CJS_Return::Success(runtime->NewNull());
+ return CJS_Return::Success(
+ value->DirectGetValue().Get(runtime->GetIsolate()));
}
CJS_Return CJX_Form::remerge(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
GetDocument()->DoDataRemerge(true);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Form::execInitialize(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (pNotify)
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false,
true);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Form::recalculate(
@@ -82,45 +83,45 @@ CJS_Return CJX_Form::recalculate(
GetDocument()->GetScriptContext()->GetEventParam();
if (pEventParam->m_eType == XFA_EVENT_Calculate ||
pEventParam->m_eType == XFA_EVENT_InitCalculate) {
- return CJS_Return();
+ return CJS_Return::Success();
}
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify || runtime->ToInt32(params[0]) != 0)
- return CJS_Return();
+ return CJS_Return::Success();
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false, true);
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate, false, true);
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Ready, true, true);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Form::execCalculate(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (pNotify)
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false,
true);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Form::execValidate(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 0)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return(runtime->NewBoolean(false));
+ return CJS_Return::Success(runtime->NewBoolean(false));
int32_t iRet = pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate,
false, true);
- return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
+ return CJS_Return::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
diff --git a/fxjs/xfa/cjx_hostpseudomodel.cpp b/fxjs/xfa/cjx_hostpseudomodel.cpp
index 37bc99ad47..8cf82b30d4 100644
--- a/fxjs/xfa/cjx_hostpseudomodel.cpp
+++ b/fxjs/xfa/cjx_hostpseudomodel.cpp
@@ -243,33 +243,33 @@ CJS_Return CJX_HostPseudoModel::gotoURL(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return CJS_Return();
+ return CJS_Return::Success();
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
WideString URL = runtime->ToWideString(params[0]);
hDoc->GetDocEnvironment()->GotoURL(hDoc, URL);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::openList(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return CJS_Return();
+ return CJS_Return::Success();
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_Node* pNode = nullptr;
if (params[0]->IsObject()) {
@@ -278,11 +278,11 @@ CJS_Return CJX_HostPseudoModel::openList(
} else if (params[0]->IsString()) {
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_Object* pObject = pScriptContext->GetThisObject();
if (!pObject)
- return CJS_Return();
+ return CJS_Return::Success();
uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings;
@@ -291,35 +291,35 @@ CJS_Return CJX_HostPseudoModel::openList(
pObject, runtime->ToWideString(params[0]).AsStringView(),
&resolveNodeRS, dwFlag, nullptr);
if (!iRet || !resolveNodeRS.objects.front()->IsNode())
- return CJS_Return();
+ return CJS_Return::Success();
pNode = resolveNodeRS.objects.front()->AsNode();
}
CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor();
if (!pDocLayout)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_FFWidget* hWidget =
XFA_GetWidgetFromLayoutItem(pDocLayout->GetLayoutItem(pNode));
if (!hWidget)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
hDoc->GetDocEnvironment()->SetFocusWidget(hDoc, hWidget);
pNotify->OpenDropDownList(hWidget);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::response(
CFX_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::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
WideString question;
if (params.size() >= 1)
@@ -339,24 +339,25 @@ CJS_Return CJX_HostPseudoModel::response(
WideString answer =
pNotify->GetAppProvider()->Response(question, title, defaultAnswer, mark);
- return CJS_Return(runtime->NewString(answer.UTF8Encode().AsStringView()));
+ return CJS_Return::Success(
+ runtime->NewString(answer.UTF8Encode().AsStringView()));
}
CJS_Return CJX_HostPseudoModel::documentInBatch(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(runtime->NewNumber(0));
+ return CJS_Return::Success(runtime->NewNumber(0));
}
CJS_Return CJX_HostPseudoModel::resetData(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() > 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
WideString expression;
if (params.size() >= 1)
@@ -364,7 +365,7 @@ CJS_Return CJX_HostPseudoModel::resetData(
if (expression.IsEmpty()) {
pNotify->ResetData(nullptr);
- return CJS_Return();
+ return CJS_Return::Success();
}
int32_t iStart = 0;
@@ -375,11 +376,11 @@ CJS_Return CJX_HostPseudoModel::resetData(
iStart = FilterName(expression.AsStringView(), iStart, wsName);
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_Object* pObject = pScriptContext->GetThisObject();
if (!pObject)
- return CJS_Return();
+ return CJS_Return::Success();
uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings;
@@ -395,42 +396,42 @@ CJS_Return CJX_HostPseudoModel::resetData(
if (!pNode)
pNotify->ResetData(nullptr);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::beep(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return CJS_Return();
+ return CJS_Return::Success();
if (params.size() > 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
uint32_t dwType = 4;
if (params.size() >= 1)
dwType = runtime->ToInt32(params[0]);
pNotify->GetAppProvider()->Beep(dwType);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::setFocus(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return CJS_Return();
+ return CJS_Return::Success();
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_Node* pNode = nullptr;
if (params.size() >= 1) {
@@ -440,11 +441,11 @@ CJS_Return CJX_HostPseudoModel::setFocus(
} else if (params[0]->IsString()) {
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_Object* pObject = pScriptContext->GetThisObject();
if (!pObject)
- return CJS_Return();
+ return CJS_Return::Success();
uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings;
@@ -453,13 +454,13 @@ CJS_Return CJX_HostPseudoModel::setFocus(
pObject, runtime->ToWideString(params[0]).AsStringView(),
&resolveNodeRS, dwFlag, nullptr);
if (!iRet || !resolveNodeRS.objects.front()->IsNode())
- return CJS_Return();
+ return CJS_Return::Success();
pNode = resolveNodeRS.objects.front()->AsNode();
}
}
pNotify->SetFocusWidgetNode(pNode);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::getFocus(
@@ -467,32 +468,33 @@ CJS_Return CJX_HostPseudoModel::getFocus(
const std::vector<v8::Local<v8::Value>>& params) {
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_Node* pNode = pNotify->GetFocusWidgetNode();
if (!pNode)
- return CJS_Return();
+ return CJS_Return::Success();
CFXJSE_Value* value =
GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode);
if (!value)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
- return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
+ return CJS_Return::Success(
+ value->DirectGetValue().Get(runtime->GetIsolate()));
}
CJS_Return CJX_HostPseudoModel::messageBox(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return CJS_Return();
+ return CJS_Return::Success();
if (params.empty() || params.size() > 4)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
WideString message;
if (params.size() >= 1)
@@ -518,27 +520,27 @@ CJS_Return CJX_HostPseudoModel::messageBox(
int32_t iValue = pNotify->GetAppProvider()->MsgBox(message, title,
messageType, buttonType);
- return CJS_Return(runtime->NewNumber(iValue));
+ return CJS_Return::Success(runtime->NewNumber(iValue));
}
CJS_Return CJX_HostPseudoModel::documentCountInBatch(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(runtime->NewNumber(0));
+ return CJS_Return::Success(runtime->NewNumber(0));
}
CJS_Return CJX_HostPseudoModel::print(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return CJS_Return();
+ return CJS_Return::Success();
if (params.size() != 8)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
uint32_t dwOptions = 0;
if (runtime->ToBoolean(params[0]))
@@ -559,27 +561,27 @@ CJS_Return CJX_HostPseudoModel::print(
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
hDoc->GetDocEnvironment()->Print(hDoc, nStartPage, nEndPage, dwOptions);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::importData(
CFX_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::Failure(JSMessage::kParamError);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::exportData(
CFX_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::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
WideString filePath;
if (params.size() >= 1)
@@ -591,7 +593,7 @@ CJS_Return CJX_HostPseudoModel::exportData(
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
hDoc->GetDocEnvironment()->ExportData(hDoc, filePath, XDP);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::pageUp(
@@ -599,17 +601,17 @@ CJS_Return CJX_HostPseudoModel::pageUp(
const std::vector<v8::Local<v8::Value>>& params) {
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
int32_t nCurPage = hDoc->GetDocEnvironment()->GetCurrentPage(hDoc);
int32_t nNewPage = 0;
if (nCurPage <= 1)
- return CJS_Return();
+ return CJS_Return::Success();
nNewPage = nCurPage - 1;
hDoc->GetDocEnvironment()->SetCurrentPage(hDoc, nNewPage);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::pageDown(
@@ -617,13 +619,13 @@ CJS_Return CJX_HostPseudoModel::pageDown(
const std::vector<v8::Local<v8::Value>>& params) {
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
int32_t nCurPage = hDoc->GetDocEnvironment()->GetCurrentPage(hDoc);
int32_t nPageCount = hDoc->GetDocEnvironment()->CountPages(hDoc);
if (!nPageCount || nCurPage == nPageCount)
- return CJS_Return();
+ return CJS_Return::Success();
int32_t nNewPage = 0;
if (nCurPage >= nPageCount)
@@ -632,5 +634,5 @@ CJS_Return CJX_HostPseudoModel::pageDown(
nNewPage = nCurPage + 1;
hDoc->GetDocEnvironment()->SetCurrentPage(hDoc, nNewPage);
- return CJS_Return();
+ return CJS_Return::Success();
}
diff --git a/fxjs/xfa/cjx_instancemanager.cpp b/fxjs/xfa/cjx_instancemanager.cpp
index 0882a182b2..ce00af18e6 100644
--- a/fxjs/xfa/cjx_instancemanager.cpp
+++ b/fxjs/xfa/cjx_instancemanager.cpp
@@ -138,10 +138,10 @@ CJS_Return CJX_InstanceManager::moveInstance(
const std::vector<v8::Local<v8::Value>>& params) {
CXFA_Document* doc = static_cast<CFXJSE_Engine*>(runtime)->GetDocument();
if (doc->GetFormType() != FormType::kXFAFull)
- return CJS_Return(JSGetStringFromID(JSMessage::kNotSupportedError));
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
if (params.size() != 2)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
int32_t iFrom = runtime->ToInt32(params[0]);
int32_t iTo = runtime->ToInt32(params[1]);
@@ -149,7 +149,7 @@ CJS_Return CJX_InstanceManager::moveInstance(
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_Node* pToInstance = GetXFANode()->GetItemIfExists(iTo);
if (pToInstance && pToInstance->GetElementType() == XFA_Element::Subform)
@@ -161,7 +161,7 @@ CJS_Return CJX_InstanceManager::moveInstance(
pNotify->RunSubformIndexChange(pFromInstance);
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_InstanceManager::removeInstance(
@@ -169,24 +169,24 @@ CJS_Return CJX_InstanceManager::removeInstance(
const std::vector<v8::Local<v8::Value>>& params) {
CXFA_Document* doc = static_cast<CFXJSE_Engine*>(runtime)->GetDocument();
if (doc->GetFormType() != FormType::kXFAFull)
- return CJS_Return(JSGetStringFromID(JSMessage::kNotSupportedError));
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
int32_t iIndex = runtime->ToInt32(params[0]);
int32_t iCount = GetXFANode()->GetCount();
if (iIndex < 0 || iIndex >= iCount)
- return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
+ return CJS_Return::Failure(JSMessage::kInvalidInputError);
CXFA_Occur* occur = GetXFANode()->GetOccurIfExists();
int32_t iMin = occur ? occur->GetMin() : CXFA_Occur::kDefaultMin;
if (iCount - 1 < iMin)
- return CJS_Return(JSGetStringFromID(JSMessage::kTooManyOccurances));
+ return CJS_Return::Failure(JSMessage::kTooManyOccurances);
CXFA_Node* pRemoveInstance = GetXFANode()->GetItemIfExists(iIndex);
if (!pRemoveInstance)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
GetXFANode()->RemoveItem(pRemoveInstance, true);
@@ -205,7 +205,7 @@ CJS_Return CJX_InstanceManager::removeInstance(
pLayoutPro->AddChangedContainer(
ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_InstanceManager::setInstances(
@@ -213,13 +213,13 @@ CJS_Return CJX_InstanceManager::setInstances(
const std::vector<v8::Local<v8::Value>>& params) {
CXFA_Document* doc = static_cast<CFXJSE_Engine*>(runtime)->GetDocument();
if (doc->GetFormType() != FormType::kXFAFull)
- return CJS_Return(JSGetStringFromID(JSMessage::kNotSupportedError));
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
SetInstances(runtime->ToInt32(params[0]));
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_InstanceManager::addInstance(
@@ -227,10 +227,10 @@ CJS_Return CJX_InstanceManager::addInstance(
const std::vector<v8::Local<v8::Value>>& params) {
CXFA_Document* doc = static_cast<CFXJSE_Engine*>(runtime)->GetDocument();
if (doc->GetFormType() != FormType::kXFAFull)
- return CJS_Return(JSGetStringFromID(JSMessage::kNotSupportedError));
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
if (!params.empty() && params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
bool fFlags = true;
if (params.size() == 1)
@@ -240,11 +240,11 @@ CJS_Return CJX_InstanceManager::addInstance(
CXFA_Occur* occur = GetXFANode()->GetOccurIfExists();
int32_t iMax = occur ? occur->GetMax() : CXFA_Occur::kDefaultMax;
if (iMax >= 0 && iCount >= iMax)
- return CJS_Return(JSGetStringFromID(JSMessage::kTooManyOccurances));
+ return CJS_Return::Failure(JSMessage::kTooManyOccurances);
CXFA_Node* pNewInstance = GetXFANode()->CreateInstanceIfPossible(fFlags);
if (!pNewInstance)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
GetXFANode()->InsertItem(pNewInstance, iCount, iCount, false);
@@ -262,9 +262,10 @@ CJS_Return CJX_InstanceManager::addInstance(
CFXJSE_Value* value =
GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance);
if (!value)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
- return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
+ return CJS_Return::Success(
+ value->DirectGetValue().Get(runtime->GetIsolate()));
}
CJS_Return CJX_InstanceManager::insertInstance(
@@ -272,10 +273,10 @@ CJS_Return CJX_InstanceManager::insertInstance(
const std::vector<v8::Local<v8::Value>>& params) {
CXFA_Document* doc = static_cast<CFXJSE_Engine*>(runtime)->GetDocument();
if (doc->GetFormType() != FormType::kXFAFull)
- return CJS_Return(JSGetStringFromID(JSMessage::kNotSupportedError));
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
if (params.size() != 1 && params.size() != 2)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
int32_t iIndex = runtime->ToInt32(params[0]);
bool bBind = false;
@@ -284,16 +285,16 @@ CJS_Return CJX_InstanceManager::insertInstance(
int32_t iCount = GetXFANode()->GetCount();
if (iIndex < 0 || iIndex > iCount)
- return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
+ return CJS_Return::Failure(JSMessage::kInvalidInputError);
CXFA_Occur* occur = GetXFANode()->GetOccurIfExists();
int32_t iMax = occur ? occur->GetMax() : CXFA_Occur::kDefaultMax;
if (iMax >= 0 && iCount >= iMax)
- return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
+ return CJS_Return::Failure(JSMessage::kInvalidInputError);
CXFA_Node* pNewInstance = GetXFANode()->CreateInstanceIfPossible(bBind);
if (!pNewInstance)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
GetXFANode()->InsertItem(pNewInstance, iIndex, iCount, true);
@@ -310,9 +311,10 @@ CJS_Return CJX_InstanceManager::insertInstance(
CFXJSE_Value* value =
GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance);
if (!value)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
- return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
+ return CJS_Return::Success(
+ value->DirectGetValue().Get(runtime->GetIsolate()));
}
void CJX_InstanceManager::max(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_layoutpseudomodel.cpp b/fxjs/xfa/cjx_layoutpseudomodel.cpp
index 4c460c8a41..aa73135607 100644
--- a/fxjs/xfa/cjx_layoutpseudomodel.cpp
+++ b/fxjs/xfa/cjx_layoutpseudomodel.cpp
@@ -74,12 +74,12 @@ CJS_Return CJX_LayoutPseudoModel::HWXY(
const std::vector<v8::Local<v8::Value>>& params,
XFA_LAYOUTMODEL_HWXY layoutModel) {
if (params.empty() || params.size() > 3)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_Node* pNode =
ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0]));
if (!pNode)
- return CJS_Return();
+ return CJS_Return::Success();
WideString unit(L"pt");
if (params.size() >= 2) {
@@ -90,12 +90,12 @@ CJS_Return CJX_LayoutPseudoModel::HWXY(
int32_t iIndex = params.size() >= 3 ? runtime->ToInt32(params[2]) : 0;
CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor();
if (!pDocLayout)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_ContentLayoutItem* pLayoutItem =
ToContentLayoutItem(pDocLayout->GetLayoutItem(pNode));
if (!pLayoutItem)
- return CJS_Return();
+ return CJS_Return::Success();
while (iIndex > 0 && pLayoutItem) {
pLayoutItem = pLayoutItem->GetNext();
@@ -103,7 +103,7 @@ CJS_Return CJX_LayoutPseudoModel::HWXY(
}
if (!pLayoutItem)
- return CJS_Return(runtime->NewNumber(0.0));
+ return CJS_Return::Success(runtime->NewNumber(0.0));
CXFA_Measurement measure;
CFX_RectF rtRect = pLayoutItem->GetRect(true);
@@ -124,7 +124,8 @@ CJS_Return CJX_LayoutPseudoModel::HWXY(
float fValue =
measure.ToUnit(CXFA_Measurement::GetUnitFromString(unit.AsStringView()));
- return CJS_Return(runtime->NewNumber(FXSYS_round(fValue * 1000) / 1000.0f));
+ return CJS_Return::Success(
+ runtime->NewNumber(FXSYS_round(fValue * 1000) / 1000.0f));
}
CJS_Return CJX_LayoutPseudoModel::h(
@@ -155,7 +156,7 @@ CJS_Return CJX_LayoutPseudoModel::NumberedPageCount(CFX_V8* runtime,
bool bNumbered) {
CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor();
if (!pDocLayout)
- return CJS_Return();
+ return CJS_Return::Success();
int32_t iPageCount = 0;
int32_t iPageNum = pDocLayout->CountPages();
@@ -172,7 +173,7 @@ CJS_Return CJX_LayoutPseudoModel::NumberedPageCount(CFX_V8* runtime,
} else {
iPageCount = iPageNum;
}
- return CJS_Return(runtime->NewNumber(iPageCount));
+ return CJS_Return::Success(runtime->NewNumber(iPageCount));
}
CJS_Return CJX_LayoutPseudoModel::pageCount(
@@ -185,26 +186,26 @@ CJS_Return CJX_LayoutPseudoModel::pageSpan(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_Node* pNode =
ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0]));
if (!pNode)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor();
if (!pDocLayout)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_ContentLayoutItem* pLayoutItem =
ToContentLayoutItem(pDocLayout->GetLayoutItem(pNode));
if (!pLayoutItem)
- return CJS_Return(runtime->NewNumber(-1));
+ return CJS_Return::Success(runtime->NewNumber(-1));
int32_t iLast = pLayoutItem->GetLast()->GetPage()->GetPageIndex();
int32_t iFirst = pLayoutItem->GetFirst()->GetPage()->GetPageIndex();
int32_t iPageSpan = iLast - iFirst + 1;
- return CJS_Return(runtime->NewNumber(iPageSpan));
+ return CJS_Return::Success(runtime->NewNumber(iPageSpan));
}
CJS_Return CJX_LayoutPseudoModel::page(
@@ -348,7 +349,7 @@ CJS_Return CJX_LayoutPseudoModel::pageContent(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.empty() || params.size() > 3)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
int32_t iIndex = 0;
if (params.size() >= 1)
@@ -364,18 +365,18 @@ CJS_Return CJX_LayoutPseudoModel::pageContent(
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor();
if (!pDocLayout)
- return CJS_Return();
+ return CJS_Return::Success();
auto pArrayNodeList = pdfium::MakeUnique<CXFA_ArrayNodeList>(GetDocument());
pArrayNodeList->SetArrayNodeList(
GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea));
// TODO(dsinclair): Who owns the array once we release it? Won't this leak?
- return CJS_Return(static_cast<CFXJSE_Engine*>(runtime)->NewXFAObject(
+ return CJS_Return::Success(static_cast<CFXJSE_Engine*>(runtime)->NewXFAObject(
pArrayNodeList.release(),
GetDocument()->GetScriptContext()->GetJseNormalClass()->GetTemplate()));
}
@@ -389,13 +390,13 @@ CJS_Return CJX_LayoutPseudoModel::absPageCount(
CJS_Return CJX_LayoutPseudoModel::absPageCountInBatch(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(runtime->NewNumber(0));
+ return CJS_Return::Success(runtime->NewNumber(0));
}
CJS_Return CJX_LayoutPseudoModel::sheetCountInBatch(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(runtime->NewNumber(0));
+ return CJS_Return::Success(runtime->NewNumber(0));
}
CJS_Return CJX_LayoutPseudoModel::relayout(
@@ -410,7 +411,7 @@ CJS_Return CJX_LayoutPseudoModel::relayout(
pLayoutProcessor->AddChangedContainer(pContentRootNode);
pLayoutProcessor->SetForceReLayout(true);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_LayoutPseudoModel::absPageSpan(
@@ -423,16 +424,18 @@ CJS_Return CJX_LayoutPseudoModel::absPageInBatch(
CFX_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));
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success(runtime->NewNumber(0));
}
CJS_Return CJX_LayoutPseudoModel::sheetInBatch(
CFX_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));
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success(runtime->NewNumber(0));
}
CJS_Return CJX_LayoutPseudoModel::sheet(
@@ -444,7 +447,7 @@ CJS_Return CJX_LayoutPseudoModel::sheet(
CJS_Return CJX_LayoutPseudoModel::relayoutPageArea(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_LayoutPseudoModel::sheetCount(
@@ -464,22 +467,22 @@ CJS_Return CJX_LayoutPseudoModel::PageInternals(
const std::vector<v8::Local<v8::Value>>& params,
bool bAbsPage) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_Node* pNode =
ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0]));
if (!pNode)
- return CJS_Return(runtime->NewNumber(0));
+ return CJS_Return::Success(runtime->NewNumber(0));
CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor();
if (!pDocLayout)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_ContentLayoutItem* pLayoutItem =
ToContentLayoutItem(pDocLayout->GetLayoutItem(pNode));
if (!pLayoutItem)
- return CJS_Return(runtime->NewNumber(-1));
+ return CJS_Return::Success(runtime->NewNumber(-1));
int32_t iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex();
- return CJS_Return(runtime->NewNumber(bAbsPage ? iPage : iPage + 1));
+ return CJS_Return::Success(runtime->NewNumber(bAbsPage ? iPage : iPage + 1));
}
diff --git a/fxjs/xfa/cjx_list.cpp b/fxjs/xfa/cjx_list.cpp
index e56515d0b1..89f483bf8e 100644
--- a/fxjs/xfa/cjx_list.cpp
+++ b/fxjs/xfa/cjx_list.cpp
@@ -34,58 +34,58 @@ CXFA_List* CJX_List::GetXFAList() {
CJS_Return CJX_List::append(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
auto* pNode =
ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0]));
if (!pNode)
- return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
+ return CJS_Return::Failure(JSMessage::kValueError);
GetXFAList()->Append(pNode);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_List::insert(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
auto* pNewNode =
ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0]));
if (!pNewNode)
- return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
+ return CJS_Return::Failure(JSMessage::kValueError);
auto* pBeforeNode =
ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[1]));
GetXFAList()->Insert(pNewNode, pBeforeNode);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_List::remove(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
auto* pNode =
ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0]));
if (!pNode)
- return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
+ return CJS_Return::Failure(JSMessage::kValueError);
GetXFAList()->Remove(pNode);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_List::item(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
int32_t index = runtime->ToInt32(params[0]);
size_t cast_index = static_cast<size_t>(index);
if (index < 0 || cast_index >= GetXFAList()->GetLength())
- return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
+ return CJS_Return::Failure(JSMessage::kInvalidInputError);
- return CJS_Return(static_cast<CFXJSE_Engine*>(runtime)->NewXFAObject(
+ return CJS_Return::Success(static_cast<CFXJSE_Engine*>(runtime)->NewXFAObject(
GetXFAList()->Item(cast_index),
GetDocument()->GetScriptContext()->GetJseNormalClass()->GetTemplate()));
}
diff --git a/fxjs/xfa/cjx_logpseudomodel.cpp b/fxjs/xfa/cjx_logpseudomodel.cpp
index 9072fef592..49f3350463 100644
--- a/fxjs/xfa/cjx_logpseudomodel.cpp
+++ b/fxjs/xfa/cjx_logpseudomodel.cpp
@@ -35,29 +35,29 @@ CJS_Return CJX_LogPseudoModel::message(
// fprintf(stderr, " %ls\n", WideString::FromUTF8(*str).c_str());
// }
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_LogPseudoModel::traceEnabled(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_LogPseudoModel::traceActivate(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_LogPseudoModel::traceDeactivate(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_LogPseudoModel::trace(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
diff --git a/fxjs/xfa/cjx_manifest.cpp b/fxjs/xfa/cjx_manifest.cpp
index a8d1fd54c5..1ca86cc4bf 100644
--- a/fxjs/xfa/cjx_manifest.cpp
+++ b/fxjs/xfa/cjx_manifest.cpp
@@ -25,9 +25,10 @@ CJS_Return CJX_Manifest::evaluate(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
- return CJS_Return(runtime->NewBoolean(GetXFANode()->IsWidgetReady()));
+ return CJS_Return::Success(
+ runtime->NewBoolean(GetXFANode()->IsWidgetReady()));
}
void CJX_Manifest::defaultValue(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_model.cpp b/fxjs/xfa/cjx_model.cpp
index d94a1b68fd..97d25175fe 100644
--- a/fxjs/xfa/cjx_model.cpp
+++ b/fxjs/xfa/cjx_model.cpp
@@ -28,14 +28,14 @@ CJX_Model::~CJX_Model() {}
CJS_Return CJX_Model::clearErrorList(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Model::createNode(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.empty() || params.size() > 3)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString name;
if (params.size() > 1)
@@ -49,11 +49,11 @@ CJS_Return CJX_Model::createNode(
XFA_Element eType = CXFA_Node::NameToElement(tagName);
CXFA_Node* pNewNode = GetXFANode()->CreateSamePacketNode(eType);
if (!pNewNode)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
if (!name.IsEmpty()) {
if (!pNewNode->HasAttribute(XFA_Attribute::Name))
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
pNewNode->JSObject()->SetAttribute(XFA_Attribute::Name, name.AsStringView(),
true);
@@ -64,22 +64,23 @@ CJS_Return CJX_Model::createNode(
CFXJSE_Value* value =
GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewNode);
if (!value)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
- return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
+ return CJS_Return::Success(
+ value->DirectGetValue().Get(runtime->GetIsolate()));
}
CJS_Return CJX_Model::isCompatibleNS(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString nameSpace;
if (params.size() >= 1)
nameSpace = runtime->ToWideString(params[0]);
- return CJS_Return(
+ return CJS_Return::Success(
runtime->NewBoolean(TryNamespace().value_or(WideString()) == nameSpace));
}
diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp
index b1d8c2cb66..9a85d94f0d 100644
--- a/fxjs/xfa/cjx_node.cpp
+++ b/fxjs/xfa/cjx_node.cpp
@@ -110,43 +110,45 @@ CXFA_Node* CJX_Node::GetXFANode() const {
CJS_Return CJX_Node::applyXSL(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
// TODO(weili): check whether we need to implement this, pdfium:501.
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Node::assignNode(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.empty() || params.size() > 3)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
// TODO(weili): check whether we need to implement this, pdfium:501.
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Node::clone(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
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()));
+ return CJS_Return::Success(runtime->NewNull());
+
+ return CJS_Return::Success(
+ value->DirectGetValue().Get(runtime->GetIsolate()));
}
CJS_Return CJX_Node::getAttribute(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString expression = runtime->ToWideString(params[0]);
- return CJS_Return(runtime->NewString(
+ return CJS_Return::Success(runtime->NewString(
GetAttribute(expression.AsStringView()).UTF8Encode().AsStringView()));
}
@@ -154,33 +156,34 @@ CJS_Return CJX_Node::getElement(
CFX_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::Failure(JSMessage::kParamError);
WideString expression = runtime->ToWideString(params[0]);
int32_t iValue = params.size() >= 2 ? runtime->ToInt32(params[1]) : 0;
-
CXFA_Node* pNode = GetOrCreateProperty<CXFA_Node>(
iValue, CXFA_Node::NameToElement(expression));
if (!pNode)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
CFXJSE_Value* value =
GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode);
if (!value)
- return CJS_Return(runtime->NewNull());
- return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
+ return CJS_Return::Success(runtime->NewNull());
+
+ return CJS_Return::Success(
+ value->DirectGetValue().Get(runtime->GetIsolate()));
}
CJS_Return CJX_Node::isPropertySpecified(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.empty() || params.size() > 3)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(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));
+ return CJS_Return::Success(runtime->NewBoolean(true));
bool bParent = params.size() < 2 || runtime->ToBoolean(params[1]);
int32_t iIndex = params.size() == 3 ? runtime->ToInt32(params[2]) : 0;
@@ -192,17 +195,17 @@ CJS_Return CJX_Node::isPropertySpecified(
bHas = jsnode->HasAttribute(attr) ||
!!jsnode->GetOrCreateProperty<CXFA_Node>(iIndex, eType);
}
- return CJS_Return(runtime->NewBoolean(bHas));
+ return CJS_Return::Success(runtime->NewBoolean(bHas));
}
CJS_Return CJX_Node::loadXML(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.empty() || params.size() > 3)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
ByteString expression = runtime->ToByteString(params[0]);
if (expression.IsEmpty())
- return CJS_Return();
+ return CJS_Return::Success();
bool bIgnoreRoot = true;
if (params.size() >= 2)
@@ -213,12 +216,9 @@ CJS_Return CJX_Node::loadXML(CFX_V8* runtime,
bOverwrite = runtime->ToBoolean(params[2]);
auto pParser = pdfium::MakeUnique<CXFA_DocumentParser>(GetDocument());
- if (!pParser)
- return CJS_Return();
-
CFX_XMLNode* pXMLNode = pParser->ParseXMLData(expression);
if (!pXMLNode)
- return CJS_Return();
+ return CJS_Return::Success();
if (bIgnoreRoot &&
(pXMLNode->GetType() != FX_XMLNODE_Element ||
@@ -274,7 +274,7 @@ CJS_Return CJX_Node::loadXML(CFX_V8* runtime,
pParser->ConstructXFANode(pFakeRoot, pFakeXMLRoot);
pFakeRoot = pParser->GetRootNode();
if (!pFakeRoot)
- return CJS_Return();
+ return CJS_Return::Success();
if (bOverwrite) {
CXFA_Node* pChild = GetXFANode()->GetFirstChild();
@@ -322,36 +322,38 @@ CJS_Return CJX_Node::loadXML(CFX_V8* runtime,
}
pFakeRoot->SetFlag(XFA_NodeFlag_HasRemovedChildren);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Node::saveFilteredXML(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
// TODO(weili): Check whether we need to implement this, pdfium:501.
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Node::saveXML(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() > 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
+
if (params.size() == 1 && runtime->ToWideString(params[0]) != L"pretty")
- return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
+ return CJS_Return::Failure(JSMessage::kValueError);
// TODO(weili): Check whether we need to save pretty print XML, pdfium:501.
ByteString bsXMLHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
if (GetXFANode()->GetPacketType() != XFA_PacketType::Form &&
GetXFANode()->GetPacketType() != XFA_PacketType::Datasets) {
- return CJS_Return(runtime->NewString(""));
+ return CJS_Return::Success(runtime->NewString(""));
}
CFX_XMLNode* pElement = nullptr;
if (GetXFANode()->GetPacketType() == XFA_PacketType::Datasets) {
pElement = GetXFANode()->GetXMLMappingNode();
if (!pElement || pElement->GetType() != FX_XMLNODE_Element) {
- return CJS_Return(runtime->NewString(bsXMLHeader.AsStringView()));
+ return CJS_Return::Success(
+ runtime->NewString(bsXMLHeader.AsStringView()));
}
XFA_DataExporter_DealWithDataGroupNode(GetXFANode());
@@ -366,7 +368,7 @@ CJS_Return CJX_Node::saveXML(CFX_V8* runtime,
pElement->Save(pMemoryStream);
}
- return CJS_Return(runtime->NewString(
+ return CJS_Return::Success(runtime->NewString(
ByteStringView(pMemoryStream->GetBuffer(), pMemoryStream->GetSize())));
}
@@ -374,22 +376,22 @@ CJS_Return CJX_Node::setAttribute(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString attributeValue = runtime->ToWideString(params[0]);
WideString attribute = runtime->ToWideString(params[1]);
SetAttribute(attribute.AsStringView(), attributeValue.AsStringView(), true);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Node::setElement(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1 && params.size() != 2)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
// TODO(weili): check whether we need to implement this, pdfium:501.
- return CJS_Return();
+ return CJS_Return::Success();
}
void CJX_Node::id(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 8684212ce2..be6879544c 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -171,7 +171,7 @@ CJS_Return CJX_Object::RunMethod(
const std::vector<v8::Local<v8::Value>>& params) {
auto it = method_specs_.find(func.UTF8Encode());
if (it == method_specs_.end())
- return CJS_Return(JSMessage::kUnknownMethod);
+ return CJS_Return::Failure(JSMessage::kUnknownMethod);
return it->second(this, GetXFAObject()->GetDocument()->GetScriptContext(),
params);
diff --git a/fxjs/xfa/cjx_packet.cpp b/fxjs/xfa/cjx_packet.cpp
index 2288de4c8d..ae706ceaf4 100644
--- a/fxjs/xfa/cjx_packet.cpp
+++ b/fxjs/xfa/cjx_packet.cpp
@@ -32,14 +32,14 @@ CJS_Return CJX_Packet::getAttribute(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString attributeValue;
CFX_XMLElement* element = ToXMLElement(GetXFANode()->GetXMLMappingNode());
if (element)
attributeValue = element->GetAttribute(runtime->ToWideString(params[0]));
- return CJS_Return(
+ return CJS_Return::Success(
runtime->NewString(attributeValue.UTF8Encode().AsStringView()));
}
@@ -47,21 +47,21 @@ CJS_Return CJX_Packet::setAttribute(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CFX_XMLElement* element = ToXMLElement(GetXFANode()->GetXMLMappingNode());
if (element) {
element->SetAttribute(runtime->ToWideString(params[1]),
runtime->ToWideString(params[0]));
}
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
}
CJS_Return CJX_Packet::removeAttribute(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CFX_XMLElement* pElement = ToXMLElement(GetXFANode()->GetXMLMappingNode());
if (pElement) {
@@ -69,7 +69,7 @@ CJS_Return CJX_Packet::removeAttribute(
if (pElement->HasAttribute(name))
pElement->RemoveAttribute(name);
}
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
}
void CJX_Packet::content(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_signaturepseudomodel.cpp b/fxjs/xfa/cjx_signaturepseudomodel.cpp
index 20cb5dcccf..49a4f1540f 100644
--- a/fxjs/xfa/cjx_signaturepseudomodel.cpp
+++ b/fxjs/xfa/cjx_signaturepseudomodel.cpp
@@ -30,30 +30,34 @@ CJS_Return CJX_SignaturePseudoModel::verifySignature(
CFX_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));
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success(runtime->NewNumber(0));
}
CJS_Return CJX_SignaturePseudoModel::sign(
CFX_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));
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success(runtime->NewBoolean(false));
}
CJS_Return CJX_SignaturePseudoModel::enumerate(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_SignaturePseudoModel::clear(
CFX_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));
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success(runtime->NewBoolean(false));
}
diff --git a/fxjs/xfa/cjx_source.cpp b/fxjs/xfa/cjx_source.cpp
index 933229e07c..0b24b8f4b4 100644
--- a/fxjs/xfa/cjx_source.cpp
+++ b/fxjs/xfa/cjx_source.cpp
@@ -40,126 +40,143 @@ CJX_Source::~CJX_Source() {}
CJS_Return CJX_Source::next(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::cancelBatch(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::first(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::updateBatch(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::previous(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::isBOF(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::isEOF(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::cancel(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::update(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::open(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::deleteItem(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::addNew(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::requery(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::resync(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::close(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::last(CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
CJS_Return CJX_Source::hasDataChanged(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success();
}
void CJX_Source::db(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_subform.cpp b/fxjs/xfa/cjx_subform.cpp
index 9f4736a6e5..c313cb4364 100644
--- a/fxjs/xfa/cjx_subform.cpp
+++ b/fxjs/xfa/cjx_subform.cpp
@@ -32,52 +32,52 @@ CJS_Return CJX_Subform::execEvent(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
execSingleEventByName(runtime->ToWideString(params[0]).AsStringView(),
XFA_Element::Subform);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Subform::execInitialize(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (pNotify)
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false,
true);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Subform::execCalculate(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (pNotify)
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false,
true);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Subform::execValidate(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return(runtime->NewBoolean(false));
+ return CJS_Return::Success(runtime->NewBoolean(false));
int32_t iRet = pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate,
false, true);
- return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
+ return CJS_Return::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
void CJX_Subform::locale(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_template.cpp b/fxjs/xfa/cjx_template.cpp
index 8690083702..8f27b64bfb 100644
--- a/fxjs/xfa/cjx_template.cpp
+++ b/fxjs/xfa/cjx_template.cpp
@@ -31,48 +31,56 @@ CJS_Return CJX_Template::formNodes(
CFX_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));
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success(runtime->NewBoolean(true));
}
CJS_Return CJX_Template::remerge(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
GetDocument()->DoDataRemerge(true);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_Template::execInitialize(
CFX_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()->IsWidgetReady()));
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success(
+ runtime->NewBoolean(GetXFANode()->IsWidgetReady()));
}
CJS_Return CJX_Template::recalculate(
CFX_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));
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success(runtime->NewBoolean(true));
}
CJS_Return CJX_Template::execCalculate(
CFX_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()->IsWidgetReady()));
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success(
+ runtime->NewBoolean(GetXFANode()->IsWidgetReady()));
}
CJS_Return CJX_Template::execValidate(
CFX_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()->IsWidgetReady()));
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success(
+ runtime->NewBoolean(GetXFANode()->IsWidgetReady()));
}
diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp
index 3a266eb450..be74b44a93 100644
--- a/fxjs/xfa/cjx_tree.cpp
+++ b/fxjs/xfa/cjx_tree.cpp
@@ -33,12 +33,12 @@ CJS_Return CJX_Tree::resolveNode(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString expression = runtime->ToWideString(params[0]);
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_Object* refNode = GetXFAObject();
if (refNode->GetElementType() == XFA_Element::Xfa)
@@ -51,7 +51,7 @@ CJS_Return CJX_Tree::resolveNode(
if (!pScriptContext->ResolveObjects(ToNode(refNode),
expression.AsStringView(), &resolveNodeRS,
dwFlag, nullptr)) {
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
}
if (resolveNodeRS.dwFlags == XFA_ResolveNode_RSType_Nodes) {
@@ -59,30 +59,32 @@ CJS_Return CJX_Tree::resolveNode(
CFXJSE_Value* value =
GetDocument()->GetScriptContext()->GetJSValueFromMap(pObject);
if (!value)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
- return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
+ return CJS_Return::Success(
+ value->DirectGetValue().Get(runtime->GetIsolate()));
}
const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo =
resolveNodeRS.pScriptAttribute;
if (!lpAttributeInfo ||
lpAttributeInfo->eValueType != XFA_ScriptType::Object) {
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
}
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()));
+ return CJS_Return::Success(
+ pValue->DirectGetValue().Get(runtime->GetIsolate()));
}
CJS_Return CJX_Tree::resolveNodes(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_Object* refNode = GetXFAObject();
if (refNode->GetElementType() == XFA_Element::Xfa)
@@ -90,7 +92,7 @@ CJS_Return CJX_Tree::resolveNodes(
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return CJS_Return();
+ return CJS_Return::Success();
auto pValue = pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetIsolate());
ResolveNodeList(pValue.get(), runtime->ToWideString(params[0]),
@@ -98,7 +100,8 @@ CJS_Return CJX_Tree::resolveNodes(
XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings,
ToNode(refNode));
- return CJS_Return(pValue->DirectGetValue().Get(runtime->GetIsolate()));
+ return CJS_Return::Success(
+ pValue->DirectGetValue().Get(runtime->GetIsolate()));
}
void CJX_Tree::all(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_treelist.cpp b/fxjs/xfa/cjx_treelist.cpp
index 53c3ec1b54..0c023003e4 100644
--- a/fxjs/xfa/cjx_treelist.cpp
+++ b/fxjs/xfa/cjx_treelist.cpp
@@ -32,17 +32,18 @@ CJS_Return CJX_TreeList::namedItem(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_Node* pNode = GetXFATreeList()->NamedItem(
runtime->ToWideString(params[0]).AsStringView());
if (!pNode)
- return CJS_Return();
+ return CJS_Return::Success();
CFXJSE_Value* value =
GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode);
if (!value)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
- return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
+ return CJS_Return::Success(
+ value->DirectGetValue().Get(runtime->GetIsolate()));
}
diff --git a/fxjs/xfa/cjx_wsdlconnection.cpp b/fxjs/xfa/cjx_wsdlconnection.cpp
index 523ea2dd3e..198d4f2f98 100644
--- a/fxjs/xfa/cjx_wsdlconnection.cpp
+++ b/fxjs/xfa/cjx_wsdlconnection.cpp
@@ -26,8 +26,9 @@ CJS_Return CJX_WsdlConnection::execute(
CFX_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));
+ return CJS_Return::Failure(JSMessage::kParamError);
+
+ return CJS_Return::Success(runtime->NewBoolean(false));
}
void CJX_WsdlConnection::dataDescription(CFXJSE_Value* pValue,