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 // FXJS_V8 is a layer that makes it easier to define native objects in V8, but | 7 // FXJS_V8 is a layer that makes it easier to define native objects in V8, but |
8 // has no knowledge of PDF-specific native objects. It could in theory be used | 8 // has no knowledge of PDF-specific native objects. It could in theory be used |
9 // to implement other sets of native objects. | 9 // to implement other sets of native objects. |
10 | 10 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 explicit CFXJS_Engine(v8::Isolate* pIsolate); | 132 explicit CFXJS_Engine(v8::Isolate* pIsolate); |
133 ~CFXJS_Engine(); | 133 ~CFXJS_Engine(); |
134 | 134 |
135 using Constructor = void (*)(CFXJS_Engine* pEngine, | 135 using Constructor = void (*)(CFXJS_Engine* pEngine, |
136 v8::Local<v8::Object> obj); | 136 v8::Local<v8::Object> obj); |
137 using Destructor = void (*)(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); | 137 using Destructor = void (*)(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); |
138 | 138 |
139 static CFXJS_Engine* CurrentEngineFromIsolate(v8::Isolate* pIsolate); | 139 static CFXJS_Engine* CurrentEngineFromIsolate(v8::Isolate* pIsolate); |
140 static int GetObjDefnID(v8::Local<v8::Object> pObj); | 140 static int GetObjDefnID(v8::Local<v8::Object> pObj); |
141 | 141 |
| 142 #ifdef PDF_ENABLE_XFA |
| 143 // Called as part of FXJS_InitializeEngine, exposed so PDF can make its |
| 144 // own contexts compatible with XFA or vice versa. |
| 145 static void SetForV8Context(v8::Local<v8::Context> v8Context, |
| 146 CFXJS_Engine* pEngine); |
| 147 #endif // PDF_ENABLE_XFA |
| 148 |
142 v8::Isolate* GetIsolate() const { return m_isolate; } | 149 v8::Isolate* GetIsolate() const { return m_isolate; } |
143 | 150 |
144 // Always returns a valid, newly-created objDefnID. | 151 // Always returns a valid, newly-created objDefnID. |
145 int DefineObj(const wchar_t* sObjName, | 152 int DefineObj(const wchar_t* sObjName, |
146 FXJSOBJTYPE eObjType, | 153 FXJSOBJTYPE eObjType, |
147 Constructor pConstructor, | 154 Constructor pConstructor, |
148 Destructor pDestructor); | 155 Destructor pDestructor); |
149 | 156 |
150 void DefineObjMethod(int nObjDefnID, | 157 void DefineObjMethod(int nObjDefnID, |
151 const wchar_t* sMethodName, | 158 const wchar_t* sMethodName, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 void SetIsolate(v8::Isolate* pIsolate) { m_isolate = pIsolate; } | 253 void SetIsolate(v8::Isolate* pIsolate) { m_isolate = pIsolate; } |
247 | 254 |
248 private: | 255 private: |
249 v8::Isolate* m_isolate; | 256 v8::Isolate* m_isolate; |
250 v8::Global<v8::Context> m_V8PersistentContext; | 257 v8::Global<v8::Context> m_V8PersistentContext; |
251 std::vector<v8::Global<v8::Object>*> m_StaticObjects; | 258 std::vector<v8::Global<v8::Object>*> m_StaticObjects; |
252 std::map<CFX_WideString, v8::Global<v8::Array>> m_ConstArrays; | 259 std::map<CFX_WideString, v8::Global<v8::Array>> m_ConstArrays; |
253 }; | 260 }; |
254 | 261 |
255 #endif // FXJS_FXJS_V8_H_ | 262 #endif // FXJS_FXJS_V8_H_ |
OLD | NEW |