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/javascript/cjs_runtime.h" | 7 #include "fpdfsdk/javascript/cjs_runtime.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "fpdfsdk/include/cpdfdoc_environment.h" | 11 #include "fpdfsdk/include/cpdfsdk_environment.h" |
12 #include "fpdfsdk/javascript/Annot.h" | 12 #include "fpdfsdk/javascript/Annot.h" |
13 #include "fpdfsdk/javascript/Consts.h" | 13 #include "fpdfsdk/javascript/Consts.h" |
14 #include "fpdfsdk/javascript/Document.h" | 14 #include "fpdfsdk/javascript/Document.h" |
15 #include "fpdfsdk/javascript/Field.h" | 15 #include "fpdfsdk/javascript/Field.h" |
16 #include "fpdfsdk/javascript/Icon.h" | 16 #include "fpdfsdk/javascript/Icon.h" |
17 #include "fpdfsdk/javascript/JS_Define.h" | 17 #include "fpdfsdk/javascript/JS_Define.h" |
18 #include "fpdfsdk/javascript/JS_EventHandler.h" | 18 #include "fpdfsdk/javascript/JS_EventHandler.h" |
19 #include "fpdfsdk/javascript/JS_GlobalData.h" | 19 #include "fpdfsdk/javascript/JS_GlobalData.h" |
20 #include "fpdfsdk/javascript/JS_Object.h" | 20 #include "fpdfsdk/javascript/JS_Object.h" |
21 #include "fpdfsdk/javascript/JS_Value.h" | 21 #include "fpdfsdk/javascript/JS_Value.h" |
(...skipping 18 matching lines...) Expand all Loading... |
40 void IJS_Runtime::Initialize(unsigned int slot, void* isolate) { | 40 void IJS_Runtime::Initialize(unsigned int slot, void* isolate) { |
41 FXJS_Initialize(slot, reinterpret_cast<v8::Isolate*>(isolate)); | 41 FXJS_Initialize(slot, reinterpret_cast<v8::Isolate*>(isolate)); |
42 } | 42 } |
43 | 43 |
44 // static | 44 // static |
45 void IJS_Runtime::Destroy() { | 45 void IJS_Runtime::Destroy() { |
46 FXJS_Release(); | 46 FXJS_Release(); |
47 } | 47 } |
48 | 48 |
49 // static | 49 // static |
50 IJS_Runtime* IJS_Runtime::Create(CPDFDoc_Environment* pEnv) { | 50 IJS_Runtime* IJS_Runtime::Create(CPDFSDK_Environment* pEnv) { |
51 return new CJS_Runtime(pEnv); | 51 return new CJS_Runtime(pEnv); |
52 } | 52 } |
53 | 53 |
54 // static | 54 // static |
55 CJS_Runtime* CJS_Runtime::FromContext(const IJS_Context* cc) { | 55 CJS_Runtime* CJS_Runtime::FromContext(const IJS_Context* cc) { |
56 const CJS_Context* pContext = static_cast<const CJS_Context*>(cc); | 56 const CJS_Context* pContext = static_cast<const CJS_Context*>(cc); |
57 return pContext->GetJSRuntime(); | 57 return pContext->GetJSRuntime(); |
58 } | 58 } |
59 | 59 |
60 // static | 60 // static |
61 CJS_Runtime* CJS_Runtime::CurrentRuntimeFromIsolate(v8::Isolate* pIsolate) { | 61 CJS_Runtime* CJS_Runtime::CurrentRuntimeFromIsolate(v8::Isolate* pIsolate) { |
62 return static_cast<CJS_Runtime*>( | 62 return static_cast<CJS_Runtime*>( |
63 CFXJS_Engine::CurrentEngineFromIsolate(pIsolate)); | 63 CFXJS_Engine::CurrentEngineFromIsolate(pIsolate)); |
64 } | 64 } |
65 | 65 |
66 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) | 66 CJS_Runtime::CJS_Runtime(CPDFSDK_Environment* pApp) |
67 : m_pApp(pApp), | 67 : m_pApp(pApp), |
68 m_pDocument(nullptr), | 68 m_pDocument(nullptr), |
69 m_bBlocking(false), | 69 m_bBlocking(false), |
70 m_isolateManaged(false) { | 70 m_isolateManaged(false) { |
71 v8::Isolate* pIsolate = nullptr; | 71 v8::Isolate* pIsolate = nullptr; |
72 #ifndef PDF_ENABLE_XFA | 72 #ifndef PDF_ENABLE_XFA |
73 IPDF_JSPLATFORM* pPlatform = m_pApp->GetFormFillInfo()->m_pJsPlatform; | 73 IPDF_JSPLATFORM* pPlatform = m_pApp->GetFormFillInfo()->m_pJsPlatform; |
74 if (pPlatform->version <= 2) { | 74 if (pPlatform->version <= 2) { |
75 unsigned int embedderDataSlot = 0; | 75 unsigned int embedderDataSlot = 0; |
76 v8::Isolate* pExternalIsolate = nullptr; | 76 v8::Isolate* pExternalIsolate = nullptr; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 // v8::Local<v8::Context>::New(GetIsolate(), m_context); | 305 // v8::Local<v8::Context>::New(GetIsolate(), m_context); |
306 v8::Local<v8::Value> propvalue = | 306 v8::Local<v8::Value> propvalue = |
307 v8::Local<v8::Value>::New(GetIsolate(), pValue->DirectGetValue()); | 307 v8::Local<v8::Value>::New(GetIsolate(), pValue->DirectGetValue()); |
308 context->Global()->Set( | 308 context->Global()->Set( |
309 v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString, | 309 v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString, |
310 utf8Name.GetLength()), | 310 utf8Name.GetLength()), |
311 propvalue); | 311 propvalue); |
312 return TRUE; | 312 return TRUE; |
313 } | 313 } |
314 #endif | 314 #endif |
OLD | NEW |