Revert "Merge to master: contention over isolate data slots"
[pdfium.git] / fpdfsdk / src / jsapi / fxjs_v8.cpp
index 2c17628..69ea2cb 100644 (file)
@@ -416,20 +416,6 @@ v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate,
   return obj;
 }
 
-v8::Local<v8::Object> FXJS_GetStaticObj(v8::Isolate* pIsolate, int nObjDefnID) {
-  v8::Isolate::Scope isolate_scope(pIsolate);
-  CFX_PtrArray* pArray = (CFX_PtrArray*)pIsolate->GetData(g_embedderDataSlot);
-  if (!pArray)
-    return v8::Local<v8::Object>();
-
-  if (nObjDefnID < 0 || nObjDefnID >= pArray->GetSize())
-    return v8::Local<v8::Object>();
-  CFXJS_ObjDefintion* pObjDef = (CFXJS_ObjDefintion*)pArray->GetAt(nObjDefnID);
-  v8::Local<v8::Object> obj =
-      v8::Local<v8::Object>::New(pIsolate, pObjDef->m_StaticObj);
-  return obj;
-}
-
 v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate) {
   // Return the global object.
   v8::Isolate::Scope isolate_scope(pIsolate);
@@ -503,13 +489,6 @@ const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj) {
     return kFXJSValueNameUndefined;
   return NULL;
 }
-void FXJS_SetPrivate(v8::Local<v8::Object> pObj, void* p) {
-  FXJS_SetPrivate(NULL, pObj, p);
-}
-
-void* FXJS_GetPrivate(v8::Local<v8::Object> pObj) {
-  return FXJS_GetPrivate(NULL, pObj);
-}
 
 void FXJS_SetPrivate(v8::Isolate* pIsolate,
                      v8::Local<v8::Object> pObj,
@@ -525,24 +504,21 @@ void FXJS_SetPrivate(v8::Isolate* pIsolate,
 
 void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj) {
   if (pObj.IsEmpty())
-    return NULL;
-  CFXJS_PrivateData* pPrivateData = NULL;
-  if (pObj->InternalFieldCount())
+    return nullptr;
+  CFXJS_PrivateData* pPrivateData = nullptr;
+  if (pObj->InternalFieldCount()) {
     pPrivateData =
         (CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0);
-  else {
+  } else {
     // It could be a global proxy object.
     v8::Local<v8::Value> v = pObj->GetPrototype();
-    v8::Isolate* isolate = (v8::Isolate*)pIsolate;
-    v8::Local<v8::Context> context = isolate->GetCurrentContext();
+    v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
     if (v->IsObject())
       pPrivateData = (CFXJS_PrivateData*)v->ToObject(context)
                          .ToLocalChecked()
                          ->GetAlignedPointerFromInternalField(0);
   }
-  if (!pPrivateData)
-    return NULL;
-  return pPrivateData->pPrivate;
+  return pPrivateData ? pPrivateData->pPrivate : nullptr;
 }
 
 void FXJS_FreePrivate(void* pPrivateData) {
@@ -567,10 +543,6 @@ v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate,
                                  v8::NewStringType::kNormal).ToLocalChecked();
 }
 
-v8::Local<v8::Value> FXJS_GetObjectValue(v8::Local<v8::Object> pObj) {
-  return pObj;
-}
-
 v8::Local<v8::Value> FXJS_GetObjectElement(v8::Isolate* pIsolate,
                                            v8::Local<v8::Object> pObj,
                                            const wchar_t* PropertyName) {
@@ -736,12 +708,6 @@ v8::Local<v8::Value> FXJS_NewString(v8::Isolate* pIsolate,
   return FXJS_WSToJSString(pIsolate, string);
 }
 
-v8::Local<v8::Value> FXJS_NewString(v8::Isolate* pIsolate,
-                                    const wchar_t* string,
-                                    unsigned nLen) {
-  return FXJS_WSToJSString(pIsolate, string, nLen);
-}
-
 v8::Local<v8::Value> FXJS_NewNull() {
   return v8::Local<v8::Value>();
 }
@@ -750,25 +716,6 @@ v8::Local<v8::Value> FXJS_NewDate(v8::Isolate* pIsolate, double d) {
   return v8::Date::New(pIsolate->GetCurrentContext(), d).ToLocalChecked();
 }
 
-v8::Local<v8::Value> FXJS_NewValue(v8::Isolate* pIsolate) {
-  return v8::Local<v8::Value>();
-}
-
-v8::Local<v8::Value> FXJS_GetListValue(v8::Isolate* pIsolate,
-                                       v8::Local<v8::Value> pList,
-                                       int index) {
-  v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
-  if (!pList.IsEmpty() && pList->IsObject()) {
-    v8::Local<v8::Object> obj;
-    if (pList->ToObject(context).ToLocal(&obj)) {
-      v8::Local<v8::Value> val;
-      if (obj->Get(context, index).ToLocal(&val))
-        return val;
-    }
-  }
-  return v8::Local<v8::Value>();
-}
-
 int FXJS_ToInt32(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue) {
   if (pValue.IsEmpty())
     return 0;