From 5b346563297d1a2cb19a3a101a4b5d50c4aee23c Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 28 Aug 2018 23:36:08 +0000 Subject: Stop using deprecated V8 APIs in CJS_Global. Also merge Initial() into the ctor. Change-Id: Ib3cb9619a65a5c33d7c739051c13dfcd7f2324d7 Reviewed-on: https://pdfium-review.googlesource.com/41356 Commit-Queue: Lei Zhang Reviewed-by: Tom Sepez --- fxjs/cjs_global.cpp | 26 +++++++++++++++----------- fxjs/cjs_global.h | 1 - 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp index ea8694fe14..d9338abcfd 100644 --- a/fxjs/cjs_global.cpp +++ b/fxjs/cjs_global.cpp @@ -113,6 +113,13 @@ void JSSpecialPropDel(const char* class_name, } } +template +v8::Local GetV8StringFromProperty(v8::Local property, + const T& info) { + return property->ToString(info.GetIsolate()->GetCurrentContext()) + .ToLocalChecked(); +} + } // namespace CJS_Global::JSGlobalData::JSGlobalData() @@ -147,7 +154,7 @@ void CJS_Global::queryprop_static( JSSpecialPropQuery( "global", v8::Local::New(info.GetIsolate(), - property->ToString(info.GetIsolate())), + GetV8StringFromProperty(property, info)), info); } @@ -159,7 +166,7 @@ void CJS_Global::getprop_static( JSSpecialPropGet( "global", v8::Local::New(info.GetIsolate(), - property->ToString(info.GetIsolate())), + GetV8StringFromProperty(property, info)), info); } @@ -172,7 +179,7 @@ void CJS_Global::putprop_static( JSSpecialPropPut( "global", v8::Local::New(info.GetIsolate(), - property->ToString(info.GetIsolate())), + GetV8StringFromProperty(property, info)), value, info); } @@ -184,7 +191,7 @@ void CJS_Global::delprop_static( JSSpecialPropDel( "global", v8::Local::New(info.GetIsolate(), - property->ToString(info.GetIsolate())), + GetV8StringFromProperty(property, info)), info); } @@ -210,7 +217,10 @@ void CJS_Global::DefineJSObjects(CFXJS_Engine* pEngine) { CJS_Global::CJS_Global(v8::Local pObject, CJS_Runtime* pRuntime) : CJS_Object(pObject, pRuntime) { - Initial(GetRuntime()->GetFormFillEnv()); + CPDFSDK_FormFillEnvironment* pFormFillEnv = GetRuntime()->GetFormFillEnv(); + m_pFormFillEnv.Reset(pFormFillEnv); + m_pGlobalData = CJS_GlobalData::GetRetainedInstance(pFormFillEnv); + UpdateGlobalPersistentVariables(); } CJS_Global::~CJS_Global() { @@ -218,12 +228,6 @@ CJS_Global::~CJS_Global() { m_pGlobalData->Release(); } -void CJS_Global::Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv) { - m_pFormFillEnv.Reset(pFormFillEnv); - m_pGlobalData = CJS_GlobalData::GetRetainedInstance(pFormFillEnv); - UpdateGlobalPersistentVariables(); -} - CJS_Result CJS_Global::QueryProperty(const wchar_t* propname) { if (WideString(propname) != L"setPersistent") return CJS_Result::Failure(JSMessage::kUnknownProperty); diff --git a/fxjs/cjs_global.h b/fxjs/cjs_global.h index 6ecd6c0130..454ddf9b4f 100644 --- a/fxjs/cjs_global.h +++ b/fxjs/cjs_global.h @@ -40,7 +40,6 @@ class CJS_Global final : public CJS_Object { ~CJS_Global() override; CJS_Result DelProperty(CJS_Runtime* pRuntime, const wchar_t* propname); - void Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv); CJS_Result setPersistent(CJS_Runtime* pRuntime, const std::vector>& params); -- cgit v1.2.3