| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 /* ------------------------------ CJS_Runtime ------------------------------ */ | 108 /* ------------------------------ CJS_Runtime ------------------------------ */ |
| 109 extern v8::Global<v8::ObjectTemplate>& _getGlobalObjectTemplate(IJS_Runtime* pJS
Runtime); | 109 extern v8::Global<v8::ObjectTemplate>& _getGlobalObjectTemplate(IJS_Runtime* pJS
Runtime); |
| 110 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) : | 110 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) : |
| 111 m_pApp(pApp), | 111 m_pApp(pApp), |
| 112 m_pDocument(NULL), | 112 m_pDocument(NULL), |
| 113 m_bBlocking(FALSE), | 113 m_bBlocking(FALSE), |
| 114 m_bRegistered(FALSE), | 114 m_bRegistered(FALSE), |
| 115 m_pFieldEventPath(NULL) | 115 m_pFieldEventPath(NULL) |
| 116 { | 116 { |
| 117 » if (FPDFXFA_GetApp()->GetJSERuntime()) { | 117 » if (CPDFXFA_App::GetInstance()->GetJSERuntime()) { |
| 118 » » m_isolate = (v8::Isolate*)FPDFXFA_GetApp()->GetJSERuntime(); | 118 » » m_isolate = (v8::Isolate*)CPDFXFA_App::GetInstance()->GetJSERunt
ime(); |
| 119 } else { | 119 } else { |
| 120 m_pArrayBufferAllocator.reset(new CJS_ArrayBufferAllocator()); | 120 m_pArrayBufferAllocator.reset(new CJS_ArrayBufferAllocator()); |
| 121 v8::Isolate::CreateParams params; | 121 v8::Isolate::CreateParams params; |
| 122 params.array_buffer_allocator = m_pArrayBufferAllocator.get(); | 122 params.array_buffer_allocator = m_pArrayBufferAllocator.get(); |
| 123 m_isolate = v8::Isolate::New(params); | 123 m_isolate = v8::Isolate::New(params); |
| 124 } | 124 } |
| 125 | 125 |
| 126 v8::Isolate* isolate = m_isolate; | 126 v8::Isolate* isolate = m_isolate; |
| 127 v8::Isolate::Scope isolate_scope(isolate); | 127 v8::Isolate::Scope isolate_scope(isolate); |
| 128 v8::Locker locker(isolate); | 128 v8::Locker locker(isolate); |
| 129 v8::HandleScope handle_scope(isolate); | 129 v8::HandleScope handle_scope(isolate); |
| 130 » if (FPDFXFA_GetApp()->InitRuntime(FALSE)) { | 130 » if (CPDFXFA_App::GetInstance()->InitRuntime(FALSE)) { |
| 131 CJS_Context * pContext = (CJS_Context*)NewContext(); | 131 CJS_Context * pContext = (CJS_Context*)NewContext(); |
| 132 JS_InitialRuntime(*this, this, pContext, m_context); | 132 JS_InitialRuntime(*this, this, pContext, m_context); |
| 133 ReleaseContext(pContext); | 133 ReleaseContext(pContext); |
| 134 return; | 134 return; |
| 135 } | 135 } |
| 136 | 136 |
| 137 InitJSObjects(); | 137 InitJSObjects(); |
| 138 | 138 |
| 139 CJS_Context * pContext = (CJS_Context*)NewContext(); | 139 CJS_Context * pContext = (CJS_Context*)NewContext(); |
| 140 JS_InitialRuntime(*this, this, pContext, m_context); | 140 JS_InitialRuntime(*this, this, pContext, m_context); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 v8::Local<v8::Context> context = | 394 v8::Local<v8::Context> context = |
| 395 v8::Local<v8::Context>::New(pIsolate, m_context); | 395 v8::Local<v8::Context>::New(pIsolate, m_context); |
| 396 v8::Context::Scope context_scope(context); | 396 v8::Context::Scope context_scope(context); |
| 397 | 397 |
| 398 //v8::Local<v8::Context> tmpCotext = v8::Local<v8::Context>::New(GetIsol
ate(), m_context); | 398 //v8::Local<v8::Context> tmpCotext = v8::Local<v8::Context>::New(GetIsol
ate(), m_context); |
| 399 v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New(GetIsolate(),
((CFXJSE_Value*)hValue)->DirectGetValue()); | 399 v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New(GetIsolate(),
((CFXJSE_Value*)hValue)->DirectGetValue()); |
| 400 context->Global()->Set(v8::String::NewFromUtf8(pIsolate, name, v8::Strin
g::kNormalString, utf8Name.GetLength()), propvalue); | 400 context->Global()->Set(v8::String::NewFromUtf8(pIsolate, name, v8::Strin
g::kNormalString, utf8Name.GetLength()), propvalue); |
| 401 | 401 |
| 402 return TRUE; | 402 return TRUE; |
| 403 } | 403 } |
| OLD | NEW |