| OLD | NEW | 
|---|
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 
| 6 | 6 | 
| 7 #include "fpdfsdk/jsapi/include/fxjs_v8.h" | 7 #include "fpdfsdk/jsapi/include/fxjs_v8.h" | 
| 8 | 8 | 
| 9 #include <vector> | 9 #include <vector> | 
| 10 | 10 | 
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 183   v8::Isolate::CreateParams params; | 183   v8::Isolate::CreateParams params; | 
| 184   params.array_buffer_allocator = g_arrayBufferAllocator; | 184   params.array_buffer_allocator = g_arrayBufferAllocator; | 
| 185   *pResultIsolate = v8::Isolate::New(params); | 185   *pResultIsolate = v8::Isolate::New(params); | 
| 186   return true; | 186   return true; | 
| 187 } | 187 } | 
| 188 | 188 | 
| 189 size_t FXJS_GlobalIsolateRefCount() { | 189 size_t FXJS_GlobalIsolateRefCount() { | 
| 190   return g_isolate_ref_count; | 190   return g_isolate_ref_count; | 
| 191 } | 191 } | 
| 192 | 192 | 
|  | 193 V8TemplateMap::V8TemplateMap(v8::Isolate* isolate) : m_map(isolate) {} | 
|  | 194 | 
|  | 195 V8TemplateMap::~V8TemplateMap() {} | 
|  | 196 | 
|  | 197 void V8TemplateMap::set(void* key, v8::Local<v8::Object> handle) { | 
|  | 198   ASSERT(!m_map.Contains(key)); | 
|  | 199   m_map.Set(key, handle); | 
|  | 200 } | 
|  | 201 | 
|  | 202 FXJS_PerIsolateData::~FXJS_PerIsolateData() {} | 
|  | 203 | 
| 193 // static | 204 // static | 
| 194 void FXJS_PerIsolateData::SetUp(v8::Isolate* pIsolate) { | 205 void FXJS_PerIsolateData::SetUp(v8::Isolate* pIsolate) { | 
| 195   if (!pIsolate->GetData(g_embedderDataSlot)) | 206   if (!pIsolate->GetData(g_embedderDataSlot)) | 
| 196     pIsolate->SetData(g_embedderDataSlot, new FXJS_PerIsolateData()); | 207     pIsolate->SetData(g_embedderDataSlot, new FXJS_PerIsolateData()); | 
| 197 } | 208 } | 
| 198 | 209 | 
| 199 // static | 210 // static | 
| 200 FXJS_PerIsolateData* FXJS_PerIsolateData::Get(v8::Isolate* pIsolate) { | 211 FXJS_PerIsolateData* FXJS_PerIsolateData::Get(v8::Isolate* pIsolate) { | 
| 201   return static_cast<FXJS_PerIsolateData*>( | 212   return static_cast<FXJS_PerIsolateData*>( | 
| 202       pIsolate->GetData(g_embedderDataSlot)); | 213       pIsolate->GetData(g_embedderDataSlot)); | 
| 203 } | 214 } | 
| 204 | 215 | 
|  | 216 #ifndef PDF_ENABLE_XFA | 
|  | 217 FXJS_PerIsolateData::FXJS_PerIsolateData() : m_pDynamicObjsMap(nullptr) {} | 
|  | 218 #else   // PDF_ENABLE_XFA | 
|  | 219 FXJS_PerIsolateData::FXJS_PerIsolateData() | 
|  | 220     : m_pFXJSERuntimeData(nullptr), m_pDynamicObjsMap(nullptr) {} | 
|  | 221 #endif  // PDF_ENABLE_XFA | 
|  | 222 | 
| 205 int FXJS_DefineObj(v8::Isolate* pIsolate, | 223 int FXJS_DefineObj(v8::Isolate* pIsolate, | 
| 206                    const wchar_t* sObjName, | 224                    const wchar_t* sObjName, | 
| 207                    FXJSOBJTYPE eObjType, | 225                    FXJSOBJTYPE eObjType, | 
| 208                    FXJS_CONSTRUCTOR pConstructor, | 226                    FXJS_CONSTRUCTOR pConstructor, | 
| 209                    FXJS_DESTRUCTOR pDestructor) { | 227                    FXJS_DESTRUCTOR pDestructor) { | 
| 210   v8::Isolate::Scope isolate_scope(pIsolate); | 228   v8::Isolate::Scope isolate_scope(pIsolate); | 
| 211   v8::HandleScope handle_scope(pIsolate); | 229   v8::HandleScope handle_scope(pIsolate); | 
| 212 | 230 | 
| 213   FXJS_PerIsolateData::SetUp(pIsolate); | 231   FXJS_PerIsolateData::SetUp(pIsolate); | 
| 214   CFXJS_ObjDefinition* pObjDef = new CFXJS_ObjDefinition( | 232   CFXJS_ObjDefinition* pObjDef = new CFXJS_ObjDefinition( | 
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 807                                   v8::Local<v8::Value> pValue) { | 825                                   v8::Local<v8::Value> pValue) { | 
| 808   if (pValue.IsEmpty()) | 826   if (pValue.IsEmpty()) | 
| 809     return v8::Local<v8::Array>(); | 827     return v8::Local<v8::Array>(); | 
| 810   v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); | 828   v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); | 
| 811   return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); | 829   return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); | 
| 812 } | 830 } | 
| 813 | 831 | 
| 814 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { | 832 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { | 
| 815   pTo = pFrom; | 833   pTo = pFrom; | 
| 816 } | 834 } | 
| OLD | NEW | 
|---|