summaryrefslogtreecommitdiff
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
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>
-rw-r--r--fxjs/cfxjse_engine.cpp2
-rw-r--r--fxjs/cjs_annot.cpp23
-rw-r--r--fxjs/cjs_app.cpp141
-rw-r--r--fxjs/cjs_color.cpp21
-rw-r--r--fxjs/cjs_console.cpp8
-rw-r--r--fxjs/cjs_document.cpp375
-rw-r--r--fxjs/cjs_event.cpp121
-rw-r--r--fxjs/cjs_field.cpp752
-rw-r--r--fxjs/cjs_global.cpp44
-rw-r--r--fxjs/cjs_icon.cpp4
-rw-r--r--fxjs/cjs_publicmethods.cpp186
-rw-r--r--fxjs/cjs_report.cpp8
-rw-r--r--fxjs/cjs_return.h31
-rw-r--r--fxjs/cjs_util.cpp86
-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
39 files changed, 1315 insertions, 1242 deletions
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp
index 78b0644976..7a4865ba21 100644
--- a/fxjs/cfxjse_engine.cpp
+++ b/fxjs/cfxjse_engine.cpp
@@ -442,7 +442,7 @@ CJS_Return CFXJSE_Engine::NormalMethodCall(
const WideString& functionName) {
CXFA_Object* pObject = ToObject(info);
if (!pObject)
- return CJS_Return(L"no Holder() present.");
+ return CJS_Return::Failure(L"no Holder() present.");
CFXJSE_Engine* lpScriptContext = pObject->GetDocument()->GetScriptContext();
pObject = lpScriptContext->GetVariablesThis(pObject, false);
diff --git a/fxjs/cjs_annot.cpp b/fxjs/cjs_annot.cpp
index c4a4f7ab1d..4e93dc2516 100644
--- a/fxjs/cjs_annot.cpp
+++ b/fxjs/cjs_annot.cpp
@@ -39,10 +39,10 @@ CJS_Annot::~CJS_Annot() = default;
CJS_Return CJS_Annot::get_hidden(CJS_Runtime* pRuntime) {
if (!m_pAnnot)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_Annot* pPDFAnnot = m_pAnnot->AsBAAnnot()->GetPDFAnnot();
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict())));
}
@@ -53,7 +53,7 @@ CJS_Return CJS_Annot::set_hidden(CJS_Runtime* pRuntime,
CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get());
if (!pBAAnnot)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
uint32_t flags = pBAAnnot->GetFlags();
if (bHidden) {
@@ -68,14 +68,15 @@ CJS_Return CJS_Annot::set_hidden(CJS_Runtime* pRuntime,
flags |= ANNOTFLAG_PRINT;
}
pBAAnnot->SetFlags(flags);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Annot::get_name(CJS_Runtime* pRuntime) {
CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get());
if (!pBAAnnot)
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+
+ return CJS_Return::Success(
pRuntime->NewString(pBAAnnot->GetAnnotName().AsStringView()));
}
@@ -85,18 +86,18 @@ CJS_Return CJS_Annot::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get());
if (!pBAAnnot)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
pBAAnnot->SetAnnotName(annotName);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Annot::get_type(CJS_Runtime* pRuntime) {
CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get());
if (!pBAAnnot)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewString(
+ return CJS_Return::Success(pRuntime->NewString(
WideString::FromLocal(
CPDF_Annot::AnnotSubtypeToString(pBAAnnot->GetAnnotSubtype())
.AsStringView())
@@ -104,5 +105,5 @@ CJS_Return CJS_Annot::get_type(CJS_Runtime* pRuntime) {
}
CJS_Return CJS_Annot::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
}
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp
index 7029ddaf26..bd57e05b8b 100644
--- a/fxjs/cjs_app.cpp
+++ b/fxjs/cjs_app.cpp
@@ -110,101 +110,102 @@ CJS_Return CJS_App::get_active_docs(CJS_Runtime* pRuntime) {
pJSDocument ? v8::Local<v8::Value>(pJSDocument->ToV8Object())
: v8::Local<v8::Value>());
if (pRuntime->GetArrayLength(aDocs) > 0)
- return CJS_Return(aDocs);
- return CJS_Return(pRuntime->NewUndefined());
+ return CJS_Return::Success(aDocs);
+
+ return CJS_Return::Success(pRuntime->NewUndefined());
}
CJS_Return CJS_App::set_active_docs(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::get_calculate(CJS_Runtime* pRuntime) {
- return CJS_Return(pRuntime->NewBoolean(m_bCalculate));
+ return CJS_Return::Success(pRuntime->NewBoolean(m_bCalculate));
}
CJS_Return CJS_App::set_calculate(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
m_bCalculate = pRuntime->ToBoolean(vp);
pRuntime->GetFormFillEnv()->GetInterForm()->EnableCalculate(m_bCalculate);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_App::get_forms_version(CJS_Runtime* pRuntime) {
- return CJS_Return(pRuntime->NewNumber(JS_NUM_FORMSVERSION));
+ return CJS_Return::Success(pRuntime->NewNumber(JS_NUM_FORMSVERSION));
}
CJS_Return CJS_App::set_forms_version(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::get_viewer_type(CJS_Runtime* pRuntime) {
- return CJS_Return(pRuntime->NewString(JS_STR_VIEWERTYPE));
+ return CJS_Return::Success(pRuntime->NewString(JS_STR_VIEWERTYPE));
}
CJS_Return CJS_App::set_viewer_type(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::get_viewer_variation(CJS_Runtime* pRuntime) {
- return CJS_Return(pRuntime->NewString(JS_STR_VIEWERVARIATION));
+ return CJS_Return::Success(pRuntime->NewString(JS_STR_VIEWERVARIATION));
}
CJS_Return CJS_App::set_viewer_variation(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::get_viewer_version(CJS_Runtime* pRuntime) {
#ifdef PDF_ENABLE_XFA
CPDFXFA_Context* pXFAContext = pRuntime->GetFormFillEnv()->GetXFAContext();
if (pXFAContext->ContainsXFAForm())
- return CJS_Return(pRuntime->NewNumber(JS_NUM_VIEWERVERSION_XFA));
+ return CJS_Return::Success(pRuntime->NewNumber(JS_NUM_VIEWERVERSION_XFA));
#endif // PDF_ENABLE_XFA
- return CJS_Return(pRuntime->NewNumber(JS_NUM_VIEWERVERSION));
+ return CJS_Return::Success(pRuntime->NewNumber(JS_NUM_VIEWERVERSION));
}
CJS_Return CJS_App::set_viewer_version(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::get_platform(CJS_Runtime* pRuntime) {
#ifdef PDF_ENABLE_XFA
CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
if (!pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
WideString platform = pFormFillEnv->GetPlatform();
if (!platform.IsEmpty())
- return CJS_Return(pRuntime->NewString(platform.AsStringView()));
+ return CJS_Return::Success(pRuntime->NewString(platform.AsStringView()));
#endif
- return CJS_Return(pRuntime->NewString(JS_STR_PLATFORM));
+ return CJS_Return::Success(pRuntime->NewString(JS_STR_PLATFORM));
}
CJS_Return CJS_App::set_platform(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::get_language(CJS_Runtime* pRuntime) {
#ifdef PDF_ENABLE_XFA
CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
if (!pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
WideString language = pFormFillEnv->GetLanguage();
if (!language.IsEmpty())
- return CJS_Return(pRuntime->NewString(language.AsStringView()));
+ return CJS_Return::Success(pRuntime->NewString(language.AsStringView()));
#endif
- return CJS_Return(pRuntime->NewString(JS_STR_LANGUAGE));
+ return CJS_Return::Success(pRuntime->NewString(JS_STR_LANGUAGE));
}
CJS_Return CJS_App::set_language(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
// creates a new fdf object that contains no data
@@ -213,7 +214,7 @@ CJS_Return CJS_App::set_language(CJS_Runtime* pRuntime,
// CFDF_Document * CPDFSDK_FormFillEnvironment::NewFDF();
CJS_Return CJS_App::newFDF(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
// opens a specified pdf document and returns its document object
@@ -225,7 +226,7 @@ CJS_Return CJS_App::newFDF(CJS_Runtime* pRuntime,
CJS_Return CJS_App::openFDF(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_App::alert(CJS_Runtime* pRuntime,
@@ -234,11 +235,11 @@ CJS_Return CJS_App::alert(CJS_Runtime* pRuntime,
pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle");
if (!IsTypeKnown(newParams[0]))
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
if (!pFormFillEnv)
- return CJS_Return(pRuntime->NewNumber(0));
+ return CJS_Return::Success(pRuntime->NewNumber(0));
WideString swMsg;
if (newParams[0]->IsArray()) {
@@ -275,51 +276,51 @@ CJS_Return CJS_App::alert(CJS_Runtime* pRuntime,
pFormFillEnv->JS_appAlert(swMsg, swTitle, iType, iIcon));
pRuntime->EndBlock();
- return CJS_Return(ret);
+ return CJS_Return::Success(ret);
}
CJS_Return CJS_App::beep(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
int type = JSPLATFORM_BEEP_DEFAULT;
if (IsTypeKnown(params[0]))
type = pRuntime->ToInt32(params[0]);
pRuntime->GetFormFillEnv()->JS_appBeep(type);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_App::findComponent(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_App::popUpMenuEx(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::get_fs(CJS_Runtime* pRuntime) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::set_fs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::setInterval(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() == 0 || params.size() > 2)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString script = pRuntime->ToWideString(params[0]);
if (script.IsEmpty())
- return CJS_Return(JSMessage::kInvalidInputError);
+ return CJS_Return::Failure(JSMessage::kInvalidInputError);
uint32_t dwInterval = params.size() > 1 ? pRuntime->ToInt32(params[1]) : 1000;
auto timerRef = pdfium::MakeUnique<GlobalTimer>(
@@ -330,24 +331,24 @@ CJS_Return CJS_App::setInterval(
v8::Local<v8::Object> pRetObj = pRuntime->NewFXJSBoundObject(
CJS_TimerObj::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pRetObj.IsEmpty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
auto* pJS_TimerObj =
static_cast<CJS_TimerObj*>(CFXJS_Engine::GetObjectPrivate(pRetObj));
pJS_TimerObj->SetTimer(pTimerRef);
- return CJS_Return(pRetObj);
+ return CJS_Return::Success(pRetObj);
}
CJS_Return CJS_App::setTimeOut(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() == 0 || params.size() > 2)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString script = pRuntime->ToWideString(params[0]);
if (script.IsEmpty())
- return CJS_Return(JSMessage::kInvalidInputError);
+ return CJS_Return::Failure(JSMessage::kInvalidInputError);
uint32_t dwTimeOut = params.size() > 1 ? pRuntime->ToInt32(params[1]) : 1000;
auto timerRef = pdfium::MakeUnique<GlobalTimer>(
@@ -359,33 +360,33 @@ CJS_Return CJS_App::setTimeOut(
v8::Local<v8::Object> pRetObj = pRuntime->NewFXJSBoundObject(
CJS_TimerObj::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pRetObj.IsEmpty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
auto* pJS_TimerObj =
static_cast<CJS_TimerObj*>(CFXJS_Engine::GetObjectPrivate(pRetObj));
pJS_TimerObj->SetTimer(pTimerRef);
- return CJS_Return(pRetObj);
+ return CJS_Return::Success(pRetObj);
}
CJS_Return CJS_App::clearTimeOut(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
CJS_App::ClearTimerCommon(pRuntime, params[0]);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_App::clearInterval(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
CJS_App::ClearTimerCommon(pRuntime, params[0]);
- return CJS_Return();
+ return CJS_Return::Success();
}
void CJS_App::ClearTimerCommon(CJS_Runtime* pRuntime,
@@ -410,7 +411,7 @@ CJS_Return CJS_App::execMenuItem(
pRuntime->GetFormFillEnv()->SaveCalled();
}
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
void CJS_App::TimerProc(GlobalTimer* pTimer) {
@@ -434,14 +435,14 @@ void CJS_App::RunJsScript(CJS_Runtime* pRuntime, const WideString& wsScript) {
CJS_Return CJS_App::goBack(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- // Not supported.
- return CJS_Return();
+ // Not supported, but do not return error.
+ return CJS_Return::Success();
}
CJS_Return CJS_App::goForward(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- // Not supported.
- return CJS_Return();
+ // Not supported, but do not return error.
+ return CJS_Return::Success();
}
CJS_Return CJS_App::mailMsg(CJS_Runtime* pRuntime,
@@ -451,7 +452,7 @@ CJS_Return CJS_App::mailMsg(CJS_Runtime* pRuntime,
L"cSubject", L"cMsg");
if (!IsTypeKnown(newParams[0]))
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
bool bUI = pRuntime->ToBoolean(newParams[0]);
WideString cTo;
@@ -460,7 +461,7 @@ CJS_Return CJS_App::mailMsg(CJS_Runtime* pRuntime,
} else {
// cTo parameter required when UI not invoked.
if (!bUI)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
}
WideString cCc;
@@ -483,44 +484,44 @@ CJS_Return CJS_App::mailMsg(CJS_Runtime* pRuntime,
pRuntime->GetFormFillEnv()->JS_docmailForm(nullptr, 0, bUI, cTo, cSubject,
cCc, cBcc, cMsg);
pRuntime->EndBlock();
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_App::launchURL(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- // Unsafe, not supported.
- return CJS_Return();
+ // Unsafe, not supported, but do not return error.
+ return CJS_Return::Success();
}
CJS_Return CJS_App::get_runtime_highlight(CJS_Runtime* pRuntime) {
- return CJS_Return(pRuntime->NewBoolean(m_bRuntimeHighLight));
+ return CJS_Return::Success(pRuntime->NewBoolean(m_bRuntimeHighLight));
}
CJS_Return CJS_App::set_runtime_highlight(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
m_bRuntimeHighLight = pRuntime->ToBoolean(vp);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_App::get_fullscreen(CJS_Runtime* pRuntime) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::set_fullscreen(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::popUpMenu(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::browseForDoc(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- // Unsafe, not supported.
- return CJS_Return();
+ // Unsafe, not supported, but do not return an error.
+ return CJS_Return::Success();
}
WideString CJS_App::SysPathToPDFPath(const WideString& sOldPath) {
@@ -534,12 +535,12 @@ WideString CJS_App::SysPathToPDFPath(const WideString& sOldPath) {
CJS_Return CJS_App::newDoc(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::openDoc(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::response(CJS_Runtime* pRuntime,
@@ -549,7 +550,7 @@ CJS_Return CJS_App::response(CJS_Runtime* pRuntime,
L"cDefault", L"bPassword", L"cLabel");
if (!IsTypeKnown(newParams[0]))
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString swQuestion = pRuntime->ToWideString(newParams[0]);
WideString swTitle = L"PDF";
@@ -575,24 +576,24 @@ CJS_Return CJS_App::response(CJS_Runtime* pRuntime,
MAX_INPUT_BYTES);
if (nLengthBytes < 0 || nLengthBytes > MAX_INPUT_BYTES)
- return CJS_Return(JSMessage::kParamTooLongError);
+ return CJS_Return::Failure(JSMessage::kParamTooLongError);
- return CJS_Return(pRuntime->NewString(
+ return CJS_Return::Success(pRuntime->NewString(
WideString::FromUTF16LE(reinterpret_cast<uint16_t*>(pBuff.data()),
nLengthBytes / sizeof(uint16_t))
.AsStringView()));
}
CJS_Return CJS_App::get_media(CJS_Runtime* pRuntime) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_App::execDialog(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
diff --git a/fxjs/cjs_color.cpp b/fxjs/cjs_color.cpp
index 1568687365..3bfa1a78df 100644
--- a/fxjs/cjs_color.cpp
+++ b/fxjs/cjs_color.cpp
@@ -250,25 +250,26 @@ CJS_Return CJS_Color::set_light_gray(CJS_Runtime* pRuntime,
CJS_Return CJS_Color::GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* var) {
v8::Local<v8::Value> array = ConvertPWLColorToArray(pRuntime, *var);
if (array.IsEmpty())
- return CJS_Return(pRuntime->NewArray());
- return CJS_Return(array);
+ return CJS_Return::Success(pRuntime->NewArray());
+
+ return CJS_Return::Success(array);
}
CJS_Return CJS_Color::SetPropertyHelper(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp,
CFX_Color* var) {
if (vp.IsEmpty() || !vp->IsArray())
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
*var = ConvertArrayToPWLColor(pRuntime, pRuntime->ToArray(vp));
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Color::convert(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
int iSize = params.size();
if (iSize < 2 || params[0].IsEmpty() || !params[0]->IsArray())
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString sDestSpace = pRuntime->ToWideString(params[1]);
int nColorType = CFX_Color::kTransparent;
@@ -283,19 +284,19 @@ CJS_Return CJS_Color::convert(CJS_Runtime* pRuntime,
CFX_Color color =
ConvertArrayToPWLColor(pRuntime, pRuntime->ToArray(params[0]));
-
v8::Local<v8::Value> array =
ConvertPWLColorToArray(pRuntime, color.ConvertColorType(nColorType));
if (array.IsEmpty())
- return CJS_Return(pRuntime->NewArray());
- return CJS_Return(array);
+ return CJS_Return::Success(pRuntime->NewArray());
+
+ return CJS_Return::Success(array);
}
CJS_Return CJS_Color::equal(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2 || params[0].IsEmpty() || !params[0]->IsArray() ||
params[1].IsEmpty() || !params[1]->IsArray()) {
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
}
CFX_Color color1 =
@@ -304,5 +305,5 @@ CJS_Return CJS_Color::equal(CJS_Runtime* pRuntime,
ConvertArrayToPWLColor(pRuntime, pRuntime->ToArray(params[1]));
color1 = color1.ConvertColorType(color2.nColorType);
- return CJS_Return(pRuntime->NewBoolean(color1 == color2));
+ return CJS_Return::Success(pRuntime->NewBoolean(color1 == color2));
}
diff --git a/fxjs/cjs_console.cpp b/fxjs/cjs_console.cpp
index d2cbb243b7..cf95ffab09 100644
--- a/fxjs/cjs_console.cpp
+++ b/fxjs/cjs_console.cpp
@@ -40,21 +40,21 @@ CJS_Console::~CJS_Console() = default;
CJS_Return CJS_Console::clear(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Console::hide(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Console::println(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Console::show(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index a6d68c8d29..b842c150bf 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -133,58 +133,61 @@ CJS_Document::~CJS_Document() = default;
// The total number of fields in document.
CJS_Return CJS_Document::get_num_fields(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
- return CJS_Return(pRuntime->NewNumber(
+ return CJS_Return::Success(pRuntime->NewNumber(
static_cast<int>(pPDFForm->CountFields(WideString()))));
}
CJS_Return CJS_Document::set_num_fields(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::get_dirty(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewBoolean(!!m_pFormFillEnv->GetChangeMark()));
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+
+ return CJS_Return::Success(
+ pRuntime->NewBoolean(!!m_pFormFillEnv->GetChangeMark()));
}
CJS_Return CJS_Document::set_dirty(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
pRuntime->ToBoolean(vp) ? m_pFormFillEnv->SetChangeMark()
: m_pFormFillEnv->ClearChangeMark();
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_ADBE(CJS_Runtime* pRuntime) {
- return CJS_Return(pRuntime->NewUndefined());
+ return CJS_Return::Success(pRuntime->NewUndefined());
}
CJS_Return CJS_Document::set_ADBE(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_page_num(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetCurrentView();
if (!pPageView)
- return CJS_Return(pRuntime->NewUndefined());
- return CJS_Return(pRuntime->NewNumber(pPageView->GetPageIndex()));
+ return CJS_Return::Success(pRuntime->NewUndefined());
+
+ return CJS_Return::Success(pRuntime->NewNumber(pPageView->GetPageIndex()));
}
CJS_Return CJS_Document::set_page_num(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
int iPageCount = m_pFormFillEnv->GetPageCount();
int iPageNum = pRuntime->ToInt32(vp);
@@ -195,70 +198,71 @@ CJS_Return CJS_Document::set_page_num(CJS_Runtime* pRuntime,
else if (iPageNum < 0)
m_pFormFillEnv->JS_docgotoPage(0);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::addAnnot(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- // Not supported.
- return CJS_Return();
+ // Not supported, but do not return an error.
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::addField(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- // Not supported.
- return CJS_Return();
+ // Not supported, but do not return an error.
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::exportAsText(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- // Unsafe, not supported.
- return CJS_Return();
+ // Unsafe, not supported, but do not return an error.
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::exportAsFDF(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- // Unsafe, not supported.
- return CJS_Return();
+ // Unsafe, not supported, but do not return an error.
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::exportAsXFDF(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- // Unsafe, not supported.
- return CJS_Return();
+ // Unsafe, not supported, but do not return an error.
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::getField(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.empty())
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
+
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
WideString wideName = pRuntime->ToWideString(params[0]);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
if (pPDFForm->CountFields(wideName) <= 0)
- return CJS_Return(pRuntime->NewUndefined());
+ return CJS_Return::Success(pRuntime->NewUndefined());
v8::Local<v8::Object> pFieldObj = pRuntime->NewFXJSBoundObject(
CJS_Field::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pFieldObj.IsEmpty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
auto* pJSField =
static_cast<CJS_Field*>(CFXJS_Engine::GetObjectPrivate(pFieldObj));
if (!pJSField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
pJSField->AttachField(this, wideName);
- return CJS_Return(pJSField->ToV8Object());
+ return CJS_Return::Success(pJSField->ToV8Object());
}
// Gets the name of the nth field in the document
@@ -266,41 +270,42 @@ CJS_Return CJS_Document::getNthFieldName(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
int nIndex = pRuntime->ToInt32(params[0]);
if (nIndex < 0)
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
CPDF_FormField* pField = pPDFForm->GetField(nIndex, WideString());
if (!pField)
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewString(pField->GetFullName().AsStringView()));
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+ return CJS_Return::Success(
+ pRuntime->NewString(pField->GetFullName().AsStringView()));
}
CJS_Return CJS_Document::importAnFDF(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::importAnXFDF(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::importTextData(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return();
+ return CJS_Return::Success();
}
// exports the form data and mails the resulting fdf file as an attachment to
@@ -310,14 +315,14 @@ CJS_Return CJS_Document::mailForm(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
- return CJS_Return(JSMessage::kPermissionError);
+ return CJS_Return::Failure(JSMessage::kPermissionError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
ByteString sTextBuf = pInterForm->ExportFormToFDFTextBuf();
if (sTextBuf.GetLength() == 0)
- return CJS_Return(L"Bad FDF format.");
+ return CJS_Return::Failure(L"Bad FDF format.");
size_t nLength = params.size();
bool bUI = nLength > 0 ? pRuntime->ToBoolean(params[0]) : true;
@@ -333,14 +338,14 @@ CJS_Return CJS_Document::mailForm(
pFormFillEnv->JS_docmailForm(mutable_buf.data(), mutable_buf.size(), bUI, cTo,
cSubject, cCc, cBcc, cMsg);
pRuntime->EndBlock();
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::print(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
bool bUI = true;
int nStart = 0;
@@ -386,11 +391,11 @@ CJS_Return CJS_Document::print(
}
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
m_pFormFillEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit,
bPrintAsImage, bReverse, bAnnotations);
- return CJS_Return();
+ return CJS_Return::Success();
}
// removes the specified field from the document.
@@ -401,20 +406,20 @@ CJS_Return CJS_Document::removeField(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM)))
- return CJS_Return(JSMessage::kPermissionError);
+ return CJS_Return::Failure(JSMessage::kPermissionError);
WideString sFieldName = pRuntime->ToWideString(params[0]);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
std::vector<CPDFSDK_Annot::ObservedPtr> widgets;
pInterForm->GetWidgets(sFieldName, &widgets);
if (widgets.empty())
- return CJS_Return();
+ return CJS_Return::Success();
for (const auto& pAnnot : widgets) {
CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get());
@@ -444,7 +449,7 @@ CJS_Return CJS_Document::removeField(
}
m_pFormFillEnv->SetChangeMark();
- return CJS_Return();
+ return CJS_Return::Success();
}
// reset filed values within a document.
@@ -455,11 +460,11 @@ CJS_Return CJS_Document::resetForm(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) {
- return CJS_Return(JSMessage::kPermissionError);
+ return CJS_Return::Failure(JSMessage::kPermissionError);
}
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
@@ -467,7 +472,7 @@ CJS_Return CJS_Document::resetForm(
if (params.empty()) {
pPDFForm->ResetForm(NotificationOption::kNotify);
m_pFormFillEnv->SetChangeMark();
- return CJS_Return();
+ return CJS_Return::Success();
}
v8::Local<v8::Array> array;
@@ -491,20 +496,20 @@ CJS_Return CJS_Document::resetForm(
m_pFormFillEnv->SetChangeMark();
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::saveAs(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::syncAnnotScan(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::submitForm(
@@ -512,9 +517,9 @@ CJS_Return CJS_Document::submitForm(
const std::vector<v8::Local<v8::Value>>& params) {
size_t nSize = params.size();
if (nSize < 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
v8::Local<v8::Array> aFields;
WideString strURL;
@@ -548,7 +553,7 @@ CJS_Return CJS_Document::submitForm(
pInterForm->SubmitForm(strURL, false);
pRuntime->EndBlock();
}
- return CJS_Return();
+ return CJS_Return::Success();
}
std::vector<CPDF_FormField*> fieldObjects;
@@ -570,7 +575,7 @@ CJS_Return CJS_Document::submitForm(
pInterForm->SubmitFields(strURL, fieldObjects, true, !bFDF);
pRuntime->EndBlock();
}
- return CJS_Return();
+ return CJS_Return::Success();
}
void CJS_Document::SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
@@ -578,12 +583,12 @@ void CJS_Document::SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
}
CJS_Return CJS_Document::get_bookmark_root(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::set_bookmark_root(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::mailDoc(
@@ -626,7 +631,7 @@ CJS_Return CJS_Document::mailDoc(
CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
pFormFillEnv->JS_docmailForm(nullptr, 0, bUI, cTo, cSubject, cCc, cBcc, cMsg);
pRuntime->EndBlock();
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_author(CJS_Runtime* pRuntime) {
@@ -640,11 +645,11 @@ CJS_Return CJS_Document::set_author(CJS_Runtime* pRuntime,
CJS_Return CJS_Document::get_info(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
const auto* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
WideString cwAuthor = pDictionary->GetUnicodeTextFor("Author");
WideString cwTitle = pDictionary->GetUnicodeTextFor("Title");
@@ -694,23 +699,23 @@ CJS_Return CJS_Document::get_info(CJS_Runtime* pRuntime) {
pObj, wsKey, pRuntime->NewBoolean(!!pValueObj->GetInteger()));
}
}
- return CJS_Return(pObj);
+ return CJS_Return::Success(pObj);
}
CJS_Return CJS_Document::set_info(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::getPropertyInternal(CJS_Runtime* pRuntime,
const ByteString& propName) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewString(
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+ return CJS_Return::Success(pRuntime->NewString(
pDictionary->GetUnicodeTextFor(propName).AsStringView()));
}
@@ -718,20 +723,20 @@ CJS_Return CJS_Document::setPropertyInternal(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp,
const ByteString& propName) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY))
- return CJS_Return(JSMessage::kPermissionError);
+ return CJS_Return::Failure(JSMessage::kPermissionError);
WideString csProperty = pRuntime->ToWideString(vp);
pDictionary->SetNewFor<CPDF_String>(propName, PDF_EncodeText(csProperty),
false);
m_pFormFillEnv->SetChangeMark();
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_creation_date(CJS_Runtime* pRuntime) {
@@ -754,21 +759,21 @@ CJS_Return CJS_Document::set_creator(CJS_Runtime* pRuntime,
CJS_Return CJS_Document::get_delay(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewBoolean(m_bDelay));
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+ return CJS_Return::Success(pRuntime->NewBoolean(m_bDelay));
}
CJS_Return CJS_Document::set_delay(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY))
- return CJS_Return(JSMessage::kPermissionError);
+ return CJS_Return::Failure(JSMessage::kPermissionError);
m_bDelay = pRuntime->ToBoolean(vp);
if (m_bDelay) {
m_DelayData.clear();
- return CJS_Return();
+ return CJS_Return::Success();
}
std::list<std::unique_ptr<CJS_DelayData>> DelayDataToProcess;
@@ -776,7 +781,7 @@ CJS_Return CJS_Document::set_delay(CJS_Runtime* pRuntime,
for (const auto& pData : DelayDataToProcess)
CJS_Field::DoDelay(m_pFormFillEnv.Get(), pData.get());
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_keywords(CJS_Runtime* pRuntime) {
@@ -817,108 +822,110 @@ CJS_Return CJS_Document::set_subject(CJS_Runtime* pRuntime,
CJS_Return CJS_Document::get_title(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv || !m_pFormFillEnv->GetPDFDocument())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
return getPropertyInternal(pRuntime, "Title");
}
CJS_Return CJS_Document::set_title(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv || !m_pFormFillEnv->GetPDFDocument())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
return setPropertyInternal(pRuntime, vp, "Title");
}
CJS_Return CJS_Document::get_num_pages(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewNumber(m_pFormFillEnv->GetPageCount()));
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+ return CJS_Return::Success(
+ pRuntime->NewNumber(m_pFormFillEnv->GetPageCount()));
}
CJS_Return CJS_Document::set_num_pages(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::get_external(CJS_Runtime* pRuntime) {
// In Chrome case, should always return true.
- return CJS_Return(pRuntime->NewBoolean(true));
+ return CJS_Return::Success(pRuntime->NewBoolean(true));
}
CJS_Return CJS_Document::set_external(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_filesize(CJS_Runtime* pRuntime) {
- return CJS_Return(pRuntime->NewNumber(0));
+ return CJS_Return::Success(pRuntime->NewNumber(0));
}
CJS_Return CJS_Document::set_filesize(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::get_mouse_x(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::set_mouse_x(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_mouse_y(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::set_mouse_y(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_URL(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+ return CJS_Return::Success(
pRuntime->NewString(m_pFormFillEnv->JS_docGetFilePath().AsStringView()));
}
CJS_Return CJS_Document::set_URL(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::get_base_URL(CJS_Runtime* pRuntime) {
- return CJS_Return(pRuntime->NewString(m_cwBaseURL.AsStringView()));
+ return CJS_Return::Success(pRuntime->NewString(m_cwBaseURL.AsStringView()));
}
CJS_Return CJS_Document::set_base_URL(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
m_cwBaseURL = pRuntime->ToWideString(vp);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_calculate(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
- return CJS_Return(pRuntime->NewBoolean(!!pInterForm->IsCalculateEnabled()));
+ return CJS_Return::Success(
+ pRuntime->NewBoolean(!!pInterForm->IsCalculateEnabled()));
}
CJS_Return CJS_Document::set_calculate(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
pInterForm->EnableCalculate(pRuntime->ToBoolean(vp));
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_document_file_name(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
WideString wsFilePath = m_pFormFillEnv->JS_docGetFilePath();
size_t i = wsFilePath.GetLength();
@@ -927,78 +934,78 @@ CJS_Return CJS_Document::get_document_file_name(CJS_Runtime* pRuntime) {
break;
}
if (i > 0 && i < wsFilePath.GetLength())
- return CJS_Return(pRuntime->NewString(wsFilePath.c_str() + i));
+ return CJS_Return::Success(pRuntime->NewString(wsFilePath.c_str() + i));
- return CJS_Return(pRuntime->NewString(L""));
+ return CJS_Return::Success(pRuntime->NewString(L""));
}
CJS_Return CJS_Document::set_document_file_name(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::get_path(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewString(
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+ return CJS_Return::Success(pRuntime->NewString(
CJS_App::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath())
.AsStringView()));
}
CJS_Return CJS_Document::set_path(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::get_page_window_rect(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::set_page_window_rect(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_layout(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::set_layout(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::addLink(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::closeDoc(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::getPageBox(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::getAnnot(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
int nPageNo = pRuntime->ToInt32(params[0]);
WideString swAnnotName = pRuntime->ToWideString(params[1]);
CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(nPageNo);
if (!pPageView)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDFSDK_AnnotIteration annotIteration(pPageView, false);
CPDFSDK_BAAnnot* pSDKBAAnnot = nullptr;
@@ -1010,27 +1017,27 @@ CJS_Return CJS_Document::getAnnot(
}
}
if (!pSDKBAAnnot)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(
CJS_Annot::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pObj.IsEmpty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
auto* pJS_Annot =
static_cast<CJS_Annot*>(CFXJS_Engine::GetObjectPrivate(pObj));
if (!pJS_Annot)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
pJS_Annot->SetSDKAnnot(pSDKBAAnnot);
- return CJS_Return(pJS_Annot->ToV8Object());
+ return CJS_Return::Success(pJS_Annot->ToV8Object());
}
CJS_Return CJS_Document::getAnnots(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
// TODO(tonikitoo): Add support supported parameters as per
// the PDF spec.
@@ -1040,17 +1047,17 @@ CJS_Return CJS_Document::getAnnots(
for (int i = 0; i < nPageNo; ++i) {
CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(i);
if (!pPageView)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDFSDK_AnnotIteration annotIteration(pPageView, false);
for (const auto& pSDKAnnotCur : annotIteration) {
if (!pSDKAnnotCur)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(
CJS_Annot::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pObj.IsEmpty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
auto* pJS_Annot =
static_cast<CJS_Annot*>(CFXJS_Engine::GetObjectPrivate(pObj));
@@ -1061,31 +1068,31 @@ CJS_Return CJS_Document::getAnnots(
: v8::Local<v8::Value>());
}
}
- return CJS_Return(annots);
+ return CJS_Return::Success(annots);
}
CJS_Return CJS_Document::getAnnot3D(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(pRuntime->NewUndefined());
+ return CJS_Return::Success(pRuntime->NewUndefined());
}
CJS_Return CJS_Document::getAnnots3D(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::getOCGs(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::getLinks(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
bool CJS_Document::IsEnclosedInRect(CFX_FloatRect rect,
@@ -1098,23 +1105,23 @@ CJS_Return CJS_Document::addIcon(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
if (!params[1]->IsObject())
- return CJS_Return(JSMessage::kTypeError);
+ return CJS_Return::Failure(JSMessage::kTypeError);
v8::Local<v8::Object> pObj = pRuntime->ToObject(params[1]);
if (!JSGetObject<CJS_Icon>(pObj))
- return CJS_Return(JSMessage::kTypeError);
+ return CJS_Return::Failure(JSMessage::kTypeError);
WideString swIconName = pRuntime->ToWideString(params[0]);
m_IconNames.push_back(swIconName);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) {
if (m_IconNames.empty())
- return CJS_Return(pRuntime->NewUndefined());
+ return CJS_Return::Success(pRuntime->NewUndefined());
v8::Local<v8::Array> Icons = pRuntime->NewArray();
int i = 0;
@@ -1122,7 +1129,7 @@ CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) {
v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(
CJS_Icon::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pObj.IsEmpty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
auto* pJS_Icon =
static_cast<CJS_Icon*>(CFXJS_Engine::GetObjectPrivate(pObj));
@@ -1132,93 +1139,93 @@ CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) {
? v8::Local<v8::Value>(pJS_Icon->ToV8Object())
: v8::Local<v8::Value>());
}
- return CJS_Return(Icons);
+ return CJS_Return::Success(Icons);
}
CJS_Return CJS_Document::set_icons(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::getIcon(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString swIconName = pRuntime->ToWideString(params[0]);
auto it = std::find(m_IconNames.begin(), m_IconNames.end(), swIconName);
if (it == m_IconNames.end())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(
CJS_Icon::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pObj.IsEmpty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
auto* pJSIcon = static_cast<CJS_Icon*>(CFXJS_Engine::GetObjectPrivate(pObj));
if (!pJSIcon)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
pJSIcon->SetIconName(*it);
- return CJS_Return(pJSIcon->ToV8Object());
+ return CJS_Return::Success(pJSIcon->ToV8Object());
}
CJS_Return CJS_Document::removeIcon(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, no supported.
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::createDataObject(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not implemented.
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_media(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::set_media(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::calculateNow(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) {
- return CJS_Return(JSMessage::kPermissionError);
+ return CJS_Return::Failure(JSMessage::kPermissionError);
}
m_pFormFillEnv->GetInterForm()->OnCalculate(nullptr);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_collab(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::set_collab(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::getPageNthWord(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
- return CJS_Return(JSMessage::kPermissionError);
+ return CJS_Return::Failure(JSMessage::kPermissionError);
// TODO(tsepez): check maximum allowable params.
@@ -1228,14 +1235,14 @@ CJS_Return CJS_Document::getPageNthWord(
CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
if (!pDocument)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
CPDF_Dictionary* pPageDict = pDocument->GetPageDictionary(nPageNo);
if (!pPageDict)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
auto page = pdfium::MakeRetain<CPDF_Page>(pDocument, pPageDict, true);
page->ParseContent();
@@ -1256,35 +1263,35 @@ CJS_Return CJS_Document::getPageNthWord(
if (bStrip)
swRet.Trim();
- return CJS_Return(pRuntime->NewString(swRet.AsStringView()));
+ return CJS_Return::Success(pRuntime->NewString(swRet.AsStringView()));
}
CJS_Return CJS_Document::getPageNthWordQuads(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Document::getPageNumWords(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
- return CJS_Return(JSMessage::kPermissionError);
+ return CJS_Return::Failure(JSMessage::kPermissionError);
int nPageNo = params.size() > 0 ? pRuntime->ToInt32(params[0]) : 0;
CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
CPDF_Dictionary* pPageDict = pDocument->GetPageDictionary(nPageNo);
if (!pPageDict)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
auto page = pdfium::MakeRetain<CPDF_Page>(pDocument, pPageDict, true);
page->ParseContent();
@@ -1295,7 +1302,7 @@ CJS_Return CJS_Document::getPageNumWords(
nWords += CountWords(pPageObj->AsText());
}
- return CJS_Return(pRuntime->NewNumber(nWords));
+ return CJS_Return::Success(pRuntime->NewNumber(nWords));
}
CJS_Return CJS_Document::getPrintParams(
@@ -1304,8 +1311,8 @@ CJS_Return CJS_Document::getPrintParams(
v8::Local<v8::Object> pRetObj = pRuntime->NewFXJSBoundObject(
CJS_PrintParamsObj::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pRetObj.IsEmpty())
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
#define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF)
@@ -1379,76 +1386,76 @@ WideString CJS_Document::GetObjWordStr(CPDF_TextObject* pTextObj,
}
CJS_Return CJS_Document::get_zoom(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::set_zoom(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::get_zoom_type(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::set_zoom_type(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::deletePages(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::extractPages(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::insertPages(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::replacePages(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::getURL(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Document::gotoNamedDest(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
if (!m_pFormFillEnv)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
if (!pDocument)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_NameTree nameTree(pDocument, "Dests");
CPDF_Array* destArray =
nameTree.LookupNamedDest(pDocument, pRuntime->ToWideString(params[0]));
if (!destArray)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_Dest dest(destArray);
const CPDF_Array* arrayObject = ToArray(dest.GetObject());
@@ -1462,7 +1469,7 @@ CJS_Return CJS_Document::gotoNamedDest(
dest.GetZoomMode(), scrollPositionArray.data(),
scrollPositionArray.size());
pRuntime->EndBlock();
- return CJS_Return();
+ return CJS_Return::Success();
}
void CJS_Document::AddDelayData(std::unique_ptr<CJS_DelayData> pData) {
diff --git a/fxjs/cjs_event.cpp b/fxjs/cjs_event.cpp
index 9594f13477..f00f07c3b9 100644
--- a/fxjs/cjs_event.cpp
+++ b/fxjs/cjs_event.cpp
@@ -55,10 +55,10 @@ CJS_Event::CJS_Event(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime)
CJS_Event::~CJS_Event() = default;
CJS_Return CJS_Event::get_change(CJS_Runtime* pRuntime) {
- ASSERT(pRuntime->GetCurrentEventContext());
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewString(pEvent->Change().AsStringView()));
+ return CJS_Return::Success(
+ pRuntime->NewString(pEvent->Change().AsStringView()));
}
CJS_Return CJS_Event::set_change(CJS_Runtime* pRuntime,
@@ -72,123 +72,116 @@ CJS_Return CJS_Event::set_change(CJS_Runtime* pRuntime,
WideString& wChange = pEvent->Change();
wChange = pRuntime->ToWideString(vp);
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_change_ex(CJS_Runtime* pRuntime) {
- ASSERT(pRuntime->GetCurrentEventContext());
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
-
- return CJS_Return(pRuntime->NewString(pEvent->ChangeEx().AsStringView()));
+ return CJS_Return::Success(
+ pRuntime->NewString(pEvent->ChangeEx().AsStringView()));
}
CJS_Return CJS_Event::set_change_ex(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_commit_key(CJS_Runtime* pRuntime) {
- ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
-
- return CJS_Return(pRuntime->NewNumber(pEvent->CommitKey()));
+ return CJS_Return::Success(pRuntime->NewNumber(pEvent->CommitKey()));
}
CJS_Return CJS_Event::set_commit_key(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_field_full(CJS_Runtime* pRuntime) {
- ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
-
if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return CJS_Return(L"unrecognized event");
+ return CJS_Return::Failure(L"unrecognized event");
- return CJS_Return(pRuntime->NewBoolean(pEvent->FieldFull()));
+ return CJS_Return::Success(pRuntime->NewBoolean(pEvent->FieldFull()));
}
CJS_Return CJS_Event::set_field_full(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_key_down(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewBoolean(pEvent->KeyDown()));
+ return CJS_Return::Success(pRuntime->NewBoolean(pEvent->KeyDown()));
}
CJS_Return CJS_Event::set_key_down(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_modifier(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewBoolean(pEvent->Modifier()));
+ return CJS_Return::Success(pRuntime->NewBoolean(pEvent->Modifier()));
}
CJS_Return CJS_Event::set_modifier(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_name(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewString(pEvent->Name()));
+ return CJS_Return::Success(pRuntime->NewString(pEvent->Name()));
}
CJS_Return CJS_Event::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_rc(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewBoolean(pEvent->Rc()));
+ return CJS_Return::Success(pRuntime->NewBoolean(pEvent->Rc()));
}
CJS_Return CJS_Event::set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
pEvent->Rc() = pRuntime->ToBoolean(vp);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_rich_change(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::set_rich_change(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_rich_change_ex(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::set_rich_change_ex(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_rich_value(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::set_rich_value(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_sel_end(CJS_Runtime* pRuntime) {
@@ -196,9 +189,9 @@ CJS_Return CJS_Event::get_sel_end(CJS_Runtime* pRuntime) {
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return CJS_Return();
+ return CJS_Return::Success();
- return CJS_Return(pRuntime->NewNumber(pEvent->SelEnd()));
+ return CJS_Return::Success(pRuntime->NewNumber(pEvent->SelEnd()));
}
CJS_Return CJS_Event::set_sel_end(CJS_Runtime* pRuntime,
@@ -206,11 +199,10 @@ CJS_Return CJS_Event::set_sel_end(CJS_Runtime* pRuntime,
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return CJS_Return();
+ if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") == 0)
+ pEvent->SetSelEnd(pRuntime->ToInt32(vp));
- pEvent->SetSelEnd(pRuntime->ToInt32(vp));
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_sel_start(CJS_Runtime* pRuntime) {
@@ -218,9 +210,9 @@ CJS_Return CJS_Event::get_sel_start(CJS_Runtime* pRuntime) {
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return CJS_Return();
+ return CJS_Return::Success();
- return CJS_Return(pRuntime->NewNumber(pEvent->SelStart()));
+ return CJS_Return::Success(pRuntime->NewNumber(pEvent->SelStart()));
}
CJS_Return CJS_Event::set_sel_start(CJS_Runtime* pRuntime,
@@ -228,84 +220,81 @@ CJS_Return CJS_Event::set_sel_start(CJS_Runtime* pRuntime,
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return CJS_Return();
+ if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") == 0)
+ pEvent->SetSelStart(pRuntime->ToInt32(vp));
- pEvent->SetSelStart(pRuntime->ToInt32(vp));
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_shift(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewBoolean(pEvent->Shift()));
+ return CJS_Return::Success(pRuntime->NewBoolean(pEvent->Shift()));
}
CJS_Return CJS_Event::set_shift(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_source(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pEvent->Source()->ToV8Object());
+ return CJS_Return::Success(pEvent->Source()->ToV8Object());
}
CJS_Return CJS_Event::set_source(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_target(CJS_Runtime* pRuntime) {
ASSERT(pRuntime->GetCurrentEventContext());
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pEvent->Target_Field()->ToV8Object());
+ return CJS_Return::Success(pEvent->Target_Field()->ToV8Object());
}
CJS_Return CJS_Event::set_target(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_target_name(CJS_Runtime* pRuntime) {
ASSERT(pRuntime->GetCurrentEventContext());
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewString(pEvent->TargetName().AsStringView()));
+ return CJS_Return::Success(
+ pRuntime->NewString(pEvent->TargetName().AsStringView()));
}
CJS_Return CJS_Event::set_target_name(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_type(CJS_Runtime* pRuntime) {
- ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewString(pEvent->Type()));
+ return CJS_Return::Success(pRuntime->NewString(pEvent->Type()));
}
CJS_Return CJS_Event::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Event::get_value(CJS_Runtime* pRuntime) {
- ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0)
- return CJS_Return(L"Bad event type.");
+ return CJS_Return::Failure(L"Bad event type.");
if (!pEvent->m_pValue)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewString(pEvent->Value().AsStringView()));
+ return CJS_Return::Success(
+ pRuntime->NewString(pEvent->Value().AsStringView()));
}
CJS_Return CJS_Event::set_value(CJS_Runtime* pRuntime,
@@ -316,13 +305,13 @@ CJS_Return CJS_Event::set_value(CJS_Runtime* pRuntime,
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0)
- return CJS_Return(L"Bad event type.");
+ return CJS_Return::Failure(L"Bad event type.");
if (!pEvent->m_pValue)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
pEvent->Value() = pRuntime->ToWideString(vp);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Event::get_will_commit(CJS_Runtime* pRuntime) {
@@ -330,10 +319,10 @@ CJS_Return CJS_Event::get_will_commit(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewBoolean(pEvent->WillCommit()));
+ return CJS_Return::Success(pRuntime->NewBoolean(pEvent->WillCommit()));
}
CJS_Return CJS_Event::set_will_commit(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index a14e16828a..4e7baf4a62 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -670,32 +670,33 @@ CJS_Return CJS_Field::get_alignment(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kTextField)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
switch (pFormControl->GetControlAlignment()) {
case 0:
- return CJS_Return(pRuntime->NewString(L"left"));
+ return CJS_Return::Success(pRuntime->NewString(L"left"));
case 1:
- return CJS_Return(pRuntime->NewString(L"center"));
+ return CJS_Return::Success(pRuntime->NewString(L"center"));
case 2:
- return CJS_Return(pRuntime->NewString(L"right"));
+ return CJS_Return::Success(pRuntime->NewString(L"right"));
}
- return CJS_Return(pRuntime->NewString(L""));
+ return CJS_Return::Success(pRuntime->NewString(L""));
}
CJS_Return CJS_Field::set_alignment(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_border_style(CJS_Runtime* pRuntime) {
@@ -703,35 +704,33 @@ CJS_Return CJS_Field::get_border_style(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
-
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDFSDK_Widget* pWidget =
GetWidget(m_pFormFillEnv.Get(), GetSmartFieldControl(pFormField));
if (!pWidget)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
switch (pWidget->GetBorderStyle()) {
case BorderStyle::SOLID:
- return CJS_Return(pRuntime->NewString(L"solid"));
+ return CJS_Return::Success(pRuntime->NewString(L"solid"));
case BorderStyle::DASH:
- return CJS_Return(pRuntime->NewString(L"dashed"));
+ return CJS_Return::Success(pRuntime->NewString(L"dashed"));
case BorderStyle::BEVELED:
- return CJS_Return(pRuntime->NewString(L"beveled"));
+ return CJS_Return::Success(pRuntime->NewString(L"beveled"));
case BorderStyle::INSET:
- return CJS_Return(pRuntime->NewString(L"inset"));
+ return CJS_Return::Success(pRuntime->NewString(L"inset"));
case BorderStyle::UNDERLINE:
- return CJS_Return(pRuntime->NewString(L"underline"));
+ return CJS_Return::Success(pRuntime->NewString(L"underline"));
}
- return CJS_Return(pRuntime->NewString(L""));
+ return CJS_Return::Success(pRuntime->NewString(L""));
}
CJS_Return CJS_Field::set_border_style(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
ByteString byte_str = pRuntime->ToWideString(vp).ToDefANSI();
if (m_bDelay) {
@@ -740,7 +739,7 @@ CJS_Return CJS_Field::set_border_style(CJS_Runtime* pRuntime,
SetBorderStyle(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
byte_str);
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_button_align_x(CJS_Runtime* pRuntime) {
@@ -748,29 +747,29 @@ CJS_Return CJS_Field::get_button_align_x(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kPushButton)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_IconFit IconFit = pFormControl->GetIconFit();
float fLeft;
float fBottom;
IconFit.GetIconPosition(fLeft, fBottom);
- return CJS_Return(pRuntime->NewNumber(static_cast<int32_t>(fLeft)));
+ return CJS_Return::Success(pRuntime->NewNumber(static_cast<int32_t>(fLeft)));
}
CJS_Return CJS_Field::set_button_align_x(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_button_align_y(CJS_Runtime* pRuntime) {
@@ -778,14 +777,14 @@ CJS_Return CJS_Field::get_button_align_y(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kPushButton)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_IconFit IconFit = pFormControl->GetIconFit();
@@ -793,15 +792,16 @@ CJS_Return CJS_Field::get_button_align_y(CJS_Runtime* pRuntime) {
float fBottom;
IconFit.GetIconPosition(fLeft, fBottom);
- return CJS_Return(pRuntime->NewNumber(static_cast<int32_t>(fBottom)));
+ return CJS_Return::Success(
+ pRuntime->NewNumber(static_cast<int32_t>(fBottom)));
}
CJS_Return CJS_Field::set_button_align_y(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_button_fit_bounds(CJS_Runtime* pRuntime) {
@@ -809,16 +809,16 @@ CJS_Return CJS_Field::get_button_fit_bounds(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kPushButton)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewBoolean(pFormControl->GetIconFit().GetFittingBounds()));
}
@@ -826,8 +826,8 @@ CJS_Return CJS_Field::set_button_fit_bounds(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_button_position(CJS_Runtime* pRuntime) {
@@ -835,24 +835,25 @@ CJS_Return CJS_Field::get_button_position(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kPushButton)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewNumber(pFormControl->GetTextPosition()));
+ return CJS_Return::Success(
+ pRuntime->NewNumber(pFormControl->GetTextPosition()));
}
CJS_Return CJS_Field::set_button_position(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_button_scale_how(CJS_Runtime* pRuntime) {
@@ -860,16 +861,16 @@ CJS_Return CJS_Field::get_button_scale_how(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kPushButton)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
pFormControl->GetIconFit().IsProportionalScale() ? 0 : 1));
}
@@ -877,8 +878,8 @@ CJS_Return CJS_Field::set_button_scale_how(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_button_scale_when(CJS_Runtime* pRuntime) {
@@ -886,40 +887,40 @@ CJS_Return CJS_Field::get_button_scale_when(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kPushButton)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_IconFit IconFit = pFormControl->GetIconFit();
int ScaleM = IconFit.GetScaleMethod();
switch (ScaleM) {
case CPDF_IconFit::Always:
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Always)));
case CPDF_IconFit::Bigger:
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Bigger)));
case CPDF_IconFit::Never:
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Never)));
case CPDF_IconFit::Smaller:
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Smaller)));
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::set_button_scale_when(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_calc_order_index(CJS_Runtime* pRuntime) {
@@ -927,14 +928,14 @@ CJS_Return CJS_Field::get_calc_order_index(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!IsComboBoxOrTextField(pFormField))
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
- return CJS_Return(pRuntime->NewNumber(static_cast<int32_t>(
+ return CJS_Return::Success(pRuntime->NewNumber(static_cast<int32_t>(
pInterForm->FindFieldInCalculationOrder(pFormField))));
}
@@ -942,8 +943,8 @@ CJS_Return CJS_Field::set_calc_order_index(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_char_limit(CJS_Runtime* pRuntime) {
@@ -951,11 +952,11 @@ CJS_Return CJS_Field::get_char_limit(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kTextField)
- return CJS_Return(JSMessage::kObjectTypeError);
- return CJS_Return(
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
+ return CJS_Return::Success(
pRuntime->NewNumber(static_cast<int32_t>(pFormField->GetMaxLen())));
}
@@ -963,8 +964,8 @@ CJS_Return CJS_Field::set_char_limit(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_comb(CJS_Runtime* pRuntime) {
@@ -972,20 +973,20 @@ CJS_Return CJS_Field::get_comb(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kTextField)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_COMB)));
}
CJS_Return CJS_Field::set_comb(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) {
@@ -993,12 +994,12 @@ CJS_Return CJS_Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!IsComboBoxOrListBox(pFormField))
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE)));
}
@@ -1006,23 +1007,24 @@ CJS_Return CJS_Field::set_commit_on_sel_change(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_current_value_indices(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!IsComboBoxOrListBox(pFormField))
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
int count = pFormField->CountSelectedItems();
if (count <= 0)
- return CJS_Return(pRuntime->NewNumber(-1));
+ return CJS_Return::Success(pRuntime->NewNumber(-1));
if (count == 1)
- return CJS_Return(pRuntime->NewNumber(pFormField->GetSelectedIndex(0)));
+ return CJS_Return::Success(
+ pRuntime->NewNumber(pFormField->GetSelectedIndex(0)));
v8::Local<v8::Array> SelArray = pRuntime->NewArray();
for (int i = 0; i < count; i++) {
@@ -1030,14 +1032,14 @@ CJS_Return CJS_Field::get_current_value_indices(CJS_Runtime* pRuntime) {
SelArray, i, pRuntime->NewNumber(pFormField->GetSelectedIndex(i)));
}
if (SelArray.IsEmpty())
- return CJS_Return(pRuntime->NewArray());
- return CJS_Return(SelArray);
+ return CJS_Return::Success(pRuntime->NewArray());
+ return CJS_Return::Success(SelArray);
}
CJS_Return CJS_Field::set_current_value_indices(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
std::vector<uint32_t> array;
if (vp->IsNumber()) {
@@ -1056,16 +1058,16 @@ CJS_Return CJS_Field::set_current_value_indices(CJS_Runtime* pRuntime,
SetCurrentValueIndices(m_pFormFillEnv.Get(), m_FieldName,
m_nFormControlIndex, array);
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_default_style(CJS_Runtime* pRuntime) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::set_default_style(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::get_default_value(CJS_Runtime* pRuntime) {
@@ -1073,14 +1075,14 @@ CJS_Return CJS_Field::get_default_value(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() == FormFieldType::kPushButton ||
pFormField->GetFieldType() == FormFieldType::kSignature) {
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
}
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewString(pFormField->GetDefaultValue().AsStringView()));
}
@@ -1088,8 +1090,8 @@ CJS_Return CJS_Field::set_default_value(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_do_not_scroll(CJS_Runtime* pRuntime) {
@@ -1097,12 +1099,12 @@ CJS_Return CJS_Field::get_do_not_scroll(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kTextField)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL)));
}
@@ -1110,8 +1112,8 @@ CJS_Return CJS_Field::set_do_not_scroll(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_do_not_spell_check(CJS_Runtime* pRuntime) {
@@ -1119,12 +1121,12 @@ CJS_Return CJS_Field::get_do_not_spell_check(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!IsComboBoxOrTextField(pFormField))
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK)));
}
@@ -1132,8 +1134,8 @@ CJS_Return CJS_Field::set_do_not_spell_check(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
void CJS_Field::SetDelay(bool bDelay) {
@@ -1146,45 +1148,45 @@ void CJS_Field::SetDelay(bool bDelay) {
}
CJS_Return CJS_Field::get_delay(CJS_Runtime* pRuntime) {
- return CJS_Return(pRuntime->NewBoolean(m_bDelay));
+ return CJS_Return::Success(pRuntime->NewBoolean(m_bDelay));
}
CJS_Return CJS_Field::set_delay(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
SetDelay(pRuntime->ToBoolean(vp));
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_display(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget =
pInterForm->GetWidget(GetSmartFieldControl(pFormField));
if (!pWidget)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
uint32_t dwFlag = pWidget->GetFlags();
if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag)
- return CJS_Return(pRuntime->NewNumber(1));
+ return CJS_Return::Success(pRuntime->NewNumber(1));
if (ANNOTFLAG_PRINT & dwFlag) {
if (ANNOTFLAG_NOVIEW & dwFlag)
- return CJS_Return(pRuntime->NewNumber(3));
- return CJS_Return(pRuntime->NewNumber(0));
+ return CJS_Return::Success(pRuntime->NewNumber(3));
+ return CJS_Return::Success(pRuntime->NewNumber(0));
}
- return CJS_Return(pRuntime->NewNumber(2));
+ return CJS_Return::Success(pRuntime->NewNumber(2));
}
CJS_Return CJS_Field::set_display(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
if (m_bDelay) {
AddDelay_Int(FP_DISPLAY, pRuntime->ToInt32(vp));
@@ -1192,43 +1194,43 @@ CJS_Return CJS_Field::set_display(CJS_Runtime* pRuntime,
SetDisplay(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
pRuntime->ToInt32(vp));
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_doc(CJS_Runtime* pRuntime) {
- return CJS_Return(m_pJSDoc->ToV8Object());
+ return CJS_Return::Success(m_pJSDoc->ToV8Object());
}
CJS_Return CJS_Field::set_doc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::get_editable(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kComboBox)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_EDIT)));
}
CJS_Return CJS_Field::set_editable(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_export_values(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!IsCheckBoxOrRadioButton(pFormField))
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
v8::Local<v8::Array> ExportValuesArray = pRuntime->NewArray();
if (m_nFormControlIndex < 0) {
@@ -1240,47 +1242,47 @@ CJS_Return CJS_Field::get_export_values(CJS_Runtime* pRuntime) {
}
} else {
if (m_nFormControlIndex >= pFormField->CountControls())
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
CPDF_FormControl* pFormControl =
pFormField->GetControl(m_nFormControlIndex);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
pRuntime->PutArrayElement(
ExportValuesArray, 0,
pRuntime->NewString(pFormControl->GetExportValue().AsStringView()));
}
- return CJS_Return(ExportValuesArray);
+ return CJS_Return::Success(ExportValuesArray);
}
CJS_Return CJS_Field::set_export_values(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!IsCheckBoxOrRadioButton(pFormField))
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
if (vp.IsEmpty() || !vp->IsArray())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_file_select(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kTextField)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT)));
}
@@ -1288,25 +1290,25 @@ CJS_Return CJS_Field::set_file_select(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kTextField)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_fill_color(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
int iColorType;
pFormControl->GetBackgroundColor(iColorType);
@@ -1329,48 +1331,48 @@ CJS_Return CJS_Field::get_fill_color(CJS_Runtime* pRuntime) {
pFormControl->GetOriginalBackgroundColor(2),
pFormControl->GetOriginalBackgroundColor(3));
} else {
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
}
v8::Local<v8::Value> array =
CJS_Color::ConvertPWLColorToArray(pRuntime, color);
if (array.IsEmpty())
- return CJS_Return(pRuntime->NewArray());
- return CJS_Return(array);
+ return CJS_Return::Success(pRuntime->NewArray());
+ return CJS_Return::Success(array);
}
CJS_Return CJS_Field::set_fill_color(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields();
if (FieldArray.empty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
if (vp.IsEmpty() || !vp->IsArray())
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_hidden(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget =
pInterForm->GetWidget(GetSmartFieldControl(pFormField));
if (!pWidget)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
uint32_t dwFlags = pWidget->GetFlags();
- return CJS_Return(pRuntime->NewBoolean(ANNOTFLAG_INVISIBLE & dwFlags ||
- ANNOTFLAG_HIDDEN & dwFlags));
+ return CJS_Return::Success(pRuntime->NewBoolean(
+ ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags));
}
CJS_Return CJS_Field::set_hidden(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
if (m_bDelay) {
AddDelay_Bool(FP_HIDDEN, pRuntime->ToBoolean(vp));
@@ -1378,7 +1380,7 @@ CJS_Return CJS_Field::set_hidden(CJS_Runtime* pRuntime,
SetHidden(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
pRuntime->ToBoolean(vp));
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_highlight(CJS_Runtime* pRuntime) {
@@ -1386,63 +1388,63 @@ CJS_Return CJS_Field::get_highlight(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kPushButton)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
int eHM = pFormControl->GetHighlightingMode();
switch (eHM) {
case CPDF_FormControl::None:
- return CJS_Return(pRuntime->NewString(L"none"));
+ return CJS_Return::Success(pRuntime->NewString(L"none"));
case CPDF_FormControl::Push:
- return CJS_Return(pRuntime->NewString(L"push"));
+ return CJS_Return::Success(pRuntime->NewString(L"push"));
case CPDF_FormControl::Invert:
- return CJS_Return(pRuntime->NewString(L"invert"));
+ return CJS_Return::Success(pRuntime->NewString(L"invert"));
case CPDF_FormControl::Outline:
- return CJS_Return(pRuntime->NewString(L"outline"));
+ return CJS_Return::Success(pRuntime->NewString(L"outline"));
case CPDF_FormControl::Toggle:
- return CJS_Return(pRuntime->NewString(L"toggle"));
+ return CJS_Return::Success(pRuntime->NewString(L"toggle"));
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::set_highlight(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_line_width(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
if (!pFormField->CountControls())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0));
if (!pWidget)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewNumber(pWidget->GetBorderWidth()));
+ return CJS_Return::Success(pRuntime->NewNumber(pWidget->GetBorderWidth()));
}
CJS_Return CJS_Field::set_line_width(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
if (m_bDelay) {
AddDelay_Int(FP_LINEWIDTH, pRuntime->ToInt32(vp));
@@ -1450,7 +1452,7 @@ CJS_Return CJS_Field::set_line_width(CJS_Runtime* pRuntime,
SetLineWidth(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
pRuntime->ToInt32(vp));
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_multiline(CJS_Runtime* pRuntime) {
@@ -1458,12 +1460,12 @@ CJS_Return CJS_Field::get_multiline(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kTextField)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)));
}
@@ -1471,20 +1473,20 @@ CJS_Return CJS_Field::set_multiline(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_multiple_selection(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kListBox)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT)));
}
@@ -1492,69 +1494,69 @@ CJS_Return CJS_Field::set_multiple_selection(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_name(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields();
if (FieldArray.empty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewString(m_FieldName.AsStringView()));
+ return CJS_Return::Success(pRuntime->NewString(m_FieldName.AsStringView()));
}
CJS_Return CJS_Field::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::get_num_items(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!IsComboBoxOrListBox(pFormField))
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
- return CJS_Return(pRuntime->NewNumber(pFormField->CountOptions()));
+ return CJS_Return::Success(pRuntime->NewNumber(pFormField->CountOptions()));
}
CJS_Return CJS_Field::set_num_items(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::get_page(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
std::vector<CPDFSDK_Annot::ObservedPtr> widgets;
m_pFormFillEnv->GetInterForm()->GetWidgets(pFormField, &widgets);
if (widgets.empty())
- return CJS_Return(pRuntime->NewNumber(-1));
+ return CJS_Return::Success(pRuntime->NewNumber(-1));
v8::Local<v8::Array> PageArray = pRuntime->NewArray();
int i = 0;
for (const auto& pObserved : widgets) {
if (!pObserved)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
auto* pWidget = ToCPDFSDKWidget(pObserved.Get());
CPDFSDK_PageView* pPageView = pWidget->GetPageView();
if (!pPageView)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
pRuntime->PutArrayElement(
PageArray, i,
pRuntime->NewNumber(static_cast<int32_t>(pPageView->GetPageIndex())));
++i;
}
- return CJS_Return(PageArray);
+ return CJS_Return::Success(PageArray);
}
CJS_Return CJS_Field::set_page(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Field::get_password(CJS_Runtime* pRuntime) {
@@ -1562,12 +1564,12 @@ CJS_Return CJS_Field::get_password(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kTextField)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD)));
}
@@ -1575,22 +1577,22 @@ CJS_Return CJS_Field::set_password(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_print(CJS_Runtime* pRuntime) {
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDFSDK_Widget* pWidget =
pInterForm->GetWidget(GetSmartFieldControl(pFormField));
if (!pWidget)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewBoolean(!!(pWidget->GetFlags() & ANNOTFLAG_PRINT)));
}
@@ -1599,10 +1601,10 @@ CJS_Return CJS_Field::set_print(CJS_Runtime* pRuntime,
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
std::vector<CPDF_FormField*> FieldArray = GetFormFields();
if (FieldArray.empty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
for (CPDF_FormField* pFormField : FieldArray) {
if (m_nFormControlIndex < 0) {
@@ -1630,7 +1632,7 @@ CJS_Return CJS_Field::set_print(CJS_Runtime* pRuntime,
}
if (m_nFormControlIndex >= pFormField->CountControls())
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
if (CPDF_FormControl* pFormControl =
pFormField->GetControl(m_nFormControlIndex)) {
@@ -1650,18 +1652,18 @@ CJS_Return CJS_Field::set_print(CJS_Runtime* pRuntime,
}
}
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_radios_in_unison(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kRadioButton)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)));
}
@@ -1669,18 +1671,18 @@ CJS_Return CJS_Field::set_radios_in_unison(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields();
if (FieldArray.empty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_readonly(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_READONLY)));
}
@@ -1688,22 +1690,22 @@ CJS_Return CJS_Field::set_readonly(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields();
if (FieldArray.empty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_rect(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget =
pInterForm->GetWidget(GetSmartFieldControl(pFormField));
if (!pWidget)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CFX_FloatRect crRect = pWidget->GetRect();
v8::Local<v8::Array> rcArray = pRuntime->NewArray();
@@ -1716,18 +1718,18 @@ CJS_Return CJS_Field::get_rect(CJS_Runtime* pRuntime) {
pRuntime->PutArrayElement(
rcArray, 3, pRuntime->NewNumber(static_cast<int32_t>(crRect.bottom)));
- return CJS_Return(rcArray);
+ return CJS_Return::Success(rcArray);
}
CJS_Return CJS_Field::set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
if (vp.IsEmpty() || !vp->IsArray())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
v8::Local<v8::Array> rcArray = pRuntime->ToArray(vp);
if (pRuntime->GetArrayLength(rcArray) < 4)
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
float pArray[4];
pArray[0] = static_cast<float>(
@@ -1745,18 +1747,18 @@ CJS_Return CJS_Field::set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
} else {
SetRect(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, crRect);
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_required(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() == FormFieldType::kPushButton)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED)));
}
@@ -1764,10 +1766,10 @@ CJS_Return CJS_Field::set_required(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields();
if (FieldArray.empty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_rich_text(CJS_Runtime* pRuntime) {
@@ -1775,12 +1777,12 @@ CJS_Return CJS_Field::get_rich_text(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kTextField)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT)));
}
@@ -1788,17 +1790,17 @@ CJS_Return CJS_Field::set_rich_text(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_rich_value(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::set_rich_value(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_rotation(CJS_Runtime* pRuntime) {
@@ -1806,31 +1808,31 @@ CJS_Return CJS_Field::get_rotation(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewNumber(pFormControl->GetRotation()));
+ return CJS_Return::Success(pRuntime->NewNumber(pFormControl->GetRotation()));
}
CJS_Return CJS_Field::set_rotation(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_stroke_color(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
int iColorType;
pFormControl->GetBorderColor(iColorType);
@@ -1851,23 +1853,23 @@ CJS_Return CJS_Field::get_stroke_color(CJS_Runtime* pRuntime) {
pFormControl->GetOriginalBorderColor(2),
pFormControl->GetOriginalBorderColor(3));
} else {
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
}
v8::Local<v8::Value> array =
CJS_Color::ConvertPWLColorToArray(pRuntime, color);
if (array.IsEmpty())
- return CJS_Return(pRuntime->NewArray());
- return CJS_Return(array);
+ return CJS_Return::Success(pRuntime->NewArray());
+ return CJS_Return::Success(array);
}
CJS_Return CJS_Field::set_stroke_color(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
if (vp.IsEmpty() || !vp->IsArray())
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_style(CJS_Runtime* pRuntime) {
@@ -1875,14 +1877,14 @@ CJS_Return CJS_Field::get_style(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!IsCheckBoxOrRadioButton(pFormField))
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
WideString csWCaption = pFormControl->GetNormalCaption();
ByteString csBCaption;
@@ -1907,7 +1909,7 @@ CJS_Return CJS_Field::get_style(CJS_Runtime* pRuntime) {
csBCaption = "check";
break;
}
- return CJS_Return(pRuntime->NewString(
+ return CJS_Return::Success(pRuntime->NewString(
WideString::FromLocal(csBCaption.AsStringView()).AsStringView()));
}
@@ -1915,27 +1917,27 @@ CJS_Return CJS_Field::set_style(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_submit_name(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::set_submit_name(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_text_color(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
Optional<CFX_Color::Type> iColorType;
FX_ARGB color;
@@ -1957,17 +1959,17 @@ CJS_Return CJS_Field::get_text_color(CJS_Runtime* pRuntime) {
v8::Local<v8::Value> array =
CJS_Color::ConvertPWLColorToArray(pRuntime, crRet);
if (array.IsEmpty())
- return CJS_Return(pRuntime->NewArray());
- return CJS_Return(array);
+ return CJS_Return::Success(pRuntime->NewArray());
+ return CJS_Return::Success(array);
}
CJS_Return CJS_Field::set_text_color(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
if (vp.IsEmpty() || !vp->IsArray())
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_text_font(CJS_Runtime* pRuntime) {
@@ -1975,25 +1977,25 @@ CJS_Return CJS_Field::get_text_font(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
FormFieldType fieldType = pFormField->GetFieldType();
if (fieldType != FormFieldType::kPushButton &&
fieldType != FormFieldType::kComboBox &&
fieldType != FormFieldType::kListBox &&
fieldType != FormFieldType::kTextField) {
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
}
CPDF_Font* pFont = pFormControl->GetDefaultControlFont();
if (!pFont)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewString(
+ return CJS_Return::Success(pRuntime->NewString(
WideString::FromLocal(pFont->GetBaseFont().AsStringView())
.AsStringView()));
}
@@ -2003,10 +2005,10 @@ CJS_Return CJS_Field::set_text_font(CJS_Runtime* pRuntime,
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
if (pRuntime->ToWideString(vp).ToDefANSI().IsEmpty())
- return CJS_Return(JSMessage::kValueError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kValueError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_text_size(CJS_Runtime* pRuntime) {
@@ -2014,55 +2016,55 @@ CJS_Return CJS_Field::get_text_size(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
float fFontSize;
CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance();
FieldAppearance.GetFont(&fFontSize);
- return CJS_Return(pRuntime->NewNumber(static_cast<int>(fFontSize)));
+ return CJS_Return::Success(pRuntime->NewNumber(static_cast<int>(fFontSize)));
}
CJS_Return CJS_Field::set_text_size(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_type(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
switch (pFormField->GetFieldType()) {
case FormFieldType::kUnknown:
- return CJS_Return(pRuntime->NewString(L"unknown"));
+ return CJS_Return::Success(pRuntime->NewString(L"unknown"));
case FormFieldType::kPushButton:
- return CJS_Return(pRuntime->NewString(L"button"));
+ return CJS_Return::Success(pRuntime->NewString(L"button"));
case FormFieldType::kCheckBox:
- return CJS_Return(pRuntime->NewString(L"checkbox"));
+ return CJS_Return::Success(pRuntime->NewString(L"checkbox"));
case FormFieldType::kRadioButton:
- return CJS_Return(pRuntime->NewString(L"radiobutton"));
+ return CJS_Return::Success(pRuntime->NewString(L"radiobutton"));
case FormFieldType::kComboBox:
- return CJS_Return(pRuntime->NewString(L"combobox"));
+ return CJS_Return::Success(pRuntime->NewString(L"combobox"));
case FormFieldType::kListBox:
- return CJS_Return(pRuntime->NewString(L"listbox"));
+ return CJS_Return::Success(pRuntime->NewString(L"listbox"));
case FormFieldType::kTextField:
- return CJS_Return(pRuntime->NewString(L"text"));
+ return CJS_Return::Success(pRuntime->NewString(L"text"));
case FormFieldType::kSignature:
- return CJS_Return(pRuntime->NewString(L"signature"));
+ return CJS_Return::Success(pRuntime->NewString(L"signature"));
default:
- return CJS_Return(pRuntime->NewString(L"unknown"));
+ return CJS_Return::Success(pRuntime->NewString(L"unknown"));
}
}
CJS_Return CJS_Field::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::get_user_name(CJS_Runtime* pRuntime) {
@@ -2070,9 +2072,9 @@ CJS_Return CJS_Field::get_user_name(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewString(pFormField->GetAlternateName().AsStringView()));
}
@@ -2080,19 +2082,19 @@ CJS_Return CJS_Field::set_user_name(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_value(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
v8::Local<v8::Value> ret;
switch (pFormField->GetFieldType()) {
case FormFieldType::kPushButton:
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
case FormFieldType::kComboBox:
case FormFieldType::kTextField:
ret = pRuntime->NewString(pFormField->GetValue().AsStringView());
@@ -2138,13 +2140,13 @@ CJS_Return CJS_Field::get_value(CJS_Runtime* pRuntime) {
ret = pRuntime->NewString(pFormField->GetValue().AsStringView());
break;
}
- return CJS_Return(pRuntime->MaybeCoerceToNumber(ret));
+ return CJS_Return::Success(pRuntime->MaybeCoerceToNumber(ret));
}
CJS_Return CJS_Field::set_value(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
std::vector<WideString> strArray;
if (!vp.IsEmpty() && vp->IsArray()) {
@@ -2162,21 +2164,21 @@ CJS_Return CJS_Field::set_value(CJS_Runtime* pRuntime,
} else {
SetValue(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, strArray);
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::get_value_as_string(CJS_Runtime* pRuntime) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() == FormFieldType::kPushButton)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
if (pFormField->GetFieldType() == FormFieldType::kCheckBox) {
if (!pFormField->CountControls())
- return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewString(
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+ return CJS_Return::Success(pRuntime->NewString(
pFormField->GetControl(0)->IsChecked() ? L"Yes" : L"Off"));
}
@@ -2184,23 +2186,24 @@ CJS_Return CJS_Field::get_value_as_string(CJS_Runtime* pRuntime) {
!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)) {
for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
if (pFormField->GetControl(i)->IsChecked()) {
- return CJS_Return(pRuntime->NewString(
+ return CJS_Return::Success(pRuntime->NewString(
pFormField->GetControl(i)->GetExportValue().AsStringView()));
}
}
- return CJS_Return(pRuntime->NewString(L"Off"));
+ return CJS_Return::Success(pRuntime->NewString(L"Off"));
}
if (pFormField->GetFieldType() == FormFieldType::kListBox &&
(pFormField->CountSelectedItems() > 1)) {
- return CJS_Return(pRuntime->NewString(L""));
+ return CJS_Return::Success(pRuntime->NewString(L""));
}
- return CJS_Return(pRuntime->NewString(pFormField->GetValue().AsStringView()));
+ return CJS_Return::Success(
+ pRuntime->NewString(pFormField->GetValue().AsStringView()));
}
CJS_Return CJS_Field::set_value_as_string(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::browseForFileToSubmit(
@@ -2208,7 +2211,7 @@ CJS_Return CJS_Field::browseForFileToSubmit(
const std::vector<v8::Local<v8::Value>>& params) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) &&
(pFormField->GetFieldType() == FormFieldType::kTextField)) {
@@ -2217,9 +2220,9 @@ CJS_Return CJS_Field::browseForFileToSubmit(
pFormField->SetValue(wsFileName, NotificationOption::kDoNotNotify);
UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, true, true);
}
- return CJS_Return();
+ return CJS_Return::Success();
}
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
}
CJS_Return CJS_Field::buttonGetCaption(
@@ -2232,28 +2235,28 @@ CJS_Return CJS_Field::buttonGetCaption(
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kPushButton)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (nface == 0) {
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewString(pFormControl->GetNormalCaption().AsStringView()));
}
if (nface == 1) {
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewString(pFormControl->GetDownCaption().AsStringView()));
}
if (nface == 2) {
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewString(pFormControl->GetRolloverCaption().AsStringView()));
}
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
}
CJS_Return CJS_Field::buttonGetIcon(
@@ -2262,46 +2265,46 @@ CJS_Return CJS_Field::buttonGetIcon(
if (params.size() >= 1) {
int nFace = pRuntime->ToInt32(params[0]);
if (nFace < 0 || nFace > 2)
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
}
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pFormField->GetFieldType() != FormFieldType::kPushButton)
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(
CJS_Icon::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pObj.IsEmpty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
auto* pJS_Icon = static_cast<CJS_Icon*>(CFXJS_Engine::GetObjectPrivate(pObj));
- return pJS_Icon ? CJS_Return(pJS_Icon->ToV8Object())
- : CJS_Return(JSMessage::kBadObjectError);
+ return pJS_Icon ? CJS_Return::Success(pJS_Icon->ToV8Object())
+ : CJS_Return::Failure(JSMessage::kBadObjectError);
}
CJS_Return CJS_Field::buttonImportIcon(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::buttonSetCaption(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::buttonSetIcon(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::checkThisBox(
@@ -2309,10 +2312,10 @@ CJS_Return CJS_Field::checkThisBox(
const std::vector<v8::Local<v8::Value>>& params) {
int iSize = params.size();
if (iSize < 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
int nWidget = pRuntime->ToInt32(params[0]);
bool bCheckit = true;
@@ -2321,52 +2324,53 @@ CJS_Return CJS_Field::checkThisBox(
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!IsCheckBoxOrRadioButton(pFormField))
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
if (nWidget < 0 || nWidget >= pFormField->CountControls())
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
// TODO(weili): Check whether anything special needed for radio button.
// (When pFormField->GetFieldType() == FormFieldType::kRadioButton.)
pFormField->CheckControl(nWidget, bCheckit, NotificationOption::kNotify);
UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, true, true);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::clearItems(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::defaultIsChecked(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_bCanSet)
- return CJS_Return(JSMessage::kReadOnlyError);
+ return CJS_Return::Failure(JSMessage::kReadOnlyError);
int iSize = params.size();
if (iSize < 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
int nWidget = pRuntime->ToInt32(params[0]);
if (nWidget < 0 || nWidget >= pFormField->CountControls())
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
- return CJS_Return(pRuntime->NewBoolean(IsCheckBoxOrRadioButton(pFormField)));
+ return CJS_Return::Success(
+ pRuntime->NewBoolean(IsCheckBoxOrRadioButton(pFormField)));
}
CJS_Return CJS_Field::deleteItemAt(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::getArray(
@@ -2374,7 +2378,7 @@ CJS_Return CJS_Field::getArray(
const std::vector<v8::Local<v8::Value>>& params) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields();
if (FieldArray.empty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
std::vector<std::unique_ptr<WideString>> swSort;
for (CPDF_FormField* pFormField : FieldArray) {
@@ -2391,7 +2395,7 @@ CJS_Return CJS_Field::getArray(
v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(
CJS_Field::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC);
if (pObj.IsEmpty())
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
auto* pJSField =
static_cast<CJS_Field*>(CFXJS_Engine::GetObjectPrivate(pObj));
@@ -2401,7 +2405,7 @@ CJS_Return CJS_Field::getArray(
? v8::Local<v8::Value>(pJSField->ToV8Object())
: v8::Local<v8::Value>());
}
- return CJS_Return(FormFieldArray);
+ return CJS_Return::Success(FormFieldArray);
}
CJS_Return CJS_Field::getItemAt(
@@ -2418,35 +2422,35 @@ CJS_Return CJS_Field::getItemAt(
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (!IsComboBoxOrListBox(pFormField))
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
if (nIdx == -1 || nIdx > pFormField->CountOptions())
nIdx = pFormField->CountOptions() - 1;
if (!bExport) {
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewString(pFormField->GetOptionLabel(nIdx).AsStringView()));
}
WideString strval = pFormField->GetOptionValue(nIdx);
if (strval.IsEmpty()) {
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewString(pFormField->GetOptionLabel(nIdx).AsStringView()));
}
- return CJS_Return(pRuntime->NewString(strval.AsStringView()));
+ return CJS_Return::Success(pRuntime->NewString(strval.AsStringView()));
}
CJS_Return CJS_Field::getLock(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::insertItemAt(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::isBoxChecked(
@@ -2458,12 +2462,12 @@ CJS_Return CJS_Field::isBoxChecked(
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (nIndex < 0 || nIndex >= pFormField->CountControls())
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewBoolean((IsCheckBoxOrRadioButton(pFormField) &&
pFormField->GetControl(nIndex)->IsChecked() != 0)));
}
@@ -2477,12 +2481,12 @@ CJS_Return CJS_Field::isDefaultChecked(
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (nIndex < 0 || nIndex >= pFormField->CountControls())
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
- return CJS_Return(pRuntime->NewBoolean(
+ return CJS_Return::Success(pRuntime->NewBoolean(
(IsCheckBoxOrRadioButton(pFormField) &&
pFormField->GetControl(nIndex)->IsDefaultChecked() != 0)));
}
@@ -2490,7 +2494,7 @@ CJS_Return CJS_Field::isDefaultChecked(
CJS_Return CJS_Field::setAction(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::setFocus(
@@ -2498,11 +2502,11 @@ CJS_Return CJS_Field::setFocus(
const std::vector<v8::Local<v8::Value>>& params) {
CPDF_FormField* pFormField = GetFirstFormField();
if (!pFormField)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
int32_t nCount = pFormField->CountControls();
if (nCount < 1)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget = nullptr;
@@ -2511,7 +2515,7 @@ CJS_Return CJS_Field::setFocus(
} else {
IPDF_Page* pPage = IPDFPageFromFPDFPage(m_pFormFillEnv->GetCurrentPage());
if (!pPage)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (CPDFSDK_PageView* pCurPageView =
m_pFormFillEnv->GetPageView(pPage, true)) {
for (int32_t i = 0; i < nCount; i++) {
@@ -2531,63 +2535,63 @@ CJS_Return CJS_Field::setFocus(
m_pFormFillEnv->SetFocusAnnot(&pObserved);
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::setItems(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::setLock(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::signatureGetModifications(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::signatureGetSeedValue(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::signatureInfo(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::signatureSetSeedValue(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::signatureSign(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::signatureValidate(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Field::get_source(CJS_Runtime* pRuntime) {
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Field::set_source(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return();
+ return CJS_Return::Success();
}
void CJS_Field::AddDelay_Int(FIELD_PROP prop, int32_t n) {
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index 1865f57ddb..e747d6205c 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -226,47 +226,47 @@ void CJS_Global::Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
CJS_Return CJS_Global::QueryProperty(const wchar_t* propname) {
if (WideString(propname) != L"setPersistent")
- return CJS_Return(JSMessage::kUnknownProperty);
- return CJS_Return();
+ return CJS_Return::Failure(JSMessage::kUnknownProperty);
+ return CJS_Return::Success();
}
CJS_Return CJS_Global::DelProperty(CJS_Runtime* pRuntime,
const wchar_t* propname) {
auto it = m_MapGlobal.find(WideString(propname).ToDefANSI());
if (it == m_MapGlobal.end())
- return CJS_Return(JSMessage::kUnknownProperty);
+ return CJS_Return::Failure(JSMessage::kUnknownProperty);
it->second->bDeleted = true;
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_Global::GetProperty(CJS_Runtime* pRuntime,
const wchar_t* propname) {
auto it = m_MapGlobal.find(WideString(propname).ToDefANSI());
if (it == m_MapGlobal.end())
- return CJS_Return();
+ return CJS_Return::Success();
JSGlobalData* pData = it->second.get();
if (pData->bDeleted)
- return CJS_Return();
+ return CJS_Return::Success();
switch (pData->nType) {
case JS_GlobalDataType::NUMBER:
- return CJS_Return(pRuntime->NewNumber(pData->dData));
+ return CJS_Return::Success(pRuntime->NewNumber(pData->dData));
case JS_GlobalDataType::BOOLEAN:
- return CJS_Return(pRuntime->NewBoolean(pData->bData));
+ return CJS_Return::Success(pRuntime->NewBoolean(pData->bData));
case JS_GlobalDataType::STRING:
- return CJS_Return(pRuntime->NewString(
+ return CJS_Return::Success(pRuntime->NewString(
WideString::FromLocal(pData->sData.AsStringView()).AsStringView()));
case JS_GlobalDataType::OBJECT:
- return CJS_Return(
+ return CJS_Return::Success(
v8::Local<v8::Object>::New(pRuntime->GetIsolate(), pData->pData));
case JS_GlobalDataType::NULLOBJ:
- return CJS_Return(pRuntime->NewNull());
+ return CJS_Return::Success(pRuntime->NewNull());
default:
break;
}
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
}
CJS_Return CJS_Global::SetProperty(CJS_Runtime* pRuntime,
@@ -298,23 +298,23 @@ CJS_Return CJS_Global::SetProperty(CJS_Runtime* pRuntime,
}
if (vp->IsUndefined()) {
DelProperty(pRuntime, propname);
- return CJS_Return();
+ return CJS_Return::Success();
}
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
}
CJS_Return CJS_Global::setPersistent(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
auto it = m_MapGlobal.find(pRuntime->ToWideString(params[0]).ToDefANSI());
if (it == m_MapGlobal.end() || it->second->bDeleted)
- return CJS_Return(JSMessage::kGlobalNotFoundError);
+ return CJS_Return::Failure(JSMessage::kGlobalNotFoundError);
it->second->bPersistent = pRuntime->ToBoolean(params[1]);
- return CJS_Return();
+ return CJS_Return::Success();
}
void CJS_Global::UpdateGlobalPersistentVariables() {
@@ -505,7 +505,7 @@ CJS_Return CJS_Global::SetGlobalVariables(const ByteString& propname,
v8::Local<v8::Object> pData,
bool bDefaultPersistent) {
if (propname.IsEmpty())
- return CJS_Return(JSMessage::kUnknownProperty);
+ return CJS_Return::Failure(JSMessage::kUnknownProperty);
auto it = m_MapGlobal.find(propname);
if (it != m_MapGlobal.end()) {
@@ -533,9 +533,9 @@ CJS_Return CJS_Global::SetGlobalVariables(const ByteString& propname,
case JS_GlobalDataType::NULLOBJ:
break;
default:
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
}
- return CJS_Return();
+ return CJS_Return::Success();
}
auto pNewData = pdfium::MakeUnique<JSGlobalData>();
@@ -565,8 +565,8 @@ CJS_Return CJS_Global::SetGlobalVariables(const ByteString& propname,
pNewData->bPersistent = bDefaultPersistent;
break;
default:
- return CJS_Return(JSMessage::kObjectTypeError);
+ return CJS_Return::Failure(JSMessage::kObjectTypeError);
}
m_MapGlobal[propname] = std::move(pNewData);
- return CJS_Return();
+ return CJS_Return::Success();
}
diff --git a/fxjs/cjs_icon.cpp b/fxjs/cjs_icon.cpp
index 3c293ea969..dca9eaf768 100644
--- a/fxjs/cjs_icon.cpp
+++ b/fxjs/cjs_icon.cpp
@@ -30,9 +30,9 @@ CJS_Icon::CJS_Icon(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime)
CJS_Icon::~CJS_Icon() = default;
CJS_Return CJS_Icon::get_name(CJS_Runtime* pRuntime) {
- return CJS_Return(pRuntime->NewString(m_swIconName.AsStringView()));
+ return CJS_Return::Success(pRuntime->NewString(m_swIconName.AsStringView()));
}
CJS_Return CJS_Icon::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSMessage::kNotSupportedError);
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
}
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index f2cd3ff7c1..86a2a777b9 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -874,17 +874,17 @@ CJS_Return CJS_PublicMethods::AFNumber_Format(
const std::vector<v8::Local<v8::Value>>& params) {
#if _FX_OS_ != _FX_OS_ANDROID_
if (params.size() != 6)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (!pEvent->m_pValue)
- return CJS_Return(L"No event handler");
+ return CJS_Return::Failure(L"No event handler");
WideString& Value = pEvent->Value();
ByteString strValue = StrTrim(Value.ToDefANSI());
if (strValue.IsEmpty())
- return CJS_Return();
+ return CJS_Return::Success();
int iDec = abs(pRuntime->ToInt32(params[0]));
int iSepStyle = ValidStyleOrZero(pRuntime->ToInt32(params[1]));
@@ -972,7 +972,7 @@ CJS_Return CJS_PublicMethods::AFNumber_Format(
}
}
#endif
- return CJS_Return();
+ return CJS_Return::Success();
}
// function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency,
@@ -981,12 +981,12 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
CJS_EventHandler* pEvent = pContext->GetEventHandler();
if (!pEvent->m_pValue)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
WideString& val = pEvent->Value();
WideString& wstrChange = pEvent->Change();
@@ -995,17 +995,17 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke(
if (pEvent->WillCommit()) {
WideString swTemp = StrTrim(wstrValue);
if (swTemp.IsEmpty())
- return CJS_Return();
+ return CJS_Return::Success();
NormalizeDecimalMarkW(&swTemp);
if (!IsNumber(swTemp)) {
pEvent->Rc() = false;
WideString sError = JSGetStringFromID(JSMessage::kInvalidInputError);
AlertIfPossible(pContext, sError);
- return CJS_Return(sError);
+ return CJS_Return::Failure(sError);
}
// It happens after the last keystroke and before validating,
- return CJS_Return();
+ return CJS_Return::Success();
}
WideString wstrSelected;
@@ -1019,7 +1019,7 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke(
// can't insert "change" in front of sign position.
if (!wstrSelected.IsEmpty() && pEvent->SelStart() == 0) {
pEvent->Rc() = false;
- return CJS_Return();
+ return CJS_Return::Success();
}
}
@@ -1031,7 +1031,7 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke(
if (wstrChange[i] == cSep) {
if (bHasSep) {
pEvent->Rc() = false;
- return CJS_Return();
+ return CJS_Return::Success();
}
bHasSep = true;
continue;
@@ -1039,16 +1039,16 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke(
if (wstrChange[i] == L'-') {
if (bHasSign) {
pEvent->Rc() = false;
- return CJS_Return();
+ return CJS_Return::Success();
}
// sign's position is not correct
if (i != 0) {
pEvent->Rc() = false;
- return CJS_Return();
+ return CJS_Return::Success();
}
if (pEvent->SelStart() != 0) {
pEvent->Rc() = false;
- return CJS_Return();
+ return CJS_Return::Success();
}
bHasSign = true;
continue;
@@ -1056,12 +1056,12 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke(
if (!std::iswdigit(wstrChange[i])) {
pEvent->Rc() = false;
- return CJS_Return();
+ return CJS_Return::Success();
}
}
val = CalcMergedString(pEvent, wstrValue, wstrChange);
- return CJS_Return();
+ return CJS_Return::Success();
}
// function AFPercent_Format(nDec, sepStyle)
@@ -1070,17 +1070,17 @@ CJS_Return CJS_PublicMethods::AFPercent_Format(
const std::vector<v8::Local<v8::Value>>& params) {
#if _FX_OS_ != _FX_OS_ANDROID_
if (params.size() != 2)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (!pEvent->m_pValue)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
WideString& Value = pEvent->Value();
ByteString strValue = StrTrim(Value.ToDefANSI());
if (strValue.IsEmpty())
- return CJS_Return();
+ return CJS_Return::Success();
int iDec = abs(pRuntime->ToInt32(params[0]));
int iSepStyle = ValidStyleOrZero(pRuntime->ToInt32(params[1]));
@@ -1141,7 +1141,7 @@ CJS_Return CJS_PublicMethods::AFPercent_Format(
strValue += '%';
Value = WideString::FromLocal(strValue.AsStringView());
#endif
- return CJS_Return();
+ return CJS_Return::Success();
}
// AFPercent_Keystroke(nDec, sepStyle)
@@ -1156,17 +1156,17 @@ CJS_Return CJS_PublicMethods::AFDate_FormatEx(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
CJS_EventHandler* pEvent = pContext->GetEventHandler();
if (!pEvent->m_pValue)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
WideString& val = pEvent->Value();
WideString strValue = val;
if (strValue.IsEmpty())
- return CJS_Return();
+ return CJS_Return::Success();
WideString sFormat = pRuntime->ToWideString(params[0]);
double dDate;
@@ -1182,11 +1182,11 @@ CJS_Return CJS_PublicMethods::AFDate_FormatEx(
WideString swMsg = WideString::Format(
JSGetStringFromID(JSMessage::kParseDateError).c_str(), sFormat.c_str());
AlertIfPossible(pContext, swMsg);
- return CJS_Return(JSMessage::kParseDateError);
+ return CJS_Return::Failure(JSMessage::kParseDateError);
}
val = MakeFormatDate(dDate, sFormat);
- return CJS_Return();
+ return CJS_Return::Success();
}
double CJS_PublicMethods::MakeInterDate(const WideString& strValue) {
@@ -1230,40 +1230,39 @@ CJS_Return CJS_PublicMethods::AFDate_KeystrokeEx(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1) {
- return CJS_Return(
- WideString(L"AFDate_KeystrokeEx's parameters' size r not correct"));
+ return CJS_Return::Failure(
+ WideString(L"AFDate_KeystrokeEx's parameter size not correct"));
}
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
CJS_EventHandler* pEvent = pContext->GetEventHandler();
- if (pEvent->WillCommit()) {
- if (!pEvent->m_pValue)
- return CJS_Return(JSMessage::kBadObjectError);
-
- const WideString& strValue = pEvent->Value();
- if (strValue.IsEmpty())
- return CJS_Return();
-
- WideString sFormat = pRuntime->ToWideString(params[0]);
- bool bWrongFormat = false;
- double dRet = MakeRegularDate(strValue, sFormat, &bWrongFormat);
- if (bWrongFormat || std::isnan(dRet)) {
- WideString swMsg = WideString::Format(
- JSGetStringFromID(JSMessage::kParseDateError).c_str(),
- sFormat.c_str());
- AlertIfPossible(pContext, swMsg);
- pEvent->Rc() = false;
- return CJS_Return();
- }
+ if (!pEvent->WillCommit())
+ return CJS_Return::Success();
+
+ if (!pEvent->m_pValue)
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
+
+ const WideString& strValue = pEvent->Value();
+ if (strValue.IsEmpty())
+ return CJS_Return::Success();
+
+ WideString sFormat = pRuntime->ToWideString(params[0]);
+ bool bWrongFormat = false;
+ double dRet = MakeRegularDate(strValue, sFormat, &bWrongFormat);
+ if (bWrongFormat || std::isnan(dRet)) {
+ WideString swMsg = WideString::Format(
+ JSGetStringFromID(JSMessage::kParseDateError).c_str(), sFormat.c_str());
+ AlertIfPossible(pContext, swMsg);
+ pEvent->Rc() = false;
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_PublicMethods::AFDate_Format(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
static constexpr const wchar_t* cFormats[] = {L"m/d",
L"m/d/yy",
@@ -1292,7 +1291,7 @@ CJS_Return CJS_PublicMethods::AFDate_Keystroke(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
static constexpr const wchar_t* cFormats[] = {L"m/d",
L"m/d/yy",
@@ -1321,7 +1320,7 @@ CJS_Return CJS_PublicMethods::AFTime_Format(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
static constexpr const wchar_t* cFormats[] = {L"HH:MM", L"h:MM tt",
L"HH:MM:ss", L"h:MM:ss tt"};
@@ -1337,7 +1336,7 @@ CJS_Return CJS_PublicMethods::AFTime_Keystroke(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
static constexpr const wchar_t* cFormats[] = {L"HH:MM", L"h:MM tt",
L"HH:MM:ss", L"h:MM:ss tt"};
@@ -1366,12 +1365,12 @@ CJS_Return CJS_PublicMethods::AFSpecial_Format(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (!pEvent->m_pValue)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
const WideString& wsSource = pEvent->Value();
WideString wsFormat;
@@ -1394,7 +1393,7 @@ CJS_Return CJS_PublicMethods::AFSpecial_Format(
}
pEvent->Value() = CJS_Util::printx(wsFormat, wsSource);
- return CJS_Return();
+ return CJS_Return::Success();
}
// function AFSpecial_KeystrokeEx(mask)
@@ -1402,40 +1401,39 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
CJS_EventHandler* pEvent = pContext->GetEventHandler();
if (!pEvent->m_pValue)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
const WideString& valEvent = pEvent->Value();
WideString wstrMask = pRuntime->ToWideString(params[0]);
if (wstrMask.IsEmpty())
- return CJS_Return();
+ return CJS_Return::Success();
if (pEvent->WillCommit()) {
if (valEvent.IsEmpty())
- return CJS_Return();
+ return CJS_Return::Success();
size_t iIndexMask = 0;
for (; iIndexMask < valEvent.GetLength(); ++iIndexMask) {
if (!MaskSatisfied(valEvent[iIndexMask], wstrMask[iIndexMask]))
break;
}
-
if (iIndexMask != wstrMask.GetLength() ||
(iIndexMask != valEvent.GetLength() && wstrMask.GetLength() != 0)) {
AlertIfPossible(pContext,
JSGetStringFromID(JSMessage::kInvalidInputError));
pEvent->Rc() = false;
}
- return CJS_Return();
+ return CJS_Return::Success();
}
WideString& wideChange = pEvent->Change();
if (wideChange.IsEmpty())
- return CJS_Return();
+ return CJS_Return::Success();
WideString wChange = wideChange;
size_t iIndexMask = pEvent->SelStart();
@@ -1444,13 +1442,13 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx(
if (combined_len > wstrMask.GetLength()) {
AlertIfPossible(pContext, JSGetStringFromID(JSMessage::kParamTooLongError));
pEvent->Rc() = false;
- return CJS_Return();
+ return CJS_Return::Success();
}
if (iIndexMask >= wstrMask.GetLength() && !wChange.IsEmpty()) {
AlertIfPossible(pContext, JSGetStringFromID(JSMessage::kParamTooLongError));
pEvent->Rc() = false;
- return CJS_Return();
+ return CJS_Return::Success();
}
for (size_t i = 0; i < wChange.GetLength(); ++i) {
@@ -1458,7 +1456,7 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx(
AlertIfPossible(pContext,
JSGetStringFromID(JSMessage::kParamTooLongError));
pEvent->Rc() = false;
- return CJS_Return();
+ return CJS_Return::Success();
}
wchar_t wMask = wstrMask[iIndexMask];
if (!IsReservedMaskChar(wMask))
@@ -1466,12 +1464,12 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx(
if (!MaskSatisfied(wChange[i], wMask)) {
pEvent->Rc() = false;
- return CJS_Return();
+ return CJS_Return::Success();
}
iIndexMask++;
}
wideChange = std::move(wChange);
- return CJS_Return();
+ return CJS_Return::Success();
}
// function AFSpecial_Keystroke(psf)
@@ -1479,12 +1477,12 @@ CJS_Return CJS_PublicMethods::AFSpecial_Keystroke(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (!pEvent->m_pValue)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
const char* cFormat = "";
switch (pRuntime->ToInt32(params[0])) {
@@ -1514,7 +1512,7 @@ CJS_Return CJS_PublicMethods::AFMergeChange(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
CJS_EventHandler* pEventHandler =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -1524,18 +1522,18 @@ CJS_Return CJS_PublicMethods::AFMergeChange(
swValue = pEventHandler->Value();
if (pEventHandler->WillCommit())
- return CJS_Return(pRuntime->NewString(swValue.AsStringView()));
+ return CJS_Return::Success(pRuntime->NewString(swValue.AsStringView()));
- WideString merged =
- CalcMergedString(pEventHandler, swValue, pEventHandler->Change());
- return CJS_Return(pRuntime->NewString(merged.AsStringView()));
+ return CJS_Return::Success(pRuntime->NewString(
+ CalcMergedString(pEventHandler, swValue, pEventHandler->Change())
+ .AsStringView()));
}
CJS_Return CJS_PublicMethods::AFParseDateEx(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString sValue = pRuntime->ToWideString(params[0]);
WideString sFormat = pRuntime->ToWideString(params[1]);
@@ -1544,18 +1542,18 @@ CJS_Return CJS_PublicMethods::AFParseDateEx(
WideString swMsg = WideString::Format(
JSGetStringFromID(JSMessage::kParseDateError).c_str(), sFormat.c_str());
AlertIfPossible(pRuntime->GetCurrentEventContext(), swMsg);
- return CJS_Return(JSMessage::kParseDateError);
+ return CJS_Return::Failure(JSMessage::kParseDateError);
}
- return CJS_Return(pRuntime->NewNumber(dDate));
+ return CJS_Return::Success(pRuntime->NewNumber(dDate));
}
CJS_Return CJS_PublicMethods::AFSimple(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 3)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
- return CJS_Return(pRuntime->NewNumber(static_cast<double>(AF_Simple(
+ return CJS_Return::Success(pRuntime->NewNumber(static_cast<double>(AF_Simple(
pRuntime->ToWideString(params[0]).c_str(), pRuntime->ToDouble(params[1]),
pRuntime->ToDouble(params[2])))));
}
@@ -1564,7 +1562,7 @@ CJS_Return CJS_PublicMethods::AFMakeNumber(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString ws = pRuntime->ToWideString(params[0]);
NormalizeDecimalMarkW(&ws);
@@ -1572,18 +1570,19 @@ CJS_Return CJS_PublicMethods::AFMakeNumber(
v8::Local<v8::Value> val =
pRuntime->MaybeCoerceToNumber(pRuntime->NewString(ws.AsStringView()));
if (!val->IsNumber())
- return CJS_Return(pRuntime->NewNumber(0));
- return CJS_Return(val);
+ return CJS_Return::Success(pRuntime->NewNumber(0));
+
+ return CJS_Return::Success(val);
}
CJS_Return CJS_PublicMethods::AFSimple_Calculate(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
if ((params[1].IsEmpty() || !params[1]->IsArray()) && !params[1]->IsString())
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
CPDFSDK_InterForm* pReaderInterForm =
pRuntime->GetFormFillEnv()->GetInterForm();
@@ -1664,24 +1663,24 @@ CJS_Return CJS_PublicMethods::AFSimple_Calculate(
pRuntime->ToWideString(pRuntime->NewNumber(dValue));
}
- return CJS_Return();
+ return CJS_Return::Success();
}
-/* This function validates the current event to ensure that its value is
-** within the specified range. */
+// This function validates the current event to ensure that its value is
+// within the specified range.
CJS_Return CJS_PublicMethods::AFRange_Validate(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 4)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
CJS_EventHandler* pEvent = pContext->GetEventHandler();
if (!pEvent->m_pValue)
- return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return::Failure(JSMessage::kBadObjectError);
if (pEvent->Value().IsEmpty())
- return CJS_Return();
+ return CJS_Return::Success();
double dEentValue = atof(pEvent->Value().ToDefANSI().c_str());
bool bGreaterThan = pRuntime->ToBoolean(params[0]);
@@ -1712,14 +1711,14 @@ CJS_Return CJS_PublicMethods::AFRange_Validate(
AlertIfPossible(pContext, swMsg);
pEvent->Rc() = false;
}
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJS_PublicMethods::AFExtractNums(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString str = pRuntime->ToWideString(params[0]);
if (str.GetLength() > 0 && IsDigitSeparatorOrDecimalMark(str[0]))
@@ -1743,6 +1742,7 @@ CJS_Return CJS_PublicMethods::AFExtractNums(
pRuntime->NewString(sPart.AsStringView()));
}
if (pRuntime->GetArrayLength(nums) > 0)
- return CJS_Return(nums);
- return CJS_Return(pRuntime->NewUndefined());
+ return CJS_Return::Success(nums);
+
+ return CJS_Return::Success(pRuntime->NewUndefined());
}
diff --git a/fxjs/cjs_report.cpp b/fxjs/cjs_report.cpp
index 6e205ef7e7..aa4ef0224b 100644
--- a/fxjs/cjs_report.cpp
+++ b/fxjs/cjs_report.cpp
@@ -38,12 +38,12 @@ CJS_Report::~CJS_Report() = default;
CJS_Return CJS_Report::writeText(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- // Unsafe, not supported.
- return CJS_Return();
+ // Unsafe, not supported, but do not return error.
+ return CJS_Return::Success();
}
CJS_Return CJS_Report::save(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- // Unsafe, not supported.
- return CJS_Return();
+ // Unsafe, not supported, but do not return error.
+ return CJS_Return::Success();
}
diff --git a/fxjs/cjs_return.h b/fxjs/cjs_return.h
index b165f3f11c..99a2af60a6 100644
--- a/fxjs/cjs_return.h
+++ b/fxjs/cjs_return.h
@@ -13,10 +13,28 @@
class CJS_Return {
public:
- CJS_Return(); // Successful but empty return.
- explicit CJS_Return(v8::Local<v8::Value>); // Successful return with value.
- explicit CJS_Return(const WideString&); // Error with custom message.
- explicit CJS_Return(JSMessage id); // Error with stock message.
+ // Wrap constructors with static methods so we can apply WARN_UNUSED_RESULT,
+ // otherwise we can't catch places where someone mistakenly writes:
+ //
+ // if (error)
+ // CJS_Return(JS_ERROR_CODE);
+ //
+ // instead of
+ //
+ // if (error)
+ // return CJS_Return(JS_ERROR_CODE);
+ //
+ static CJS_Return Success() WARN_UNUSED_RESULT { return CJS_Return(); }
+ static CJS_Return Success(v8::Local<v8::Value> value) WARN_UNUSED_RESULT {
+ return CJS_Return(value);
+ }
+ static CJS_Return Failure(const WideString& str) WARN_UNUSED_RESULT {
+ return CJS_Return(str);
+ }
+ static CJS_Return Failure(JSMessage id) WARN_UNUSED_RESULT {
+ return CJS_Return(id);
+ }
+
CJS_Return(const CJS_Return&);
~CJS_Return();
@@ -27,6 +45,11 @@ class CJS_Return {
v8::Local<v8::Value> Return() const { return return_; }
private:
+ CJS_Return(); // Successful but empty return.
+ explicit CJS_Return(v8::Local<v8::Value>); // Successful return with value.
+ explicit CJS_Return(const WideString&); // Error with custom message.
+ explicit CJS_Return(JSMessage id); // Error with stock message.
+
Optional<WideString> error_;
v8::Local<v8::Value> return_;
};
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index eee9db3fb9..54a74f2952 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -88,7 +88,7 @@ CJS_Return CJS_Util::printf(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
const size_t iSize = params.size();
if (iSize < 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
std::wstring unsafe_fmt_string(pRuntime->ToWideString(params[0]).c_str());
std::vector<std::wstring> unsafe_conversion_specifiers;
@@ -143,23 +143,21 @@ CJS_Return CJS_Util::printf(CJS_Runtime* pRuntime,
}
c_strResult.erase(c_strResult.begin());
- return CJS_Return(pRuntime->NewString(c_strResult.c_str()));
+ return CJS_Return::Success(pRuntime->NewString(c_strResult.c_str()));
}
CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
const size_t iSize = params.size();
if (iSize < 2)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
if (params[1].IsEmpty() || !params[1]->IsDate())
- return CJS_Return(JSMessage::kSecondParamNotDateError);
+ return CJS_Return::Failure(JSMessage::kSecondParamNotDateError);
v8::Local<v8::Date> v8_date = params[1].As<v8::Date>();
- if (v8_date.IsEmpty() || std::isnan(pRuntime->ToDouble(v8_date))) {
- return CJS_Return(
- JSGetStringFromID(JSMessage::kSecondParamInvalidDateError));
- }
+ if (v8_date.IsEmpty() || std::isnan(pRuntime->ToDouble(v8_date)))
+ return CJS_Return::Failure(JSMessage::kSecondParamInvalidDateError);
double date = JS_LocalTime(pRuntime->ToDouble(v8_date));
int year = JS_GetYearFromTime(date);
@@ -185,37 +183,38 @@ CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime,
month, day, hour, min, sec);
break;
default:
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
}
- return CJS_Return(pRuntime->NewString(swResult.AsStringView()));
+ return CJS_Return::Success(pRuntime->NewString(swResult.AsStringView()));
}
- if (params[0]->IsString()) {
- // We don't support XFAPicture at the moment.
- if (iSize > 2 && pRuntime->ToBoolean(params[2]))
- return CJS_Return(JSMessage::kNotSupportedError);
-
- // Convert PDF-style format specifiers to wcsftime specifiers. Remove any
- // pre-existing %-directives before inserting our own.
- std::basic_string<wchar_t> cFormat =
- pRuntime->ToWideString(params[0]).c_str();
- cFormat.erase(std::remove(cFormat.begin(), cFormat.end(), '%'),
- cFormat.end());
-
- for (size_t i = 0; i < FX_ArraySize(TbConvertTable); ++i) {
- int iStart = 0;
- int iEnd;
- while ((iEnd = cFormat.find(TbConvertTable[i].lpszJSMark, iStart)) !=
- -1) {
- cFormat.replace(iEnd, wcslen(TbConvertTable[i].lpszJSMark),
- TbConvertTable[i].lpszCppMark);
- iStart = iEnd;
- }
+ if (!params[0]->IsString())
+ return CJS_Return::Failure(JSMessage::kTypeError);
+
+ // We don't support XFAPicture at the moment.
+ if (iSize > 2 && pRuntime->ToBoolean(params[2]))
+ return CJS_Return::Failure(JSMessage::kNotSupportedError);
+
+ // Convert PDF-style format specifiers to wcsftime specifiers. Remove any
+ // pre-existing %-directives before inserting our own.
+ std::basic_string<wchar_t> cFormat =
+ pRuntime->ToWideString(params[0]).c_str();
+ cFormat.erase(std::remove(cFormat.begin(), cFormat.end(), '%'),
+ cFormat.end());
+
+ for (size_t i = 0; i < FX_ArraySize(TbConvertTable); ++i) {
+ int iStart = 0;
+ int iEnd;
+ while ((iEnd = cFormat.find(TbConvertTable[i].lpszJSMark, iStart)) != -1) {
+ cFormat.replace(iEnd, wcslen(TbConvertTable[i].lpszJSMark),
+ TbConvertTable[i].lpszCppMark);
+ iStart = iEnd;
+ }
}
if (year < 0)
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
const TbConvertAdditional cTableAd[] = {
{L"m", month}, {L"d", day},
@@ -250,18 +249,15 @@ CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime,
wchar_t buf[64] = {};
FXSYS_wcsftime(buf, 64, cFormat.c_str(), &time);
cFormat = buf;
- return CJS_Return(pRuntime->NewString(cFormat.c_str()));
- }
-
- return CJS_Return(JSMessage::kTypeError);
+ return CJS_Return::Success(pRuntime->NewString(cFormat.c_str()));
}
CJS_Return CJS_Util::printx(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
- return CJS_Return(
+ return CJS_Return::Success(
pRuntime->NewString(printx(pRuntime->ToWideString(params[0]),
pRuntime->ToWideString(params[1]))
.AsStringView()));
@@ -368,31 +364,31 @@ WideString CJS_Util::printx(const WideString& wsFormat,
CJS_Return CJS_Util::scand(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
WideString sFormat = pRuntime->ToWideString(params[0]);
WideString sDate = pRuntime->ToWideString(params[1]);
double dDate = JS_GetDateTime();
if (sDate.GetLength() > 0)
dDate = CJS_PublicMethods::MakeRegularDate(sDate, sFormat, nullptr);
-
if (std::isnan(dDate))
- return CJS_Return(pRuntime->NewUndefined());
- return CJS_Return(pRuntime->NewDate(dDate));
+ return CJS_Return::Success(pRuntime->NewUndefined());
+
+ return CJS_Return::Success(pRuntime->NewDate(dDate));
}
CJS_Return CJS_Util::byteToChar(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 1)
- return CJS_Return(JSMessage::kParamError);
+ return CJS_Return::Failure(JSMessage::kParamError);
int arg = pRuntime->ToInt32(params[0]);
if (arg < 0 || arg > 255)
- return CJS_Return(JSMessage::kValueError);
+ return CJS_Return::Failure(JSMessage::kValueError);
WideString wStr(static_cast<wchar_t>(arg));
- return CJS_Return(pRuntime->NewString(wStr.AsStringView()));
+ return CJS_Return::Success(pRuntime->NewString(wStr.AsStringView()));
}
// Ensure that sFormat contains at most one well-understood printf formatting
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,