diff options
Diffstat (limited to 'fpdfsdk/include/javascript/JS_Define.h')
-rw-r--r-- | fpdfsdk/include/javascript/JS_Define.h | 68 |
1 files changed, 50 insertions, 18 deletions
diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h index 3b5798ef5c..adf69ec0e9 100644 --- a/fpdfsdk/include/javascript/JS_Define.h +++ b/fpdfsdk/include/javascript/JS_Define.h @@ -79,13 +79,18 @@ void JSPropGetter(const char* prop_name_string, v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); - FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(isolate); - IFXJS_Context* pRuntimeContext = pData->m_pFXJSRuntime->GetCurrentContext(); - CJS_PropValue value(isolate); - value.StartGetting(); + v8::Local<v8::Context> context = isolate->GetCurrentContext(); + v8::Local<v8::Value> v = context->GetEmbedderData(1); + if (v.IsEmpty()) + return; + v8::Local<v8::External> field = v8::Local<v8::External>::Cast(v); + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); + IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); CFX_WideString sError; + CJS_PropValue value(isolate); + value.StartGetting(); if (!(pObj->*M)(pRuntimeContext, value, sError)) { FXJS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, sError)); @@ -102,13 +107,18 @@ void JSPropSetter(const char* prop_name_string, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { v8::Isolate* isolate = info.GetIsolate(); - FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(isolate); - IFXJS_Context* pRuntimeContext = pData->m_pFXJSRuntime->GetCurrentContext(); - CJS_PropValue propValue(CJS_Value(isolate, value, CJS_Value::VT_unknown)); - propValue.StartSetting(); + v8::Local<v8::Context> context = isolate->GetCurrentContext(); + v8::Local<v8::Value> v = context->GetEmbedderData(1); + if (v.IsEmpty()) + return; + v8::Local<v8::External> field = v8::Local<v8::External>::Cast(v); + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); + IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); CFX_WideString sError; + CJS_PropValue propValue(CJS_Value(isolate, value, CJS_Value::VT_unknown)); + propValue.StartSetting(); if (!(pObj->*M)(pRuntimeContext, propValue, sError)) { FXJS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, sError)); @@ -141,8 +151,13 @@ void JSMethod(const char* method_name_string, const char* class_name_string, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); - FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(isolate); - IFXJS_Context* pRuntimeContext = pData->m_pFXJSRuntime->GetCurrentContext(); + v8::Local<v8::Context> context = isolate->GetCurrentContext(); + v8::Local<v8::Value> v = context->GetEmbedderData(1); + if (v.IsEmpty()) + return; + v8::Local<v8::External> field = v8::Local<v8::External>::Cast(v); + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); + IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); CJS_Parameters parameters; for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { parameters.push_back(CJS_Value(isolate, info[i], CJS_Value::VT_unknown)); @@ -268,8 +283,12 @@ void JSSpecialPropGet(const char* class_name, const v8::PropertyCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); v8::Local<v8::Context> context = isolate->GetCurrentContext(); - FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(isolate); - IFXJS_Context* pRuntimeContext = pData->m_pFXJSRuntime->GetCurrentContext(); + v8::Local<v8::Value> v = context->GetEmbedderData(1); + if (v.IsEmpty()) + return; + v8::Local<v8::External> field = v8::Local<v8::External>::Cast(v); + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); + IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder())); Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject()); @@ -293,8 +312,12 @@ void JSSpecialPropPut(const char* class_name, const v8::PropertyCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); v8::Local<v8::Context> context = isolate->GetCurrentContext(); - FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(isolate); - IFXJS_Context* pRuntimeContext = pData->m_pFXJSRuntime->GetCurrentContext(); + v8::Local<v8::Value> v = context->GetEmbedderData(1); + if (v.IsEmpty()) + return; + v8::Local<v8::External> field = v8::Local<v8::External>::Cast(v); + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); + IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder())); Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject()); @@ -315,8 +338,12 @@ void JSSpecialPropDel(const char* class_name, const v8::PropertyCallbackInfo<v8::Boolean>& info) { v8::Isolate* isolate = info.GetIsolate(); v8::Local<v8::Context> context = isolate->GetCurrentContext(); - FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(isolate); - IFXJS_Context* pRuntimeContext = pData->m_pFXJSRuntime->GetCurrentContext(); + v8::Local<v8::Value> v = context->GetEmbedderData(1); + if (v.IsEmpty()) + return; + v8::Local<v8::External> field = v8::Local<v8::External>::Cast(v); + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); + IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder())); Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject()); @@ -421,8 +448,13 @@ template <FX_BOOL ( void JSGlobalFunc(const char* func_name_string, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); - FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(isolate); - IFXJS_Context* pRuntimeContext = pData->m_pFXJSRuntime->GetCurrentContext(); + v8::Local<v8::Context> context = isolate->GetCurrentContext(); + v8::Local<v8::Value> v = context->GetEmbedderData(1); + if (v.IsEmpty()) + return; + v8::Local<v8::External> field = v8::Local<v8::External>::Cast(v); + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); + IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); CJS_Parameters parameters; for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { parameters.push_back(CJS_Value(isolate, info[i], CJS_Value::VT_unknown)); |