diff options
62 files changed, 2154 insertions, 2154 deletions
@@ -1279,8 +1279,8 @@ jumbo_static_library("fxjs") { "fxjs/cjs_publicmethods.h", "fxjs/cjs_report.cpp", "fxjs/cjs_report.h", - "fxjs/cjs_return.cpp", - "fxjs/cjs_return.h", + "fxjs/cjs_result.cpp", + "fxjs/cjs_result.h", "fxjs/cjs_runtime.cpp", "fxjs/cjs_runtime.h", "fxjs/cjs_scalehow.cpp", diff --git a/fxjs/cfxjse_class.cpp b/fxjs/cfxjse_class.cpp index 9207fd5094..0d68147326 100644 --- a/fxjs/cfxjse_class.cpp +++ b/fxjs/cfxjse_class.cpp @@ -12,7 +12,7 @@ #include "fxjs/cfxjse_arguments.h" #include "fxjs/cfxjse_context.h" #include "fxjs/cfxjse_value.h" -#include "fxjs/cjs_return.h" +#include "fxjs/cjs_result.h" #include "fxjs/js_resources.h" #include "third_party/base/ptr_util.h" @@ -105,7 +105,7 @@ void DynPropGetterAdapter_MethodCallback( return; v8::String::Utf8Value szPropName(info.GetIsolate(), hPropName); - CJS_Return result = + CJS_Result result = pClassDescriptor->dynMethodCall(info, WideString::FromUTF8(*szPropName)); if (result.HasError()) { diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp index 7a4865ba21..5d2ee25d43 100644 --- a/fxjs/cfxjse_engine.cpp +++ b/fxjs/cfxjse_engine.cpp @@ -437,12 +437,12 @@ int32_t CFXJSE_Engine::NormalPropTypeGetter(CFXJSE_Value* pOriginalValue, return FXJSE_ClassPropType_Property; } -CJS_Return CFXJSE_Engine::NormalMethodCall( +CJS_Result CFXJSE_Engine::NormalMethodCall( const v8::FunctionCallbackInfo<v8::Value>& info, const WideString& functionName) { CXFA_Object* pObject = ToObject(info); if (!pObject) - return CJS_Return::Failure(L"no Holder() present."); + return CJS_Result::Failure(L"no Holder() present."); CFXJSE_Engine* lpScriptContext = pObject->GetDocument()->GetScriptContext(); pObject = lpScriptContext->GetVariablesThis(pObject, false); diff --git a/fxjs/cfxjse_engine.h b/fxjs/cfxjse_engine.h index 380965e8d3..01bce537bd 100644 --- a/fxjs/cfxjse_engine.h +++ b/fxjs/cfxjse_engine.h @@ -42,7 +42,7 @@ class CFXJSE_Engine : public CFX_V8 { static void NormalPropertySetter(CFXJSE_Value* pObject, const ByteStringView& szPropName, CFXJSE_Value* pValue); - static CJS_Return NormalMethodCall( + static CJS_Result NormalMethodCall( const v8::FunctionCallbackInfo<v8::Value>& info, const WideString& functionName); static int32_t NormalPropTypeGetter(CFXJSE_Value* pObject, diff --git a/fxjs/cjs_annot.cpp b/fxjs/cjs_annot.cpp index 4e93dc2516..dda52f629c 100644 --- a/fxjs/cjs_annot.cpp +++ b/fxjs/cjs_annot.cpp @@ -37,23 +37,23 @@ CJS_Annot::CJS_Annot(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime) CJS_Annot::~CJS_Annot() = default; -CJS_Return CJS_Annot::get_hidden(CJS_Runtime* pRuntime) { +CJS_Result CJS_Annot::get_hidden(CJS_Runtime* pRuntime) { if (!m_pAnnot) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_Annot* pPDFAnnot = m_pAnnot->AsBAAnnot()->GetPDFAnnot(); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict()))); } -CJS_Return CJS_Annot::set_hidden(CJS_Runtime* pRuntime, +CJS_Result CJS_Annot::set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { // May invalidate m_pAnnot. bool bHidden = pRuntime->ToBoolean(vp); CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get()); if (!pBAAnnot) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); uint32_t flags = pBAAnnot->GetFlags(); if (bHidden) { @@ -68,42 +68,42 @@ CJS_Return CJS_Annot::set_hidden(CJS_Runtime* pRuntime, flags |= ANNOTFLAG_PRINT; } pBAAnnot->SetFlags(flags); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Annot::get_name(CJS_Runtime* pRuntime) { +CJS_Result CJS_Annot::get_name(CJS_Runtime* pRuntime) { CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get()); if (!pBAAnnot) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewString(pBAAnnot->GetAnnotName().AsStringView())); } -CJS_Return CJS_Annot::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { +CJS_Result CJS_Annot::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { // May invalidate m_pAnnot. WideString annotName = pRuntime->ToWideString(vp); CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get()); if (!pBAAnnot) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); pBAAnnot->SetAnnotName(annotName); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Annot::get_type(CJS_Runtime* pRuntime) { +CJS_Result CJS_Annot::get_type(CJS_Runtime* pRuntime) { CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get()); if (!pBAAnnot) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(pRuntime->NewString( + return CJS_Result::Success(pRuntime->NewString( WideString::FromLocal( CPDF_Annot::AnnotSubtypeToString(pBAAnnot->GetAnnotSubtype()) .AsStringView()) .AsStringView())); } -CJS_Return CJS_Annot::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); +CJS_Result CJS_Annot::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { + return CJS_Result::Failure(JSMessage::kReadOnlyError); } diff --git a/fxjs/cjs_annot.h b/fxjs/cjs_annot.h index d313d5656f..79b2663162 100644 --- a/fxjs/cjs_annot.h +++ b/fxjs/cjs_annot.h @@ -29,14 +29,14 @@ class CJS_Annot : public CJS_Object { static const char kName[]; static const JSPropertySpec PropertySpecs[]; - CJS_Return get_hidden(CJS_Runtime* pRuntime); - CJS_Return set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_hidden(CJS_Runtime* pRuntime); + CJS_Result set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_name(CJS_Runtime* pRuntime); - CJS_Return set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_name(CJS_Runtime* pRuntime); + CJS_Result set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_type(CJS_Runtime* pRuntime); - CJS_Return set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_type(CJS_Runtime* pRuntime); + CJS_Result set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); CPDFSDK_Annot::ObservedPtr m_pAnnot; }; diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp index bd57e05b8b..12bb8ddc84 100644 --- a/fxjs/cjs_app.cpp +++ b/fxjs/cjs_app.cpp @@ -101,7 +101,7 @@ CJS_App::CJS_App(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime) CJS_App::~CJS_App() = default; -CJS_Return CJS_App::get_active_docs(CJS_Runtime* pRuntime) { +CJS_Result CJS_App::get_active_docs(CJS_Runtime* pRuntime) { v8::Local<v8::Object> pObj = pRuntime->GetThisObj(); auto pJSDocument = JSGetObject<CJS_Document>(pObj); v8::Local<v8::Array> aDocs = pRuntime->NewArray(); @@ -110,111 +110,111 @@ 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::Success(aDocs); + return CJS_Result::Success(aDocs); - return CJS_Return::Success(pRuntime->NewUndefined()); + return CJS_Result::Success(pRuntime->NewUndefined()); } -CJS_Return CJS_App::set_active_docs(CJS_Runtime* pRuntime, +CJS_Result CJS_App::set_active_docs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::get_calculate(CJS_Runtime* pRuntime) { - return CJS_Return::Success(pRuntime->NewBoolean(m_bCalculate)); +CJS_Result CJS_App::get_calculate(CJS_Runtime* pRuntime) { + return CJS_Result::Success(pRuntime->NewBoolean(m_bCalculate)); } -CJS_Return CJS_App::set_calculate(CJS_Runtime* pRuntime, +CJS_Result 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::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_App::get_forms_version(CJS_Runtime* pRuntime) { - return CJS_Return::Success(pRuntime->NewNumber(JS_NUM_FORMSVERSION)); +CJS_Result CJS_App::get_forms_version(CJS_Runtime* pRuntime) { + return CJS_Result::Success(pRuntime->NewNumber(JS_NUM_FORMSVERSION)); } -CJS_Return CJS_App::set_forms_version(CJS_Runtime* pRuntime, +CJS_Result CJS_App::set_forms_version(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::get_viewer_type(CJS_Runtime* pRuntime) { - return CJS_Return::Success(pRuntime->NewString(JS_STR_VIEWERTYPE)); +CJS_Result CJS_App::get_viewer_type(CJS_Runtime* pRuntime) { + return CJS_Result::Success(pRuntime->NewString(JS_STR_VIEWERTYPE)); } -CJS_Return CJS_App::set_viewer_type(CJS_Runtime* pRuntime, +CJS_Result CJS_App::set_viewer_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::get_viewer_variation(CJS_Runtime* pRuntime) { - return CJS_Return::Success(pRuntime->NewString(JS_STR_VIEWERVARIATION)); +CJS_Result CJS_App::get_viewer_variation(CJS_Runtime* pRuntime) { + return CJS_Result::Success(pRuntime->NewString(JS_STR_VIEWERVARIATION)); } -CJS_Return CJS_App::set_viewer_variation(CJS_Runtime* pRuntime, +CJS_Result CJS_App::set_viewer_variation(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::get_viewer_version(CJS_Runtime* pRuntime) { +CJS_Result CJS_App::get_viewer_version(CJS_Runtime* pRuntime) { #ifdef PDF_ENABLE_XFA CPDFXFA_Context* pXFAContext = pRuntime->GetFormFillEnv()->GetXFAContext(); if (pXFAContext->ContainsXFAForm()) - return CJS_Return::Success(pRuntime->NewNumber(JS_NUM_VIEWERVERSION_XFA)); + return CJS_Result::Success(pRuntime->NewNumber(JS_NUM_VIEWERVERSION_XFA)); #endif // PDF_ENABLE_XFA - return CJS_Return::Success(pRuntime->NewNumber(JS_NUM_VIEWERVERSION)); + return CJS_Result::Success(pRuntime->NewNumber(JS_NUM_VIEWERVERSION)); } -CJS_Return CJS_App::set_viewer_version(CJS_Runtime* pRuntime, +CJS_Result CJS_App::set_viewer_version(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::get_platform(CJS_Runtime* pRuntime) { +CJS_Result CJS_App::get_platform(CJS_Runtime* pRuntime) { #ifdef PDF_ENABLE_XFA CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv(); if (!pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); WideString platform = pFormFillEnv->GetPlatform(); if (!platform.IsEmpty()) - return CJS_Return::Success(pRuntime->NewString(platform.AsStringView())); + return CJS_Result::Success(pRuntime->NewString(platform.AsStringView())); #endif - return CJS_Return::Success(pRuntime->NewString(JS_STR_PLATFORM)); + return CJS_Result::Success(pRuntime->NewString(JS_STR_PLATFORM)); } -CJS_Return CJS_App::set_platform(CJS_Runtime* pRuntime, +CJS_Result CJS_App::set_platform(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::get_language(CJS_Runtime* pRuntime) { +CJS_Result CJS_App::get_language(CJS_Runtime* pRuntime) { #ifdef PDF_ENABLE_XFA CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv(); if (!pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); WideString language = pFormFillEnv->GetLanguage(); if (!language.IsEmpty()) - return CJS_Return::Success(pRuntime->NewString(language.AsStringView())); + return CJS_Result::Success(pRuntime->NewString(language.AsStringView())); #endif - return CJS_Return::Success(pRuntime->NewString(JS_STR_LANGUAGE)); + return CJS_Result::Success(pRuntime->NewString(JS_STR_LANGUAGE)); } -CJS_Return CJS_App::set_language(CJS_Runtime* pRuntime, +CJS_Result CJS_App::set_language(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } // creates a new fdf object that contains no data // comment: need reader support // note: // CFDF_Document * CPDFSDK_FormFillEnvironment::NewFDF(); -CJS_Return CJS_App::newFDF(CJS_Runtime* pRuntime, +CJS_Result CJS_App::newFDF(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } // opens a specified pdf document and returns its document object @@ -224,22 +224,22 @@ CJS_Return CJS_App::newFDF(CJS_Runtime* pRuntime, // CFDF_Document * CPDFSDK_FormFillEnvironment::OpenFDF(string strPath,bool // bUserConv); -CJS_Return CJS_App::openFDF(CJS_Runtime* pRuntime, +CJS_Result CJS_App::openFDF(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_App::alert(CJS_Runtime* pRuntime, +CJS_Result CJS_App::alert(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { std::vector<v8::Local<v8::Value>> newParams = ExpandKeywordParams( pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle"); if (!IsTypeKnown(newParams[0])) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv(); if (!pFormFillEnv) - return CJS_Return::Success(pRuntime->NewNumber(0)); + return CJS_Result::Success(pRuntime->NewNumber(0)); WideString swMsg; if (newParams[0]->IsArray()) { @@ -276,51 +276,51 @@ CJS_Return CJS_App::alert(CJS_Runtime* pRuntime, pFormFillEnv->JS_appAlert(swMsg, swTitle, iType, iIcon)); pRuntime->EndBlock(); - return CJS_Return::Success(ret); + return CJS_Result::Success(ret); } -CJS_Return CJS_App::beep(CJS_Runtime* pRuntime, +CJS_Result CJS_App::beep(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::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::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_App::findComponent( +CJS_Result CJS_App::findComponent( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_App::popUpMenuEx( +CJS_Result CJS_App::popUpMenuEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::get_fs(CJS_Runtime* pRuntime) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); +CJS_Result CJS_App::get_fs(CJS_Runtime* pRuntime) { + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::set_fs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); +CJS_Result CJS_App::set_fs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::setInterval( +CJS_Result CJS_App::setInterval( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() == 0 || params.size() > 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); WideString script = pRuntime->ToWideString(params[0]); if (script.IsEmpty()) - return CJS_Return::Failure(JSMessage::kInvalidInputError); + return CJS_Result::Failure(JSMessage::kInvalidInputError); uint32_t dwInterval = params.size() > 1 ? pRuntime->ToInt32(params[1]) : 1000; auto timerRef = pdfium::MakeUnique<GlobalTimer>( @@ -331,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::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pJS_TimerObj = static_cast<CJS_TimerObj*>(CFXJS_Engine::GetObjectPrivate(pRetObj)); pJS_TimerObj->SetTimer(pTimerRef); - return CJS_Return::Success(pRetObj); + return CJS_Result::Success(pRetObj); } -CJS_Return CJS_App::setTimeOut( +CJS_Result CJS_App::setTimeOut( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() == 0 || params.size() > 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); WideString script = pRuntime->ToWideString(params[0]); if (script.IsEmpty()) - return CJS_Return::Failure(JSMessage::kInvalidInputError); + return CJS_Result::Failure(JSMessage::kInvalidInputError); uint32_t dwTimeOut = params.size() > 1 ? pRuntime->ToInt32(params[1]) : 1000; auto timerRef = pdfium::MakeUnique<GlobalTimer>( @@ -360,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::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pJS_TimerObj = static_cast<CJS_TimerObj*>(CFXJS_Engine::GetObjectPrivate(pRetObj)); pJS_TimerObj->SetTimer(pTimerRef); - return CJS_Return::Success(pRetObj); + return CJS_Result::Success(pRetObj); } -CJS_Return CJS_App::clearTimeOut( +CJS_Result CJS_App::clearTimeOut( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CJS_App::ClearTimerCommon(pRuntime, params[0]); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_App::clearInterval( +CJS_Result CJS_App::clearInterval( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CJS_App::ClearTimerCommon(pRuntime, params[0]); - return CJS_Return::Success(); + return CJS_Result::Success(); } void CJS_App::ClearTimerCommon(CJS_Runtime* pRuntime, @@ -402,7 +402,7 @@ void CJS_App::ClearTimerCommon(CJS_Runtime* pRuntime, GlobalTimer::Cancel(pTimer->GetTimerID()); } -CJS_Return CJS_App::execMenuItem( +CJS_Result CJS_App::execMenuItem( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() > 0 && IsTypeKnown(params[0])) { @@ -411,7 +411,7 @@ CJS_Return CJS_App::execMenuItem( pRuntime->GetFormFillEnv()->SaveCalled(); } - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } void CJS_App::TimerProc(GlobalTimer* pTimer) { @@ -433,26 +433,26 @@ void CJS_App::RunJsScript(CJS_Runtime* pRuntime, const WideString& wsScript) { pContext->RunScript(wsScript); } -CJS_Return CJS_App::goBack(CJS_Runtime* pRuntime, +CJS_Result CJS_App::goBack(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Not supported, but do not return error. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_App::goForward(CJS_Runtime* pRuntime, +CJS_Result CJS_App::goForward(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Not supported, but do not return error. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_App::mailMsg(CJS_Runtime* pRuntime, +CJS_Result CJS_App::mailMsg(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { std::vector<v8::Local<v8::Value>> newParams = ExpandKeywordParams(pRuntime, params, 6, L"bUI", L"cTo", L"cCc", L"cBcc", L"cSubject", L"cMsg"); if (!IsTypeKnown(newParams[0])) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); bool bUI = pRuntime->ToBoolean(newParams[0]); WideString cTo; @@ -461,7 +461,7 @@ CJS_Return CJS_App::mailMsg(CJS_Runtime* pRuntime, } else { // cTo parameter required when UI not invoked. if (!bUI) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); } WideString cCc; @@ -484,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::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_App::launchURL(CJS_Runtime* pRuntime, +CJS_Result CJS_App::launchURL(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported, but do not return error. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_App::get_runtime_highlight(CJS_Runtime* pRuntime) { - return CJS_Return::Success(pRuntime->NewBoolean(m_bRuntimeHighLight)); +CJS_Result CJS_App::get_runtime_highlight(CJS_Runtime* pRuntime) { + return CJS_Result::Success(pRuntime->NewBoolean(m_bRuntimeHighLight)); } -CJS_Return CJS_App::set_runtime_highlight(CJS_Runtime* pRuntime, +CJS_Result CJS_App::set_runtime_highlight(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { m_bRuntimeHighLight = pRuntime->ToBoolean(vp); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_App::get_fullscreen(CJS_Runtime* pRuntime) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); +CJS_Result CJS_App::get_fullscreen(CJS_Runtime* pRuntime) { + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::set_fullscreen(CJS_Runtime* pRuntime, +CJS_Result CJS_App::set_fullscreen(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::popUpMenu(CJS_Runtime* pRuntime, +CJS_Result CJS_App::popUpMenu(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::browseForDoc( +CJS_Result CJS_App::browseForDoc( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported, but do not return an error. - return CJS_Return::Success(); + return CJS_Result::Success(); } WideString CJS_App::SysPathToPDFPath(const WideString& sOldPath) { @@ -533,24 +533,24 @@ WideString CJS_App::SysPathToPDFPath(const WideString& sOldPath) { return sRet; } -CJS_Return CJS_App::newDoc(CJS_Runtime* pRuntime, +CJS_Result CJS_App::newDoc(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::openDoc(CJS_Runtime* pRuntime, +CJS_Result CJS_App::openDoc(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::response(CJS_Runtime* pRuntime, +CJS_Result CJS_App::response(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { std::vector<v8::Local<v8::Value>> newParams = ExpandKeywordParams(pRuntime, params, 5, L"cQuestion", L"cTitle", L"cDefault", L"bPassword", L"cLabel"); if (!IsTypeKnown(newParams[0])) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); WideString swQuestion = pRuntime->ToWideString(newParams[0]); WideString swTitle = L"PDF"; @@ -576,24 +576,24 @@ CJS_Return CJS_App::response(CJS_Runtime* pRuntime, MAX_INPUT_BYTES); if (nLengthBytes < 0 || nLengthBytes > MAX_INPUT_BYTES) - return CJS_Return::Failure(JSMessage::kParamTooLongError); + return CJS_Result::Failure(JSMessage::kParamTooLongError); - return CJS_Return::Success(pRuntime->NewString( + return CJS_Result::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::Failure(JSMessage::kNotSupportedError); +CJS_Result CJS_App::get_media(CJS_Runtime* pRuntime) { + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); +CJS_Result CJS_App::set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_App::execDialog( +CJS_Result CJS_App::execDialog( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } diff --git a/fxjs/cjs_app.h b/fxjs/cjs_app.h index e962b34d49..5690f479db 100644 --- a/fxjs/cjs_app.h +++ b/fxjs/cjs_app.h @@ -70,85 +70,85 @@ class CJS_App : public CJS_Object { static const JSPropertySpec PropertySpecs[]; static const JSMethodSpec MethodSpecs[]; - CJS_Return get_active_docs(CJS_Runtime* pRuntime); - CJS_Return set_active_docs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_active_docs(CJS_Runtime* pRuntime); + CJS_Result set_active_docs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_calculate(CJS_Runtime* pRuntime); - CJS_Return set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_calculate(CJS_Runtime* pRuntime); + CJS_Result set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_forms_version(CJS_Runtime* pRuntime); - CJS_Return set_forms_version(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_forms_version(CJS_Runtime* pRuntime); + CJS_Result set_forms_version(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_fs(CJS_Runtime* pRuntime); - CJS_Return set_fs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_fs(CJS_Runtime* pRuntime); + CJS_Result set_fs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_fullscreen(CJS_Runtime* pRuntime); - CJS_Return set_fullscreen(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_fullscreen(CJS_Runtime* pRuntime); + CJS_Result set_fullscreen(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_language(CJS_Runtime* pRuntime); - CJS_Return set_language(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_language(CJS_Runtime* pRuntime); + CJS_Result set_language(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_media(CJS_Runtime* pRuntime); - CJS_Return set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_media(CJS_Runtime* pRuntime); + CJS_Result set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_platform(CJS_Runtime* pRuntime); - CJS_Return set_platform(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_platform(CJS_Runtime* pRuntime); + CJS_Result set_platform(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_runtime_highlight(CJS_Runtime* pRuntime); - CJS_Return set_runtime_highlight(CJS_Runtime* pRuntime, + CJS_Result get_runtime_highlight(CJS_Runtime* pRuntime); + CJS_Result set_runtime_highlight(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_viewer_type(CJS_Runtime* pRuntime); - CJS_Return set_viewer_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_viewer_type(CJS_Runtime* pRuntime); + CJS_Result set_viewer_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_viewer_variation(CJS_Runtime* pRuntime); - CJS_Return set_viewer_variation(CJS_Runtime* pRuntime, + CJS_Result get_viewer_variation(CJS_Runtime* pRuntime); + CJS_Result set_viewer_variation(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_viewer_version(CJS_Runtime* pRuntime); - CJS_Return set_viewer_version(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_viewer_version(CJS_Runtime* pRuntime); + CJS_Result set_viewer_version(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return alert(CJS_Runtime* pRuntime, + CJS_Result alert(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return beep(CJS_Runtime* pRuntime, + CJS_Result beep(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return browseForDoc(CJS_Runtime* pRuntime, + CJS_Result browseForDoc(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return clearInterval(CJS_Runtime* pRuntime, + CJS_Result clearInterval(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return clearTimeOut(CJS_Runtime* pRuntime, + CJS_Result clearTimeOut(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return execDialog(CJS_Runtime* pRuntime, + CJS_Result execDialog(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return execMenuItem(CJS_Runtime* pRuntime, + CJS_Result execMenuItem(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return findComponent(CJS_Runtime* pRuntime, + CJS_Result findComponent(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return goBack(CJS_Runtime* pRuntime, + CJS_Result goBack(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return goForward(CJS_Runtime* pRuntime, + CJS_Result goForward(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return launchURL(CJS_Runtime* pRuntime, + CJS_Result launchURL(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return mailMsg(CJS_Runtime* pRuntime, + CJS_Result mailMsg(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return newFDF(CJS_Runtime* pRuntime, + CJS_Result newFDF(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return newDoc(CJS_Runtime* pRuntime, + CJS_Result newDoc(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return openDoc(CJS_Runtime* pRuntime, + CJS_Result openDoc(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return openFDF(CJS_Runtime* pRuntime, + CJS_Result openFDF(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return popUpMenuEx(CJS_Runtime* pRuntime, + CJS_Result popUpMenuEx(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return popUpMenu(CJS_Runtime* pRuntime, + CJS_Result popUpMenu(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return response(CJS_Runtime* pRuntime, + CJS_Result response(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return setInterval(CJS_Runtime* pRuntime, + CJS_Result setInterval(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return setTimeOut(CJS_Runtime* pRuntime, + CJS_Result setTimeOut(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); void RunJsScript(CJS_Runtime* pRuntime, const WideString& wsScript); diff --git a/fxjs/cjs_color.cpp b/fxjs/cjs_color.cpp index 3bfa1a78df..bba4513b67 100644 --- a/fxjs/cjs_color.cpp +++ b/fxjs/cjs_color.cpp @@ -143,133 +143,133 @@ CJS_Color::CJS_Color(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime) CJS_Color::~CJS_Color() = default; -CJS_Return CJS_Color::get_transparent(CJS_Runtime* pRuntime) { +CJS_Result CJS_Color::get_transparent(CJS_Runtime* pRuntime) { return GetPropertyHelper(pRuntime, &m_crTransparent); } -CJS_Return CJS_Color::set_transparent(CJS_Runtime* pRuntime, +CJS_Result CJS_Color::set_transparent(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return SetPropertyHelper(pRuntime, vp, &m_crTransparent); } -CJS_Return CJS_Color::get_black(CJS_Runtime* pRuntime) { +CJS_Result CJS_Color::get_black(CJS_Runtime* pRuntime) { return GetPropertyHelper(pRuntime, &m_crBlack); } -CJS_Return CJS_Color::set_black(CJS_Runtime* pRuntime, +CJS_Result CJS_Color::set_black(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return SetPropertyHelper(pRuntime, vp, &m_crBlack); } -CJS_Return CJS_Color::get_white(CJS_Runtime* pRuntime) { +CJS_Result CJS_Color::get_white(CJS_Runtime* pRuntime) { return GetPropertyHelper(pRuntime, &m_crWhite); } -CJS_Return CJS_Color::set_white(CJS_Runtime* pRuntime, +CJS_Result CJS_Color::set_white(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return SetPropertyHelper(pRuntime, vp, &m_crWhite); } -CJS_Return CJS_Color::get_red(CJS_Runtime* pRuntime) { +CJS_Result CJS_Color::get_red(CJS_Runtime* pRuntime) { return GetPropertyHelper(pRuntime, &m_crRed); } -CJS_Return CJS_Color::set_red(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { +CJS_Result CJS_Color::set_red(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return SetPropertyHelper(pRuntime, vp, &m_crRed); } -CJS_Return CJS_Color::get_green(CJS_Runtime* pRuntime) { +CJS_Result CJS_Color::get_green(CJS_Runtime* pRuntime) { return GetPropertyHelper(pRuntime, &m_crGreen); } -CJS_Return CJS_Color::set_green(CJS_Runtime* pRuntime, +CJS_Result CJS_Color::set_green(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return SetPropertyHelper(pRuntime, vp, &m_crGreen); } -CJS_Return CJS_Color::get_blue(CJS_Runtime* pRuntime) { +CJS_Result CJS_Color::get_blue(CJS_Runtime* pRuntime) { return GetPropertyHelper(pRuntime, &m_crBlue); } -CJS_Return CJS_Color::set_blue(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { +CJS_Result CJS_Color::set_blue(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return SetPropertyHelper(pRuntime, vp, &m_crBlue); } -CJS_Return CJS_Color::get_cyan(CJS_Runtime* pRuntime) { +CJS_Result CJS_Color::get_cyan(CJS_Runtime* pRuntime) { return GetPropertyHelper(pRuntime, &m_crCyan); } -CJS_Return CJS_Color::set_cyan(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { +CJS_Result CJS_Color::set_cyan(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return SetPropertyHelper(pRuntime, vp, &m_crCyan); } -CJS_Return CJS_Color::get_magenta(CJS_Runtime* pRuntime) { +CJS_Result CJS_Color::get_magenta(CJS_Runtime* pRuntime) { return GetPropertyHelper(pRuntime, &m_crMagenta); } -CJS_Return CJS_Color::set_magenta(CJS_Runtime* pRuntime, +CJS_Result CJS_Color::set_magenta(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return SetPropertyHelper(pRuntime, vp, &m_crMagenta); } -CJS_Return CJS_Color::get_yellow(CJS_Runtime* pRuntime) { +CJS_Result CJS_Color::get_yellow(CJS_Runtime* pRuntime) { return GetPropertyHelper(pRuntime, &m_crYellow); } -CJS_Return CJS_Color::set_yellow(CJS_Runtime* pRuntime, +CJS_Result CJS_Color::set_yellow(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return SetPropertyHelper(pRuntime, vp, &m_crYellow); } -CJS_Return CJS_Color::get_dark_gray(CJS_Runtime* pRuntime) { +CJS_Result CJS_Color::get_dark_gray(CJS_Runtime* pRuntime) { return GetPropertyHelper(pRuntime, &m_crDKGray); } -CJS_Return CJS_Color::set_dark_gray(CJS_Runtime* pRuntime, +CJS_Result CJS_Color::set_dark_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return SetPropertyHelper(pRuntime, vp, &m_crDKGray); } -CJS_Return CJS_Color::get_gray(CJS_Runtime* pRuntime) { +CJS_Result CJS_Color::get_gray(CJS_Runtime* pRuntime) { return GetPropertyHelper(pRuntime, &m_crGray); } -CJS_Return CJS_Color::set_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { +CJS_Result CJS_Color::set_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return SetPropertyHelper(pRuntime, vp, &m_crGray); } -CJS_Return CJS_Color::get_light_gray(CJS_Runtime* pRuntime) { +CJS_Result CJS_Color::get_light_gray(CJS_Runtime* pRuntime) { return GetPropertyHelper(pRuntime, &m_crLTGray); } -CJS_Return CJS_Color::set_light_gray(CJS_Runtime* pRuntime, +CJS_Result CJS_Color::set_light_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return SetPropertyHelper(pRuntime, vp, &m_crLTGray); } -CJS_Return CJS_Color::GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* var) { +CJS_Result CJS_Color::GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* var) { v8::Local<v8::Value> array = ConvertPWLColorToArray(pRuntime, *var); if (array.IsEmpty()) - return CJS_Return::Success(pRuntime->NewArray()); + return CJS_Result::Success(pRuntime->NewArray()); - return CJS_Return::Success(array); + return CJS_Result::Success(array); } -CJS_Return CJS_Color::SetPropertyHelper(CJS_Runtime* pRuntime, +CJS_Result CJS_Color::SetPropertyHelper(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp, CFX_Color* var) { if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); *var = ConvertArrayToPWLColor(pRuntime, pRuntime->ToArray(vp)); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Color::convert(CJS_Runtime* pRuntime, +CJS_Result 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::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); WideString sDestSpace = pRuntime->ToWideString(params[1]); int nColorType = CFX_Color::kTransparent; @@ -287,16 +287,16 @@ CJS_Return CJS_Color::convert(CJS_Runtime* pRuntime, v8::Local<v8::Value> array = ConvertPWLColorToArray(pRuntime, color.ConvertColorType(nColorType)); if (array.IsEmpty()) - return CJS_Return::Success(pRuntime->NewArray()); + return CJS_Result::Success(pRuntime->NewArray()); - return CJS_Return::Success(array); + return CJS_Result::Success(array); } -CJS_Return CJS_Color::equal(CJS_Runtime* pRuntime, +CJS_Result 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::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); } CFX_Color color1 = @@ -305,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::Success(pRuntime->NewBoolean(color1 == color2)); + return CJS_Result::Success(pRuntime->NewBoolean(color1 == color2)); } diff --git a/fxjs/cjs_color.h b/fxjs/cjs_color.h index e1b7caa78a..aff19d7b73 100644 --- a/fxjs/cjs_color.h +++ b/fxjs/cjs_color.h @@ -46,49 +46,49 @@ class CJS_Color : public CJS_Object { static const JSPropertySpec PropertySpecs[]; static const JSMethodSpec MethodSpecs[]; - CJS_Return get_black(CJS_Runtime* pRuntime); - CJS_Return set_black(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_black(CJS_Runtime* pRuntime); + CJS_Result set_black(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_blue(CJS_Runtime* pRuntime); - CJS_Return set_blue(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_blue(CJS_Runtime* pRuntime); + CJS_Result set_blue(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_cyan(CJS_Runtime* pRuntime); - CJS_Return set_cyan(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_cyan(CJS_Runtime* pRuntime); + CJS_Result set_cyan(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_dark_gray(CJS_Runtime* pRuntime); - CJS_Return set_dark_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_dark_gray(CJS_Runtime* pRuntime); + CJS_Result set_dark_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_gray(CJS_Runtime* pRuntime); - CJS_Return set_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_gray(CJS_Runtime* pRuntime); + CJS_Result set_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_green(CJS_Runtime* pRuntime); - CJS_Return set_green(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_green(CJS_Runtime* pRuntime); + CJS_Result set_green(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_light_gray(CJS_Runtime* pRuntime); - CJS_Return set_light_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_light_gray(CJS_Runtime* pRuntime); + CJS_Result set_light_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_magenta(CJS_Runtime* pRuntime); - CJS_Return set_magenta(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_magenta(CJS_Runtime* pRuntime); + CJS_Result set_magenta(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_red(CJS_Runtime* pRuntime); - CJS_Return set_red(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_red(CJS_Runtime* pRuntime); + CJS_Result set_red(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_transparent(CJS_Runtime* pRuntime); - CJS_Return set_transparent(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_transparent(CJS_Runtime* pRuntime); + CJS_Result set_transparent(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_white(CJS_Runtime* pRuntime); - CJS_Return set_white(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_white(CJS_Runtime* pRuntime); + CJS_Result set_white(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_yellow(CJS_Runtime* pRuntime); - CJS_Return set_yellow(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_yellow(CJS_Runtime* pRuntime); + CJS_Result set_yellow(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return convert(CJS_Runtime* pRuntime, + CJS_Result convert(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return equal(CJS_Runtime* pRuntime, + CJS_Result equal(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* val); - CJS_Return SetPropertyHelper(CJS_Runtime* pRuntime, + CJS_Result GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* val); + CJS_Result SetPropertyHelper(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp, CFX_Color* val); diff --git a/fxjs/cjs_console.cpp b/fxjs/cjs_console.cpp index cf95ffab09..4d432db665 100644 --- a/fxjs/cjs_console.cpp +++ b/fxjs/cjs_console.cpp @@ -38,23 +38,23 @@ CJS_Console::CJS_Console(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime) CJS_Console::~CJS_Console() = default; -CJS_Return CJS_Console::clear(CJS_Runtime* pRuntime, +CJS_Result CJS_Console::clear(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Console::hide(CJS_Runtime* pRuntime, +CJS_Result CJS_Console::hide(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Console::println( +CJS_Result CJS_Console::println( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Console::show(CJS_Runtime* pRuntime, +CJS_Result CJS_Console::show(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } diff --git a/fxjs/cjs_console.h b/fxjs/cjs_console.h index 236ad47cf3..9ab2555664 100644 --- a/fxjs/cjs_console.h +++ b/fxjs/cjs_console.h @@ -29,13 +29,13 @@ class CJS_Console : public CJS_Object { static const char kName[]; static const JSMethodSpec MethodSpecs[]; - CJS_Return clear(CJS_Runtime* pRuntime, + CJS_Result clear(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return hide(CJS_Runtime* pRuntime, + CJS_Result hide(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return println(CJS_Runtime* pRuntime, + CJS_Result println(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return show(CJS_Runtime* pRuntime, + CJS_Result show(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); }; diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp index b842c150bf..486da1159c 100644 --- a/fxjs/cjs_document.cpp +++ b/fxjs/cjs_document.cpp @@ -131,63 +131,63 @@ CJS_Document::CJS_Document(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime) CJS_Document::~CJS_Document() = default; // The total number of fields in document. -CJS_Return CJS_Document::get_num_fields(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_num_fields(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); - return CJS_Return::Success(pRuntime->NewNumber( + return CJS_Result::Success(pRuntime->NewNumber( static_cast<int>(pPDFForm->CountFields(WideString())))); } -CJS_Return CJS_Document::set_num_fields(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_num_fields(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::get_dirty(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_dirty(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewBoolean(!!m_pFormFillEnv->GetChangeMark())); } -CJS_Return CJS_Document::set_dirty(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_dirty(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); pRuntime->ToBoolean(vp) ? m_pFormFillEnv->SetChangeMark() : m_pFormFillEnv->ClearChangeMark(); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_ADBE(CJS_Runtime* pRuntime) { - return CJS_Return::Success(pRuntime->NewUndefined()); +CJS_Result CJS_Document::get_ADBE(CJS_Runtime* pRuntime) { + return CJS_Result::Success(pRuntime->NewUndefined()); } -CJS_Return CJS_Document::set_ADBE(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_ADBE(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_page_num(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_page_num(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetCurrentView(); if (!pPageView) - return CJS_Return::Success(pRuntime->NewUndefined()); + return CJS_Result::Success(pRuntime->NewUndefined()); - return CJS_Return::Success(pRuntime->NewNumber(pPageView->GetPageIndex())); + return CJS_Result::Success(pRuntime->NewNumber(pPageView->GetPageIndex())); } -CJS_Return CJS_Document::set_page_num(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_page_num(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); int iPageCount = m_pFormFillEnv->GetPageCount(); int iPageNum = pRuntime->ToInt32(vp); @@ -198,131 +198,131 @@ CJS_Return CJS_Document::set_page_num(CJS_Runtime* pRuntime, else if (iPageNum < 0) m_pFormFillEnv->JS_docgotoPage(0); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::addAnnot( +CJS_Result CJS_Document::addAnnot( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Not supported, but do not return an error. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::addField( +CJS_Result CJS_Document::addField( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Not supported, but do not return an error. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::exportAsText( +CJS_Result CJS_Document::exportAsText( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported, but do not return an error. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::exportAsFDF( +CJS_Result CJS_Document::exportAsFDF( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported, but do not return an error. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::exportAsXFDF( +CJS_Result CJS_Document::exportAsXFDF( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported, but do not return an error. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::getField( +CJS_Result CJS_Document::getField( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::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::Success(pRuntime->NewUndefined()); + return CJS_Result::Success(pRuntime->NewUndefined()); v8::Local<v8::Object> pFieldObj = pRuntime->NewFXJSBoundObject( CJS_Field::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); if (pFieldObj.IsEmpty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pJSField = static_cast<CJS_Field*>(CFXJS_Engine::GetObjectPrivate(pFieldObj)); if (!pJSField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); pJSField->AttachField(this, wideName); - return CJS_Return::Success(pJSField->ToV8Object()); + return CJS_Result::Success(pJSField->ToV8Object()); } // Gets the name of the nth field in the document -CJS_Return CJS_Document::getNthFieldName( +CJS_Result CJS_Document::getNthFieldName( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); int nIndex = pRuntime->ToInt32(params[0]); if (nIndex < 0) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::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::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success( + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success( pRuntime->NewString(pField->GetFullName().AsStringView())); } -CJS_Return CJS_Document::importAnFDF( +CJS_Result CJS_Document::importAnFDF( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::importAnXFDF( +CJS_Result CJS_Document::importAnXFDF( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::importTextData( +CJS_Result CJS_Document::importTextData( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } // exports the form data and mails the resulting fdf file as an attachment to // all recipients. // comment: need reader supports -CJS_Return CJS_Document::mailForm( +CJS_Result CJS_Document::mailForm( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::Failure(JSMessage::kPermissionError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); ByteString sTextBuf = pInterForm->ExportFormToFDFTextBuf(); if (sTextBuf.GetLength() == 0) - return CJS_Return::Failure(L"Bad FDF format."); + return CJS_Result::Failure(L"Bad FDF format."); size_t nLength = params.size(); bool bUI = nLength > 0 ? pRuntime->ToBoolean(params[0]) : true; @@ -338,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::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::print( +CJS_Result CJS_Document::print( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); bool bUI = true; int nStart = 0; @@ -391,35 +391,35 @@ CJS_Return CJS_Document::print( } if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); m_pFormFillEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, bReverse, bAnnotations); - return CJS_Return::Success(); + return CJS_Result::Success(); } // removes the specified field from the document. // comment: // note: if the filed name is not rational, adobe is dumb for it. -CJS_Return CJS_Document::removeField( +CJS_Result CJS_Document::removeField( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) || m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM))) - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::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::Success(); + return CJS_Result::Success(); for (const auto& pAnnot : widgets) { CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get()); @@ -449,22 +449,22 @@ CJS_Return CJS_Document::removeField( } m_pFormFillEnv->SetChangeMark(); - return CJS_Return::Success(); + return CJS_Result::Success(); } // reset filed values within a document. // comment: // note: if the fields names r not rational, aodbe is dumb for it. -CJS_Return CJS_Document::resetForm( +CJS_Result CJS_Document::resetForm( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) || m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) || m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) { - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::Failure(JSMessage::kPermissionError); } CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); @@ -472,7 +472,7 @@ CJS_Return CJS_Document::resetForm( if (params.empty()) { pPDFForm->ResetForm(NotificationOption::kNotify); m_pFormFillEnv->SetChangeMark(); - return CJS_Return::Success(); + return CJS_Result::Success(); } v8::Local<v8::Array> array; @@ -496,30 +496,30 @@ CJS_Return CJS_Document::resetForm( m_pFormFillEnv->SetChangeMark(); } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::saveAs( +CJS_Result CJS_Document::saveAs( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::syncAnnotScan( +CJS_Result CJS_Document::syncAnnotScan( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::submitForm( +CJS_Result CJS_Document::submitForm( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { size_t nSize = params.size(); if (nSize < 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); v8::Local<v8::Array> aFields; WideString strURL; @@ -553,7 +553,7 @@ CJS_Return CJS_Document::submitForm( pInterForm->SubmitForm(strURL, false); pRuntime->EndBlock(); } - return CJS_Return::Success(); + return CJS_Result::Success(); } std::vector<CPDF_FormField*> fieldObjects; @@ -575,23 +575,23 @@ CJS_Return CJS_Document::submitForm( pInterForm->SubmitFields(strURL, fieldObjects, true, !bFDF); pRuntime->EndBlock(); } - return CJS_Return::Success(); + return CJS_Result::Success(); } void CJS_Document::SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) { m_pFormFillEnv.Reset(pFormFillEnv); } -CJS_Return CJS_Document::get_bookmark_root(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_bookmark_root(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_bookmark_root(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_bookmark_root(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::mailDoc( +CJS_Result CJS_Document::mailDoc( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // TODO(tsepez): Check maximum number of allowed params. @@ -631,25 +631,25 @@ 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::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_author(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_author(CJS_Runtime* pRuntime) { return getPropertyInternal(pRuntime, "Author"); } -CJS_Return CJS_Document::set_author(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_author(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return setPropertyInternal(pRuntime, vp, "Author"); } -CJS_Return CJS_Document::get_info(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_info(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); const auto* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo(); if (!pDictionary) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); WideString cwAuthor = pDictionary->GetUnicodeTextFor("Author"); WideString cwTitle = pDictionary->GetUnicodeTextFor("Title"); @@ -699,81 +699,81 @@ CJS_Return CJS_Document::get_info(CJS_Runtime* pRuntime) { pObj, wsKey, pRuntime->NewBoolean(!!pValueObj->GetInteger())); } } - return CJS_Return::Success(pObj); + return CJS_Result::Success(pObj); } -CJS_Return CJS_Document::set_info(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_info(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::getPropertyInternal(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::getPropertyInternal(CJS_Runtime* pRuntime, const ByteString& propName) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo(); if (!pDictionary) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(pRuntime->NewString( + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success(pRuntime->NewString( pDictionary->GetUnicodeTextFor(propName).AsStringView())); } -CJS_Return CJS_Document::setPropertyInternal(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::setPropertyInternal(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp, const ByteString& propName) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo(); if (!pDictionary) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY)) - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::Failure(JSMessage::kPermissionError); WideString csProperty = pRuntime->ToWideString(vp); pDictionary->SetNewFor<CPDF_String>(propName, PDF_EncodeText(csProperty), false); m_pFormFillEnv->SetChangeMark(); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_creation_date(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_creation_date(CJS_Runtime* pRuntime) { return getPropertyInternal(pRuntime, "CreationDate"); } -CJS_Return CJS_Document::set_creation_date(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_creation_date(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return setPropertyInternal(pRuntime, vp, "CreationDate"); } -CJS_Return CJS_Document::get_creator(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_creator(CJS_Runtime* pRuntime) { return getPropertyInternal(pRuntime, "Creator"); } -CJS_Return CJS_Document::set_creator(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_creator(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return setPropertyInternal(pRuntime, vp, "Creator"); } -CJS_Return CJS_Document::get_delay(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_delay(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(pRuntime->NewBoolean(m_bDelay)); + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success(pRuntime->NewBoolean(m_bDelay)); } -CJS_Return CJS_Document::set_delay(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY)) - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::Failure(JSMessage::kPermissionError); m_bDelay = pRuntime->ToBoolean(vp); if (m_bDelay) { m_DelayData.clear(); - return CJS_Return::Success(); + return CJS_Result::Success(); } std::list<std::unique_ptr<CJS_DelayData>> DelayDataToProcess; @@ -781,151 +781,151 @@ 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::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_keywords(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_keywords(CJS_Runtime* pRuntime) { return getPropertyInternal(pRuntime, "Keywords"); } -CJS_Return CJS_Document::set_keywords(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_keywords(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return setPropertyInternal(pRuntime, vp, "Keywords"); } -CJS_Return CJS_Document::get_mod_date(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_mod_date(CJS_Runtime* pRuntime) { return getPropertyInternal(pRuntime, "ModDate"); } -CJS_Return CJS_Document::set_mod_date(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_mod_date(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return setPropertyInternal(pRuntime, vp, "ModDate"); } -CJS_Return CJS_Document::get_producer(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_producer(CJS_Runtime* pRuntime) { return getPropertyInternal(pRuntime, "Producer"); } -CJS_Return CJS_Document::set_producer(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_producer(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return setPropertyInternal(pRuntime, vp, "Producer"); } -CJS_Return CJS_Document::get_subject(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_subject(CJS_Runtime* pRuntime) { return getPropertyInternal(pRuntime, "Subject"); } -CJS_Return CJS_Document::set_subject(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_subject(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return setPropertyInternal(pRuntime, vp, "Subject"); } -CJS_Return CJS_Document::get_title(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_title(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv || !m_pFormFillEnv->GetPDFDocument()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); return getPropertyInternal(pRuntime, "Title"); } -CJS_Return CJS_Document::set_title(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_title(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv || !m_pFormFillEnv->GetPDFDocument()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); return setPropertyInternal(pRuntime, vp, "Title"); } -CJS_Return CJS_Document::get_num_pages(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_num_pages(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success( + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success( pRuntime->NewNumber(m_pFormFillEnv->GetPageCount())); } -CJS_Return CJS_Document::set_num_pages(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_num_pages(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::get_external(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_external(CJS_Runtime* pRuntime) { // In Chrome case, should always return true. - return CJS_Return::Success(pRuntime->NewBoolean(true)); + return CJS_Result::Success(pRuntime->NewBoolean(true)); } -CJS_Return CJS_Document::set_external(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_external(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_filesize(CJS_Runtime* pRuntime) { - return CJS_Return::Success(pRuntime->NewNumber(0)); +CJS_Result CJS_Document::get_filesize(CJS_Runtime* pRuntime) { + return CJS_Result::Success(pRuntime->NewNumber(0)); } -CJS_Return CJS_Document::set_filesize(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_filesize(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::get_mouse_x(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_mouse_x(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_mouse_x(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_mouse_x(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_mouse_y(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_mouse_y(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_mouse_y(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_mouse_y(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_URL(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_URL(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success( + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success( pRuntime->NewString(m_pFormFillEnv->JS_docGetFilePath().AsStringView())); } -CJS_Return CJS_Document::set_URL(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::get_base_URL(CJS_Runtime* pRuntime) { - return CJS_Return::Success(pRuntime->NewString(m_cwBaseURL.AsStringView())); +CJS_Result CJS_Document::get_base_URL(CJS_Runtime* pRuntime) { + return CJS_Result::Success(pRuntime->NewString(m_cwBaseURL.AsStringView())); } -CJS_Return CJS_Document::set_base_URL(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_base_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { m_cwBaseURL = pRuntime->ToWideString(vp); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_calculate(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_calculate(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewBoolean(!!pInterForm->IsCalculateEnabled())); } -CJS_Return CJS_Document::set_calculate(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); pInterForm->EnableCalculate(pRuntime->ToBoolean(vp)); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_document_file_name(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_document_file_name(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); WideString wsFilePath = m_pFormFillEnv->JS_docGetFilePath(); size_t i = wsFilePath.GetLength(); @@ -934,78 +934,78 @@ CJS_Return CJS_Document::get_document_file_name(CJS_Runtime* pRuntime) { break; } if (i > 0 && i < wsFilePath.GetLength()) - return CJS_Return::Success(pRuntime->NewString(wsFilePath.c_str() + i)); + return CJS_Result::Success(pRuntime->NewString(wsFilePath.c_str() + i)); - return CJS_Return::Success(pRuntime->NewString(L"")); + return CJS_Result::Success(pRuntime->NewString(L"")); } -CJS_Return CJS_Document::set_document_file_name(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_document_file_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::get_path(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_path(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(pRuntime->NewString( + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success(pRuntime->NewString( CJS_App::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath()) .AsStringView())); } -CJS_Return CJS_Document::set_path(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_path(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::get_page_window_rect(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_page_window_rect(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_page_window_rect(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_page_window_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_layout(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_layout(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_layout(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_layout(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::addLink( +CJS_Result CJS_Document::addLink( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::closeDoc( +CJS_Result CJS_Document::closeDoc( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::getPageBox( +CJS_Result CJS_Document::getPageBox( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::getAnnot( +CJS_Result CJS_Document::getAnnot( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::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::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_AnnotIteration annotIteration(pPageView, false); CPDFSDK_BAAnnot* pSDKBAAnnot = nullptr; @@ -1017,27 +1017,27 @@ CJS_Return CJS_Document::getAnnot( } } if (!pSDKBAAnnot) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject( CJS_Annot::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); if (pObj.IsEmpty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pJS_Annot = static_cast<CJS_Annot*>(CFXJS_Engine::GetObjectPrivate(pObj)); if (!pJS_Annot) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); pJS_Annot->SetSDKAnnot(pSDKBAAnnot); - return CJS_Return::Success(pJS_Annot->ToV8Object()); + return CJS_Result::Success(pJS_Annot->ToV8Object()); } -CJS_Return CJS_Document::getAnnots( +CJS_Result CJS_Document::getAnnots( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); // TODO(tonikitoo): Add support supported parameters as per // the PDF spec. @@ -1047,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::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_AnnotIteration annotIteration(pPageView, false); for (const auto& pSDKAnnotCur : annotIteration) { if (!pSDKAnnotCur) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject( CJS_Annot::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); if (pObj.IsEmpty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pJS_Annot = static_cast<CJS_Annot*>(CFXJS_Engine::GetObjectPrivate(pObj)); @@ -1068,31 +1068,31 @@ CJS_Return CJS_Document::getAnnots( : v8::Local<v8::Value>()); } } - return CJS_Return::Success(annots); + return CJS_Result::Success(annots); } -CJS_Return CJS_Document::getAnnot3D( +CJS_Result CJS_Document::getAnnot3D( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(pRuntime->NewUndefined()); + return CJS_Result::Success(pRuntime->NewUndefined()); } -CJS_Return CJS_Document::getAnnots3D( +CJS_Result CJS_Document::getAnnots3D( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::getOCGs( +CJS_Result CJS_Document::getOCGs( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::getLinks( +CJS_Result CJS_Document::getLinks( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } bool CJS_Document::IsEnclosedInRect(CFX_FloatRect rect, @@ -1101,27 +1101,27 @@ bool CJS_Document::IsEnclosedInRect(CFX_FloatRect rect, rect.right >= LinkRect.right && rect.bottom >= LinkRect.bottom); } -CJS_Return CJS_Document::addIcon( +CJS_Result CJS_Document::addIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!params[1]->IsObject()) - return CJS_Return::Failure(JSMessage::kTypeError); + return CJS_Result::Failure(JSMessage::kTypeError); v8::Local<v8::Object> pObj = pRuntime->ToObject(params[1]); if (!JSGetObject<CJS_Icon>(pObj)) - return CJS_Return::Failure(JSMessage::kTypeError); + return CJS_Result::Failure(JSMessage::kTypeError); WideString swIconName = pRuntime->ToWideString(params[0]); m_IconNames.push_back(swIconName); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_icons(CJS_Runtime* pRuntime) { if (m_IconNames.empty()) - return CJS_Return::Success(pRuntime->NewUndefined()); + return CJS_Result::Success(pRuntime->NewUndefined()); v8::Local<v8::Array> Icons = pRuntime->NewArray(); int i = 0; @@ -1129,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::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pJS_Icon = static_cast<CJS_Icon*>(CFXJS_Engine::GetObjectPrivate(pObj)); @@ -1139,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::Success(Icons); + return CJS_Result::Success(Icons); } -CJS_Return CJS_Document::set_icons(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_icons(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::getIcon( +CJS_Result CJS_Document::getIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::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::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject( CJS_Icon::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); if (pObj.IsEmpty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pJSIcon = static_cast<CJS_Icon*>(CFXJS_Engine::GetObjectPrivate(pObj)); if (!pJSIcon) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); pJSIcon->SetIconName(*it); - return CJS_Return::Success(pJSIcon->ToV8Object()); + return CJS_Result::Success(pJSIcon->ToV8Object()); } -CJS_Return CJS_Document::removeIcon( +CJS_Result CJS_Document::removeIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, no supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::createDataObject( +CJS_Result CJS_Document::createDataObject( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not implemented. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_media(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_media(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_media(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::calculateNow( +CJS_Result CJS_Document::calculateNow( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) || m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) || m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) { - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::Failure(JSMessage::kPermissionError); } m_pFormFillEnv->GetInterForm()->OnCalculate(nullptr); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_collab(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_collab(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_collab(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_collab(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::getPageNthWord( +CJS_Result CJS_Document::getPageNthWord( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::Failure(JSMessage::kPermissionError); // TODO(tsepez): check maximum allowable params. @@ -1235,14 +1235,14 @@ CJS_Return CJS_Document::getPageNthWord( CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument(); if (!pDocument) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); CPDF_Dictionary* pPageDict = pDocument->GetPageDictionary(nPageNo); if (!pPageDict) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto page = pdfium::MakeRetain<CPDF_Page>(pDocument, pPageDict, true); page->ParseContent(); @@ -1263,35 +1263,35 @@ CJS_Return CJS_Document::getPageNthWord( if (bStrip) swRet.Trim(); - return CJS_Return::Success(pRuntime->NewString(swRet.AsStringView())); + return CJS_Result::Success(pRuntime->NewString(swRet.AsStringView())); } -CJS_Return CJS_Document::getPageNthWordQuads( +CJS_Result CJS_Document::getPageNthWordQuads( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Document::getPageNumWords( +CJS_Result CJS_Document::getPageNumWords( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::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::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); CPDF_Dictionary* pPageDict = pDocument->GetPageDictionary(nPageNo); if (!pPageDict) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto page = pdfium::MakeRetain<CPDF_Page>(pDocument, pPageDict, true); page->ParseContent(); @@ -1302,17 +1302,17 @@ CJS_Return CJS_Document::getPageNumWords( nWords += CountWords(pPageObj->AsText()); } - return CJS_Return::Success(pRuntime->NewNumber(nWords)); + return CJS_Result::Success(pRuntime->NewNumber(nWords)); } -CJS_Return CJS_Document::getPrintParams( +CJS_Result CJS_Document::getPrintParams( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { v8::Local<v8::Object> pRetObj = pRuntime->NewFXJSBoundObject( CJS_PrintParamsObj::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); if (pRetObj.IsEmpty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } #define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF) @@ -1385,77 +1385,77 @@ WideString CJS_Document::GetObjWordStr(CPDF_TextObject* pTextObj, return swRet; } -CJS_Return CJS_Document::get_zoom(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_zoom(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_zoom(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_zoom(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_zoom_type(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_zoom_type(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_zoom_type(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_zoom_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::deletePages( +CJS_Result CJS_Document::deletePages( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::extractPages( +CJS_Result CJS_Document::extractPages( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::insertPages( +CJS_Result CJS_Document::insertPages( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::replacePages( +CJS_Result CJS_Document::replacePages( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::getURL( +CJS_Result CJS_Document::getURL( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::gotoNamedDest( +CJS_Result CJS_Document::gotoNamedDest( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument(); if (!pDocument) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_NameTree nameTree(pDocument, "Dests"); CPDF_Array* destArray = nameTree.LookupNamedDest(pDocument, pRuntime->ToWideString(params[0])); if (!destArray) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_Dest dest(destArray); const CPDF_Array* arrayObject = ToArray(dest.GetObject()); @@ -1469,7 +1469,7 @@ CJS_Return CJS_Document::gotoNamedDest( dest.GetZoomMode(), scrollPositionArray.data(), scrollPositionArray.size()); pRuntime->EndBlock(); - return CJS_Return::Success(); + return CJS_Result::Success(); } void CJS_Document::AddDelayData(std::unique_ptr<CJS_DelayData> pData) { diff --git a/fxjs/cjs_document.h b/fxjs/cjs_document.h index 2af617f8ad..69a0b656ca 100644 --- a/fxjs/cjs_document.h +++ b/fxjs/cjs_document.h @@ -114,197 +114,197 @@ class CJS_Document : public CJS_Object, public Observable<CJS_Document> { static const JSPropertySpec PropertySpecs[]; static const JSMethodSpec MethodSpecs[]; - CJS_Return get_ADBE(CJS_Runtime* pRuntime); - CJS_Return set_ADBE(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_ADBE(CJS_Runtime* pRuntime); + CJS_Result set_ADBE(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_author(CJS_Runtime* pRuntime); - CJS_Return set_author(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_author(CJS_Runtime* pRuntime); + CJS_Result set_author(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_base_URL(CJS_Runtime* pRuntime); - CJS_Return set_base_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_base_URL(CJS_Runtime* pRuntime); + CJS_Result set_base_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_bookmark_root(CJS_Runtime* pRuntime); - CJS_Return set_bookmark_root(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_bookmark_root(CJS_Runtime* pRuntime); + CJS_Result set_bookmark_root(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_calculate(CJS_Runtime* pRuntime); - CJS_Return set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_calculate(CJS_Runtime* pRuntime); + CJS_Result set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_collab(CJS_Runtime* pRuntime); - CJS_Return set_collab(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_collab(CJS_Runtime* pRuntime); + CJS_Result set_collab(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_creation_date(CJS_Runtime* pRuntime); - CJS_Return set_creation_date(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_creation_date(CJS_Runtime* pRuntime); + CJS_Result set_creation_date(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_creator(CJS_Runtime* pRuntime); - CJS_Return set_creator(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_creator(CJS_Runtime* pRuntime); + CJS_Result set_creator(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_delay(CJS_Runtime* pRuntime); - CJS_Return set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_delay(CJS_Runtime* pRuntime); + CJS_Result set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_dirty(CJS_Runtime* pRuntime); - CJS_Return set_dirty(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_dirty(CJS_Runtime* pRuntime); + CJS_Result set_dirty(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_document_file_name(CJS_Runtime* pRuntime); - CJS_Return set_document_file_name(CJS_Runtime* pRuntime, + CJS_Result get_document_file_name(CJS_Runtime* pRuntime); + CJS_Result set_document_file_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_external(CJS_Runtime* pRuntime); - CJS_Return set_external(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_external(CJS_Runtime* pRuntime); + CJS_Result set_external(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_filesize(CJS_Runtime* pRuntime); - CJS_Return set_filesize(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_filesize(CJS_Runtime* pRuntime); + CJS_Result set_filesize(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_icons(CJS_Runtime* pRuntime); - CJS_Return set_icons(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_icons(CJS_Runtime* pRuntime); + CJS_Result set_icons(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_info(CJS_Runtime* pRuntime); - CJS_Return set_info(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_info(CJS_Runtime* pRuntime); + CJS_Result set_info(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_keywords(CJS_Runtime* pRuntime); - CJS_Return set_keywords(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_keywords(CJS_Runtime* pRuntime); + CJS_Result set_keywords(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_layout(CJS_Runtime* pRuntime); - CJS_Return set_layout(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_layout(CJS_Runtime* pRuntime); + CJS_Result set_layout(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_media(CJS_Runtime* pRuntime); - CJS_Return set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_media(CJS_Runtime* pRuntime); + CJS_Result set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_mod_date(CJS_Runtime* pRuntime); - CJS_Return set_mod_date(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_mod_date(CJS_Runtime* pRuntime); + CJS_Result set_mod_date(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_mouse_x(CJS_Runtime* pRuntime); - CJS_Return set_mouse_x(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_mouse_x(CJS_Runtime* pRuntime); + CJS_Result set_mouse_x(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_mouse_y(CJS_Runtime* pRuntime); - CJS_Return set_mouse_y(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_mouse_y(CJS_Runtime* pRuntime); + CJS_Result set_mouse_y(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_num_fields(CJS_Runtime* pRuntime); - CJS_Return set_num_fields(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_num_fields(CJS_Runtime* pRuntime); + CJS_Result set_num_fields(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_num_pages(CJS_Runtime* pRuntime); - CJS_Return set_num_pages(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_num_pages(CJS_Runtime* pRuntime); + CJS_Result set_num_pages(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_page_num(CJS_Runtime* pRuntime); - CJS_Return set_page_num(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_page_num(CJS_Runtime* pRuntime); + CJS_Result set_page_num(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_page_window_rect(CJS_Runtime* pRuntime); - CJS_Return set_page_window_rect(CJS_Runtime* pRuntime, + CJS_Result get_page_window_rect(CJS_Runtime* pRuntime); + CJS_Result set_page_window_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_path(CJS_Runtime* pRuntime); - CJS_Return set_path(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_path(CJS_Runtime* pRuntime); + CJS_Result set_path(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_producer(CJS_Runtime* pRuntime); - CJS_Return set_producer(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_producer(CJS_Runtime* pRuntime); + CJS_Result set_producer(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_subject(CJS_Runtime* pRuntime); - CJS_Return set_subject(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_subject(CJS_Runtime* pRuntime); + CJS_Result set_subject(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_title(CJS_Runtime* pRuntime); - CJS_Return set_title(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_title(CJS_Runtime* pRuntime); + CJS_Result set_title(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_zoom(CJS_Runtime* pRuntime); - CJS_Return set_zoom(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_zoom(CJS_Runtime* pRuntime); + CJS_Result set_zoom(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_zoom_type(CJS_Runtime* pRuntime); - CJS_Return set_zoom_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_zoom_type(CJS_Runtime* pRuntime); + CJS_Result set_zoom_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_URL(CJS_Runtime* pRuntime); - CJS_Return set_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_URL(CJS_Runtime* pRuntime); + CJS_Result set_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return addAnnot(CJS_Runtime* pRuntime, + CJS_Result addAnnot(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return addField(CJS_Runtime* pRuntime, + CJS_Result addField(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return addLink(CJS_Runtime* pRuntime, + CJS_Result addLink(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return addIcon(CJS_Runtime* pRuntime, + CJS_Result addIcon(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return calculateNow(CJS_Runtime* pRuntime, + CJS_Result calculateNow(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return closeDoc(CJS_Runtime* pRuntime, + CJS_Result closeDoc(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return createDataObject(CJS_Runtime* pRuntime, + CJS_Result createDataObject(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return deletePages(CJS_Runtime* pRuntime, + CJS_Result deletePages(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return exportAsText(CJS_Runtime* pRuntime, + CJS_Result exportAsText(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return exportAsFDF(CJS_Runtime* pRuntime, + CJS_Result exportAsFDF(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return exportAsXFDF(CJS_Runtime* pRuntime, + CJS_Result exportAsXFDF(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return extractPages(CJS_Runtime* pRuntime, + CJS_Result extractPages(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getAnnot(CJS_Runtime* pRuntime, + CJS_Result getAnnot(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getAnnots(CJS_Runtime* pRuntime, + CJS_Result getAnnots(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getAnnot3D(CJS_Runtime* pRuntime, + CJS_Result getAnnot3D(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getAnnots3D(CJS_Runtime* pRuntime, + CJS_Result getAnnots3D(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getField(CJS_Runtime* pRuntime, + CJS_Result getField(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getIcon(CJS_Runtime* pRuntime, + CJS_Result getIcon(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getLinks(CJS_Runtime* pRuntime, + CJS_Result getLinks(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getNthFieldName(CJS_Runtime* pRuntime, + CJS_Result getNthFieldName(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getOCGs(CJS_Runtime* pRuntime, + CJS_Result getOCGs(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getPageBox(CJS_Runtime* pRuntime, + CJS_Result getPageBox(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getPageNthWord(CJS_Runtime* pRuntime, + CJS_Result getPageNthWord(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getPageNthWordQuads( + CJS_Result getPageNthWordQuads( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getPageNumWords(CJS_Runtime* pRuntime, + CJS_Result getPageNumWords(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getPrintParams(CJS_Runtime* pRuntime, + CJS_Result getPrintParams(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getURL(CJS_Runtime* pRuntime, + CJS_Result getURL(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return gotoNamedDest(CJS_Runtime* pRuntime, + CJS_Result gotoNamedDest(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return importAnFDF(CJS_Runtime* pRuntime, + CJS_Result importAnFDF(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return importAnXFDF(CJS_Runtime* pRuntime, + CJS_Result importAnXFDF(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return importTextData(CJS_Runtime* pRuntime, + CJS_Result importTextData(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return insertPages(CJS_Runtime* pRuntime, + CJS_Result insertPages(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return mailForm(CJS_Runtime* pRuntime, + CJS_Result mailForm(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return print(CJS_Runtime* pRuntime, + CJS_Result print(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return removeField(CJS_Runtime* pRuntime, + CJS_Result removeField(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return replacePages(CJS_Runtime* pRuntime, + CJS_Result replacePages(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return resetForm(CJS_Runtime* pRuntime, + CJS_Result resetForm(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return saveAs(CJS_Runtime* pRuntime, + CJS_Result saveAs(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return submitForm(CJS_Runtime* pRuntime, + CJS_Result submitForm(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return syncAnnotScan(CJS_Runtime* pRuntime, + CJS_Result syncAnnotScan(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return mailDoc(CJS_Runtime* pRuntime, + CJS_Result mailDoc(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return removeIcon(CJS_Runtime* pRuntime, + CJS_Result removeIcon(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); bool IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect); int CountWords(CPDF_TextObject* pTextObj); WideString GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex); - CJS_Return getPropertyInternal(CJS_Runtime* pRuntime, + CJS_Result getPropertyInternal(CJS_Runtime* pRuntime, const ByteString& propName); - CJS_Return setPropertyInternal(CJS_Runtime* pRuntime, + CJS_Result setPropertyInternal(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp, const ByteString& propName); diff --git a/fxjs/cjs_event.cpp b/fxjs/cjs_event.cpp index f00f07c3b9..0895d9c009 100644 --- a/fxjs/cjs_event.cpp +++ b/fxjs/cjs_event.cpp @@ -54,14 +54,14 @@ 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) { +CJS_Result CJS_Event::get_change(CJS_Runtime* pRuntime) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewString(pEvent->Change().AsStringView())); } -CJS_Return CJS_Event::set_change(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(pRuntime->GetCurrentEventContext()); @@ -72,129 +72,129 @@ CJS_Return CJS_Event::set_change(CJS_Runtime* pRuntime, WideString& wChange = pEvent->Change(); wChange = pRuntime->ToWideString(vp); } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Event::get_change_ex(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_change_ex(CJS_Runtime* pRuntime) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewString(pEvent->ChangeEx().AsStringView())); } -CJS_Return CJS_Event::set_change_ex(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_change_ex(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Event::get_commit_key(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_commit_key(CJS_Runtime* pRuntime) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - return CJS_Return::Success(pRuntime->NewNumber(pEvent->CommitKey())); + return CJS_Result::Success(pRuntime->NewNumber(pEvent->CommitKey())); } -CJS_Return CJS_Event::set_commit_key(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_commit_key(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Event::get_field_full(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_field_full(CJS_Runtime* pRuntime) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) - return CJS_Return::Failure(L"unrecognized event"); + return CJS_Result::Failure(L"unrecognized event"); - return CJS_Return::Success(pRuntime->NewBoolean(pEvent->FieldFull())); + return CJS_Result::Success(pRuntime->NewBoolean(pEvent->FieldFull())); } -CJS_Return CJS_Event::set_field_full(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_field_full(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Event::get_key_down(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_key_down(CJS_Runtime* pRuntime) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - return CJS_Return::Success(pRuntime->NewBoolean(pEvent->KeyDown())); + return CJS_Result::Success(pRuntime->NewBoolean(pEvent->KeyDown())); } -CJS_Return CJS_Event::set_key_down(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_key_down(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Event::get_modifier(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_modifier(CJS_Runtime* pRuntime) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - return CJS_Return::Success(pRuntime->NewBoolean(pEvent->Modifier())); + return CJS_Result::Success(pRuntime->NewBoolean(pEvent->Modifier())); } -CJS_Return CJS_Event::set_modifier(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_modifier(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Event::get_name(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_name(CJS_Runtime* pRuntime) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - return CJS_Return::Success(pRuntime->NewString(pEvent->Name())); + return CJS_Result::Success(pRuntime->NewString(pEvent->Name())); } -CJS_Return CJS_Event::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); +CJS_Result CJS_Event::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Event::get_rc(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_rc(CJS_Runtime* pRuntime) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - return CJS_Return::Success(pRuntime->NewBoolean(pEvent->Rc())); + return CJS_Result::Success(pRuntime->NewBoolean(pEvent->Rc())); } -CJS_Return CJS_Event::set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { +CJS_Result 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::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Event::get_rich_change(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Event::get_rich_change(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Event::set_rich_change(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_rich_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Event::get_rich_change_ex(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Event::get_rich_change_ex(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Event::set_rich_change_ex(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_rich_change_ex(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Event::get_rich_value(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Event::get_rich_value(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Event::set_rich_value(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_rich_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Event::get_sel_end(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_sel_end(CJS_Runtime* pRuntime) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) - return CJS_Return::Success(); + return CJS_Result::Success(); - return CJS_Return::Success(pRuntime->NewNumber(pEvent->SelEnd())); + return CJS_Result::Success(pRuntime->NewNumber(pEvent->SelEnd())); } -CJS_Return CJS_Event::set_sel_end(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_sel_end(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); @@ -202,20 +202,20 @@ CJS_Return CJS_Event::set_sel_end(CJS_Runtime* pRuntime, if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") == 0) pEvent->SetSelEnd(pRuntime->ToInt32(vp)); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Event::get_sel_start(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_sel_start(CJS_Runtime* pRuntime) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) - return CJS_Return::Success(); + return CJS_Result::Success(); - return CJS_Return::Success(pRuntime->NewNumber(pEvent->SelStart())); + return CJS_Result::Success(pRuntime->NewNumber(pEvent->SelStart())); } -CJS_Return CJS_Event::set_sel_start(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_sel_start(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); @@ -223,81 +223,81 @@ CJS_Return CJS_Event::set_sel_start(CJS_Runtime* pRuntime, if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") == 0) pEvent->SetSelStart(pRuntime->ToInt32(vp)); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Event::get_shift(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_shift(CJS_Runtime* pRuntime) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - return CJS_Return::Success(pRuntime->NewBoolean(pEvent->Shift())); + return CJS_Result::Success(pRuntime->NewBoolean(pEvent->Shift())); } -CJS_Return CJS_Event::set_shift(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_shift(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Event::get_source(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_source(CJS_Runtime* pRuntime) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - return CJS_Return::Success(pEvent->Source()->ToV8Object()); + return CJS_Result::Success(pEvent->Source()->ToV8Object()); } -CJS_Return CJS_Event::set_source(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Event::get_target(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_target(CJS_Runtime* pRuntime) { ASSERT(pRuntime->GetCurrentEventContext()); CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - return CJS_Return::Success(pEvent->Target_Field()->ToV8Object()); + return CJS_Result::Success(pEvent->Target_Field()->ToV8Object()); } -CJS_Return CJS_Event::set_target(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_target(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Event::get_target_name(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_target_name(CJS_Runtime* pRuntime) { ASSERT(pRuntime->GetCurrentEventContext()); CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewString(pEvent->TargetName().AsStringView())); } -CJS_Return CJS_Event::set_target_name(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_target_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Event::get_type(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_type(CJS_Runtime* pRuntime) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - return CJS_Return::Success(pRuntime->NewString(pEvent->Type())); + return CJS_Result::Success(pRuntime->NewString(pEvent->Type())); } -CJS_Return CJS_Event::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); +CJS_Result CJS_Event::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Event::get_value(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_value(CJS_Runtime* pRuntime) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0) - return CJS_Return::Failure(L"Bad event type."); + return CJS_Result::Failure(L"Bad event type."); if (!pEvent->m_pValue) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewString(pEvent->Value().AsStringView())); } -CJS_Return CJS_Event::set_value(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(pRuntime->GetCurrentEventContext()); @@ -305,24 +305,24 @@ 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::Failure(L"Bad event type."); + return CJS_Result::Failure(L"Bad event type."); if (!pEvent->m_pValue) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); pEvent->Value() = pRuntime->ToWideString(vp); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Event::get_will_commit(CJS_Runtime* pRuntime) { +CJS_Result CJS_Event::get_will_commit(CJS_Runtime* pRuntime) { ASSERT(pRuntime->GetCurrentEventContext()); CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - return CJS_Return::Success(pRuntime->NewBoolean(pEvent->WillCommit())); + return CJS_Result::Success(pRuntime->NewBoolean(pEvent->WillCommit())); } -CJS_Return CJS_Event::set_will_commit(CJS_Runtime* pRuntime, +CJS_Result CJS_Event::set_will_commit(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } diff --git a/fxjs/cjs_event.h b/fxjs/cjs_event.h index 804c6f6c7d..67bd3f52fa 100644 --- a/fxjs/cjs_event.h +++ b/fxjs/cjs_event.h @@ -43,65 +43,65 @@ class CJS_Event : public CJS_Object { static const char kName[]; static const JSPropertySpec PropertySpecs[]; - CJS_Return get_change(CJS_Runtime* pRuntime); - CJS_Return set_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_change(CJS_Runtime* pRuntime); + CJS_Result set_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_change_ex(CJS_Runtime* pRuntime); - CJS_Return set_change_ex(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_change_ex(CJS_Runtime* pRuntime); + CJS_Result set_change_ex(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_commit_key(CJS_Runtime* pRuntime); - CJS_Return set_commit_key(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_commit_key(CJS_Runtime* pRuntime); + CJS_Result set_commit_key(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_field_full(CJS_Runtime* pRuntime); - CJS_Return set_field_full(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_field_full(CJS_Runtime* pRuntime); + CJS_Result set_field_full(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_key_down(CJS_Runtime* pRuntime); - CJS_Return set_key_down(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_key_down(CJS_Runtime* pRuntime); + CJS_Result set_key_down(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_modifier(CJS_Runtime* pRuntime); - CJS_Return set_modifier(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_modifier(CJS_Runtime* pRuntime); + CJS_Result set_modifier(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_name(CJS_Runtime* pRuntime); - CJS_Return set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_name(CJS_Runtime* pRuntime); + CJS_Result set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_rc(CJS_Runtime* pRuntime); - CJS_Return set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_rc(CJS_Runtime* pRuntime); + CJS_Result set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_rich_change(CJS_Runtime* pRuntime); - CJS_Return set_rich_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_rich_change(CJS_Runtime* pRuntime); + CJS_Result set_rich_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_rich_change_ex(CJS_Runtime* pRuntime); - CJS_Return set_rich_change_ex(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_rich_change_ex(CJS_Runtime* pRuntime); + CJS_Result set_rich_change_ex(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_rich_value(CJS_Runtime* pRuntime); - CJS_Return set_rich_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_rich_value(CJS_Runtime* pRuntime); + CJS_Result set_rich_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_sel_end(CJS_Runtime* pRuntime); - CJS_Return set_sel_end(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_sel_end(CJS_Runtime* pRuntime); + CJS_Result set_sel_end(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_sel_start(CJS_Runtime* pRuntime); - CJS_Return set_sel_start(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_sel_start(CJS_Runtime* pRuntime); + CJS_Result set_sel_start(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_shift(CJS_Runtime* pRuntime); - CJS_Return set_shift(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_shift(CJS_Runtime* pRuntime); + CJS_Result set_shift(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_source(CJS_Runtime* pRuntime); - CJS_Return set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_source(CJS_Runtime* pRuntime); + CJS_Result set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_target(CJS_Runtime* pRuntime); - CJS_Return set_target(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_target(CJS_Runtime* pRuntime); + CJS_Result set_target(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_target_name(CJS_Runtime* pRuntime); - CJS_Return set_target_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_target_name(CJS_Runtime* pRuntime); + CJS_Result set_target_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_type(CJS_Runtime* pRuntime); - CJS_Return set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_type(CJS_Runtime* pRuntime); + CJS_Result set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_value(CJS_Runtime* pRuntime); - CJS_Return set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_value(CJS_Runtime* pRuntime); + CJS_Result set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_will_commit(CJS_Runtime* pRuntime); - CJS_Return set_will_commit(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_will_commit(CJS_Runtime* pRuntime); + CJS_Result set_will_commit(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); }; #endif // FXJS_CJS_EVENT_H_ diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp index 4e7baf4a62..1f390519fd 100644 --- a/fxjs/cjs_field.cpp +++ b/fxjs/cjs_field.cpp @@ -665,72 +665,72 @@ CPDF_FormControl* CJS_Field::GetSmartFieldControl(CPDF_FormField* pFormField) { return pFormField->GetControl(m_nFormControlIndex); } -CJS_Return CJS_Field::get_alignment(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_alignment(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); switch (pFormControl->GetControlAlignment()) { case 0: - return CJS_Return::Success(pRuntime->NewString(L"left")); + return CJS_Result::Success(pRuntime->NewString(L"left")); case 1: - return CJS_Return::Success(pRuntime->NewString(L"center")); + return CJS_Result::Success(pRuntime->NewString(L"center")); case 2: - return CJS_Return::Success(pRuntime->NewString(L"right")); + return CJS_Result::Success(pRuntime->NewString(L"right")); } - return CJS_Return::Success(pRuntime->NewString(L"")); + return CJS_Result::Success(pRuntime->NewString(L"")); } -CJS_Return CJS_Field::set_alignment(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_alignment(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_border_style(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_border_style(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_Widget* pWidget = GetWidget(m_pFormFillEnv.Get(), GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); switch (pWidget->GetBorderStyle()) { case BorderStyle::SOLID: - return CJS_Return::Success(pRuntime->NewString(L"solid")); + return CJS_Result::Success(pRuntime->NewString(L"solid")); case BorderStyle::DASH: - return CJS_Return::Success(pRuntime->NewString(L"dashed")); + return CJS_Result::Success(pRuntime->NewString(L"dashed")); case BorderStyle::BEVELED: - return CJS_Return::Success(pRuntime->NewString(L"beveled")); + return CJS_Result::Success(pRuntime->NewString(L"beveled")); case BorderStyle::INSET: - return CJS_Return::Success(pRuntime->NewString(L"inset")); + return CJS_Result::Success(pRuntime->NewString(L"inset")); case BorderStyle::UNDERLINE: - return CJS_Return::Success(pRuntime->NewString(L"underline")); + return CJS_Result::Success(pRuntime->NewString(L"underline")); } - return CJS_Return::Success(pRuntime->NewString(L"")); + return CJS_Result::Success(pRuntime->NewString(L"")); } -CJS_Return CJS_Field::set_border_style(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_border_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); ByteString byte_str = pRuntime->ToWideString(vp).ToDefANSI(); if (m_bDelay) { @@ -739,52 +739,52 @@ CJS_Return CJS_Field::set_border_style(CJS_Runtime* pRuntime, SetBorderStyle(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, byte_str); } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_button_align_x(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_button_align_x(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_IconFit IconFit = pFormControl->GetIconFit(); float fLeft; float fBottom; IconFit.GetIconPosition(fLeft, fBottom); - return CJS_Return::Success(pRuntime->NewNumber(static_cast<int32_t>(fLeft))); + return CJS_Result::Success(pRuntime->NewNumber(static_cast<int32_t>(fLeft))); } -CJS_Return CJS_Field::set_button_align_x(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_button_align_x(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_button_align_y(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_button_align_y(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_IconFit IconFit = pFormControl->GetIconFit(); @@ -792,238 +792,238 @@ CJS_Return CJS_Field::get_button_align_y(CJS_Runtime* pRuntime) { float fBottom; IconFit.GetIconPosition(fLeft, fBottom); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewNumber(static_cast<int32_t>(fBottom))); } -CJS_Return CJS_Field::set_button_align_y(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_button_align_y(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_button_fit_bounds(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_button_fit_bounds(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewBoolean(pFormControl->GetIconFit().GetFittingBounds())); } -CJS_Return CJS_Field::set_button_fit_bounds(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_button_fit_bounds(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_button_position(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_button_position(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewNumber(pFormControl->GetTextPosition())); } -CJS_Return CJS_Field::set_button_position(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_button_position(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_button_scale_how(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_button_scale_how(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( pFormControl->GetIconFit().IsProportionalScale() ? 0 : 1)); } -CJS_Return CJS_Field::set_button_scale_how(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_button_scale_how(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_button_scale_when(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_button_scale_when(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_IconFit IconFit = pFormControl->GetIconFit(); int ScaleM = IconFit.GetScaleMethod(); switch (ScaleM) { case CPDF_IconFit::Always: - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Always))); case CPDF_IconFit::Bigger: - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Bigger))); case CPDF_IconFit::Never: - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Never))); case CPDF_IconFit::Smaller: - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Smaller))); } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::set_button_scale_when(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_button_scale_when(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_calc_order_index(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_calc_order_index(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!IsComboBoxOrTextField(pFormField)) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm(); CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); - return CJS_Return::Success(pRuntime->NewNumber(static_cast<int32_t>( + return CJS_Result::Success(pRuntime->NewNumber(static_cast<int32_t>( pInterForm->FindFieldInCalculationOrder(pFormField)))); } -CJS_Return CJS_Field::set_calc_order_index(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_calc_order_index(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_char_limit(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_char_limit(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return::Failure(JSMessage::kObjectTypeError); - return CJS_Return::Success( + return CJS_Result::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Success( pRuntime->NewNumber(static_cast<int32_t>(pFormField->GetMaxLen()))); } -CJS_Return CJS_Field::set_char_limit(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_char_limit(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_comb(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_comb(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_COMB))); } -CJS_Return CJS_Field::set_comb(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { +CJS_Result CJS_Field::set_comb(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!IsComboBoxOrListBox(pFormField)) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE))); } -CJS_Return CJS_Field::set_commit_on_sel_change(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_commit_on_sel_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_current_value_indices(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_current_value_indices(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!IsComboBoxOrListBox(pFormField)) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); int count = pFormField->CountSelectedItems(); if (count <= 0) - return CJS_Return::Success(pRuntime->NewNumber(-1)); + return CJS_Result::Success(pRuntime->NewNumber(-1)); if (count == 1) - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewNumber(pFormField->GetSelectedIndex(0))); v8::Local<v8::Array> SelArray = pRuntime->NewArray(); @@ -1032,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::Success(pRuntime->NewArray()); - return CJS_Return::Success(SelArray); + return CJS_Result::Success(pRuntime->NewArray()); + return CJS_Result::Success(SelArray); } -CJS_Return CJS_Field::set_current_value_indices(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_current_value_indices(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); std::vector<uint32_t> array; if (vp->IsNumber()) { @@ -1058,84 +1058,84 @@ CJS_Return CJS_Field::set_current_value_indices(CJS_Runtime* pRuntime, SetCurrentValueIndices(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, array); } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_default_style(CJS_Runtime* pRuntime) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); +CJS_Result CJS_Field::get_default_style(CJS_Runtime* pRuntime) { + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::set_default_style(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_default_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::get_default_value(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_default_value(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() == FormFieldType::kPushButton || pFormField->GetFieldType() == FormFieldType::kSignature) { - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); } - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewString(pFormField->GetDefaultValue().AsStringView())); } -CJS_Return CJS_Field::set_default_value(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_default_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_do_not_scroll(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_do_not_scroll(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL))); } -CJS_Return CJS_Field::set_do_not_scroll(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_do_not_scroll(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_do_not_spell_check(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_do_not_spell_check(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!IsComboBoxOrTextField(pFormField)) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK))); } -CJS_Return CJS_Field::set_do_not_spell_check(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_do_not_spell_check(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } void CJS_Field::SetDelay(bool bDelay) { @@ -1147,46 +1147,46 @@ void CJS_Field::SetDelay(bool bDelay) { m_pJSDoc->DoFieldDelay(m_FieldName, m_nFormControlIndex); } -CJS_Return CJS_Field::get_delay(CJS_Runtime* pRuntime) { - return CJS_Return::Success(pRuntime->NewBoolean(m_bDelay)); +CJS_Result CJS_Field::get_delay(CJS_Runtime* pRuntime) { + return CJS_Result::Success(pRuntime->NewBoolean(m_bDelay)); } -CJS_Return CJS_Field::set_delay(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); SetDelay(pRuntime->ToBoolean(vp)); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_display(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_display(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); uint32_t dwFlag = pWidget->GetFlags(); if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) - return CJS_Return::Success(pRuntime->NewNumber(1)); + return CJS_Result::Success(pRuntime->NewNumber(1)); if (ANNOTFLAG_PRINT & dwFlag) { if (ANNOTFLAG_NOVIEW & dwFlag) - return CJS_Return::Success(pRuntime->NewNumber(3)); - return CJS_Return::Success(pRuntime->NewNumber(0)); + return CJS_Result::Success(pRuntime->NewNumber(3)); + return CJS_Result::Success(pRuntime->NewNumber(0)); } - return CJS_Return::Success(pRuntime->NewNumber(2)); + return CJS_Result::Success(pRuntime->NewNumber(2)); } -CJS_Return CJS_Field::set_display(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_display(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); if (m_bDelay) { AddDelay_Int(FP_DISPLAY, pRuntime->ToInt32(vp)); @@ -1194,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::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_doc(CJS_Runtime* pRuntime) { - return CJS_Return::Success(m_pJSDoc->ToV8Object()); +CJS_Result CJS_Field::get_doc(CJS_Runtime* pRuntime) { + return CJS_Result::Success(m_pJSDoc->ToV8Object()); } -CJS_Return CJS_Field::set_doc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); +CJS_Result CJS_Field::set_doc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::get_editable(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_editable(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kComboBox) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_EDIT))); } -CJS_Return CJS_Field::set_editable(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_editable(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_export_values(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_export_values(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!IsCheckBoxOrRadioButton(pFormField)) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); v8::Local<v8::Array> ExportValuesArray = pRuntime->NewArray(); if (m_nFormControlIndex < 0) { @@ -1242,73 +1242,73 @@ CJS_Return CJS_Field::get_export_values(CJS_Runtime* pRuntime) { } } else { if (m_nFormControlIndex >= pFormField->CountControls()) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); CPDF_FormControl* pFormControl = pFormField->GetControl(m_nFormControlIndex); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); pRuntime->PutArrayElement( ExportValuesArray, 0, pRuntime->NewString(pFormControl->GetExportValue().AsStringView())); } - return CJS_Return::Success(ExportValuesArray); + return CJS_Result::Success(ExportValuesArray); } -CJS_Return CJS_Field::set_export_values(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_export_values(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!IsCheckBoxOrRadioButton(pFormField)) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_file_select(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_file_select(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT))); } -CJS_Return CJS_Field::set_file_select(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_file_select(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_fill_color(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_fill_color(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); int iColorType; pFormControl->GetBackgroundColor(iColorType); @@ -1331,48 +1331,48 @@ CJS_Return CJS_Field::get_fill_color(CJS_Runtime* pRuntime) { pFormControl->GetOriginalBackgroundColor(2), pFormControl->GetOriginalBackgroundColor(3)); } else { - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); } v8::Local<v8::Value> array = CJS_Color::ConvertPWLColorToArray(pRuntime, color); if (array.IsEmpty()) - return CJS_Return::Success(pRuntime->NewArray()); - return CJS_Return::Success(array); + return CJS_Result::Success(pRuntime->NewArray()); + return CJS_Result::Success(array); } -CJS_Return CJS_Field::set_fill_color(CJS_Runtime* pRuntime, +CJS_Result 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::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_hidden(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_hidden(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); uint32_t dwFlags = pWidget->GetFlags(); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags)); } -CJS_Return CJS_Field::set_hidden(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); if (m_bDelay) { AddDelay_Bool(FP_HIDDEN, pRuntime->ToBoolean(vp)); @@ -1380,71 +1380,71 @@ CJS_Return CJS_Field::set_hidden(CJS_Runtime* pRuntime, SetHidden(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, pRuntime->ToBoolean(vp)); } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_highlight(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_highlight(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); int eHM = pFormControl->GetHighlightingMode(); switch (eHM) { case CPDF_FormControl::None: - return CJS_Return::Success(pRuntime->NewString(L"none")); + return CJS_Result::Success(pRuntime->NewString(L"none")); case CPDF_FormControl::Push: - return CJS_Return::Success(pRuntime->NewString(L"push")); + return CJS_Result::Success(pRuntime->NewString(L"push")); case CPDF_FormControl::Invert: - return CJS_Return::Success(pRuntime->NewString(L"invert")); + return CJS_Result::Success(pRuntime->NewString(L"invert")); case CPDF_FormControl::Outline: - return CJS_Return::Success(pRuntime->NewString(L"outline")); + return CJS_Result::Success(pRuntime->NewString(L"outline")); case CPDF_FormControl::Toggle: - return CJS_Return::Success(pRuntime->NewString(L"toggle")); + return CJS_Result::Success(pRuntime->NewString(L"toggle")); } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::set_highlight(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_highlight(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_line_width(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_line_width(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); if (!pFormField->CountControls()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0)); if (!pWidget) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(pRuntime->NewNumber(pWidget->GetBorderWidth())); + return CJS_Result::Success(pRuntime->NewNumber(pWidget->GetBorderWidth())); } -CJS_Return CJS_Field::set_line_width(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_line_width(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); if (m_bDelay) { AddDelay_Int(FP_LINEWIDTH, pRuntime->ToInt32(vp)); @@ -1452,159 +1452,159 @@ CJS_Return CJS_Field::set_line_width(CJS_Runtime* pRuntime, SetLineWidth(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, pRuntime->ToInt32(vp)); } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_multiline(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_multiline(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE))); } -CJS_Return CJS_Field::set_multiline(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_multiline(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_multiple_selection(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_multiple_selection(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kListBox) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT))); } -CJS_Return CJS_Field::set_multiple_selection(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_multiple_selection(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_name(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_name(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(); if (FieldArray.empty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(pRuntime->NewString(m_FieldName.AsStringView())); + return CJS_Result::Success(pRuntime->NewString(m_FieldName.AsStringView())); } -CJS_Return CJS_Field::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); +CJS_Result CJS_Field::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::get_num_items(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_num_items(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!IsComboBoxOrListBox(pFormField)) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); - return CJS_Return::Success(pRuntime->NewNumber(pFormField->CountOptions())); + return CJS_Result::Success(pRuntime->NewNumber(pFormField->CountOptions())); } -CJS_Return CJS_Field::set_num_items(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_num_items(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::get_page(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_page(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); std::vector<CPDFSDK_Annot::ObservedPtr> widgets; m_pFormFillEnv->GetInterForm()->GetWidgets(pFormField, &widgets); if (widgets.empty()) - return CJS_Return::Success(pRuntime->NewNumber(-1)); + return CJS_Result::Success(pRuntime->NewNumber(-1)); v8::Local<v8::Array> PageArray = pRuntime->NewArray(); int i = 0; for (const auto& pObserved : widgets) { if (!pObserved) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pWidget = ToCPDFSDKWidget(pObserved.Get()); CPDFSDK_PageView* pPageView = pWidget->GetPageView(); if (!pPageView) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); pRuntime->PutArrayElement( PageArray, i, pRuntime->NewNumber(static_cast<int32_t>(pPageView->GetPageIndex()))); ++i; } - return CJS_Return::Success(PageArray); + return CJS_Result::Success(PageArray); } -CJS_Return CJS_Field::set_page(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); +CJS_Result CJS_Field::set_page(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Field::get_password(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_password(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD))); } -CJS_Return CJS_Field::set_password(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_password(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_print(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_print(CJS_Runtime* pRuntime) { CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewBoolean(!!(pWidget->GetFlags() & ANNOTFLAG_PRINT))); } -CJS_Return CJS_Field::set_print(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_print(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); std::vector<CPDF_FormField*> FieldArray = GetFormFields(); if (FieldArray.empty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); for (CPDF_FormField* pFormField : FieldArray) { if (m_nFormControlIndex < 0) { @@ -1632,7 +1632,7 @@ CJS_Return CJS_Field::set_print(CJS_Runtime* pRuntime, } if (m_nFormControlIndex >= pFormField->CountControls()) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); if (CPDF_FormControl* pFormControl = pFormField->GetControl(m_nFormControlIndex)) { @@ -1652,60 +1652,60 @@ CJS_Return CJS_Field::set_print(CJS_Runtime* pRuntime, } } } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_radios_in_unison(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_radios_in_unison(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kRadioButton) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON))); } -CJS_Return CJS_Field::set_radios_in_unison(CJS_Runtime* pRuntime, +CJS_Result 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::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_readonly(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_readonly(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_READONLY))); } -CJS_Return CJS_Field::set_readonly(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_readonly(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(); if (FieldArray.empty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_rect(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_rect(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CFX_FloatRect crRect = pWidget->GetRect(); v8::Local<v8::Array> rcArray = pRuntime->NewArray(); @@ -1718,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::Success(rcArray); + return CJS_Result::Success(rcArray); } -CJS_Return CJS_Field::set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { +CJS_Result CJS_Field::set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); v8::Local<v8::Array> rcArray = pRuntime->ToArray(vp); if (pRuntime->GetArrayLength(rcArray) < 4) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); float pArray[4]; pArray[0] = static_cast<float>( @@ -1747,92 +1747,92 @@ 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::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_required(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_required(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() == FormFieldType::kPushButton) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED))); } -CJS_Return CJS_Field::set_required(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_required(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(); if (FieldArray.empty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_rich_text(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_rich_text(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT))); } -CJS_Return CJS_Field::set_rich_text(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_rich_text(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_rich_value(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Field::get_rich_value(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Field::set_rich_value(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_rich_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_rotation(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_rotation(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(pRuntime->NewNumber(pFormControl->GetRotation())); + return CJS_Result::Success(pRuntime->NewNumber(pFormControl->GetRotation())); } -CJS_Return CJS_Field::set_rotation(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_rotation(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_stroke_color(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_stroke_color(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); int iColorType; pFormControl->GetBorderColor(iColorType); @@ -1853,38 +1853,38 @@ CJS_Return CJS_Field::get_stroke_color(CJS_Runtime* pRuntime) { pFormControl->GetOriginalBorderColor(2), pFormControl->GetOriginalBorderColor(3)); } else { - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); } v8::Local<v8::Value> array = CJS_Color::ConvertPWLColorToArray(pRuntime, color); if (array.IsEmpty()) - return CJS_Return::Success(pRuntime->NewArray()); - return CJS_Return::Success(array); + return CJS_Result::Success(pRuntime->NewArray()); + return CJS_Result::Success(array); } -CJS_Return CJS_Field::set_stroke_color(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_stroke_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_style(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_style(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!IsCheckBoxOrRadioButton(pFormField)) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); WideString csWCaption = pFormControl->GetNormalCaption(); ByteString csBCaption; @@ -1909,35 +1909,35 @@ CJS_Return CJS_Field::get_style(CJS_Runtime* pRuntime) { csBCaption = "check"; break; } - return CJS_Return::Success(pRuntime->NewString( + return CJS_Result::Success(pRuntime->NewString( WideString::FromLocal(csBCaption.AsStringView()).AsStringView())); } -CJS_Return CJS_Field::set_style(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_submit_name(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Field::get_submit_name(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Field::set_submit_name(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_submit_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_text_color(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_text_color(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); Optional<CFX_Color::Type> iColorType; FX_ARGB color; @@ -1959,142 +1959,142 @@ 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::Success(pRuntime->NewArray()); - return CJS_Return::Success(array); + return CJS_Result::Success(pRuntime->NewArray()); + return CJS_Result::Success(array); } -CJS_Return CJS_Field::set_text_color(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_text_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_text_font(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_text_font(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); FormFieldType fieldType = pFormField->GetFieldType(); if (fieldType != FormFieldType::kPushButton && fieldType != FormFieldType::kComboBox && fieldType != FormFieldType::kListBox && fieldType != FormFieldType::kTextField) { - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); } CPDF_Font* pFont = pFormControl->GetDefaultControlFont(); if (!pFont) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(pRuntime->NewString( + return CJS_Result::Success(pRuntime->NewString( WideString::FromLocal(pFont->GetBaseFont().AsStringView()) .AsStringView())); } -CJS_Return CJS_Field::set_text_font(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_text_font(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); if (pRuntime->ToWideString(vp).ToDefANSI().IsEmpty()) - return CJS_Return::Failure(JSMessage::kValueError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kValueError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_text_size(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_text_size(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); float fFontSize; CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance(); FieldAppearance.GetFont(&fFontSize); - return CJS_Return::Success(pRuntime->NewNumber(static_cast<int>(fFontSize))); + return CJS_Result::Success(pRuntime->NewNumber(static_cast<int>(fFontSize))); } -CJS_Return CJS_Field::set_text_size(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_text_size(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_type(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_type(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); switch (pFormField->GetFieldType()) { case FormFieldType::kUnknown: - return CJS_Return::Success(pRuntime->NewString(L"unknown")); + return CJS_Result::Success(pRuntime->NewString(L"unknown")); case FormFieldType::kPushButton: - return CJS_Return::Success(pRuntime->NewString(L"button")); + return CJS_Result::Success(pRuntime->NewString(L"button")); case FormFieldType::kCheckBox: - return CJS_Return::Success(pRuntime->NewString(L"checkbox")); + return CJS_Result::Success(pRuntime->NewString(L"checkbox")); case FormFieldType::kRadioButton: - return CJS_Return::Success(pRuntime->NewString(L"radiobutton")); + return CJS_Result::Success(pRuntime->NewString(L"radiobutton")); case FormFieldType::kComboBox: - return CJS_Return::Success(pRuntime->NewString(L"combobox")); + return CJS_Result::Success(pRuntime->NewString(L"combobox")); case FormFieldType::kListBox: - return CJS_Return::Success(pRuntime->NewString(L"listbox")); + return CJS_Result::Success(pRuntime->NewString(L"listbox")); case FormFieldType::kTextField: - return CJS_Return::Success(pRuntime->NewString(L"text")); + return CJS_Result::Success(pRuntime->NewString(L"text")); case FormFieldType::kSignature: - return CJS_Return::Success(pRuntime->NewString(L"signature")); + return CJS_Result::Success(pRuntime->NewString(L"signature")); default: - return CJS_Return::Success(pRuntime->NewString(L"unknown")); + return CJS_Result::Success(pRuntime->NewString(L"unknown")); } } -CJS_Return CJS_Field::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); +CJS_Result CJS_Field::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::get_user_name(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_user_name(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewString(pFormField->GetAlternateName().AsStringView())); } -CJS_Return CJS_Field::set_user_name(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_user_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_value(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_value(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); v8::Local<v8::Value> ret; switch (pFormField->GetFieldType()) { case FormFieldType::kPushButton: - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); case FormFieldType::kComboBox: case FormFieldType::kTextField: ret = pRuntime->NewString(pFormField->GetValue().AsStringView()); @@ -2140,13 +2140,13 @@ CJS_Return CJS_Field::get_value(CJS_Runtime* pRuntime) { ret = pRuntime->NewString(pFormField->GetValue().AsStringView()); break; } - return CJS_Return::Success(pRuntime->MaybeCoerceToNumber(ret)); + return CJS_Result::Success(pRuntime->MaybeCoerceToNumber(ret)); } -CJS_Return CJS_Field::set_value(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); std::vector<WideString> strArray; if (!vp.IsEmpty() && vp->IsArray()) { @@ -2164,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::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::get_value_as_string(CJS_Runtime* pRuntime) { +CJS_Result CJS_Field::get_value_as_string(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() == FormFieldType::kPushButton) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); if (pFormField->GetFieldType() == FormFieldType::kCheckBox) { if (!pFormField->CountControls()) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(pRuntime->NewString( + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success(pRuntime->NewString( pFormField->GetControl(0)->IsChecked() ? L"Yes" : L"Off")); } @@ -2186,32 +2186,32 @@ 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::Success(pRuntime->NewString( + return CJS_Result::Success(pRuntime->NewString( pFormField->GetControl(i)->GetExportValue().AsStringView())); } } - return CJS_Return::Success(pRuntime->NewString(L"Off")); + return CJS_Result::Success(pRuntime->NewString(L"Off")); } if (pFormField->GetFieldType() == FormFieldType::kListBox && (pFormField->CountSelectedItems() > 1)) { - return CJS_Return::Success(pRuntime->NewString(L"")); + return CJS_Result::Success(pRuntime->NewString(L"")); } - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewString(pFormField->GetValue().AsStringView())); } -CJS_Return CJS_Field::set_value_as_string(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_value_as_string(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::browseForFileToSubmit( +CJS_Result CJS_Field::browseForFileToSubmit( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) && (pFormField->GetFieldType() == FormFieldType::kTextField)) { @@ -2220,12 +2220,12 @@ CJS_Return CJS_Field::browseForFileToSubmit( pFormField->SetValue(wsFileName, NotificationOption::kDoNotNotify); UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, true, true); } - return CJS_Return::Success(); + return CJS_Result::Success(); } - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); } -CJS_Return CJS_Field::buttonGetCaption( +CJS_Result CJS_Field::buttonGetCaption( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { int nface = 0; @@ -2235,87 +2235,87 @@ CJS_Return CJS_Field::buttonGetCaption( CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (nface == 0) { - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewString(pFormControl->GetNormalCaption().AsStringView())); } if (nface == 1) { - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewString(pFormControl->GetDownCaption().AsStringView())); } if (nface == 2) { - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewString(pFormControl->GetRolloverCaption().AsStringView())); } - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); } -CJS_Return CJS_Field::buttonGetIcon( +CJS_Result CJS_Field::buttonGetIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() >= 1) { int nFace = pRuntime->ToInt32(params[0]); if (nFace < 0 || nFace > 2) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); } CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject( CJS_Icon::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); if (pObj.IsEmpty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pJS_Icon = static_cast<CJS_Icon*>(CFXJS_Engine::GetObjectPrivate(pObj)); - return pJS_Icon ? CJS_Return::Success(pJS_Icon->ToV8Object()) - : CJS_Return::Failure(JSMessage::kBadObjectError); + return pJS_Icon ? CJS_Result::Success(pJS_Icon->ToV8Object()) + : CJS_Result::Failure(JSMessage::kBadObjectError); } -CJS_Return CJS_Field::buttonImportIcon( +CJS_Result CJS_Field::buttonImportIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::buttonSetCaption( +CJS_Result CJS_Field::buttonSetCaption( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::buttonSetIcon( +CJS_Result CJS_Field::buttonSetIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::checkThisBox( +CJS_Result CJS_Field::checkThisBox( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { int iSize = params.size(); if (iSize < 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); int nWidget = pRuntime->ToInt32(params[0]); bool bCheckit = true; @@ -2324,61 +2324,61 @@ CJS_Return CJS_Field::checkThisBox( CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!IsCheckBoxOrRadioButton(pFormField)) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); if (nWidget < 0 || nWidget >= pFormField->CountControls()) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::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::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::clearItems( +CJS_Result CJS_Field::clearItems( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::defaultIsChecked( +CJS_Result CJS_Field::defaultIsChecked( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_bCanSet) - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); int iSize = params.size(); if (iSize < 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); int nWidget = pRuntime->ToInt32(params[0]); if (nWidget < 0 || nWidget >= pFormField->CountControls()) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewBoolean(IsCheckBoxOrRadioButton(pFormField))); } -CJS_Return CJS_Field::deleteItemAt( +CJS_Result CJS_Field::deleteItemAt( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::getArray( +CJS_Result CJS_Field::getArray( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(); if (FieldArray.empty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); std::vector<std::unique_ptr<WideString>> swSort; for (CPDF_FormField* pFormField : FieldArray) { @@ -2395,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::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pJSField = static_cast<CJS_Field*>(CFXJS_Engine::GetObjectPrivate(pObj)); @@ -2405,10 +2405,10 @@ CJS_Return CJS_Field::getArray( ? v8::Local<v8::Value>(pJSField->ToV8Object()) : v8::Local<v8::Value>()); } - return CJS_Return::Success(FormFieldArray); + return CJS_Result::Success(FormFieldArray); } -CJS_Return CJS_Field::getItemAt( +CJS_Result CJS_Field::getItemAt( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { int iSize = params.size(); @@ -2422,38 +2422,38 @@ CJS_Return CJS_Field::getItemAt( CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!IsComboBoxOrListBox(pFormField)) - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); if (nIdx == -1 || nIdx > pFormField->CountOptions()) nIdx = pFormField->CountOptions() - 1; if (!bExport) { - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewString(pFormField->GetOptionLabel(nIdx).AsStringView())); } WideString strval = pFormField->GetOptionValue(nIdx); if (strval.IsEmpty()) { - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewString(pFormField->GetOptionLabel(nIdx).AsStringView())); } - return CJS_Return::Success(pRuntime->NewString(strval.AsStringView())); + return CJS_Result::Success(pRuntime->NewString(strval.AsStringView())); } -CJS_Return CJS_Field::getLock(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::getLock(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::insertItemAt( +CJS_Result CJS_Field::insertItemAt( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::isBoxChecked( +CJS_Result CJS_Field::isBoxChecked( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { int nIndex = -1; @@ -2462,17 +2462,17 @@ CJS_Return CJS_Field::isBoxChecked( CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (nIndex < 0 || nIndex >= pFormField->CountControls()) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewBoolean((IsCheckBoxOrRadioButton(pFormField) && pFormField->GetControl(nIndex)->IsChecked() != 0))); } -CJS_Return CJS_Field::isDefaultChecked( +CJS_Result CJS_Field::isDefaultChecked( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { int nIndex = -1; @@ -2481,32 +2481,32 @@ CJS_Return CJS_Field::isDefaultChecked( CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (nIndex < 0 || nIndex >= pFormField->CountControls()) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); - return CJS_Return::Success(pRuntime->NewBoolean( + return CJS_Result::Success(pRuntime->NewBoolean( (IsCheckBoxOrRadioButton(pFormField) && pFormField->GetControl(nIndex)->IsDefaultChecked() != 0))); } -CJS_Return CJS_Field::setAction( +CJS_Result CJS_Field::setAction( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::setFocus( +CJS_Result CJS_Field::setFocus( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { CPDF_FormField* pFormField = GetFirstFormField(); if (!pFormField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); int32_t nCount = pFormField->CountControls(); if (nCount < 1) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDFSDK_Widget* pWidget = nullptr; @@ -2515,7 +2515,7 @@ CJS_Return CJS_Field::setFocus( } else { IPDF_Page* pPage = IPDFPageFromFPDFPage(m_pFormFillEnv->GetCurrentPage()); if (!pPage) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (CPDFSDK_PageView* pCurPageView = m_pFormFillEnv->GetPageView(pPage, true)) { for (int32_t i = 0; i < nCount; i++) { @@ -2535,63 +2535,63 @@ CJS_Return CJS_Field::setFocus( m_pFormFillEnv->SetFocusAnnot(&pObserved); } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::setItems( +CJS_Result CJS_Field::setItems( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Field::setLock(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::setLock(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::signatureGetModifications( +CJS_Result CJS_Field::signatureGetModifications( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::signatureGetSeedValue( +CJS_Result CJS_Field::signatureGetSeedValue( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::signatureInfo( +CJS_Result CJS_Field::signatureInfo( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::signatureSetSeedValue( +CJS_Result CJS_Field::signatureSetSeedValue( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::signatureSign( +CJS_Result CJS_Field::signatureSign( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::signatureValidate( +CJS_Result CJS_Field::signatureValidate( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Field::get_source(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Field::get_source(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Field::set_source(CJS_Runtime* pRuntime, +CJS_Result CJS_Field::set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } void CJS_Field::AddDelay_Int(FIELD_PROP prop, int32_t n) { diff --git a/fxjs/cjs_field.h b/fxjs/cjs_field.h index 75456b5a8d..69d6c8eb07 100644 --- a/fxjs/cjs_field.h +++ b/fxjs/cjs_field.h @@ -119,8 +119,8 @@ class CJS_Field : public CJS_Object { JS_STATIC_METHOD(signatureSign, CJS_Field); JS_STATIC_METHOD(signatureValidate, CJS_Field); - CJS_Return get_text_color(CJS_Runtime* pRuntime); - CJS_Return set_text_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_text_color(CJS_Runtime* pRuntime); + CJS_Result set_text_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); private: static int ObjDefnID; @@ -128,225 +128,225 @@ class CJS_Field : public CJS_Object { static const JSPropertySpec PropertySpecs[]; static const JSMethodSpec MethodSpecs[]; - CJS_Return get_alignment(CJS_Runtime* pRuntime); - CJS_Return set_alignment(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_alignment(CJS_Runtime* pRuntime); + CJS_Result set_alignment(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_border_style(CJS_Runtime* pRuntime); - CJS_Return set_border_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_border_style(CJS_Runtime* pRuntime); + CJS_Result set_border_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_button_align_x(CJS_Runtime* pRuntime); - CJS_Return set_button_align_x(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_button_align_x(CJS_Runtime* pRuntime); + CJS_Result set_button_align_x(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_button_align_y(CJS_Runtime* pRuntime); - CJS_Return set_button_align_y(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_button_align_y(CJS_Runtime* pRuntime); + CJS_Result set_button_align_y(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_button_fit_bounds(CJS_Runtime* pRuntime); - CJS_Return set_button_fit_bounds(CJS_Runtime* pRuntime, + CJS_Result get_button_fit_bounds(CJS_Runtime* pRuntime); + CJS_Result set_button_fit_bounds(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_button_position(CJS_Runtime* pRuntime); - CJS_Return set_button_position(CJS_Runtime* pRuntime, + CJS_Result get_button_position(CJS_Runtime* pRuntime); + CJS_Result set_button_position(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_button_scale_how(CJS_Runtime* pRuntime); - CJS_Return set_button_scale_how(CJS_Runtime* pRuntime, + CJS_Result get_button_scale_how(CJS_Runtime* pRuntime); + CJS_Result set_button_scale_how(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_button_scale_when(CJS_Runtime* pRuntime); - CJS_Return set_button_scale_when(CJS_Runtime* pRuntime, + CJS_Result get_button_scale_when(CJS_Runtime* pRuntime); + CJS_Result set_button_scale_when(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_calc_order_index(CJS_Runtime* pRuntime); - CJS_Return set_calc_order_index(CJS_Runtime* pRuntime, + CJS_Result get_calc_order_index(CJS_Runtime* pRuntime); + CJS_Result set_calc_order_index(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_char_limit(CJS_Runtime* pRuntime); - CJS_Return set_char_limit(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_char_limit(CJS_Runtime* pRuntime); + CJS_Result set_char_limit(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_comb(CJS_Runtime* pRuntime); - CJS_Return set_comb(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_comb(CJS_Runtime* pRuntime); + CJS_Result set_comb(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_commit_on_sel_change(CJS_Runtime* pRuntime); - CJS_Return set_commit_on_sel_change(CJS_Runtime* pRuntime, + CJS_Result get_commit_on_sel_change(CJS_Runtime* pRuntime); + CJS_Result set_commit_on_sel_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_current_value_indices(CJS_Runtime* pRuntime); - CJS_Return set_current_value_indices(CJS_Runtime* pRuntime, + CJS_Result get_current_value_indices(CJS_Runtime* pRuntime); + CJS_Result set_current_value_indices(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_default_style(CJS_Runtime* pRuntime); - CJS_Return set_default_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_default_style(CJS_Runtime* pRuntime); + CJS_Result set_default_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_default_value(CJS_Runtime* pRuntime); - CJS_Return set_default_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_default_value(CJS_Runtime* pRuntime); + CJS_Result set_default_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_do_not_scroll(CJS_Runtime* pRuntime); - CJS_Return set_do_not_scroll(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_do_not_scroll(CJS_Runtime* pRuntime); + CJS_Result set_do_not_scroll(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_do_not_spell_check(CJS_Runtime* pRuntime); - CJS_Return set_do_not_spell_check(CJS_Runtime* pRuntime, + CJS_Result get_do_not_spell_check(CJS_Runtime* pRuntime); + CJS_Result set_do_not_spell_check(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_delay(CJS_Runtime* pRuntime); - CJS_Return set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_delay(CJS_Runtime* pRuntime); + CJS_Result set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_display(CJS_Runtime* pRuntime); - CJS_Return set_display(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_display(CJS_Runtime* pRuntime); + CJS_Result set_display(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_doc(CJS_Runtime* pRuntime); - CJS_Return set_doc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_doc(CJS_Runtime* pRuntime); + CJS_Result set_doc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_editable(CJS_Runtime* pRuntime); - CJS_Return set_editable(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_editable(CJS_Runtime* pRuntime); + CJS_Result set_editable(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_export_values(CJS_Runtime* pRuntime); - CJS_Return set_export_values(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_export_values(CJS_Runtime* pRuntime); + CJS_Result set_export_values(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_file_select(CJS_Runtime* pRuntime); - CJS_Return set_file_select(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_file_select(CJS_Runtime* pRuntime); + CJS_Result set_file_select(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_fill_color(CJS_Runtime* pRuntime); - CJS_Return set_fill_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_fill_color(CJS_Runtime* pRuntime); + CJS_Result set_fill_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_hidden(CJS_Runtime* pRuntime); - CJS_Return set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_hidden(CJS_Runtime* pRuntime); + CJS_Result set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_highlight(CJS_Runtime* pRuntime); - CJS_Return set_highlight(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_highlight(CJS_Runtime* pRuntime); + CJS_Result set_highlight(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_line_width(CJS_Runtime* pRuntime); - CJS_Return set_line_width(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_line_width(CJS_Runtime* pRuntime); + CJS_Result set_line_width(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_multiline(CJS_Runtime* pRuntime); - CJS_Return set_multiline(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_multiline(CJS_Runtime* pRuntime); + CJS_Result set_multiline(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_multiple_selection(CJS_Runtime* pRuntime); - CJS_Return set_multiple_selection(CJS_Runtime* pRuntime, + CJS_Result get_multiple_selection(CJS_Runtime* pRuntime); + CJS_Result set_multiple_selection(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_name(CJS_Runtime* pRuntime); - CJS_Return set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_name(CJS_Runtime* pRuntime); + CJS_Result set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_num_items(CJS_Runtime* pRuntime); - CJS_Return set_num_items(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_num_items(CJS_Runtime* pRuntime); + CJS_Result set_num_items(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_page(CJS_Runtime* pRuntime); - CJS_Return set_page(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_page(CJS_Runtime* pRuntime); + CJS_Result set_page(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_password(CJS_Runtime* pRuntime); - CJS_Return set_password(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_password(CJS_Runtime* pRuntime); + CJS_Result set_password(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_print(CJS_Runtime* pRuntime); - CJS_Return set_print(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_print(CJS_Runtime* pRuntime); + CJS_Result set_print(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_radios_in_unison(CJS_Runtime* pRuntime); - CJS_Return set_radios_in_unison(CJS_Runtime* pRuntime, + CJS_Result get_radios_in_unison(CJS_Runtime* pRuntime); + CJS_Result set_radios_in_unison(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_readonly(CJS_Runtime* pRuntime); - CJS_Return set_readonly(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_readonly(CJS_Runtime* pRuntime); + CJS_Result set_readonly(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_rect(CJS_Runtime* pRuntime); - CJS_Return set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_rect(CJS_Runtime* pRuntime); + CJS_Result set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_required(CJS_Runtime* pRuntime); - CJS_Return set_required(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_required(CJS_Runtime* pRuntime); + CJS_Result set_required(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_rich_text(CJS_Runtime* pRuntime); - CJS_Return set_rich_text(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_rich_text(CJS_Runtime* pRuntime); + CJS_Result set_rich_text(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_rich_value(CJS_Runtime* pRuntime); - CJS_Return set_rich_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_rich_value(CJS_Runtime* pRuntime); + CJS_Result set_rich_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_rotation(CJS_Runtime* pRuntime); - CJS_Return set_rotation(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_rotation(CJS_Runtime* pRuntime); + CJS_Result set_rotation(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_stroke_color(CJS_Runtime* pRuntime); - CJS_Return set_stroke_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_stroke_color(CJS_Runtime* pRuntime); + CJS_Result set_stroke_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_style(CJS_Runtime* pRuntime); - CJS_Return set_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_style(CJS_Runtime* pRuntime); + CJS_Result set_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_submit_name(CJS_Runtime* pRuntime); - CJS_Return set_submit_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_submit_name(CJS_Runtime* pRuntime); + CJS_Result set_submit_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_text_font(CJS_Runtime* pRuntime); - CJS_Return set_text_font(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_text_font(CJS_Runtime* pRuntime); + CJS_Result set_text_font(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_text_size(CJS_Runtime* pRuntime); - CJS_Return set_text_size(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_text_size(CJS_Runtime* pRuntime); + CJS_Result set_text_size(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_type(CJS_Runtime* pRuntime); - CJS_Return set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_type(CJS_Runtime* pRuntime); + CJS_Result set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_user_name(CJS_Runtime* pRuntime); - CJS_Return set_user_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_user_name(CJS_Runtime* pRuntime); + CJS_Result set_user_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_value(CJS_Runtime* pRuntime); - CJS_Return set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_value(CJS_Runtime* pRuntime); + CJS_Result set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_value_as_string(CJS_Runtime* pRuntime); - CJS_Return set_value_as_string(CJS_Runtime* pRuntime, + CJS_Result get_value_as_string(CJS_Runtime* pRuntime); + CJS_Result set_value_as_string(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return get_source(CJS_Runtime* pRuntime); - CJS_Return set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_source(CJS_Runtime* pRuntime); + CJS_Result set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); - CJS_Return browseForFileToSubmit( + CJS_Result browseForFileToSubmit( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return buttonGetCaption(CJS_Runtime* pRuntime, + CJS_Result buttonGetCaption(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return buttonGetIcon(CJS_Runtime* pRuntime, + CJS_Result buttonGetIcon(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return buttonImportIcon(CJS_Runtime* pRuntime, + CJS_Result buttonImportIcon(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return buttonSetCaption(CJS_Runtime* pRuntime, + CJS_Result buttonSetCaption(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return buttonSetIcon(CJS_Runtime* pRuntime, + CJS_Result buttonSetIcon(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return checkThisBox(CJS_Runtime* pRuntime, + CJS_Result checkThisBox(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return clearItems(CJS_Runtime* pRuntime, + CJS_Result clearItems(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return defaultIsChecked(CJS_Runtime* pRuntime, + CJS_Result defaultIsChecked(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return deleteItemAt(CJS_Runtime* pRuntime, + CJS_Result deleteItemAt(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getArray(CJS_Runtime* pRuntime, + CJS_Result getArray(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getItemAt(CJS_Runtime* pRuntime, + CJS_Result getItemAt(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return getLock(CJS_Runtime* pRuntime, + CJS_Result getLock(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return insertItemAt(CJS_Runtime* pRuntime, + CJS_Result insertItemAt(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return isBoxChecked(CJS_Runtime* pRuntime, + CJS_Result isBoxChecked(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return isDefaultChecked(CJS_Runtime* pRuntime, + CJS_Result isDefaultChecked(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return setAction(CJS_Runtime* pRuntime, + CJS_Result setAction(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return setFocus(CJS_Runtime* pRuntime, + CJS_Result setFocus(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return setItems(CJS_Runtime* pRuntime, + CJS_Result setItems(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return setLock(CJS_Runtime* pRuntime, + CJS_Result setLock(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return signatureGetModifications( + CJS_Result signatureGetModifications( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return signatureGetSeedValue( + CJS_Result signatureGetSeedValue( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return signatureInfo(CJS_Runtime* pRuntime, + CJS_Result signatureInfo(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return signatureSetSeedValue( + CJS_Result signatureSetSeedValue( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return signatureSign(CJS_Runtime* pRuntime, + CJS_Result signatureSign(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return signatureValidate(CJS_Runtime* pRuntime, + CJS_Result signatureValidate(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); void SetDelay(bool bDelay); diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp index e747d6205c..ea8694fe14 100644 --- a/fxjs/cjs_global.cpp +++ b/fxjs/cjs_global.cpp @@ -40,7 +40,7 @@ void JSSpecialPropQuery(const char*, if (!pRuntime) return; - CJS_Return result = + CJS_Result result = pObj->QueryProperty(PropFromV8Prop(info.GetIsolate(), property).c_str()); info.GetReturnValue().Set(!result.HasError() ? 4 : 0); @@ -58,7 +58,7 @@ void JSSpecialPropGet(const char* class_name, if (!pRuntime) return; - CJS_Return result = pObj->GetProperty( + CJS_Result result = pObj->GetProperty( pRuntime, PropFromV8Prop(info.GetIsolate(), property).c_str()); if (result.HasError()) { @@ -83,7 +83,7 @@ void JSSpecialPropPut(const char* class_name, if (!pRuntime) return; - CJS_Return result = pObj->SetProperty( + CJS_Result result = pObj->SetProperty( pRuntime, PropFromV8Prop(info.GetIsolate(), property).c_str(), value); if (result.HasError()) { @@ -104,7 +104,7 @@ void JSSpecialPropDel(const char* class_name, if (!pRuntime) return; - CJS_Return result = pObj->DelProperty( + CJS_Result result = pObj->DelProperty( pRuntime, PropFromV8Prop(info.GetIsolate(), property).c_str()); if (result.HasError()) { // TODO(dsinclair): Should this set the pRuntime->Error result? @@ -224,52 +224,52 @@ void CJS_Global::Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv) { UpdateGlobalPersistentVariables(); } -CJS_Return CJS_Global::QueryProperty(const wchar_t* propname) { +CJS_Result CJS_Global::QueryProperty(const wchar_t* propname) { if (WideString(propname) != L"setPersistent") - return CJS_Return::Failure(JSMessage::kUnknownProperty); - return CJS_Return::Success(); + return CJS_Result::Failure(JSMessage::kUnknownProperty); + return CJS_Result::Success(); } -CJS_Return CJS_Global::DelProperty(CJS_Runtime* pRuntime, +CJS_Result 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::Failure(JSMessage::kUnknownProperty); + return CJS_Result::Failure(JSMessage::kUnknownProperty); it->second->bDeleted = true; - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Global::GetProperty(CJS_Runtime* pRuntime, +CJS_Result 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::Success(); + return CJS_Result::Success(); JSGlobalData* pData = it->second.get(); if (pData->bDeleted) - return CJS_Return::Success(); + return CJS_Result::Success(); switch (pData->nType) { case JS_GlobalDataType::NUMBER: - return CJS_Return::Success(pRuntime->NewNumber(pData->dData)); + return CJS_Result::Success(pRuntime->NewNumber(pData->dData)); case JS_GlobalDataType::BOOLEAN: - return CJS_Return::Success(pRuntime->NewBoolean(pData->bData)); + return CJS_Result::Success(pRuntime->NewBoolean(pData->bData)); case JS_GlobalDataType::STRING: - return CJS_Return::Success(pRuntime->NewString( + return CJS_Result::Success(pRuntime->NewString( WideString::FromLocal(pData->sData.AsStringView()).AsStringView())); case JS_GlobalDataType::OBJECT: - return CJS_Return::Success( + return CJS_Result::Success( v8::Local<v8::Object>::New(pRuntime->GetIsolate(), pData->pData)); case JS_GlobalDataType::NULLOBJ: - return CJS_Return::Success(pRuntime->NewNull()); + return CJS_Result::Success(pRuntime->NewNull()); default: break; } - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); } -CJS_Return CJS_Global::SetProperty(CJS_Runtime* pRuntime, +CJS_Result CJS_Global::SetProperty(CJS_Runtime* pRuntime, const wchar_t* propname, v8::Local<v8::Value> vp) { ByteString sPropName = WideString(propname).ToDefANSI(); @@ -298,23 +298,23 @@ CJS_Return CJS_Global::SetProperty(CJS_Runtime* pRuntime, } if (vp->IsUndefined()) { DelProperty(pRuntime, propname); - return CJS_Return::Success(); + return CJS_Result::Success(); } - return CJS_Return::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); } -CJS_Return CJS_Global::setPersistent( +CJS_Result CJS_Global::setPersistent( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); auto it = m_MapGlobal.find(pRuntime->ToWideString(params[0]).ToDefANSI()); if (it == m_MapGlobal.end() || it->second->bDeleted) - return CJS_Return::Failure(JSMessage::kGlobalNotFoundError); + return CJS_Result::Failure(JSMessage::kGlobalNotFoundError); it->second->bPersistent = pRuntime->ToBoolean(params[1]); - return CJS_Return::Success(); + return CJS_Result::Success(); } void CJS_Global::UpdateGlobalPersistentVariables() { @@ -497,7 +497,7 @@ void CJS_Global::DestroyGlobalPersisitentVariables() { m_MapGlobal.clear(); } -CJS_Return CJS_Global::SetGlobalVariables(const ByteString& propname, +CJS_Result CJS_Global::SetGlobalVariables(const ByteString& propname, JS_GlobalDataType nType, double dData, bool bData, @@ -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::Failure(JSMessage::kUnknownProperty); + return CJS_Result::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::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); } - return CJS_Return::Success(); + return CJS_Result::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::Failure(JSMessage::kObjectTypeError); + return CJS_Result::Failure(JSMessage::kObjectTypeError); } m_MapGlobal[propname] = std::move(pNewData); - return CJS_Return::Success(); + return CJS_Result::Success(); } diff --git a/fxjs/cjs_global.h b/fxjs/cjs_global.h index 51f872a782..491897adb3 100644 --- a/fxjs/cjs_global.h +++ b/fxjs/cjs_global.h @@ -39,14 +39,14 @@ class CJS_Global : public CJS_Object { CJS_Global(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime); ~CJS_Global() override; - CJS_Return DelProperty(CJS_Runtime* pRuntime, const wchar_t* propname); + CJS_Result DelProperty(CJS_Runtime* pRuntime, const wchar_t* propname); void Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv); - CJS_Return setPersistent(CJS_Runtime* pRuntime, + CJS_Result setPersistent(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return QueryProperty(const wchar_t* propname); - CJS_Return GetProperty(CJS_Runtime* pRuntime, const wchar_t* propname); - CJS_Return SetProperty(CJS_Runtime* pRuntime, + CJS_Result QueryProperty(const wchar_t* propname); + CJS_Result GetProperty(CJS_Runtime* pRuntime, const wchar_t* propname); + CJS_Result SetProperty(CJS_Runtime* pRuntime, const wchar_t* propname, v8::Local<v8::Value> vp); @@ -70,7 +70,7 @@ class CJS_Global : public CJS_Object { void UpdateGlobalPersistentVariables(); void CommitGlobalPersisitentVariables(CJS_Runtime* pRuntime); void DestroyGlobalPersisitentVariables(); - CJS_Return SetGlobalVariables(const ByteString& propname, + CJS_Result SetGlobalVariables(const ByteString& propname, JS_GlobalDataType nType, double dData, bool bData, diff --git a/fxjs/cjs_icon.cpp b/fxjs/cjs_icon.cpp index dca9eaf768..29fde8a6c5 100644 --- a/fxjs/cjs_icon.cpp +++ b/fxjs/cjs_icon.cpp @@ -29,10 +29,10 @@ 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::Success(pRuntime->NewString(m_swIconName.AsStringView())); +CJS_Result CJS_Icon::get_name(CJS_Runtime* pRuntime) { + return CJS_Result::Success(pRuntime->NewString(m_swIconName.AsStringView())); } -CJS_Return CJS_Icon::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kNotSupportedError); +CJS_Result CJS_Icon::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { + return CJS_Result::Failure(JSMessage::kNotSupportedError); } diff --git a/fxjs/cjs_icon.h b/fxjs/cjs_icon.h index 05fa43015f..6df671b874 100644 --- a/fxjs/cjs_icon.h +++ b/fxjs/cjs_icon.h @@ -27,8 +27,8 @@ class CJS_Icon : public CJS_Object { static const char kName[]; static const JSPropertySpec PropertySpecs[]; - CJS_Return get_name(CJS_Runtime* pRuntime); - CJS_Return set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); + CJS_Result get_name(CJS_Runtime* pRuntime); + CJS_Result set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp); WideString m_swIconName; }; diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp index 86a2a777b9..3cf70ccf3a 100644 --- a/fxjs/cjs_publicmethods.cpp +++ b/fxjs/cjs_publicmethods.cpp @@ -118,7 +118,7 @@ WideString CalcMergedString(const CJS_EventHandler* event, return prefix + change + postfix; } -template <CJS_Return (*F)(CJS_Runtime*, +template <CJS_Result (*F)(CJS_Runtime*, const std::vector<v8::Local<v8::Value>>&)> void JSGlobalFunc(const char* func_name_string, const v8::FunctionCallbackInfo<v8::Value>& info) { @@ -134,7 +134,7 @@ void JSGlobalFunc(const char* func_name_string, for (int i = 0; i < info.Length(); ++i) parameters.push_back(info[i]); - CJS_Return result = (*F)(pRuntime, parameters); + CJS_Result result = (*F)(pRuntime, parameters); if (result.HasError()) { pRuntime->Error( JSFormatErrorString(func_name_string, nullptr, result.Error())); @@ -869,22 +869,22 @@ WideString CJS_PublicMethods::MakeFormatDate(double dDate, // function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency, // bCurrencyPrepend) -CJS_Return CJS_PublicMethods::AFNumber_Format( +CJS_Result CJS_PublicMethods::AFNumber_Format( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { #if _FX_OS_ != _FX_OS_ANDROID_ if (params.size() != 6) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return::Failure(L"No event handler"); + return CJS_Result::Failure(L"No event handler"); WideString& Value = pEvent->Value(); ByteString strValue = StrTrim(Value.ToDefANSI()); if (strValue.IsEmpty()) - return CJS_Return::Success(); + return CJS_Result::Success(); int iDec = abs(pRuntime->ToInt32(params[0])); int iSepStyle = ValidStyleOrZero(pRuntime->ToInt32(params[1])); @@ -961,7 +961,7 @@ CJS_Return CJS_PublicMethods::AFNumber_Format( pRuntime->PutArrayElement(arColor, 2, pRuntime->NewNumber(0)); pRuntime->PutArrayElement(arColor, 3, pRuntime->NewNumber(0)); - CJS_Return result = fTarget->get_text_color(pRuntime); + CJS_Result result = fTarget->get_text_color(pRuntime); CFX_Color crProp = CJS_Color::ConvertArrayToPWLColor( pRuntime, pRuntime->ToArray(result.Return())); CFX_Color crColor = @@ -972,21 +972,21 @@ CJS_Return CJS_PublicMethods::AFNumber_Format( } } #endif - return CJS_Return::Success(); + return CJS_Result::Success(); } // function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, // bCurrencyPrepend) -CJS_Return CJS_PublicMethods::AFNumber_Keystroke( +CJS_Result CJS_PublicMethods::AFNumber_Keystroke( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() < 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::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::Success(); + return CJS_Result::Success(); NormalizeDecimalMarkW(&swTemp); if (!IsNumber(swTemp)) { pEvent->Rc() = false; WideString sError = JSGetStringFromID(JSMessage::kInvalidInputError); AlertIfPossible(pContext, sError); - return CJS_Return::Failure(sError); + return CJS_Result::Failure(sError); } // It happens after the last keystroke and before validating, - return CJS_Return::Success(); + return CJS_Result::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::Success(); + return CJS_Result::Success(); } } @@ -1031,7 +1031,7 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke( if (wstrChange[i] == cSep) { if (bHasSep) { pEvent->Rc() = false; - return CJS_Return::Success(); + return CJS_Result::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::Success(); + return CJS_Result::Success(); } // sign's position is not correct if (i != 0) { pEvent->Rc() = false; - return CJS_Return::Success(); + return CJS_Result::Success(); } if (pEvent->SelStart() != 0) { pEvent->Rc() = false; - return CJS_Return::Success(); + return CJS_Result::Success(); } bHasSign = true; continue; @@ -1056,31 +1056,31 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke( if (!std::iswdigit(wstrChange[i])) { pEvent->Rc() = false; - return CJS_Return::Success(); + return CJS_Result::Success(); } } val = CalcMergedString(pEvent, wstrValue, wstrChange); - return CJS_Return::Success(); + return CJS_Result::Success(); } // function AFPercent_Format(nDec, sepStyle) -CJS_Return CJS_PublicMethods::AFPercent_Format( +CJS_Result CJS_PublicMethods::AFPercent_Format( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { #if _FX_OS_ != _FX_OS_ANDROID_ if (params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); WideString& Value = pEvent->Value(); ByteString strValue = StrTrim(Value.ToDefANSI()); if (strValue.IsEmpty()) - return CJS_Return::Success(); + return CJS_Result::Success(); int iDec = abs(pRuntime->ToInt32(params[0])); int iSepStyle = ValidStyleOrZero(pRuntime->ToInt32(params[1])); @@ -1141,32 +1141,32 @@ CJS_Return CJS_PublicMethods::AFPercent_Format( strValue += '%'; Value = WideString::FromLocal(strValue.AsStringView()); #endif - return CJS_Return::Success(); + return CJS_Result::Success(); } // AFPercent_Keystroke(nDec, sepStyle) -CJS_Return CJS_PublicMethods::AFPercent_Keystroke( +CJS_Result CJS_PublicMethods::AFPercent_Keystroke( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { return AFNumber_Keystroke(pRuntime, params); } // function AFDate_FormatEx(cFormat) -CJS_Return CJS_PublicMethods::AFDate_FormatEx( +CJS_Result CJS_PublicMethods::AFDate_FormatEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); WideString& val = pEvent->Value(); WideString strValue = val; if (strValue.IsEmpty()) - return CJS_Return::Success(); + return CJS_Result::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::Failure(JSMessage::kParseDateError); + return CJS_Result::Failure(JSMessage::kParseDateError); } val = MakeFormatDate(dDate, sFormat); - return CJS_Return::Success(); + return CJS_Result::Success(); } double CJS_PublicMethods::MakeInterDate(const WideString& strValue) { @@ -1226,25 +1226,25 @@ double CJS_PublicMethods::MakeInterDate(const WideString& strValue) { } // AFDate_KeystrokeEx(cFormat) -CJS_Return CJS_PublicMethods::AFDate_KeystrokeEx( +CJS_Result CJS_PublicMethods::AFDate_KeystrokeEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) { - return CJS_Return::Failure( + return CJS_Result::Failure( WideString(L"AFDate_KeystrokeEx's parameter size not correct")); } CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (!pEvent->WillCommit()) - return CJS_Return::Success(); + return CJS_Result::Success(); if (!pEvent->m_pValue) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); const WideString& strValue = pEvent->Value(); if (strValue.IsEmpty()) - return CJS_Return::Success(); + return CJS_Result::Success(); WideString sFormat = pRuntime->ToWideString(params[0]); bool bWrongFormat = false; @@ -1255,14 +1255,14 @@ CJS_Return CJS_PublicMethods::AFDate_KeystrokeEx( AlertIfPossible(pContext, swMsg); pEvent->Rc() = false; } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_PublicMethods::AFDate_Format( +CJS_Result CJS_PublicMethods::AFDate_Format( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); static constexpr const wchar_t* cFormats[] = {L"m/d", L"m/d/yy", @@ -1287,11 +1287,11 @@ CJS_Return CJS_PublicMethods::AFDate_Format( } // AFDate_KeystrokeEx(cFormat) -CJS_Return CJS_PublicMethods::AFDate_Keystroke( +CJS_Result CJS_PublicMethods::AFDate_Keystroke( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); static constexpr const wchar_t* cFormats[] = {L"m/d", L"m/d/yy", @@ -1316,11 +1316,11 @@ CJS_Return CJS_PublicMethods::AFDate_Keystroke( } // function AFTime_Format(ptf) -CJS_Return CJS_PublicMethods::AFTime_Format( +CJS_Result CJS_PublicMethods::AFTime_Format( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::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"}; @@ -1332,11 +1332,11 @@ CJS_Return CJS_PublicMethods::AFTime_Format( return AFDate_FormatEx(pRuntime, newParams); } -CJS_Return CJS_PublicMethods::AFTime_Keystroke( +CJS_Result CJS_PublicMethods::AFTime_Keystroke( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::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"}; @@ -1348,29 +1348,29 @@ CJS_Return CJS_PublicMethods::AFTime_Keystroke( return AFDate_KeystrokeEx(pRuntime, newParams); } -CJS_Return CJS_PublicMethods::AFTime_FormatEx( +CJS_Result CJS_PublicMethods::AFTime_FormatEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { return AFDate_FormatEx(pRuntime, params); } -CJS_Return CJS_PublicMethods::AFTime_KeystrokeEx( +CJS_Result CJS_PublicMethods::AFTime_KeystrokeEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { return AFDate_KeystrokeEx(pRuntime, params); } // function AFSpecial_Format(psf) -CJS_Return CJS_PublicMethods::AFSpecial_Format( +CJS_Result CJS_PublicMethods::AFSpecial_Format( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); const WideString& wsSource = pEvent->Value(); WideString wsFormat; @@ -1393,29 +1393,29 @@ CJS_Return CJS_PublicMethods::AFSpecial_Format( } pEvent->Value() = CJS_Util::printx(wsFormat, wsSource); - return CJS_Return::Success(); + return CJS_Result::Success(); } // function AFSpecial_KeystrokeEx(mask) -CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx( +CJS_Result CJS_PublicMethods::AFSpecial_KeystrokeEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() < 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); const WideString& valEvent = pEvent->Value(); WideString wstrMask = pRuntime->ToWideString(params[0]); if (wstrMask.IsEmpty()) - return CJS_Return::Success(); + return CJS_Result::Success(); if (pEvent->WillCommit()) { if (valEvent.IsEmpty()) - return CJS_Return::Success(); + return CJS_Result::Success(); size_t iIndexMask = 0; for (; iIndexMask < valEvent.GetLength(); ++iIndexMask) { @@ -1428,12 +1428,12 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx( JSGetStringFromID(JSMessage::kInvalidInputError)); pEvent->Rc() = false; } - return CJS_Return::Success(); + return CJS_Result::Success(); } WideString& wideChange = pEvent->Change(); if (wideChange.IsEmpty()) - return CJS_Return::Success(); + return CJS_Result::Success(); WideString wChange = wideChange; size_t iIndexMask = pEvent->SelStart(); @@ -1442,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::Success(); + return CJS_Result::Success(); } if (iIndexMask >= wstrMask.GetLength() && !wChange.IsEmpty()) { AlertIfPossible(pContext, JSGetStringFromID(JSMessage::kParamTooLongError)); pEvent->Rc() = false; - return CJS_Return::Success(); + return CJS_Result::Success(); } for (size_t i = 0; i < wChange.GetLength(); ++i) { @@ -1456,7 +1456,7 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx( AlertIfPossible(pContext, JSGetStringFromID(JSMessage::kParamTooLongError)); pEvent->Rc() = false; - return CJS_Return::Success(); + return CJS_Result::Success(); } wchar_t wMask = wstrMask[iIndexMask]; if (!IsReservedMaskChar(wMask)) @@ -1464,25 +1464,25 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx( if (!MaskSatisfied(wChange[i], wMask)) { pEvent->Rc() = false; - return CJS_Return::Success(); + return CJS_Result::Success(); } iIndexMask++; } wideChange = std::move(wChange); - return CJS_Return::Success(); + return CJS_Result::Success(); } // function AFSpecial_Keystroke(psf) -CJS_Return CJS_PublicMethods::AFSpecial_Keystroke( +CJS_Result CJS_PublicMethods::AFSpecial_Keystroke( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); const char* cFormat = ""; switch (pRuntime->ToInt32(params[0])) { @@ -1508,11 +1508,11 @@ CJS_Return CJS_PublicMethods::AFSpecial_Keystroke( return AFSpecial_KeystrokeEx(pRuntime, params2); } -CJS_Return CJS_PublicMethods::AFMergeChange( +CJS_Result CJS_PublicMethods::AFMergeChange( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CJS_EventHandler* pEventHandler = pRuntime->GetCurrentEventContext()->GetEventHandler(); @@ -1522,18 +1522,18 @@ CJS_Return CJS_PublicMethods::AFMergeChange( swValue = pEventHandler->Value(); if (pEventHandler->WillCommit()) - return CJS_Return::Success(pRuntime->NewString(swValue.AsStringView())); + return CJS_Result::Success(pRuntime->NewString(swValue.AsStringView())); - return CJS_Return::Success(pRuntime->NewString( + return CJS_Result::Success(pRuntime->NewString( CalcMergedString(pEventHandler, swValue, pEventHandler->Change()) .AsStringView())); } -CJS_Return CJS_PublicMethods::AFParseDateEx( +CJS_Result CJS_PublicMethods::AFParseDateEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); WideString sValue = pRuntime->ToWideString(params[0]); WideString sFormat = pRuntime->ToWideString(params[1]); @@ -1542,27 +1542,27 @@ CJS_Return CJS_PublicMethods::AFParseDateEx( WideString swMsg = WideString::Format( JSGetStringFromID(JSMessage::kParseDateError).c_str(), sFormat.c_str()); AlertIfPossible(pRuntime->GetCurrentEventContext(), swMsg); - return CJS_Return::Failure(JSMessage::kParseDateError); + return CJS_Result::Failure(JSMessage::kParseDateError); } - return CJS_Return::Success(pRuntime->NewNumber(dDate)); + return CJS_Result::Success(pRuntime->NewNumber(dDate)); } -CJS_Return CJS_PublicMethods::AFSimple( +CJS_Result CJS_PublicMethods::AFSimple( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 3) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(pRuntime->NewNumber(static_cast<double>(AF_Simple( + return CJS_Result::Success(pRuntime->NewNumber(static_cast<double>(AF_Simple( pRuntime->ToWideString(params[0]).c_str(), pRuntime->ToDouble(params[1]), pRuntime->ToDouble(params[2]))))); } -CJS_Return CJS_PublicMethods::AFMakeNumber( +CJS_Result CJS_PublicMethods::AFMakeNumber( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); WideString ws = pRuntime->ToWideString(params[0]); NormalizeDecimalMarkW(&ws); @@ -1570,19 +1570,19 @@ CJS_Return CJS_PublicMethods::AFMakeNumber( v8::Local<v8::Value> val = pRuntime->MaybeCoerceToNumber(pRuntime->NewString(ws.AsStringView())); if (!val->IsNumber()) - return CJS_Return::Success(pRuntime->NewNumber(0)); + return CJS_Result::Success(pRuntime->NewNumber(0)); - return CJS_Return::Success(val); + return CJS_Result::Success(val); } -CJS_Return CJS_PublicMethods::AFSimple_Calculate( +CJS_Result CJS_PublicMethods::AFSimple_Calculate( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if ((params[1].IsEmpty() || !params[1]->IsArray()) && !params[1]->IsString()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CPDFSDK_InterForm* pReaderInterForm = pRuntime->GetFormFillEnv()->GetInterForm(); @@ -1663,24 +1663,24 @@ CJS_Return CJS_PublicMethods::AFSimple_Calculate( pRuntime->ToWideString(pRuntime->NewNumber(dValue)); } - return CJS_Return::Success(); + return CJS_Result::Success(); } // This function validates the current event to ensure that its value is // within the specified range. -CJS_Return CJS_PublicMethods::AFRange_Validate( +CJS_Result CJS_PublicMethods::AFRange_Validate( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 4) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (pEvent->Value().IsEmpty()) - return CJS_Return::Success(); + return CJS_Result::Success(); double dEentValue = atof(pEvent->Value().ToDefANSI().c_str()); bool bGreaterThan = pRuntime->ToBoolean(params[0]); @@ -1711,14 +1711,14 @@ CJS_Return CJS_PublicMethods::AFRange_Validate( AlertIfPossible(pContext, swMsg); pEvent->Rc() = false; } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_PublicMethods::AFExtractNums( +CJS_Result CJS_PublicMethods::AFExtractNums( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); WideString str = pRuntime->ToWideString(params[0]); if (str.GetLength() > 0 && IsDigitSeparatorOrDecimalMark(str[0])) @@ -1742,7 +1742,7 @@ CJS_Return CJS_PublicMethods::AFExtractNums( pRuntime->NewString(sPart.AsStringView())); } if (pRuntime->GetArrayLength(nums) > 0) - return CJS_Return::Success(nums); + return CJS_Result::Success(nums); - return CJS_Return::Success(pRuntime->NewUndefined()); + return CJS_Result::Success(pRuntime->NewUndefined()); } diff --git a/fxjs/cjs_publicmethods.h b/fxjs/cjs_publicmethods.h index 89603ca79d..8ec35626af 100644 --- a/fxjs/cjs_publicmethods.h +++ b/fxjs/cjs_publicmethods.h @@ -26,69 +26,69 @@ class CJS_PublicMethods : public CJS_Object { static WideString MakeFormatDate(double dDate, const WideString& format); static bool IsNumber(const WideString& str); - static CJS_Return AFNumber_Format( + static CJS_Result AFNumber_Format( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFNumber_Keystroke( + static CJS_Result AFNumber_Keystroke( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFPercent_Format( + static CJS_Result AFPercent_Format( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFPercent_Keystroke( + static CJS_Result AFPercent_Keystroke( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFDate_FormatEx( + static CJS_Result AFDate_FormatEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFDate_KeystrokeEx( + static CJS_Result AFDate_KeystrokeEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFDate_Format( + static CJS_Result AFDate_Format( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFDate_Keystroke( + static CJS_Result AFDate_Keystroke( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFTime_FormatEx( + static CJS_Result AFTime_FormatEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFTime_KeystrokeEx( + static CJS_Result AFTime_KeystrokeEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFTime_Format( + static CJS_Result AFTime_Format( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFTime_Keystroke( + static CJS_Result AFTime_Keystroke( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFSpecial_Format( + static CJS_Result AFSpecial_Format( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFSpecial_Keystroke( + static CJS_Result AFSpecial_Keystroke( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFSpecial_KeystrokeEx( + static CJS_Result AFSpecial_KeystrokeEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFSimple(CJS_Runtime* pRuntime, + static CJS_Result AFSimple(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFMakeNumber( + static CJS_Result AFMakeNumber( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFSimple_Calculate( + static CJS_Result AFSimple_Calculate( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFRange_Validate( + static CJS_Result AFRange_Validate( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFMergeChange( + static CJS_Result AFMergeChange( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFParseDateEx( + static CJS_Result AFParseDateEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - static CJS_Return AFExtractNums( + static CJS_Result AFExtractNums( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); diff --git a/fxjs/cjs_publicmethods_embeddertest.cpp b/fxjs/cjs_publicmethods_embeddertest.cpp index 623ce6801e..5f241f391e 100644 --- a/fxjs/cjs_publicmethods_embeddertest.cpp +++ b/fxjs/cjs_publicmethods_embeddertest.cpp @@ -196,7 +196,7 @@ TEST_F(CJS_PublicMethodsEmbedderTest, AFSimple_CalculateSum) { params.push_back(runtime.NewString("SUM")); params.push_back(ary); - CJS_Return ret = CJS_PublicMethods::AFSimple_Calculate(&runtime, params); + CJS_Result ret = CJS_PublicMethods::AFSimple_Calculate(&runtime, params); UnloadPage(page); runtime.GetCurrentEventContext()->GetEventHandler()->m_pValue = nullptr; @@ -237,7 +237,7 @@ TEST_F(CJS_PublicMethodsEmbedderTest, AFNumber_Keystroke) { params.push_back(runtime.NewString(L"-10")); params.push_back(runtime.NewString(L"")); - CJS_Return ret = CJS_PublicMethods::AFNumber_Keystroke(&runtime, params); + CJS_Result ret = CJS_PublicMethods::AFNumber_Keystroke(&runtime, params); EXPECT_TRUE(valid); EXPECT_TRUE(!ret.HasError()); EXPECT_TRUE(!ret.HasReturn()); diff --git a/fxjs/cjs_report.cpp b/fxjs/cjs_report.cpp index aa4ef0224b..1cebefe2cc 100644 --- a/fxjs/cjs_report.cpp +++ b/fxjs/cjs_report.cpp @@ -35,15 +35,15 @@ CJS_Report::CJS_Report(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime) CJS_Report::~CJS_Report() = default; -CJS_Return CJS_Report::writeText( +CJS_Result CJS_Report::writeText( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported, but do not return error. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Report::save(CJS_Runtime* pRuntime, +CJS_Result CJS_Report::save(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported, but do not return error. - return CJS_Return::Success(); + return CJS_Result::Success(); } diff --git a/fxjs/cjs_report.h b/fxjs/cjs_report.h index f9d1dc8ce4..a969b41f55 100644 --- a/fxjs/cjs_report.h +++ b/fxjs/cjs_report.h @@ -27,9 +27,9 @@ class CJS_Report : public CJS_Object { static const char kName[]; static const JSMethodSpec MethodSpecs[]; - CJS_Return save(CJS_Runtime* pRuntime, + CJS_Result save(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return writeText(CJS_Runtime* pRuntime, + CJS_Result writeText(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); }; diff --git a/fxjs/cjs_result.cpp b/fxjs/cjs_result.cpp new file mode 100644 index 0000000000..92f2b0bb82 --- /dev/null +++ b/fxjs/cjs_result.cpp @@ -0,0 +1,19 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "fxjs/cjs_result.h" + +CJS_Result::CJS_Result() {} + +CJS_Result::CJS_Result(v8::Local<v8::Value> ret) : return_(ret) {} + +CJS_Result::CJS_Result(const WideString& err) : error_(err) {} + +CJS_Result::CJS_Result(JSMessage id) : CJS_Result(JSGetStringFromID(id)) {} + +CJS_Result::CJS_Result(const CJS_Result&) = default; + +CJS_Result::~CJS_Result() = default; diff --git a/fxjs/cjs_return.h b/fxjs/cjs_result.h index 99a2af60a6..dc65d18c73 100644 --- a/fxjs/cjs_return.h +++ b/fxjs/cjs_result.h @@ -4,39 +4,39 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef FXJS_CJS_RETURN_H_ -#define FXJS_CJS_RETURN_H_ +#ifndef FXJS_CJS_RESULT_H_ +#define FXJS_CJS_RESULT_H_ #include "fxjs/cfxjs_engine.h" #include "fxjs/js_resources.h" #include "third_party/base/optional.h" -class CJS_Return { +class CJS_Result { public: // 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); + // CJS_Result(JS_ERROR_CODE); // // instead of // // if (error) - // return CJS_Return(JS_ERROR_CODE); + // return CJS_Result(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_Result Success() WARN_UNUSED_RESULT { return CJS_Result(); } + static CJS_Result Success(v8::Local<v8::Value> value) WARN_UNUSED_RESULT { + return CJS_Result(value); } - static CJS_Return Failure(const WideString& str) WARN_UNUSED_RESULT { - return CJS_Return(str); + static CJS_Result Failure(const WideString& str) WARN_UNUSED_RESULT { + return CJS_Result(str); } - static CJS_Return Failure(JSMessage id) WARN_UNUSED_RESULT { - return CJS_Return(id); + static CJS_Result Failure(JSMessage id) WARN_UNUSED_RESULT { + return CJS_Result(id); } - CJS_Return(const CJS_Return&); - ~CJS_Return(); + CJS_Result(const CJS_Result&); + ~CJS_Result(); bool HasError() const { return error_.has_value(); } WideString Error() const { return error_.value(); } @@ -45,13 +45,13 @@ 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. + CJS_Result(); // Successful but empty return. + explicit CJS_Result(v8::Local<v8::Value>); // Successful return with value. + explicit CJS_Result(const WideString&); // Error with custom message. + explicit CJS_Result(JSMessage id); // Error with stock message. Optional<WideString> error_; v8::Local<v8::Value> return_; }; -#endif // FXJS_CJS_RETURN_H_ +#endif // FXJS_CJS_RESULT_H_ diff --git a/fxjs/cjs_return.cpp b/fxjs/cjs_return.cpp deleted file mode 100644 index 49ad54ab07..0000000000 --- a/fxjs/cjs_return.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "fxjs/cjs_return.h" - -CJS_Return::CJS_Return() {} - -CJS_Return::CJS_Return(v8::Local<v8::Value> ret) : return_(ret) {} - -CJS_Return::CJS_Return(const WideString& err) : error_(err) {} - -CJS_Return::CJS_Return(JSMessage id) : CJS_Return(JSGetStringFromID(id)) {} - -CJS_Return::CJS_Return(const CJS_Return&) = default; - -CJS_Return::~CJS_Return() = default; diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp index 54a74f2952..0c40b10117 100644 --- a/fxjs/cjs_util.cpp +++ b/fxjs/cjs_util.cpp @@ -84,11 +84,11 @@ CJS_Util::CJS_Util(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime) CJS_Util::~CJS_Util() = default; -CJS_Return CJS_Util::printf(CJS_Runtime* pRuntime, +CJS_Result 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::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); std::wstring unsafe_fmt_string(pRuntime->ToWideString(params[0]).c_str()); std::vector<std::wstring> unsafe_conversion_specifiers; @@ -143,21 +143,21 @@ CJS_Return CJS_Util::printf(CJS_Runtime* pRuntime, } c_strResult.erase(c_strResult.begin()); - return CJS_Return::Success(pRuntime->NewString(c_strResult.c_str())); + return CJS_Result::Success(pRuntime->NewString(c_strResult.c_str())); } -CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime, +CJS_Result 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::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (params[1].IsEmpty() || !params[1]->IsDate()) - return CJS_Return::Failure(JSMessage::kSecondParamNotDateError); + return CJS_Result::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::Failure(JSMessage::kSecondParamInvalidDateError); + return CJS_Result::Failure(JSMessage::kSecondParamInvalidDateError); double date = JS_LocalTime(pRuntime->ToDouble(v8_date)); int year = JS_GetYearFromTime(date); @@ -183,18 +183,18 @@ CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime, month, day, hour, min, sec); break; default: - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); } - return CJS_Return::Success(pRuntime->NewString(swResult.AsStringView())); + return CJS_Result::Success(pRuntime->NewString(swResult.AsStringView())); } if (!params[0]->IsString()) - return CJS_Return::Failure(JSMessage::kTypeError); + return CJS_Result::Failure(JSMessage::kTypeError); // We don't support XFAPicture at the moment. if (iSize > 2 && pRuntime->ToBoolean(params[2])) - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); // Convert PDF-style format specifiers to wcsftime specifiers. Remove any // pre-existing %-directives before inserting our own. @@ -214,7 +214,7 @@ CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime, } if (year < 0) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); const TbConvertAdditional cTableAd[] = { {L"m", month}, {L"d", day}, @@ -249,15 +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::Success(pRuntime->NewString(cFormat.c_str())); + return CJS_Result::Success(pRuntime->NewString(cFormat.c_str())); } -CJS_Return CJS_Util::printx(CJS_Runtime* pRuntime, +CJS_Result CJS_Util::printx(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() < 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewString(printx(pRuntime->ToWideString(params[0]), pRuntime->ToWideString(params[1])) .AsStringView())); @@ -361,10 +361,10 @@ WideString CJS_Util::printx(const WideString& wsFormat, return wsResult; } -CJS_Return CJS_Util::scand(CJS_Runtime* pRuntime, +CJS_Result CJS_Util::scand(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() < 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); WideString sFormat = pRuntime->ToWideString(params[0]); WideString sDate = pRuntime->ToWideString(params[1]); @@ -372,23 +372,23 @@ CJS_Return CJS_Util::scand(CJS_Runtime* pRuntime, if (sDate.GetLength() > 0) dDate = CJS_PublicMethods::MakeRegularDate(sDate, sFormat, nullptr); if (std::isnan(dDate)) - return CJS_Return::Success(pRuntime->NewUndefined()); + return CJS_Result::Success(pRuntime->NewUndefined()); - return CJS_Return::Success(pRuntime->NewDate(dDate)); + return CJS_Result::Success(pRuntime->NewDate(dDate)); } -CJS_Return CJS_Util::byteToChar( +CJS_Result CJS_Util::byteToChar( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() < 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); int arg = pRuntime->ToInt32(params[0]); if (arg < 0 || arg > 255) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); WideString wStr(static_cast<wchar_t>(arg)); - return CJS_Return::Success(pRuntime->NewString(wStr.AsStringView())); + return CJS_Result::Success(pRuntime->NewString(wStr.AsStringView())); } // Ensure that sFormat contains at most one well-understood printf formatting diff --git a/fxjs/cjs_util.h b/fxjs/cjs_util.h index 611443c330..f948afb691 100644 --- a/fxjs/cjs_util.h +++ b/fxjs/cjs_util.h @@ -43,15 +43,15 @@ class CJS_Util : public CJS_Object { static int ParseDataType(std::wstring* sFormat); - CJS_Return printd(CJS_Runtime* pRuntime, + CJS_Result printd(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return printf(CJS_Runtime* pRuntime, + CJS_Result printf(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return printx(CJS_Runtime* pRuntime, + CJS_Result printx(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return scand(CJS_Runtime* pRuntime, + CJS_Result scand(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); - CJS_Return byteToChar(CJS_Runtime* pRuntime, + CJS_Result byteToChar(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params); }; diff --git a/fxjs/fxjse.h b/fxjs/fxjse.h index c28cc6c919..2171c2340f 100644 --- a/fxjs/fxjse.h +++ b/fxjs/fxjse.h @@ -23,7 +23,7 @@ extern const char kClassTag[]; class CFXJSE_Arguments; class CFXJSE_FormCalcContext; class CFXJSE_Value; -class CJS_Return; +class CJS_Result; class CXFA_Object; // C++ object which is retrieved from v8 object's slot. @@ -39,7 +39,7 @@ class CFXJSE_HostObject { CFXJSE_HostObject(); }; -typedef CJS_Return (*FXJSE_MethodCallback)( +typedef CJS_Result (*FXJSE_MethodCallback)( const v8::FunctionCallbackInfo<v8::Value>& info, const WideString& functionName); typedef void (*FXJSE_FuncCallback)(CFXJSE_Value* pThis, diff --git a/fxjs/js_define.h b/fxjs/js_define.h index ae1557eb02..0d8c43f86e 100644 --- a/fxjs/js_define.h +++ b/fxjs/js_define.h @@ -13,7 +13,7 @@ #include "core/fxcrt/unowned_ptr.h" #include "fxjs/cfxjs_engine.h" #include "fxjs/cjs_object.h" -#include "fxjs/cjs_return.h" +#include "fxjs/cjs_result.h" #include "fxjs/js_resources.h" #include "third_party/base/ptr_util.h" @@ -70,7 +70,7 @@ UnownedPtr<C> JSGetObject(v8::Local<v8::Object> obj) { return UnownedPtr<C>(static_cast<C*>(pJSObj)); } -template <class C, CJS_Return (C::*M)(CJS_Runtime*)> +template <class C, CJS_Result (C::*M)(CJS_Runtime*)> void JSPropGetter(const char* prop_name_string, const char* class_name_string, v8::Local<v8::String> property, @@ -83,7 +83,7 @@ void JSPropGetter(const char* prop_name_string, if (!pRuntime) return; - CJS_Return result = (pObj.Get()->*M)(pRuntime); + CJS_Result result = (pObj.Get()->*M)(pRuntime); if (result.HasError()) { pRuntime->Error(JSFormatErrorString(class_name_string, prop_name_string, result.Error())); @@ -94,7 +94,7 @@ void JSPropGetter(const char* prop_name_string, info.GetReturnValue().Set(result.Return()); } -template <class C, CJS_Return (C::*M)(CJS_Runtime*, v8::Local<v8::Value>)> +template <class C, CJS_Result (C::*M)(CJS_Runtime*, v8::Local<v8::Value>)> void JSPropSetter(const char* prop_name_string, const char* class_name_string, v8::Local<v8::String> property, @@ -108,7 +108,7 @@ void JSPropSetter(const char* prop_name_string, if (!pRuntime) return; - CJS_Return result = (pObj.Get()->*M)(pRuntime, value); + CJS_Result result = (pObj.Get()->*M)(pRuntime, value); if (result.HasError()) { pRuntime->Error(JSFormatErrorString(class_name_string, prop_name_string, result.Error())); @@ -116,7 +116,7 @@ void JSPropSetter(const char* prop_name_string, } template <class C, - CJS_Return (C::*M)(CJS_Runtime*, + CJS_Result (C::*M)(CJS_Runtime*, const std::vector<v8::Local<v8::Value>>&)> void JSMethod(const char* method_name_string, const char* class_name_string, @@ -133,7 +133,7 @@ void JSMethod(const char* method_name_string, for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) parameters.push_back(info[i]); - CJS_Return result = (pObj.Get()->*M)(pRuntime, parameters); + CJS_Result result = (pObj.Get()->*M)(pRuntime, parameters); if (result.HasError()) { pRuntime->Error(JSFormatErrorString(class_name_string, method_name_string, result.Error())); diff --git a/fxjs/jse_define.h b/fxjs/jse_define.h index ddc9d591f1..373917fe6a 100644 --- a/fxjs/jse_define.h +++ b/fxjs/jse_define.h @@ -10,25 +10,25 @@ #include <vector> #include "fxjs/cfx_v8.h" -#include "fxjs/cjs_return.h" +#include "fxjs/cjs_result.h" template <class C, - CJS_Return (C::*M)(CFX_V8* runtime, + CJS_Result (C::*M)(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params)> -CJS_Return JSMethod(C* node, +CJS_Result JSMethod(C* node, CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { return (node->*M)(runtime, params); } #define JSE_METHOD(method_name, class_name) \ - static CJS_Return method_name##_static( \ + static CJS_Result method_name##_static( \ CJX_Object* node, CFX_V8* runtime, \ const std::vector<v8::Local<v8::Value>>& params) { \ return JSMethod<class_name, &class_name::method_name>( \ static_cast<class_name*>(node), runtime, params); \ } \ - CJS_Return method_name(CFX_V8* runtime, \ + CJS_Result method_name(CFX_V8* runtime, \ const std::vector<v8::Local<v8::Value>>& params) #define JSE_PROP(prop_name) \ diff --git a/fxjs/xfa/cjx_container.cpp b/fxjs/xfa/cjx_container.cpp index ddf5ba12ef..6b0d488a4f 100644 --- a/fxjs/xfa/cjx_container.cpp +++ b/fxjs/xfa/cjx_container.cpp @@ -24,17 +24,17 @@ CJX_Container::CJX_Container(CXFA_Node* node) : CJX_Node(node) { CJX_Container::~CJX_Container() {} -CJS_Return CJX_Container::getDelta( +CJS_Result CJX_Container::getDelta( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Container::getDeltas( +CJS_Result CJX_Container::getDeltas( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { auto* pEngine = static_cast<CFXJSE_Engine*>(runtime); - return CJS_Return::Success(pEngine->NewXFAObject( + return CJS_Result::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 b03e24161d..dbd672a702 100644 --- a/fxjs/xfa/cjx_datawindow.cpp +++ b/fxjs/xfa/cjx_datawindow.cpp @@ -24,28 +24,28 @@ CJX_DataWindow::CJX_DataWindow(CScript_DataWindow* window) CJX_DataWindow::~CJX_DataWindow() {} -CJS_Return CJX_DataWindow::moveCurrentRecord( +CJS_Result CJX_DataWindow::moveCurrentRecord( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_DataWindow::record( +CJS_Result CJX_DataWindow::record( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_DataWindow::gotoRecord( +CJS_Result CJX_DataWindow::gotoRecord( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_DataWindow::isRecordGroup( +CJS_Result CJX_DataWindow::isRecordGroup( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } void CJX_DataWindow::recordsBefore(CFXJSE_Value* pValue, diff --git a/fxjs/xfa/cjx_delta.cpp b/fxjs/xfa/cjx_delta.cpp index 791fd213df..edf17b9469 100644 --- a/fxjs/xfa/cjx_delta.cpp +++ b/fxjs/xfa/cjx_delta.cpp @@ -20,12 +20,12 @@ CJX_Delta::CJX_Delta(CXFA_Delta* delta) : CJX_Object(delta) { CJX_Delta::~CJX_Delta() {} -CJS_Return CJX_Delta::restore(CFX_V8* runtime, +CJS_Result CJX_Delta::restore(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } void CJX_Delta::currentValue(CFXJSE_Value* pValue, diff --git a/fxjs/xfa/cjx_desc.cpp b/fxjs/xfa/cjx_desc.cpp index 03379cedbc..004fa447b1 100644 --- a/fxjs/xfa/cjx_desc.cpp +++ b/fxjs/xfa/cjx_desc.cpp @@ -20,12 +20,12 @@ CJX_Desc::CJX_Desc(CXFA_Desc* desc) : CJX_Node(desc) { CJX_Desc::~CJX_Desc() {} -CJS_Return CJX_Desc::metadata(CFX_V8* runtime, +CJS_Result CJX_Desc::metadata(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 0 && params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(runtime->NewString("")); + return CJS_Result::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 3adf1e39a8..b80f8f3754 100644 --- a/fxjs/xfa/cjx_eventpseudomodel.cpp +++ b/fxjs/xfa/cjx_eventpseudomodel.cpp @@ -169,41 +169,41 @@ void CJX_EventPseudoModel::target(CFXJSE_Value* pValue, Property(pValue, XFA_Event::Target, bSetting); } -CJS_Return CJX_EventPseudoModel::emit( +CJS_Result CJX_EventPseudoModel::emit( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); if (!pScriptContext) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); if (!pEventParam) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_FFWidgetHandler* pWidgetHandler = pNotify->GetWidgetHandler(); if (!pWidgetHandler) - return CJS_Return::Success(); + return CJS_Result::Success(); pWidgetHandler->ProcessEvent(pEventParam->m_pTarget.Get(), pEventParam); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_EventPseudoModel::reset( +CJS_Result CJX_EventPseudoModel::reset( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); if (!pScriptContext) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); if (pEventParam) pEventParam->Reset(); - return CJS_Return::Success(); + return CJS_Result::Success(); } void CJX_EventPseudoModel::Property(CFXJSE_Value* pValue, diff --git a/fxjs/xfa/cjx_exclgroup.cpp b/fxjs/xfa/cjx_exclgroup.cpp index 3a7f9dd2fb..a5ddc940f1 100644 --- a/fxjs/xfa/cjx_exclgroup.cpp +++ b/fxjs/xfa/cjx_exclgroup.cpp @@ -30,67 +30,67 @@ CJX_ExclGroup::CJX_ExclGroup(CXFA_ExclGroup* group) : CJX_Node(group) { CJX_ExclGroup::~CJX_ExclGroup() {} -CJS_Return CJX_ExclGroup::execEvent( +CJS_Result CJX_ExclGroup::execEvent( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); execSingleEventByName(runtime->ToWideString(params[0]).AsStringView(), XFA_Element::ExclGroup); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_ExclGroup::execInitialize( +CJS_Result CJX_ExclGroup::execInitialize( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (pNotify) pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false, true); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_ExclGroup::execCalculate( +CJS_Result CJX_ExclGroup::execCalculate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (pNotify) pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false, true); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_ExclGroup::execValidate( +CJS_Result CJX_ExclGroup::execValidate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* notify = GetDocument()->GetNotify(); if (!notify) - return CJS_Return::Success(runtime->NewBoolean(false)); + return CJS_Result::Success(runtime->NewBoolean(false)); int32_t iRet = notify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate, false, true); - return CJS_Return::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error)); + return CJS_Result::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error)); } -CJS_Return CJX_ExclGroup::selectedMember( +CJS_Result CJX_ExclGroup::selectedMember( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_Node* node = GetXFANode(); if (!node->IsWidgetReady()) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); CXFA_Node* pReturnNode = nullptr; if (params.empty()) { @@ -100,14 +100,14 @@ CJS_Return CJX_ExclGroup::selectedMember( runtime->ToWideString(params[0]).AsStringView(), true); } if (!pReturnNode) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); CFXJSE_Value* value = GetDocument()->GetScriptContext()->GetJSValueFromMap(pReturnNode); if (!value) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); - return CJS_Return::Success( + return CJS_Result::Success( value->DirectGetValue().Get(runtime->GetIsolate())); } diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp index c1210b9808..bb84588ece 100644 --- a/fxjs/xfa/cjx_field.cpp +++ b/fxjs/xfa/cjx_field.cpp @@ -38,175 +38,175 @@ CJX_Field::CJX_Field(CXFA_Field* field) : CJX_Container(field) { CJX_Field::~CJX_Field() {} -CJS_Return CJX_Field::clearItems( +CJS_Result CJX_Field::clearItems( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { CXFA_Node* node = GetXFANode(); if (node->IsWidgetReady()) node->DeleteItem(-1, true, false); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Field::execEvent( +CJS_Result CJX_Field::execEvent( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::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::Success(); + return CJS_Result::Success(); - return CJS_Return::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error)); + return CJS_Result::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error)); } -CJS_Return CJX_Field::execInitialize( +CJS_Result CJX_Field::execInitialize( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (pNotify) { pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false, false); } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Field::deleteItem( +CJS_Result CJX_Field::deleteItem( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_Node* node = GetXFANode(); if (!node->IsWidgetReady()) - return CJS_Return::Success(); + return CJS_Result::Success(); bool bValue = node->DeleteItem(runtime->ToInt32(params[0]), true, true); - return CJS_Return::Success(runtime->NewBoolean(bValue)); + return CJS_Result::Success(runtime->NewBoolean(bValue)); } -CJS_Return CJX_Field::getSaveItem( +CJS_Result CJX_Field::getSaveItem( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); int32_t iIndex = runtime->ToInt32(params[0]); if (iIndex < 0) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); CXFA_Node* node = GetXFANode(); if (!node->IsWidgetReady()) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); Optional<WideString> value = node->GetChoiceListItem(iIndex, true); if (!value) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); - return CJS_Return::Success( + return CJS_Result::Success( runtime->NewString(value->UTF8Encode().AsStringView())); } -CJS_Return CJX_Field::boundItem( +CJS_Result CJX_Field::boundItem( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_Node* node = GetXFANode(); if (!node->IsWidgetReady()) - return CJS_Return::Success(); + return CJS_Result::Success(); WideString value = runtime->ToWideString(params[0]); WideString boundValue = node->GetItemValue(value.AsStringView()); - return CJS_Return::Success( + return CJS_Result::Success( runtime->NewString(boundValue.UTF8Encode().AsStringView())); } -CJS_Return CJX_Field::getItemState( +CJS_Result CJX_Field::getItemState( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_Node* node = GetXFANode(); if (!node->IsWidgetReady()) - return CJS_Return::Success(); + return CJS_Result::Success(); int32_t state = node->GetItemState(runtime->ToInt32(params[0])); - return CJS_Return::Success(runtime->NewBoolean(state != 0)); + return CJS_Result::Success(runtime->NewBoolean(state != 0)); } -CJS_Return CJX_Field::execCalculate( +CJS_Result CJX_Field::execCalculate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (pNotify) { pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false, false); } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Field::getDisplayItem( +CJS_Result CJX_Field::getDisplayItem( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); int32_t iIndex = runtime->ToInt32(params[0]); if (iIndex < 0) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); CXFA_Node* node = GetXFANode(); if (!node->IsWidgetReady()) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); Optional<WideString> value = node->GetChoiceListItem(iIndex, false); if (!value) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); - return CJS_Return::Success( + return CJS_Result::Success( runtime->NewString(value->UTF8Encode().AsStringView())); } -CJS_Return CJX_Field::setItemState( +CJS_Result CJX_Field::setItemState( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_Node* node = GetXFANode(); if (!node->IsWidgetReady()) - return CJS_Return::Success(); + return CJS_Result::Success(); int32_t iIndex = runtime->ToInt32(params[0]); if (runtime->ToInt32(params[1]) != 0) { node->SetItemState(iIndex, true, true, true, true); - return CJS_Return::Success(); + return CJS_Result::Success(); } if (node->GetItemState(iIndex)) node->SetItemState(iIndex, false, true, true, true); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Field::addItem(CFX_V8* runtime, +CJS_Result CJX_Field::addItem(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1 && params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_Node* node = GetXFANode(); if (!node->IsWidgetReady()) - return CJS_Return::Success(); + return CJS_Result::Success(); WideString label; if (params.size() >= 1) @@ -217,22 +217,22 @@ CJS_Return CJX_Field::addItem(CFX_V8* runtime, value = runtime->ToWideString(params[1]); node->InsertItem(label, value, true); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Field::execValidate( +CJS_Result CJX_Field::execValidate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(runtime->NewBoolean(false)); + return CJS_Result::Success(runtime->NewBoolean(false)); int32_t iRet = pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate, false, false); - return CJS_Return::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error)); + return CJS_Result::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 3bbdb72bfb..a59edd01ef 100644 --- a/fxjs/xfa/cjx_form.cpp +++ b/fxjs/xfa/cjx_form.cpp @@ -31,16 +31,16 @@ CJX_Form::CJX_Form(CXFA_Form* form) : CJX_Model(form) { CJX_Form::~CJX_Form() {} -CJS_Return CJX_Form::formNodes( +CJS_Result CJX_Form::formNodes( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_Node* pDataNode = ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0])); if (!pDataNode) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); std::vector<CXFA_Node*> formItems; CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(GetDocument()); @@ -49,79 +49,79 @@ CJS_Return CJX_Form::formNodes( CFXJSE_Value* value = GetDocument()->GetScriptContext()->GetJSValueFromMap(pFormNodes); if (!value) - return CJS_Return::Success(runtime->NewNull()); - return CJS_Return::Success( + return CJS_Result::Success(runtime->NewNull()); + return CJS_Result::Success( value->DirectGetValue().Get(runtime->GetIsolate())); } -CJS_Return CJX_Form::remerge(CFX_V8* runtime, +CJS_Result CJX_Form::remerge(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); GetDocument()->DoDataRemerge(true); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Form::execInitialize( +CJS_Result CJX_Form::execInitialize( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (pNotify) pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false, true); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Form::recalculate( +CJS_Result CJX_Form::recalculate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { CXFA_EventParam* pEventParam = GetDocument()->GetScriptContext()->GetEventParam(); if (pEventParam->m_eType == XFA_EVENT_Calculate || pEventParam->m_eType == XFA_EVENT_InitCalculate) { - return CJS_Return::Success(); + return CJS_Result::Success(); } if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify || runtime->ToInt32(params[0]) != 0) - return CJS_Return::Success(); + return CJS_Result::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::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Form::execCalculate( +CJS_Result CJX_Form::execCalculate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (pNotify) pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false, true); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Form::execValidate( +CJS_Result CJX_Form::execValidate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 0) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(runtime->NewBoolean(false)); + return CJS_Result::Success(runtime->NewBoolean(false)); int32_t iRet = pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate, false, true); - return CJS_Return::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error)); + return CJS_Result::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error)); } diff --git a/fxjs/xfa/cjx_hostpseudomodel.cpp b/fxjs/xfa/cjx_hostpseudomodel.cpp index 8cf82b30d4..748641ab8a 100644 --- a/fxjs/xfa/cjx_hostpseudomodel.cpp +++ b/fxjs/xfa/cjx_hostpseudomodel.cpp @@ -239,37 +239,37 @@ void CJX_HostPseudoModel::name(CFXJSE_Value* pValue, pNotify->GetAppProvider()->GetAppName().UTF8Encode().AsStringView()); } -CJS_Return CJX_HostPseudoModel::gotoURL( +CJS_Result CJX_HostPseudoModel::gotoURL( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!GetDocument()->GetScriptContext()->IsRunAtClient()) - return CJS_Return::Success(); + return CJS_Result::Success(); if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_FFDoc* hDoc = pNotify->GetHDOC(); WideString URL = runtime->ToWideString(params[0]); hDoc->GetDocEnvironment()->GotoURL(hDoc, URL); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_HostPseudoModel::openList( +CJS_Result CJX_HostPseudoModel::openList( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!GetDocument()->GetScriptContext()->IsRunAtClient()) - return CJS_Return::Success(); + return CJS_Result::Success(); if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(); + return CJS_Result::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::Success(); + return CJS_Result::Success(); CXFA_Object* pObject = pScriptContext->GetThisObject(); if (!pObject) - return CJS_Return::Success(); + return CJS_Result::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::Success(); + return CJS_Result::Success(); pNode = resolveNodeRS.objects.front()->AsNode(); } CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_FFWidget* hWidget = XFA_GetWidgetFromLayoutItem(pDocLayout->GetLayoutItem(pNode)); if (!hWidget) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_FFDoc* hDoc = pNotify->GetHDOC(); hDoc->GetDocEnvironment()->SetFocusWidget(hDoc, hWidget); pNotify->OpenDropDownList(hWidget); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_HostPseudoModel::response( +CJS_Result CJX_HostPseudoModel::response( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty() || params.size() > 4) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(); + return CJS_Result::Success(); WideString question; if (params.size() >= 1) @@ -339,25 +339,25 @@ CJS_Return CJX_HostPseudoModel::response( WideString answer = pNotify->GetAppProvider()->Response(question, title, defaultAnswer, mark); - return CJS_Return::Success( + return CJS_Result::Success( runtime->NewString(answer.UTF8Encode().AsStringView())); } -CJS_Return CJX_HostPseudoModel::documentInBatch( +CJS_Result CJX_HostPseudoModel::documentInBatch( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(runtime->NewNumber(0)); + return CJS_Result::Success(runtime->NewNumber(0)); } -CJS_Return CJX_HostPseudoModel::resetData( +CJS_Result CJX_HostPseudoModel::resetData( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() > 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(); + return CJS_Result::Success(); WideString expression; if (params.size() >= 1) @@ -365,7 +365,7 @@ CJS_Return CJX_HostPseudoModel::resetData( if (expression.IsEmpty()) { pNotify->ResetData(nullptr); - return CJS_Return::Success(); + return CJS_Result::Success(); } int32_t iStart = 0; @@ -376,11 +376,11 @@ CJS_Return CJX_HostPseudoModel::resetData( iStart = FilterName(expression.AsStringView(), iStart, wsName); CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); if (!pScriptContext) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_Object* pObject = pScriptContext->GetThisObject(); if (!pObject) - return CJS_Return::Success(); + return CJS_Result::Success(); uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; @@ -396,42 +396,42 @@ CJS_Return CJX_HostPseudoModel::resetData( if (!pNode) pNotify->ResetData(nullptr); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_HostPseudoModel::beep( +CJS_Result CJX_HostPseudoModel::beep( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!GetDocument()->GetScriptContext()->IsRunAtClient()) - return CJS_Return::Success(); + return CJS_Result::Success(); if (params.size() > 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(); + return CJS_Result::Success(); uint32_t dwType = 4; if (params.size() >= 1) dwType = runtime->ToInt32(params[0]); pNotify->GetAppProvider()->Beep(dwType); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_HostPseudoModel::setFocus( +CJS_Result CJX_HostPseudoModel::setFocus( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!GetDocument()->GetScriptContext()->IsRunAtClient()) - return CJS_Return::Success(); + return CJS_Result::Success(); if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_Node* pNode = nullptr; if (params.size() >= 1) { @@ -441,11 +441,11 @@ CJS_Return CJX_HostPseudoModel::setFocus( } else if (params[0]->IsString()) { CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); if (!pScriptContext) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_Object* pObject = pScriptContext->GetThisObject(); if (!pObject) - return CJS_Return::Success(); + return CJS_Result::Success(); uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; @@ -454,47 +454,47 @@ CJS_Return CJX_HostPseudoModel::setFocus( pObject, runtime->ToWideString(params[0]).AsStringView(), &resolveNodeRS, dwFlag, nullptr); if (!iRet || !resolveNodeRS.objects.front()->IsNode()) - return CJS_Return::Success(); + return CJS_Result::Success(); pNode = resolveNodeRS.objects.front()->AsNode(); } } pNotify->SetFocusWidgetNode(pNode); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_HostPseudoModel::getFocus( +CJS_Result CJX_HostPseudoModel::getFocus( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_Node* pNode = pNotify->GetFocusWidgetNode(); if (!pNode) - return CJS_Return::Success(); + return CJS_Result::Success(); CFXJSE_Value* value = GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode); if (!value) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); - return CJS_Return::Success( + return CJS_Result::Success( value->DirectGetValue().Get(runtime->GetIsolate())); } -CJS_Return CJX_HostPseudoModel::messageBox( +CJS_Result CJX_HostPseudoModel::messageBox( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!GetDocument()->GetScriptContext()->IsRunAtClient()) - return CJS_Return::Success(); + return CJS_Result::Success(); if (params.empty() || params.size() > 4) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(); + return CJS_Result::Success(); WideString message; if (params.size() >= 1) @@ -520,27 +520,27 @@ CJS_Return CJX_HostPseudoModel::messageBox( int32_t iValue = pNotify->GetAppProvider()->MsgBox(message, title, messageType, buttonType); - return CJS_Return::Success(runtime->NewNumber(iValue)); + return CJS_Result::Success(runtime->NewNumber(iValue)); } -CJS_Return CJX_HostPseudoModel::documentCountInBatch( +CJS_Result CJX_HostPseudoModel::documentCountInBatch( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(runtime->NewNumber(0)); + return CJS_Result::Success(runtime->NewNumber(0)); } -CJS_Return CJX_HostPseudoModel::print( +CJS_Result CJX_HostPseudoModel::print( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!GetDocument()->GetScriptContext()->IsRunAtClient()) - return CJS_Return::Success(); + return CJS_Result::Success(); if (params.size() != 8) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(); + return CJS_Result::Success(); uint32_t dwOptions = 0; if (runtime->ToBoolean(params[0])) @@ -561,27 +561,27 @@ CJS_Return CJX_HostPseudoModel::print( CXFA_FFDoc* hDoc = pNotify->GetHDOC(); hDoc->GetDocEnvironment()->Print(hDoc, nStartPage, nEndPage, dwOptions); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_HostPseudoModel::importData( +CJS_Result CJX_HostPseudoModel::importData( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty() || params.size() > 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_HostPseudoModel::exportData( +CJS_Result CJX_HostPseudoModel::exportData( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty() || params.size() > 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(); + return CJS_Result::Success(); WideString filePath; if (params.size() >= 1) @@ -593,39 +593,39 @@ CJS_Return CJX_HostPseudoModel::exportData( CXFA_FFDoc* hDoc = pNotify->GetHDOC(); hDoc->GetDocEnvironment()->ExportData(hDoc, filePath, XDP); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_HostPseudoModel::pageUp( +CJS_Result CJX_HostPseudoModel::pageUp( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_FFDoc* hDoc = pNotify->GetHDOC(); int32_t nCurPage = hDoc->GetDocEnvironment()->GetCurrentPage(hDoc); int32_t nNewPage = 0; if (nCurPage <= 1) - return CJS_Return::Success(); + return CJS_Result::Success(); nNewPage = nCurPage - 1; hDoc->GetDocEnvironment()->SetCurrentPage(hDoc, nNewPage); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_HostPseudoModel::pageDown( +CJS_Result CJX_HostPseudoModel::pageDown( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(); + return CJS_Result::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::Success(); + return CJS_Result::Success(); int32_t nNewPage = 0; if (nCurPage >= nPageCount) @@ -634,5 +634,5 @@ CJS_Return CJX_HostPseudoModel::pageDown( nNewPage = nCurPage + 1; hDoc->GetDocEnvironment()->SetCurrentPage(hDoc, nNewPage); - return CJS_Return::Success(); + return CJS_Result::Success(); } diff --git a/fxjs/xfa/cjx_instancemanager.cpp b/fxjs/xfa/cjx_instancemanager.cpp index ce00af18e6..b36fddc4fc 100644 --- a/fxjs/xfa/cjx_instancemanager.cpp +++ b/fxjs/xfa/cjx_instancemanager.cpp @@ -133,15 +133,15 @@ int32_t CJX_InstanceManager::MoveInstance(int32_t iTo, int32_t iFrom) { return 0; } -CJS_Return CJX_InstanceManager::moveInstance( +CJS_Result CJX_InstanceManager::moveInstance( CFX_V8* runtime, 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::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); if (params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::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::Success(); + return CJS_Result::Success(); CXFA_Node* pToInstance = GetXFANode()->GetItemIfExists(iTo); if (pToInstance && pToInstance->GetElementType() == XFA_Element::Subform) @@ -161,32 +161,32 @@ CJS_Return CJX_InstanceManager::moveInstance( pNotify->RunSubformIndexChange(pFromInstance); } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_InstanceManager::removeInstance( +CJS_Result CJX_InstanceManager::removeInstance( CFX_V8* runtime, 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::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); int32_t iIndex = runtime->ToInt32(params[0]); int32_t iCount = GetXFANode()->GetCount(); if (iIndex < 0 || iIndex >= iCount) - return CJS_Return::Failure(JSMessage::kInvalidInputError); + return CJS_Result::Failure(JSMessage::kInvalidInputError); CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); int32_t iMin = occur ? occur->GetMin() : CXFA_Occur::kDefaultMin; if (iCount - 1 < iMin) - return CJS_Return::Failure(JSMessage::kTooManyOccurances); + return CJS_Result::Failure(JSMessage::kTooManyOccurances); CXFA_Node* pRemoveInstance = GetXFANode()->GetItemIfExists(iIndex); if (!pRemoveInstance) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); GetXFANode()->RemoveItem(pRemoveInstance, true); @@ -205,32 +205,32 @@ CJS_Return CJX_InstanceManager::removeInstance( pLayoutPro->AddChangedContainer( ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_InstanceManager::setInstances( +CJS_Result CJX_InstanceManager::setInstances( CFX_V8* runtime, 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::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); SetInstances(runtime->ToInt32(params[0])); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_InstanceManager::addInstance( +CJS_Result CJX_InstanceManager::addInstance( CFX_V8* runtime, 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::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); if (!params.empty() && params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::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::Failure(JSMessage::kTooManyOccurances); + return CJS_Result::Failure(JSMessage::kTooManyOccurances); CXFA_Node* pNewInstance = GetXFANode()->CreateInstanceIfPossible(fFlags); if (!pNewInstance) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); GetXFANode()->InsertItem(pNewInstance, iCount, iCount, false); @@ -262,21 +262,21 @@ CJS_Return CJX_InstanceManager::addInstance( CFXJSE_Value* value = GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance); if (!value) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); - return CJS_Return::Success( + return CJS_Result::Success( value->DirectGetValue().Get(runtime->GetIsolate())); } -CJS_Return CJX_InstanceManager::insertInstance( +CJS_Result CJX_InstanceManager::insertInstance( CFX_V8* runtime, 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::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); if (params.size() != 1 && params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); int32_t iIndex = runtime->ToInt32(params[0]); bool bBind = false; @@ -285,16 +285,16 @@ CJS_Return CJX_InstanceManager::insertInstance( int32_t iCount = GetXFANode()->GetCount(); if (iIndex < 0 || iIndex > iCount) - return CJS_Return::Failure(JSMessage::kInvalidInputError); + return CJS_Result::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::Failure(JSMessage::kInvalidInputError); + return CJS_Result::Failure(JSMessage::kInvalidInputError); CXFA_Node* pNewInstance = GetXFANode()->CreateInstanceIfPossible(bBind); if (!pNewInstance) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); GetXFANode()->InsertItem(pNewInstance, iIndex, iCount, true); @@ -311,9 +311,9 @@ CJS_Return CJX_InstanceManager::insertInstance( CFXJSE_Value* value = GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance); if (!value) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); - return CJS_Return::Success( + return CJS_Result::Success( value->DirectGetValue().Get(runtime->GetIsolate())); } diff --git a/fxjs/xfa/cjx_layoutpseudomodel.cpp b/fxjs/xfa/cjx_layoutpseudomodel.cpp index aa73135607..6985c5061f 100644 --- a/fxjs/xfa/cjx_layoutpseudomodel.cpp +++ b/fxjs/xfa/cjx_layoutpseudomodel.cpp @@ -69,17 +69,17 @@ void CJX_LayoutPseudoModel::ready(CFXJSE_Value* pValue, pValue->SetBoolean(iStatus >= 2); } -CJS_Return CJX_LayoutPseudoModel::HWXY( +CJS_Result CJX_LayoutPseudoModel::HWXY( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params, XFA_LAYOUTMODEL_HWXY layoutModel) { if (params.empty() || params.size() > 3) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_Node* pNode = ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0])); if (!pNode) - return CJS_Return::Success(); + return CJS_Result::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::Success(); + return CJS_Result::Success(); CXFA_ContentLayoutItem* pLayoutItem = ToContentLayoutItem(pDocLayout->GetLayoutItem(pNode)); if (!pLayoutItem) - return CJS_Return::Success(); + return CJS_Result::Success(); while (iIndex > 0 && pLayoutItem) { pLayoutItem = pLayoutItem->GetNext(); @@ -103,7 +103,7 @@ CJS_Return CJX_LayoutPseudoModel::HWXY( } if (!pLayoutItem) - return CJS_Return::Success(runtime->NewNumber(0.0)); + return CJS_Result::Success(runtime->NewNumber(0.0)); CXFA_Measurement measure; CFX_RectF rtRect = pLayoutItem->GetRect(true); @@ -124,39 +124,39 @@ CJS_Return CJX_LayoutPseudoModel::HWXY( float fValue = measure.ToUnit(CXFA_Measurement::GetUnitFromString(unit.AsStringView())); - return CJS_Return::Success( + return CJS_Result::Success( runtime->NewNumber(FXSYS_round(fValue * 1000) / 1000.0f)); } -CJS_Return CJX_LayoutPseudoModel::h( +CJS_Result CJX_LayoutPseudoModel::h( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { return HWXY(runtime, params, XFA_LAYOUTMODEL_H); } -CJS_Return CJX_LayoutPseudoModel::w( +CJS_Result CJX_LayoutPseudoModel::w( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { return HWXY(runtime, params, XFA_LAYOUTMODEL_W); } -CJS_Return CJX_LayoutPseudoModel::x( +CJS_Result CJX_LayoutPseudoModel::x( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { return HWXY(runtime, params, XFA_LAYOUTMODEL_X); } -CJS_Return CJX_LayoutPseudoModel::y( +CJS_Result CJX_LayoutPseudoModel::y( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { return HWXY(runtime, params, XFA_LAYOUTMODEL_Y); } -CJS_Return CJX_LayoutPseudoModel::NumberedPageCount(CFX_V8* runtime, +CJS_Result CJX_LayoutPseudoModel::NumberedPageCount(CFX_V8* runtime, bool bNumbered) { CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) - return CJS_Return::Success(); + return CJS_Result::Success(); int32_t iPageCount = 0; int32_t iPageNum = pDocLayout->CountPages(); @@ -173,42 +173,42 @@ CJS_Return CJX_LayoutPseudoModel::NumberedPageCount(CFX_V8* runtime, } else { iPageCount = iPageNum; } - return CJS_Return::Success(runtime->NewNumber(iPageCount)); + return CJS_Result::Success(runtime->NewNumber(iPageCount)); } -CJS_Return CJX_LayoutPseudoModel::pageCount( +CJS_Result CJX_LayoutPseudoModel::pageCount( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { return NumberedPageCount(runtime, true); } -CJS_Return CJX_LayoutPseudoModel::pageSpan( +CJS_Result CJX_LayoutPseudoModel::pageSpan( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_Node* pNode = ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0])); if (!pNode) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_ContentLayoutItem* pLayoutItem = ToContentLayoutItem(pDocLayout->GetLayoutItem(pNode)); if (!pLayoutItem) - return CJS_Return::Success(runtime->NewNumber(-1)); + return CJS_Result::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::Success(runtime->NewNumber(iPageSpan)); + return CJS_Result::Success(runtime->NewNumber(iPageSpan)); } -CJS_Return CJX_LayoutPseudoModel::page( +CJS_Result CJX_LayoutPseudoModel::page( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { return PageInternals(runtime, params, false); @@ -345,11 +345,11 @@ std::vector<CXFA_Node*> CJX_LayoutPseudoModel::GetObjArray( return retArray; } -CJS_Return CJX_LayoutPseudoModel::pageContent( +CJS_Result CJX_LayoutPseudoModel::pageContent( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty() || params.size() > 3) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); int32_t iIndex = 0; if (params.size() >= 1) @@ -365,41 +365,41 @@ CJS_Return CJX_LayoutPseudoModel::pageContent( CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) - return CJS_Return::Success(); + return CJS_Result::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::Success(static_cast<CFXJSE_Engine*>(runtime)->NewXFAObject( + return CJS_Result::Success(static_cast<CFXJSE_Engine*>(runtime)->NewXFAObject( pArrayNodeList.release(), GetDocument()->GetScriptContext()->GetJseNormalClass()->GetTemplate())); } -CJS_Return CJX_LayoutPseudoModel::absPageCount( +CJS_Result CJX_LayoutPseudoModel::absPageCount( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { return NumberedPageCount(runtime, false); } -CJS_Return CJX_LayoutPseudoModel::absPageCountInBatch( +CJS_Result CJX_LayoutPseudoModel::absPageCountInBatch( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(runtime->NewNumber(0)); + return CJS_Result::Success(runtime->NewNumber(0)); } -CJS_Return CJX_LayoutPseudoModel::sheetCountInBatch( +CJS_Result CJX_LayoutPseudoModel::sheetCountInBatch( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(runtime->NewNumber(0)); + return CJS_Result::Success(runtime->NewNumber(0)); } -CJS_Return CJX_LayoutPseudoModel::relayout( +CJS_Result CJX_LayoutPseudoModel::relayout( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { CXFA_Node* pRootNode = GetDocument()->GetRoot(); @@ -411,78 +411,78 @@ CJS_Return CJX_LayoutPseudoModel::relayout( pLayoutProcessor->AddChangedContainer(pContentRootNode); pLayoutProcessor->SetForceReLayout(true); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_LayoutPseudoModel::absPageSpan( +CJS_Result CJX_LayoutPseudoModel::absPageSpan( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { return pageSpan(runtime, params); } -CJS_Return CJX_LayoutPseudoModel::absPageInBatch( +CJS_Result CJX_LayoutPseudoModel::absPageInBatch( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(runtime->NewNumber(0)); + return CJS_Result::Success(runtime->NewNumber(0)); } -CJS_Return CJX_LayoutPseudoModel::sheetInBatch( +CJS_Result CJX_LayoutPseudoModel::sheetInBatch( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(runtime->NewNumber(0)); + return CJS_Result::Success(runtime->NewNumber(0)); } -CJS_Return CJX_LayoutPseudoModel::sheet( +CJS_Result CJX_LayoutPseudoModel::sheet( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { return PageInternals(runtime, params, true); } -CJS_Return CJX_LayoutPseudoModel::relayoutPageArea( +CJS_Result CJX_LayoutPseudoModel::relayoutPageArea( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_LayoutPseudoModel::sheetCount( +CJS_Result CJX_LayoutPseudoModel::sheetCount( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { return NumberedPageCount(runtime, false); } -CJS_Return CJX_LayoutPseudoModel::absPage( +CJS_Result CJX_LayoutPseudoModel::absPage( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { return PageInternals(runtime, params, true); } -CJS_Return CJX_LayoutPseudoModel::PageInternals( +CJS_Result CJX_LayoutPseudoModel::PageInternals( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params, bool bAbsPage) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_Node* pNode = ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0])); if (!pNode) - return CJS_Return::Success(runtime->NewNumber(0)); + return CJS_Result::Success(runtime->NewNumber(0)); CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) - return CJS_Return::Success(); + return CJS_Result::Success(); CXFA_ContentLayoutItem* pLayoutItem = ToContentLayoutItem(pDocLayout->GetLayoutItem(pNode)); if (!pLayoutItem) - return CJS_Return::Success(runtime->NewNumber(-1)); + return CJS_Result::Success(runtime->NewNumber(-1)); int32_t iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); - return CJS_Return::Success(runtime->NewNumber(bAbsPage ? iPage : iPage + 1)); + return CJS_Result::Success(runtime->NewNumber(bAbsPage ? iPage : iPage + 1)); } diff --git a/fxjs/xfa/cjx_layoutpseudomodel.h b/fxjs/xfa/cjx_layoutpseudomodel.h index 3d14b8570a..3fd77ef6b5 100644 --- a/fxjs/xfa/cjx_layoutpseudomodel.h +++ b/fxjs/xfa/cjx_layoutpseudomodel.h @@ -52,15 +52,15 @@ class CJX_LayoutPseudoModel : public CJX_Object { JSE_PROP(ready); private: - CJS_Return NumberedPageCount(CFX_V8* runtime, bool bNumbered); - CJS_Return HWXY(CFX_V8* runtime, + CJS_Result NumberedPageCount(CFX_V8* runtime, bool bNumbered); + CJS_Result HWXY(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params, XFA_LAYOUTMODEL_HWXY layoutModel); std::vector<CXFA_Node*> GetObjArray(CXFA_LayoutProcessor* pDocLayout, int32_t iPageNo, const WideString& wsType, bool bOnPageArea); - CJS_Return PageInternals(CFX_V8* runtime, + CJS_Result PageInternals(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params, bool bAbsPage); diff --git a/fxjs/xfa/cjx_list.cpp b/fxjs/xfa/cjx_list.cpp index 89f483bf8e..e86e1fa7c5 100644 --- a/fxjs/xfa/cjx_list.cpp +++ b/fxjs/xfa/cjx_list.cpp @@ -31,61 +31,61 @@ CXFA_List* CJX_List::GetXFAList() { return ToList(GetXFAObject()); } -CJS_Return CJX_List::append(CFX_V8* runtime, +CJS_Result CJX_List::append(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); auto* pNode = ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0])); if (!pNode) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); GetXFAList()->Append(pNode); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_List::insert(CFX_V8* runtime, +CJS_Result CJX_List::insert(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); auto* pNewNode = ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0])); if (!pNewNode) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); auto* pBeforeNode = ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[1])); GetXFAList()->Insert(pNewNode, pBeforeNode); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_List::remove(CFX_V8* runtime, +CJS_Result CJX_List::remove(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); auto* pNode = ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0])); if (!pNode) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); GetXFAList()->Remove(pNode); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_List::item(CFX_V8* runtime, +CJS_Result CJX_List::item(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::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::Failure(JSMessage::kInvalidInputError); + return CJS_Result::Failure(JSMessage::kInvalidInputError); - return CJS_Return::Success(static_cast<CFXJSE_Engine*>(runtime)->NewXFAObject( + return CJS_Result::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 49f3350463..27d37ad127 100644 --- a/fxjs/xfa/cjx_logpseudomodel.cpp +++ b/fxjs/xfa/cjx_logpseudomodel.cpp @@ -25,7 +25,7 @@ CJX_LogPseudoModel::CJX_LogPseudoModel(CScript_LogPseudoModel* model) CJX_LogPseudoModel::~CJX_LogPseudoModel() {} -CJS_Return CJX_LogPseudoModel::message( +CJS_Result CJX_LogPseudoModel::message( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { // Uncomment to allow using xfa.log.message(""); from JS. @@ -35,29 +35,29 @@ CJS_Return CJX_LogPseudoModel::message( // fprintf(stderr, " %ls\n", WideString::FromUTF8(*str).c_str()); // } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_LogPseudoModel::traceEnabled( +CJS_Result CJX_LogPseudoModel::traceEnabled( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_LogPseudoModel::traceActivate( +CJS_Result CJX_LogPseudoModel::traceActivate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_LogPseudoModel::traceDeactivate( +CJS_Result CJX_LogPseudoModel::traceDeactivate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_LogPseudoModel::trace( +CJS_Result CJX_LogPseudoModel::trace( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } diff --git a/fxjs/xfa/cjx_manifest.cpp b/fxjs/xfa/cjx_manifest.cpp index 1ca86cc4bf..b53c7edd85 100644 --- a/fxjs/xfa/cjx_manifest.cpp +++ b/fxjs/xfa/cjx_manifest.cpp @@ -21,13 +21,13 @@ CJX_Manifest::CJX_Manifest(CXFA_Manifest* manifest) : CJX_Node(manifest) { CJX_Manifest::~CJX_Manifest() {} -CJS_Return CJX_Manifest::evaluate( +CJS_Result CJX_Manifest::evaluate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success( + return CJS_Result::Success( runtime->NewBoolean(GetXFANode()->IsWidgetReady())); } diff --git a/fxjs/xfa/cjx_model.cpp b/fxjs/xfa/cjx_model.cpp index 97d25175fe..61004e2d1a 100644 --- a/fxjs/xfa/cjx_model.cpp +++ b/fxjs/xfa/cjx_model.cpp @@ -25,17 +25,17 @@ CJX_Model::CJX_Model(CXFA_Node* node) : CJX_Node(node) { CJX_Model::~CJX_Model() {} -CJS_Return CJX_Model::clearErrorList( +CJS_Result CJX_Model::clearErrorList( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Model::createNode( +CJS_Result CJX_Model::createNode( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty() || params.size() > 3) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::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::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); if (!name.IsEmpty()) { if (!pNewNode->HasAttribute(XFA_Attribute::Name)) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); pNewNode->JSObject()->SetAttribute(XFA_Attribute::Name, name.AsStringView(), true); @@ -64,23 +64,23 @@ CJS_Return CJX_Model::createNode( CFXJSE_Value* value = GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewNode); if (!value) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); - return CJS_Return::Success( + return CJS_Result::Success( value->DirectGetValue().Get(runtime->GetIsolate())); } -CJS_Return CJX_Model::isCompatibleNS( +CJS_Result CJX_Model::isCompatibleNS( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); WideString nameSpace; if (params.size() >= 1) nameSpace = runtime->ToWideString(params[0]); - return CJS_Return::Success( + return CJS_Result::Success( runtime->NewBoolean(TryNamespace().value_or(WideString()) == nameSpace)); } diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp index 9a85d94f0d..fed94094a7 100644 --- a/fxjs/xfa/cjx_node.cpp +++ b/fxjs/xfa/cjx_node.cpp @@ -107,83 +107,83 @@ CXFA_Node* CJX_Node::GetXFANode() const { return ToNode(GetXFAObject()); } -CJS_Return CJX_Node::applyXSL(CFX_V8* runtime, +CJS_Result CJX_Node::applyXSL(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); // TODO(weili): check whether we need to implement this, pdfium:501. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Node::assignNode( +CJS_Result CJX_Node::assignNode( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty() || params.size() > 3) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); // TODO(weili): check whether we need to implement this, pdfium:501. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Node::clone(CFX_V8* runtime, +CJS_Result CJX_Node::clone(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_Node* pCloneNode = GetXFANode()->Clone(runtime->ToBoolean(params[0])); CFXJSE_Value* value = GetDocument()->GetScriptContext()->GetJSValueFromMap(pCloneNode); if (!value) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); - return CJS_Return::Success( + return CJS_Result::Success( value->DirectGetValue().Get(runtime->GetIsolate())); } -CJS_Return CJX_Node::getAttribute( +CJS_Result CJX_Node::getAttribute( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); WideString expression = runtime->ToWideString(params[0]); - return CJS_Return::Success(runtime->NewString( + return CJS_Result::Success(runtime->NewString( GetAttribute(expression.AsStringView()).UTF8Encode().AsStringView())); } -CJS_Return CJX_Node::getElement( +CJS_Result CJX_Node::getElement( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty() || params.size() > 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::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::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); CFXJSE_Value* value = GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode); if (!value) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); - return CJS_Return::Success( + return CJS_Result::Success( value->DirectGetValue().Get(runtime->GetIsolate())); } -CJS_Return CJX_Node::isPropertySpecified( +CJS_Result CJX_Node::isPropertySpecified( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty() || params.size() > 3) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::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::Success(runtime->NewBoolean(true)); + return CJS_Result::Success(runtime->NewBoolean(true)); bool bParent = params.size() < 2 || runtime->ToBoolean(params[1]); int32_t iIndex = params.size() == 3 ? runtime->ToInt32(params[2]) : 0; @@ -195,17 +195,17 @@ CJS_Return CJX_Node::isPropertySpecified( bHas = jsnode->HasAttribute(attr) || !!jsnode->GetOrCreateProperty<CXFA_Node>(iIndex, eType); } - return CJS_Return::Success(runtime->NewBoolean(bHas)); + return CJS_Result::Success(runtime->NewBoolean(bHas)); } -CJS_Return CJX_Node::loadXML(CFX_V8* runtime, +CJS_Result CJX_Node::loadXML(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty() || params.size() > 3) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); ByteString expression = runtime->ToByteString(params[0]); if (expression.IsEmpty()) - return CJS_Return::Success(); + return CJS_Result::Success(); bool bIgnoreRoot = true; if (params.size() >= 2) @@ -218,7 +218,7 @@ CJS_Return CJX_Node::loadXML(CFX_V8* runtime, auto pParser = pdfium::MakeUnique<CXFA_DocumentParser>(GetDocument()); CFX_XMLNode* pXMLNode = pParser->ParseXMLData(expression); if (!pXMLNode) - return CJS_Return::Success(); + return CJS_Result::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::Success(); + return CJS_Result::Success(); if (bOverwrite) { CXFA_Node* pChild = GetXFANode()->GetFirstChild(); @@ -322,37 +322,37 @@ CJS_Return CJX_Node::loadXML(CFX_V8* runtime, } pFakeRoot->SetFlag(XFA_NodeFlag_HasRemovedChildren); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Node::saveFilteredXML( +CJS_Result 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::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Node::saveXML(CFX_V8* runtime, +CJS_Result CJX_Node::saveXML(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() > 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (params.size() == 1 && runtime->ToWideString(params[0]) != L"pretty") - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::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::Success(runtime->NewString("")); + return CJS_Result::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::Success( + return CJS_Result::Success( runtime->NewString(bsXMLHeader.AsStringView())); } @@ -368,30 +368,30 @@ CJS_Return CJX_Node::saveXML(CFX_V8* runtime, pElement->Save(pMemoryStream); } - return CJS_Return::Success(runtime->NewString( + return CJS_Result::Success(runtime->NewString( ByteStringView(pMemoryStream->GetBuffer(), pMemoryStream->GetSize()))); } -CJS_Return CJX_Node::setAttribute( +CJS_Result CJX_Node::setAttribute( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); WideString attributeValue = runtime->ToWideString(params[0]); WideString attribute = runtime->ToWideString(params[1]); SetAttribute(attribute.AsStringView(), attributeValue.AsStringView(), true); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Node::setElement( +CJS_Result CJX_Node::setElement( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1 && params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); // TODO(weili): check whether we need to implement this, pdfium:501. - return CJS_Return::Success(); + return CJS_Result::Success(); } void CJX_Node::id(CFXJSE_Value* pValue, diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp index be6879544c..27d1f1524f 100644 --- a/fxjs/xfa/cjx_object.cpp +++ b/fxjs/xfa/cjx_object.cpp @@ -13,7 +13,7 @@ #include "core/fxcrt/xml/cfx_xmltext.h" #include "fxjs/cfxjse_engine.h" #include "fxjs/cfxjse_value.h" -#include "fxjs/cjs_return.h" +#include "fxjs/cjs_result.h" #include "fxjs/xfa/cjx_boolean.h" #include "fxjs/xfa/cjx_draw.h" #include "fxjs/xfa/cjx_field.h" @@ -166,12 +166,12 @@ bool CJX_Object::HasMethod(const WideString& func) const { return pdfium::ContainsKey(method_specs_, func.UTF8Encode()); } -CJS_Return CJX_Object::RunMethod( +CJS_Result CJX_Object::RunMethod( const WideString& func, const std::vector<v8::Local<v8::Value>>& params) { auto it = method_specs_.find(func.UTF8Encode()); if (it == method_specs_.end()) - return CJS_Return::Failure(JSMessage::kUnknownMethod); + return CJS_Result::Failure(JSMessage::kUnknownMethod); return it->second(this, GetXFAObject()->GetDocument()->GetScriptContext(), params); diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h index 4116f378ca..a88900e73e 100644 --- a/fxjs/xfa/cjx_object.h +++ b/fxjs/xfa/cjx_object.h @@ -31,7 +31,7 @@ class CXFA_Node; class CXFA_Object; struct XFA_MAPMODULEDATA; -typedef CJS_Return (*CJX_MethodCall)( +typedef CJS_Result (*CJX_MethodCall)( CJX_Object* obj, CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params); @@ -71,7 +71,7 @@ class CJX_Object { CXFA_LayoutItem* GetLayoutItem() const { return layout_item_; } bool HasMethod(const WideString& func) const; - CJS_Return RunMethod(const WideString& func, + CJS_Result RunMethod(const WideString& func, const std::vector<v8::Local<v8::Value>>& params); bool HasAttribute(XFA_Attribute eAttr); diff --git a/fxjs/xfa/cjx_packet.cpp b/fxjs/xfa/cjx_packet.cpp index ae706ceaf4..5673f8aecd 100644 --- a/fxjs/xfa/cjx_packet.cpp +++ b/fxjs/xfa/cjx_packet.cpp @@ -28,40 +28,40 @@ CJX_Packet::CJX_Packet(CXFA_Packet* packet) : CJX_Node(packet) { CJX_Packet::~CJX_Packet() {} -CJS_Return CJX_Packet::getAttribute( +CJS_Result CJX_Packet::getAttribute( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); WideString attributeValue; CFX_XMLElement* element = ToXMLElement(GetXFANode()->GetXMLMappingNode()); if (element) attributeValue = element->GetAttribute(runtime->ToWideString(params[0])); - return CJS_Return::Success( + return CJS_Result::Success( runtime->NewString(attributeValue.UTF8Encode().AsStringView())); } -CJS_Return CJX_Packet::setAttribute( +CJS_Result CJX_Packet::setAttribute( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CFX_XMLElement* element = ToXMLElement(GetXFANode()->GetXMLMappingNode()); if (element) { element->SetAttribute(runtime->ToWideString(params[1]), runtime->ToWideString(params[0])); } - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); } -CJS_Return CJX_Packet::removeAttribute( +CJS_Result CJX_Packet::removeAttribute( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::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::Success(runtime->NewNull()); + return CJS_Result::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 49a4f1540f..0a604a5b40 100644 --- a/fxjs/xfa/cjx_signaturepseudomodel.cpp +++ b/fxjs/xfa/cjx_signaturepseudomodel.cpp @@ -26,38 +26,38 @@ CJX_SignaturePseudoModel::CJX_SignaturePseudoModel( CJX_SignaturePseudoModel::~CJX_SignaturePseudoModel() {} -CJS_Return CJX_SignaturePseudoModel::verifySignature( +CJS_Result CJX_SignaturePseudoModel::verifySignature( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty() || params.size() > 4) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(runtime->NewNumber(0)); + return CJS_Result::Success(runtime->NewNumber(0)); } -CJS_Return CJX_SignaturePseudoModel::sign( +CJS_Result CJX_SignaturePseudoModel::sign( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() < 3 || params.size() > 7) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(runtime->NewBoolean(false)); + return CJS_Result::Success(runtime->NewBoolean(false)); } -CJS_Return CJX_SignaturePseudoModel::enumerate( +CJS_Result CJX_SignaturePseudoModel::enumerate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_SignaturePseudoModel::clear( +CJS_Result CJX_SignaturePseudoModel::clear( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty() || params.size() > 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(runtime->NewBoolean(false)); + return CJS_Result::Success(runtime->NewBoolean(false)); } diff --git a/fxjs/xfa/cjx_source.cpp b/fxjs/xfa/cjx_source.cpp index 0b24b8f4b4..6a710951fa 100644 --- a/fxjs/xfa/cjx_source.cpp +++ b/fxjs/xfa/cjx_source.cpp @@ -37,146 +37,146 @@ CJX_Source::CJX_Source(CXFA_Source* src) : CJX_Node(src) { CJX_Source::~CJX_Source() {} -CJS_Return CJX_Source::next(CFX_V8* runtime, +CJS_Result CJX_Source::next(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::cancelBatch( +CJS_Result CJX_Source::cancelBatch( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::first(CFX_V8* runtime, +CJS_Result CJX_Source::first(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::updateBatch( +CJS_Result CJX_Source::updateBatch( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::previous( +CJS_Result CJX_Source::previous( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::isBOF(CFX_V8* runtime, +CJS_Result CJX_Source::isBOF(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::isEOF(CFX_V8* runtime, +CJS_Result CJX_Source::isEOF(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::cancel(CFX_V8* runtime, +CJS_Result CJX_Source::cancel(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::update(CFX_V8* runtime, +CJS_Result CJX_Source::update(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::open(CFX_V8* runtime, +CJS_Result CJX_Source::open(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::deleteItem( +CJS_Result CJX_Source::deleteItem( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::addNew(CFX_V8* runtime, +CJS_Result CJX_Source::addNew(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::requery( +CJS_Result CJX_Source::requery( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::resync(CFX_V8* runtime, +CJS_Result CJX_Source::resync(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::close(CFX_V8* runtime, +CJS_Result CJX_Source::close(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::last(CFX_V8* runtime, +CJS_Result CJX_Source::last(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Source::hasDataChanged( +CJS_Result CJX_Source::hasDataChanged( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(); + return CJS_Result::Success(); } void CJX_Source::db(CFXJSE_Value* pValue, diff --git a/fxjs/xfa/cjx_subform.cpp b/fxjs/xfa/cjx_subform.cpp index c313cb4364..c08d2e684c 100644 --- a/fxjs/xfa/cjx_subform.cpp +++ b/fxjs/xfa/cjx_subform.cpp @@ -28,56 +28,56 @@ CJX_Subform::CJX_Subform(CXFA_Node* node) : CJX_Container(node) { CJX_Subform::~CJX_Subform() {} -CJS_Return CJX_Subform::execEvent( +CJS_Result CJX_Subform::execEvent( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); execSingleEventByName(runtime->ToWideString(params[0]).AsStringView(), XFA_Element::Subform); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Subform::execInitialize( +CJS_Result CJX_Subform::execInitialize( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (pNotify) pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false, true); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Subform::execCalculate( +CJS_Result CJX_Subform::execCalculate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (pNotify) pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false, true); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Subform::execValidate( +CJS_Result CJX_Subform::execValidate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return::Success(runtime->NewBoolean(false)); + return CJS_Result::Success(runtime->NewBoolean(false)); int32_t iRet = pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate, false, true); - return CJS_Return::Success(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error)); + return CJS_Result::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 8f27b64bfb..b97d5e3634 100644 --- a/fxjs/xfa/cjx_template.cpp +++ b/fxjs/xfa/cjx_template.cpp @@ -27,60 +27,60 @@ CJX_Template::CJX_Template(CXFA_Template* tmpl) : CJX_Model(tmpl) { CJX_Template::~CJX_Template() {} -CJS_Return CJX_Template::formNodes( +CJS_Result CJX_Template::formNodes( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(runtime->NewBoolean(true)); + return CJS_Result::Success(runtime->NewBoolean(true)); } -CJS_Return CJX_Template::remerge( +CJS_Result CJX_Template::remerge( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); GetDocument()->DoDataRemerge(true); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJX_Template::execInitialize( +CJS_Result CJX_Template::execInitialize( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success( + return CJS_Result::Success( runtime->NewBoolean(GetXFANode()->IsWidgetReady())); } -CJS_Return CJX_Template::recalculate( +CJS_Result CJX_Template::recalculate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(runtime->NewBoolean(true)); + return CJS_Result::Success(runtime->NewBoolean(true)); } -CJS_Return CJX_Template::execCalculate( +CJS_Result CJX_Template::execCalculate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success( + return CJS_Result::Success( runtime->NewBoolean(GetXFANode()->IsWidgetReady())); } -CJS_Return CJX_Template::execValidate( +CJS_Result CJX_Template::execValidate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success( + return CJS_Result::Success( runtime->NewBoolean(GetXFANode()->IsWidgetReady())); } diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp index be74b44a93..9787b9b885 100644 --- a/fxjs/xfa/cjx_tree.cpp +++ b/fxjs/xfa/cjx_tree.cpp @@ -29,16 +29,16 @@ CJX_Tree::CJX_Tree(CXFA_Object* obj) : CJX_Object(obj) { CJX_Tree::~CJX_Tree() {} -CJS_Return CJX_Tree::resolveNode( +CJS_Result CJX_Tree::resolveNode( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); WideString expression = runtime->ToWideString(params[0]); CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); if (!pScriptContext) - return CJS_Return::Success(); + return CJS_Result::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::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); } if (resolveNodeRS.dwFlags == XFA_ResolveNode_RSType_Nodes) { @@ -59,9 +59,9 @@ CJS_Return CJX_Tree::resolveNode( CFXJSE_Value* value = GetDocument()->GetScriptContext()->GetJSValueFromMap(pObject); if (!value) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); - return CJS_Return::Success( + return CJS_Result::Success( value->DirectGetValue().Get(runtime->GetIsolate())); } @@ -69,22 +69,22 @@ CJS_Return CJX_Tree::resolveNode( resolveNodeRS.pScriptAttribute; if (!lpAttributeInfo || lpAttributeInfo->eValueType != XFA_ScriptType::Object) { - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::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::Success( + return CJS_Result::Success( pValue->DirectGetValue().Get(runtime->GetIsolate())); } -CJS_Return CJX_Tree::resolveNodes( +CJS_Result CJX_Tree::resolveNodes( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_Object* refNode = GetXFAObject(); if (refNode->GetElementType() == XFA_Element::Xfa) @@ -92,7 +92,7 @@ CJS_Return CJX_Tree::resolveNodes( CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); if (!pScriptContext) - return CJS_Return::Success(); + return CJS_Result::Success(); auto pValue = pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetIsolate()); ResolveNodeList(pValue.get(), runtime->ToWideString(params[0]), @@ -100,7 +100,7 @@ CJS_Return CJX_Tree::resolveNodes( XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings, ToNode(refNode)); - return CJS_Return::Success( + return CJS_Result::Success( pValue->DirectGetValue().Get(runtime->GetIsolate())); } diff --git a/fxjs/xfa/cjx_treelist.cpp b/fxjs/xfa/cjx_treelist.cpp index 0c023003e4..acf5307e8f 100644 --- a/fxjs/xfa/cjx_treelist.cpp +++ b/fxjs/xfa/cjx_treelist.cpp @@ -28,22 +28,22 @@ CXFA_TreeList* CJX_TreeList::GetXFATreeList() { return ToTreeList(GetXFAObject()); } -CJS_Return CJX_TreeList::namedItem( +CJS_Result CJX_TreeList::namedItem( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); CXFA_Node* pNode = GetXFATreeList()->NamedItem( runtime->ToWideString(params[0]).AsStringView()); if (!pNode) - return CJS_Return::Success(); + return CJS_Result::Success(); CFXJSE_Value* value = GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode); if (!value) - return CJS_Return::Success(runtime->NewNull()); + return CJS_Result::Success(runtime->NewNull()); - return CJS_Return::Success( + return CJS_Result::Success( value->DirectGetValue().Get(runtime->GetIsolate())); } diff --git a/fxjs/xfa/cjx_wsdlconnection.cpp b/fxjs/xfa/cjx_wsdlconnection.cpp index 198d4f2f98..dec20d7163 100644 --- a/fxjs/xfa/cjx_wsdlconnection.cpp +++ b/fxjs/xfa/cjx_wsdlconnection.cpp @@ -22,13 +22,13 @@ CJX_WsdlConnection::CJX_WsdlConnection(CXFA_WsdlConnection* connection) CJX_WsdlConnection::~CJX_WsdlConnection() {} -CJS_Return CJX_WsdlConnection::execute( +CJS_Result CJX_WsdlConnection::execute( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty() && params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); - return CJS_Return::Success(runtime->NewBoolean(false)); + return CJS_Result::Success(runtime->NewBoolean(false)); } void CJX_WsdlConnection::dataDescription(CFXJSE_Value* pValue, |