summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-08-28 23:36:08 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-28 23:36:08 +0000
commit5b346563297d1a2cb19a3a101a4b5d50c4aee23c (patch)
treeb0f52d1f066668ed87669be23fd0ae68e9bc0e9a /fxjs
parentb719bc4a6f219483059f66c33e4a3a7667d75ed5 (diff)
downloadpdfium-5b346563297d1a2cb19a3a101a4b5d50c4aee23c.tar.xz
Stop using deprecated V8 APIs in CJS_Global.chromium/3537chromium/3536
Also merge Initial() into the ctor. Change-Id: Ib3cb9619a65a5c33d7c739051c13dfcd7f2324d7 Reviewed-on: https://pdfium-review.googlesource.com/41356 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cjs_global.cpp26
-rw-r--r--fxjs/cjs_global.h1
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 <class T>
+v8::Local<v8::String> GetV8StringFromProperty(v8::Local<v8::Name> 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<CJS_Global>(
"global",
v8::Local<v8::String>::New(info.GetIsolate(),
- property->ToString(info.GetIsolate())),
+ GetV8StringFromProperty(property, info)),
info);
}
@@ -159,7 +166,7 @@ void CJS_Global::getprop_static(
JSSpecialPropGet<CJS_Global>(
"global",
v8::Local<v8::String>::New(info.GetIsolate(),
- property->ToString(info.GetIsolate())),
+ GetV8StringFromProperty(property, info)),
info);
}
@@ -172,7 +179,7 @@ void CJS_Global::putprop_static(
JSSpecialPropPut<CJS_Global>(
"global",
v8::Local<v8::String>::New(info.GetIsolate(),
- property->ToString(info.GetIsolate())),
+ GetV8StringFromProperty(property, info)),
value, info);
}
@@ -184,7 +191,7 @@ void CJS_Global::delprop_static(
JSSpecialPropDel<CJS_Global>(
"global",
v8::Local<v8::String>::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<v8::Object> 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<v8::Local<v8::Value>>& params);