diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-09-28 10:31:27 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-09-28 10:31:27 -0700 |
commit | bd7fabf61f41e5ac2ded12ac46a4193c3dbffc44 (patch) | |
tree | 0f4bfd65d3ca48aa2cfb16232e60ebf10991c411 /fpdfsdk/include | |
parent | a25fd09cd880ad82aea09a7ffffe3f8e5b121bbe (diff) | |
download | pdfium-bd7fabf61f41e5ac2ded12ac46a4193c3dbffc44.tar.xz |
Merge to XFA: Introduce kPerIsolateDataIndex and tidy JS_Define.h
(cherry picked from commit d6d9dc6b9a45368abdf43477592ee9f6cdb6102e)
(cherry picked from commit cfff2f65aaec70247d020188bc68a0dc4fb34c3e)
Original Review URL: https://codereview.chromium.org/1372963003 .
Original Review URL: https://codereview.chromium.org/1367813003 .
TBR=jochen@chromium.org
Review URL: https://codereview.chromium.org/1370133007 .
Diffstat (limited to 'fpdfsdk/include')
-rw-r--r-- | fpdfsdk/include/javascript/JS_Define.h | 49 | ||||
-rw-r--r-- | fpdfsdk/include/jsapi/fxjs_v8.h | 5 |
2 files changed, 15 insertions, 39 deletions
diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h index adf69ec0e9..e91ce03d30 100644 --- a/fpdfsdk/include/javascript/JS_Define.h +++ b/fpdfsdk/include/javascript/JS_Define.h @@ -79,12 +79,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* pRuntimeContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); @@ -107,12 +104,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* pRuntimeContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); @@ -151,12 +145,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* pRuntimeContext = pRuntime->GetCurrentContext(); CJS_Parameters parameters; for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { @@ -282,12 +273,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())); @@ -311,12 +299,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())); @@ -337,12 +322,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())); @@ -448,12 +430,9 @@ template <FX_BOOL ( 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* pRuntimeContext = pRuntime->GetCurrentContext(); CJS_Parameters parameters; for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { diff --git a/fpdfsdk/include/jsapi/fxjs_v8.h b/fpdfsdk/include/jsapi/fxjs_v8.h index 0b51332dbc..ed652942af 100644 --- a/fpdfsdk/include/jsapi/fxjs_v8.h +++ b/fpdfsdk/include/jsapi/fxjs_v8.h @@ -74,10 +74,6 @@ void FXJS_Release(); // as part of FXJS_ReleaseRuntime(). void FXJS_PrepareIsolate(v8::Isolate* pIsolate); -// Call before making JS_PrepareIsolate call. -void JS_Initialize(unsigned int embedderDataSlot); -void JS_Release(); - // Call before making JS_Define* calls. Resources allocated here are cleared // as part of JS_ReleaseRuntime(). void JS_PrepareIsolate(v8::Isolate* pIsolate); @@ -122,6 +118,7 @@ void FXJS_InitializeRuntime(v8::Isolate* pIsolate, v8::Global<v8::Context>& v8PersistentContext); void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, v8::Global<v8::Context>& v8PersistentContext); +IFXJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate); // Called after FXJS_InitializeRuntime call made. int FXJS_Execute(v8::Isolate* pIsolate, |