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/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
9 #include "../../include/javascript/JS_EventHandler.h" | 9 #include "../../include/javascript/JS_EventHandler.h" |
10 #include "../../include/javascript/JS_Runtime.h" | 10 #include "../../include/javascript/JS_Runtime.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 free(data); | 103 free(data); |
104 } | 104 } |
105 | 105 |
106 /* ------------------------------ CJS_Runtime ------------------------------ */ | 106 /* ------------------------------ CJS_Runtime ------------------------------ */ |
107 | 107 |
108 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment * pApp) : | 108 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment * pApp) : |
109 m_pApp(pApp), | 109 m_pApp(pApp), |
110 m_pDocument(NULL), | 110 m_pDocument(NULL), |
111 m_bBlocking(FALSE), | 111 m_bBlocking(FALSE), |
112 m_bRegistered(FALSE), | 112 m_bRegistered(FALSE), |
113 » m_pFieldEventPath(NULL) | 113 » m_pFieldEventPath(NULL), |
| 114 m_isolate(NULL) |
114 { | 115 { |
115 » m_pArrayBufferAllocator.reset(new CJS_ArrayBufferAllocator()); | 116 » if (m_pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) { |
| 117 » » m_isolate = m_pApp->GetFormFillInfo()->m_pJsPlatform->m_isolate; |
| 118 » } |
| 119 » if (!m_isolate) { |
| 120 » » m_pArrayBufferAllocator.reset(new CJS_ArrayBufferAllocator()); |
116 | 121 |
117 » v8::Isolate::CreateParams params; | 122 » » v8::Isolate::CreateParams params; |
118 » params.array_buffer_allocator = m_pArrayBufferAllocator.get(); | 123 » » params.array_buffer_allocator = m_pArrayBufferAllocator.get(); |
119 » m_isolate = v8::Isolate::New(params); | 124 » » m_isolate = v8::Isolate::New(params); |
| 125 } |
120 | 126 |
121 InitJSObjects(); | 127 InitJSObjects(); |
122 | 128 |
123 CJS_Context * pContext = (CJS_Context*)NewContext(); | 129 CJS_Context * pContext = (CJS_Context*)NewContext(); |
124 JS_InitialRuntime(*this, this, pContext, m_context); | 130 JS_InitialRuntime(*this, this, pContext, m_context); |
125 ReleaseContext(pContext); | 131 ReleaseContext(pContext); |
126 } | 132 } |
127 | 133 |
128 CJS_Runtime::~CJS_Runtime() | 134 CJS_Runtime::~CJS_Runtime() |
129 { | 135 { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 { | 338 { |
333 return v8::Local<v8::Context>::New(m_isolate, m_context); | 339 return v8::Local<v8::Context>::New(m_isolate, m_context); |
334 } | 340 } |
335 | 341 |
336 CFX_WideString ChangeObjName(const CFX_WideString& str) | 342 CFX_WideString ChangeObjName(const CFX_WideString& str) |
337 { | 343 { |
338 CFX_WideString sRet = str; | 344 CFX_WideString sRet = str; |
339 sRet.Replace(L"_", L"."); | 345 sRet.Replace(L"_", L"."); |
340 return sRet; | 346 return sRet; |
341 } | 347 } |
OLD | NEW |