| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 305 | 305 | 
| 306 void FXJS_InitializeRuntime( | 306 void FXJS_InitializeRuntime( | 
| 307     v8::Isolate* pIsolate, | 307     v8::Isolate* pIsolate, | 
| 308     IJS_Runtime* pIRuntime, | 308     IJS_Runtime* pIRuntime, | 
| 309     v8::Global<v8::Context>* pV8PersistentContext, | 309     v8::Global<v8::Context>* pV8PersistentContext, | 
| 310     std::vector<v8::Global<v8::Object>*>* pStaticObjects) { | 310     std::vector<v8::Global<v8::Object>*>* pStaticObjects) { | 
| 311   if (pIsolate == g_isolate) | 311   if (pIsolate == g_isolate) | 
| 312     ++g_isolate_ref_count; | 312     ++g_isolate_ref_count; | 
| 313 | 313 | 
| 314   v8::Isolate::Scope isolate_scope(pIsolate); | 314   v8::Isolate::Scope isolate_scope(pIsolate); | 
| 315 #ifdef PDF_ENABLE_XFA |  | 
| 316   v8::Locker locker(pIsolate); |  | 
| 317 #endif  // PDF_ENABLE_XFA |  | 
| 318   v8::HandleScope handle_scope(pIsolate); | 315   v8::HandleScope handle_scope(pIsolate); | 
| 319   v8::Local<v8::Context> v8Context = | 316   v8::Local<v8::Context> v8Context = | 
| 320       v8::Context::New(pIsolate, NULL, GetGlobalObjectTemplate(pIsolate)); | 317       v8::Context::New(pIsolate, NULL, GetGlobalObjectTemplate(pIsolate)); | 
| 321   v8::Context::Scope context_scope(v8Context); | 318   v8::Context::Scope context_scope(v8Context); | 
| 322 | 319 | 
| 323   FXJS_PerIsolateData::SetUp(pIsolate); | 320   FXJS_PerIsolateData::SetUp(pIsolate); | 
| 324   FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate); | 321   FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate); | 
| 325   if (!pData) | 322   if (!pData) | 
| 326     return; | 323     return; | 
| 327   pData->CreateDynamicObjsMap(pIsolate); | 324   pData->CreateDynamicObjsMap(pIsolate); | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 356       pStaticObjects->at(i) = new v8::Global<v8::Object>(pIsolate, obj); | 353       pStaticObjects->at(i) = new v8::Global<v8::Object>(pIsolate, obj); | 
| 357     } | 354     } | 
| 358   } | 355   } | 
| 359   pV8PersistentContext->Reset(pIsolate, v8Context); | 356   pV8PersistentContext->Reset(pIsolate, v8Context); | 
| 360 } | 357 } | 
| 361 | 358 | 
| 362 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, | 359 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, | 
| 363                          v8::Global<v8::Context>* pV8PersistentContext, | 360                          v8::Global<v8::Context>* pV8PersistentContext, | 
| 364                          std::vector<v8::Global<v8::Object>*>* pStaticObjects) { | 361                          std::vector<v8::Global<v8::Object>*>* pStaticObjects) { | 
| 365   v8::Isolate::Scope isolate_scope(pIsolate); | 362   v8::Isolate::Scope isolate_scope(pIsolate); | 
| 366 #ifdef PDF_ENABLE_XFA |  | 
| 367   v8::Locker locker(pIsolate); |  | 
| 368 #endif  // PDF_ENABLE_XFA |  | 
| 369   v8::HandleScope handle_scope(pIsolate); | 363   v8::HandleScope handle_scope(pIsolate); | 
| 370   v8::Local<v8::Context> context = | 364   v8::Local<v8::Context> context = | 
| 371       v8::Local<v8::Context>::New(pIsolate, *pV8PersistentContext); | 365       v8::Local<v8::Context>::New(pIsolate, *pV8PersistentContext); | 
| 372   v8::Context::Scope context_scope(context); | 366   v8::Context::Scope context_scope(context); | 
| 373 | 367 | 
| 374   FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate); | 368   FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate); | 
| 375   if (!pData) | 369   if (!pData) | 
| 376     return; | 370     return; | 
| 377 | 371 | 
| 378   int maxID = CFXJS_ObjDefinition::MaxID(pIsolate); | 372   int maxID = CFXJS_ObjDefinition::MaxID(pIsolate); | 
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 814                                   v8::Local<v8::Value> pValue) { | 808                                   v8::Local<v8::Value> pValue) { | 
| 815   if (pValue.IsEmpty()) | 809   if (pValue.IsEmpty()) | 
| 816     return v8::Local<v8::Array>(); | 810     return v8::Local<v8::Array>(); | 
| 817   v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); | 811   v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); | 
| 818   return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); | 812   return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); | 
| 819 } | 813 } | 
| 820 | 814 | 
| 821 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { | 815 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { | 
| 822   pTo = pFrom; | 816   pTo = pFrom; | 
| 823 } | 817 } | 
| OLD | NEW | 
|---|