From d5f427901b52e1311ab51f16e87459ec34691591 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 29 Aug 2018 23:18:08 +0000 Subject: Stop using deprecated V8 APIs in CJS_Runtime. Also for CFXJSE_Arguments. Change-Id: I15bfa4e09675bb48aecfa0c55539bf8dc50675e6 Reviewed-on: https://pdfium-review.googlesource.com/41370 Reviewed-by: Tom Sepez Commit-Queue: Lei Zhang --- fxjs/cfxjse_arguments.cpp | 4 +++- fxjs/cfxjse_arguments.h | 4 ++-- fxjs/cjs_runtime.cpp | 19 ++++++++++--------- fxjs/cjs_runtime.h | 4 ++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/fxjs/cfxjse_arguments.cpp b/fxjs/cfxjse_arguments.cpp index 0b0dc39953..174fd3c2c7 100644 --- a/fxjs/cfxjse_arguments.cpp +++ b/fxjs/cfxjse_arguments.cpp @@ -49,7 +49,9 @@ float CFXJSE_Arguments::GetFloat(int32_t index) const { ByteString CFXJSE_Arguments::GetUTF8String(int32_t index) const { v8::Isolate* isolate = m_pInfo->GetIsolate(); - v8::Local hString = (*m_pInfo)[index]->ToString(isolate); + v8::Local info = (*m_pInfo)[index]; + v8::Local hString = + info->ToString(isolate->GetCurrentContext()).ToLocalChecked(); v8::String::Utf8Value szStringVal(isolate, hString); return ByteString(*szStringVal); } diff --git a/fxjs/cfxjse_arguments.h b/fxjs/cfxjse_arguments.h index e24fc8feb8..d523d6f906 100644 --- a/fxjs/cfxjse_arguments.h +++ b/fxjs/cfxjse_arguments.h @@ -28,8 +28,8 @@ class CFXJSE_Arguments { CFXJSE_Value* GetReturnValue() const; private: - UnownedPtr> m_pInfo; - UnownedPtr m_pRetValue; + UnownedPtr> const m_pInfo; + UnownedPtr const m_pRetValue; }; #endif // FXJS_CFXJSE_ARGUMENTS_H_ diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp index 6042538e30..e7de7abd8f 100644 --- a/fxjs/cjs_runtime.cpp +++ b/fxjs/cjs_runtime.cpp @@ -47,9 +47,7 @@ #endif // PDF_ENABLE_XFA CJS_Runtime::CJS_Runtime(CPDFSDK_FormFillEnvironment* pFormFillEnv) - : m_pFormFillEnv(pFormFillEnv), - m_bBlocking(false), - m_isolateManaged(false) { + : m_pFormFillEnv(pFormFillEnv) { v8::Isolate* pIsolate = nullptr; IPDF_JSPLATFORM* pPlatform = m_pFormFillEnv->GetFormFillInfo()->m_pJsPlatform; @@ -199,9 +197,12 @@ bool CJS_Runtime::GetValueByNameFromGlobalObject(const ByteStringView& utf8Name, v8::HandleScope handle_scope(GetIsolate()); v8::Local context = GetV8Context(); v8::Context::Scope context_scope(context); - v8::Local propvalue = context->Global()->Get( + v8::Local str = v8::String::NewFromUtf8(GetIsolate(), utf8Name.unterminated_c_str(), - v8::String::kNormalString, utf8Name.GetLength())); + v8::NewStringType::kNormal, utf8Name.GetLength()) + .ToLocalChecked(); + v8::Local propvalue = + context->Global()->Get(context, str).ToLocalChecked(); if (propvalue.IsEmpty()) { pValue->SetUndefined(); return false; @@ -222,11 +223,11 @@ bool CJS_Runtime::SetValueByNameInGlobalObject(const ByteStringView& utf8Name, v8::Context::Scope context_scope(context); v8::Local propvalue = v8::Local::New(pIsolate, pValue->DirectGetValue()); - context->Global()->Set( + v8::Local str = v8::String::NewFromUtf8(pIsolate, utf8Name.unterminated_c_str(), - v8::String::kNormalString, utf8Name.GetLength()), - propvalue); - return true; + v8::NewStringType::kNormal, utf8Name.GetLength()) + .ToLocalChecked(); + return context->Global()->Set(context, str, propvalue).FromJust(); } #endif diff --git a/fxjs/cjs_runtime.h b/fxjs/cjs_runtime.h index f7b2679523..8835106697 100644 --- a/fxjs/cjs_runtime.h +++ b/fxjs/cjs_runtime.h @@ -65,8 +65,8 @@ class CJS_Runtime final : public IJS_Runtime, std::vector> m_EventContextArray; CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv; - bool m_bBlocking; - bool m_isolateManaged; + bool m_bBlocking = false; + bool m_isolateManaged = false; std::set m_FieldEventSet; }; -- cgit v1.2.3