| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 v8::Isolate::CreateParams params; | 52 v8::Isolate::CreateParams params; |
| 53 params.array_buffer_allocator = m_pArrayBufferAllocator.get(); | 53 params.array_buffer_allocator = m_pArrayBufferAllocator.get(); |
| 54 m_isolate = v8::Isolate::New(params); | 54 m_isolate = v8::Isolate::New(params); |
| 55 m_isolateManaged = true; | 55 m_isolateManaged = true; |
| 56 } | 56 } |
| 57 | 57 |
| 58 v8::Isolate* isolate = m_isolate; | 58 v8::Isolate* isolate = m_isolate; |
| 59 v8::Isolate::Scope isolate_scope(isolate); | 59 v8::Isolate::Scope isolate_scope(isolate); |
| 60 v8::Locker locker(isolate); | 60 v8::Locker locker(isolate); |
| 61 v8::HandleScope handle_scope(isolate); | 61 v8::HandleScope handle_scope(isolate); |
| 62 if (CPDFXFA_App::GetInstance()->InitRuntime(FALSE)) { | 62 if (CPDFXFA_App::GetInstance()->IsJavaScriptInitialized()) { |
| 63 CJS_Context* pContext = (CJS_Context*)NewContext(); | 63 CJS_Context* pContext = (CJS_Context*)NewContext(); |
| 64 FXJS_InitializeRuntime(GetIsolate(), this, pContext, m_context); | 64 FXJS_InitializeRuntime(GetIsolate(), this, pContext, m_context); |
| 65 ReleaseContext(pContext); | 65 ReleaseContext(pContext); |
| 66 return; | 66 return; |
| 67 } | 67 } |
| 68 | 68 |
| 69 unsigned int embedderDataSlot = 0; | 69 unsigned int embedderDataSlot = 0; |
| 70 if (m_pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) | 70 if (m_pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) |
| 71 embedderDataSlot = pApp->GetFormFillInfo()->m_pJsPlatform->m_v8EmbedderSlot; | 71 embedderDataSlot = pApp->GetFormFillInfo()->m_pJsPlatform->m_v8EmbedderSlot; |
| 72 FXJS_Initialize(embedderDataSlot); | 72 FXJS_Initialize(embedderDataSlot); |
| 73 DefineJSObjects(); | 73 DefineJSObjects(); |
| 74 CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE); |
| 74 | 75 |
| 75 CJS_Context* pContext = (CJS_Context*)NewContext(); | 76 CJS_Context* pContext = (CJS_Context*)NewContext(); |
| 76 FXJS_InitializeRuntime(GetIsolate(), this, pContext, m_context); | 77 FXJS_InitializeRuntime(GetIsolate(), this, pContext, m_context); |
| 77 ReleaseContext(pContext); | 78 ReleaseContext(pContext); |
| 78 } | 79 } |
| 79 | 80 |
| 80 CJS_Runtime::~CJS_Runtime() { | 81 CJS_Runtime::~CJS_Runtime() { |
| 81 int size = m_ContextArray.GetSize(); | 82 int size = m_ContextArray.GetSize(); |
| 82 for (int i = 0; i < size; i++) | 83 for (int i = 0; i < size; i++) |
| 83 delete m_ContextArray.GetAt(i); | 84 delete m_ContextArray.GetAt(i); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 // v8::Local<v8::Context>::New(GetIsolate(), m_context); | 316 // v8::Local<v8::Context>::New(GetIsolate(), m_context); |
| 316 v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New( | 317 v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New( |
| 317 GetIsolate(), ((CFXJSE_Value*)hValue)->DirectGetValue()); | 318 GetIsolate(), ((CFXJSE_Value*)hValue)->DirectGetValue()); |
| 318 context->Global()->Set( | 319 context->Global()->Set( |
| 319 v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString, | 320 v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString, |
| 320 utf8Name.GetLength()), | 321 utf8Name.GetLength()), |
| 321 propvalue); | 322 propvalue); |
| 322 | 323 |
| 323 return TRUE; | 324 return TRUE; |
| 324 } | 325 } |
| OLD | NEW |