| 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 "../../include/jsapi/fxjs_v8.h" | 7 #include "../../include/jsapi/fxjs_v8.h" |
| 8 | 8 |
| 9 #include "../../../core/include/fxcrt/fx_basic.h" | 9 #include "../../../core/include/fxcrt/fx_basic.h" |
| 10 | 10 |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 v8Context->Global() | 301 v8Context->Global() |
| 302 ->GetPrototype() | 302 ->GetPrototype() |
| 303 ->ToObject(v8Context) | 303 ->ToObject(v8Context) |
| 304 .ToLocalChecked() | 304 .ToLocalChecked() |
| 305 ->SetAlignedPointerInInternalField(0, new CFXJS_PrivateData(i)); | 305 ->SetAlignedPointerInInternalField(0, new CFXJS_PrivateData(i)); |
| 306 | 306 |
| 307 if (pObjDef->m_pConstructor) | 307 if (pObjDef->m_pConstructor) |
| 308 pObjDef->m_pConstructor(context, v8Context->Global() | 308 pObjDef->m_pConstructor(context, v8Context->Global() |
| 309 ->GetPrototype() | 309 ->GetPrototype() |
| 310 ->ToObject(v8Context) | 310 ->ToObject(v8Context) |
| 311 .ToLocalChecked(), | 311 .ToLocalChecked()); |
| 312 v8Context->Global() | |
| 313 ->GetPrototype() | |
| 314 ->ToObject(v8Context) | |
| 315 .ToLocalChecked()); | |
| 316 } else if (pObjDef->m_ObjType == FXJSOBJTYPE_STATIC) { | 312 } else if (pObjDef->m_ObjType == FXJSOBJTYPE_STATIC) { |
| 317 v8::Local<v8::Object> obj = FXJS_NewFxDynamicObj(pIsolate, context, i); | 313 v8::Local<v8::Object> obj = FXJS_NewFxDynamicObj(pIsolate, context, i); |
| 318 v8Context->Global()->Set(v8Context, m_ObjName, obj).FromJust(); | 314 v8Context->Global()->Set(v8Context, m_ObjName, obj).FromJust(); |
| 319 pObjDef->m_StaticObj.Reset(pIsolate, obj); | 315 pObjDef->m_StaticObj.Reset(pIsolate, obj); |
| 320 } | 316 } |
| 321 } | 317 } |
| 322 v8PersistentContext.Reset(pIsolate, v8Context); | 318 v8PersistentContext.Reset(pIsolate, v8Context); |
| 323 } | 319 } |
| 324 | 320 |
| 325 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, | 321 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 if (nObjDefnID < 0 || nObjDefnID >= CFXJS_ObjDefinition::MaxID(pIsolate)) | 405 if (nObjDefnID < 0 || nObjDefnID >= CFXJS_ObjDefinition::MaxID(pIsolate)) |
| 410 return v8::Local<v8::Object>(); | 406 return v8::Local<v8::Object>(); |
| 411 | 407 |
| 412 CFXJS_ObjDefinition* pObjDef = | 408 CFXJS_ObjDefinition* pObjDef = |
| 413 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID); | 409 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID); |
| 414 v8::Local<v8::Object> obj; | 410 v8::Local<v8::Object> obj; |
| 415 if (!pObjDef->GetInstanceTemplate()->NewInstance(context).ToLocal(&obj)) | 411 if (!pObjDef->GetInstanceTemplate()->NewInstance(context).ToLocal(&obj)) |
| 416 return v8::Local<v8::Object>(); | 412 return v8::Local<v8::Object>(); |
| 417 | 413 |
| 418 obj->SetAlignedPointerInInternalField(0, new CFXJS_PrivateData(nObjDefnID)); | 414 obj->SetAlignedPointerInInternalField(0, new CFXJS_PrivateData(nObjDefnID)); |
| 419 if (pObjDef->m_pConstructor) { | 415 if (pObjDef->m_pConstructor) |
| 420 pObjDef->m_pConstructor( | 416 pObjDef->m_pConstructor(pJSContext, obj); |
| 421 pJSContext, obj, | |
| 422 context->Global()->GetPrototype()->ToObject(context).ToLocalChecked()); | |
| 423 } | |
| 424 | 417 |
| 425 return obj; | 418 return obj; |
| 426 } | 419 } |
| 427 | 420 |
| 428 v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate) { | 421 v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate) { |
| 429 v8::Isolate::Scope isolate_scope(pIsolate); | 422 v8::Isolate::Scope isolate_scope(pIsolate); |
| 430 if (!FXJS_PerIsolateData::Get(pIsolate)) | 423 if (!FXJS_PerIsolateData::Get(pIsolate)) |
| 431 return v8::Local<v8::Object>(); | 424 return v8::Local<v8::Object>(); |
| 432 | 425 |
| 433 // Return the global object. | 426 // Return the global object. |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 return v8::Local<v8::Array>(); | 748 return v8::Local<v8::Array>(); |
| 756 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); | 749 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); |
| 757 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); | 750 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); |
| 758 } | 751 } |
| 759 | 752 |
| 760 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { | 753 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { |
| 761 pTo = pFrom; | 754 pTo = pFrom; |
| 762 } | 755 } |
| 763 | 756 |
| 764 | 757 |
| OLD | NEW |