summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
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);