diff options
Diffstat (limited to 'fpdfsdk/include/javascript/JS_Define.h')
-rw-r--r-- | fpdfsdk/include/javascript/JS_Define.h | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h index 04f5eceef5..0f93b0b38e 100644 --- a/fpdfsdk/include/javascript/JS_Define.h +++ b/fpdfsdk/include/javascript/JS_Define.h @@ -81,12 +81,9 @@ void JSPropGetter(const char* prop_name_string, v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); - v8::Local<v8::Context> context = isolate->GetCurrentContext(); - v8::Local<v8::Value> v = context->GetEmbedderData(1); - if (v.IsEmpty()) + IFXJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); + if (!pRuntime) return; - v8::Local<v8::External> field = v8::Local<v8::External>::Cast(v); - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* pContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); @@ -111,12 +108,9 @@ void JSPropSetter(const char* prop_name_string, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { v8::Isolate* isolate = info.GetIsolate(); - v8::Local<v8::Context> context = isolate->GetCurrentContext(); - v8::Local<v8::Value> v = context->GetEmbedderData(1); - if (v.IsEmpty()) + IFXJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); + if (!pRuntime) return; - v8::Local<v8::External> field = v8::Local<v8::External>::Cast(v); - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* pContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); @@ -155,12 +149,9 @@ void JSMethod(const char* method_name_string, const char* class_name_string, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); - v8::Local<v8::Context> context = isolate->GetCurrentContext(); - v8::Local<v8::Value> v = context->GetEmbedderData(1); - if (v.IsEmpty()) + IFXJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); + if (!pRuntime) return; - v8::Local<v8::External> field = v8::Local<v8::External>::Cast(v); - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* cc = pRuntime->GetCurrentContext(); CJS_Parameters parameters; for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { @@ -286,12 +277,9 @@ void JSSpecialPropGet(const char* class_name, v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); - v8::Local<v8::Context> context = isolate->GetCurrentContext(); - v8::Local<v8::Value> v = context->GetEmbedderData(1); - if (v.IsEmpty()) + IFXJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); + if (!pRuntime) 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())); @@ -315,12 +303,9 @@ void JSSpecialPropPut(const char* class_name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); - v8::Local<v8::Context> context = isolate->GetCurrentContext(); - v8::Local<v8::Value> v = context->GetEmbedderData(1); - if (v.IsEmpty()) + IFXJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); + if (!pRuntime) 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())); @@ -341,12 +326,9 @@ void JSSpecialPropDel(const char* class_name, v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Boolean>& info) { v8::Isolate* isolate = info.GetIsolate(); - v8::Local<v8::Context> context = isolate->GetCurrentContext(); - v8::Local<v8::Value> v = context->GetEmbedderData(1); - if (v.IsEmpty()) + IFXJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); + if (!pRuntime) 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())); @@ -454,12 +436,9 @@ template <FX_BOOL (*F)(IFXJS_Context* cc, void JSGlobalFunc(const char* func_name_string, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); - v8::Local<v8::Context> context = isolate->GetCurrentContext(); - v8::Local<v8::Value> v = context->GetEmbedderData(1); - if (v.IsEmpty()) + IFXJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); + if (!pRuntime) return; - v8::Local<v8::External> field = v8::Local<v8::External>::Cast(v); - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* cc = pRuntime->GetCurrentContext(); CJS_Parameters parameters; for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { |