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 "fxjs/include/fxjs_v8.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "core/fxcrt/include/fx_basic.h" | 11 #include "core/fxcrt/include/fx_basic.h" |
12 | 12 |
13 const wchar_t kFXJSValueNameString[] = L"string"; | 13 const wchar_t kFXJSValueNameString[] = L"string"; |
14 const wchar_t kFXJSValueNameNumber[] = L"number"; | 14 const wchar_t kFXJSValueNameNumber[] = L"number"; |
15 const wchar_t kFXJSValueNameBoolean[] = L"boolean"; | 15 const wchar_t kFXJSValueNameBoolean[] = L"boolean"; |
16 const wchar_t kFXJSValueNameDate[] = L"date"; | 16 const wchar_t kFXJSValueNameDate[] = L"date"; |
17 const wchar_t kFXJSValueNameObject[] = L"object"; | 17 const wchar_t kFXJSValueNameObject[] = L"object"; |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 v8::Local<v8::Object> obj; | 507 v8::Local<v8::Object> obj; |
508 if (!pObjDef->GetInstanceTemplate()->NewInstance(context).ToLocal(&obj)) | 508 if (!pObjDef->GetInstanceTemplate()->NewInstance(context).ToLocal(&obj)) |
509 return v8::Local<v8::Object>(); | 509 return v8::Local<v8::Object>(); |
510 | 510 |
511 CFXJS_PerObjectData* pPerObjData = new CFXJS_PerObjectData(nObjDefnID); | 511 CFXJS_PerObjectData* pPerObjData = new CFXJS_PerObjectData(nObjDefnID); |
512 obj->SetAlignedPointerInInternalField(0, pPerObjData); | 512 obj->SetAlignedPointerInInternalField(0, pPerObjData); |
513 if (pObjDef->m_pConstructor) | 513 if (pObjDef->m_pConstructor) |
514 pObjDef->m_pConstructor(pIRuntime, obj); | 514 pObjDef->m_pConstructor(pIRuntime, obj); |
515 | 515 |
516 if (!bStatic && FXJS_PerIsolateData::Get(pIsolate)->m_pDynamicObjsMap) { | 516 if (!bStatic && FXJS_PerIsolateData::Get(pIsolate)->m_pDynamicObjsMap) { |
517 FXJS_PerIsolateData::Get(pIsolate) | 517 FXJS_PerIsolateData::Get(pIsolate)->m_pDynamicObjsMap->set(pPerObjData, |
518 ->m_pDynamicObjsMap->set(pPerObjData, obj); | 518 obj); |
519 } | 519 } |
520 return obj; | 520 return obj; |
521 } | 521 } |
522 | 522 |
523 v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate) { | 523 v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate) { |
524 v8::Isolate::Scope isolate_scope(pIsolate); | 524 v8::Isolate::Scope isolate_scope(pIsolate); |
525 if (!FXJS_PerIsolateData::Get(pIsolate)) | 525 if (!FXJS_PerIsolateData::Get(pIsolate)) |
526 return v8::Local<v8::Object>(); | 526 return v8::Local<v8::Object>(); |
527 | 527 |
528 // Return the global object. | 528 // Return the global object. |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 v8::Local<v8::Value> pValue) { | 847 v8::Local<v8::Value> pValue) { |
848 if (pValue.IsEmpty()) | 848 if (pValue.IsEmpty()) |
849 return v8::Local<v8::Array>(); | 849 return v8::Local<v8::Array>(); |
850 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); | 850 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); |
851 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); | 851 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); |
852 } | 852 } |
853 | 853 |
854 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { | 854 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { |
855 pTo = pFrom; | 855 pTo = pFrom; |
856 } | 856 } |
OLD | NEW |