From 93f191bb011508a8d4e66746135e8ba8e9583870 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 6 Nov 2015 08:19:44 -0800 Subject: Remove FXJS_GetRuntime Its pointless to have a function that gets the isolate given a v8::object, since v8 gives us that directly. Also remove some CreationContext() calls, since they are only used to get the isolate, and we can do so directly. R=jochen@chromium.org Review URL: https://codereview.chromium.org/1413733004 . --- fpdfsdk/include/jsapi/fxjs_v8.h | 1 - fpdfsdk/src/javascript/JS_Object.cpp | 2 +- fpdfsdk/src/javascript/global.cpp | 11 +++++------ fpdfsdk/src/jsapi/fxjs_v8.cpp | 9 --------- 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/fpdfsdk/include/jsapi/fxjs_v8.h b/fpdfsdk/include/jsapi/fxjs_v8.h index 13fbb02a72..c4a31bbf07 100644 --- a/fpdfsdk/include/jsapi/fxjs_v8.h +++ b/fpdfsdk/include/jsapi/fxjs_v8.h @@ -136,7 +136,6 @@ v8::Local FXJS_NewFxDynamicObj(v8::Isolate* pIsolate, int nObjDefnID); v8::Local FXJS_GetThisObj(v8::Isolate* pIsolate); int FXJS_GetObjDefnID(v8::Local pObj); -v8::Isolate* FXJS_GetRuntime(v8::Local pObj); const wchar_t* FXJS_GetTypeof(v8::Local pObj); void FXJS_SetPrivate(v8::Isolate* pIsolate, diff --git a/fpdfsdk/src/javascript/JS_Object.cpp b/fpdfsdk/src/javascript/JS_Object.cpp index 883ecc82ae..1e649ae791 100644 --- a/fpdfsdk/src/javascript/JS_Object.cpp +++ b/fpdfsdk/src/javascript/JS_Object.cpp @@ -61,7 +61,7 @@ void DisposeObject(const v8::WeakCallbackInfo& data) { } CJS_Object::CJS_Object(v8::Local pObject) { - m_pIsolate = pObject->CreationContext()->GetIsolate(); + m_pIsolate = pObject->GetIsolate(); m_pV8Object.Reset(m_pIsolate, pObject); } diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp index cd0048d95b..4dd93c150f 100644 --- a/fpdfsdk/src/javascript/global.cpp +++ b/fpdfsdk/src/javascript/global.cpp @@ -259,7 +259,7 @@ void JSGlobalAlternate::UpdateGlobalPersistentVariables() { pData->data.sData.UTF8Decode().c_str()); break; case JS_GLOBALDATA_TYPE_OBJECT: { - v8::Isolate* pRuntime = FXJS_GetRuntime(m_pJSObject->ToV8Object()); + v8::Isolate* pRuntime = m_pJSObject->ToV8Object()->GetIsolate(); v8::Local pObj = FXJS_NewFxDynamicObj(pRuntime, NULL, -1); PutObjectProperty(pObj, &pData->data); @@ -324,8 +324,7 @@ void JSGlobalAlternate::CommitGlobalPersisitentVariables(IJS_Context* cc) { void JSGlobalAlternate::ObjectToArray(IJS_Context* cc, v8::Local pObj, CJS_GlobalVariableArray& array) { - v8::Local context = pObj->CreationContext(); - v8::Isolate* isolate = context->GetIsolate(); + v8::Isolate* isolate = pObj->GetIsolate(); CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); v8::Local pKeyList = FXJS_GetObjectElementNames(isolate, pObj); @@ -401,7 +400,7 @@ void JSGlobalAlternate::PutObjectProperty(v8::Local pObj, pObjData->sData.UTF8Decode().c_str()); break; case JS_GLOBALDATA_TYPE_OBJECT: { - v8::Isolate* pRuntime = FXJS_GetRuntime(m_pJSObject->ToV8Object()); + v8::Isolate* pRuntime = m_pJSObject->ToV8Object()->GetIsolate(); v8::Local pNewObj = FXJS_NewFxDynamicObj(pRuntime, NULL, -1); PutObjectProperty(pNewObj, pObjData); @@ -454,7 +453,7 @@ FX_BOOL JSGlobalAlternate::SetGlobalVariables(const FX_CHAR* propname, pTemp->sData = sData; } break; case JS_GLOBALDATA_TYPE_OBJECT: { - pTemp->pData.Reset(FXJS_GetRuntime(pData), pData); + pTemp->pData.Reset(pData->GetIsolate(), pData); } break; case JS_GLOBALDATA_TYPE_NULL: break; @@ -488,7 +487,7 @@ FX_BOOL JSGlobalAlternate::SetGlobalVariables(const FX_CHAR* propname, case JS_GLOBALDATA_TYPE_OBJECT: { pNewData = new JSGlobalData; pNewData->nType = JS_GLOBALDATA_TYPE_OBJECT; - pNewData->pData.Reset(FXJS_GetRuntime(pData), pData); + pNewData->pData.Reset(pData->GetIsolate(), pData); pNewData->bPersistent = bDefaultPersistent; } break; case JS_GLOBALDATA_TYPE_NULL: { diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp index 2fb3e13064..8180f76e67 100644 --- a/fpdfsdk/src/jsapi/fxjs_v8.cpp +++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp @@ -442,15 +442,6 @@ int FXJS_GetObjDefnID(v8::Local pObj) { return -1; } -v8::Isolate* FXJS_GetRuntime(v8::Local pObj) { - if (pObj.IsEmpty()) - return NULL; - v8::Local context = pObj->CreationContext(); - if (context.IsEmpty()) - return NULL; - return context->GetIsolate(); -} - void FXJS_Error(v8::Isolate* pIsolate, const CFX_WideString& message) { // Conversion from pdfium's wchar_t wide-strings to v8's uint16_t // wide-strings isn't handled by v8, so use UTF8 as a common -- cgit v1.2.3