| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 v8::Isolate::CreateParams params; | 74 v8::Isolate::CreateParams params; |
| 75 params.array_buffer_allocator = m_pArrayBufferAllocator.get(); | 75 params.array_buffer_allocator = m_pArrayBufferAllocator.get(); |
| 76 m_isolate = v8::Isolate::New(params); | 76 m_isolate = v8::Isolate::New(params); |
| 77 m_isolateManaged = true; | 77 m_isolateManaged = true; |
| 78 } | 78 } |
| 79 | 79 |
| 80 v8::Isolate* isolate = m_isolate; | 80 v8::Isolate* isolate = m_isolate; |
| 81 v8::Isolate::Scope isolate_scope(isolate); | 81 v8::Isolate::Scope isolate_scope(isolate); |
| 82 v8::Locker locker(isolate); | 82 v8::Locker locker(isolate); |
| 83 v8::HandleScope handle_scope(isolate); | 83 v8::HandleScope handle_scope(isolate); |
| 84 if (CPDFXFA_App::GetInstance()->InitRuntime(FALSE)) { | 84 if (CPDFXFA_App::GetInstance()->IsJavaScriptInitialized()) { |
| 85 CJS_Context* pContext = (CJS_Context*)NewContext(); | 85 CJS_Context* pContext = (CJS_Context*)NewContext(); |
| 86 JS_InitializeRuntime(GetIsolate(), this, pContext, m_context); | 86 JS_InitializeRuntime(GetIsolate(), this, pContext, m_context); |
| 87 ReleaseContext(pContext); | 87 ReleaseContext(pContext); |
| 88 return; | 88 return; |
| 89 } | 89 } |
| 90 | 90 |
| 91 unsigned int embedderDataSlot = 0; | 91 unsigned int embedderDataSlot = 0; |
| 92 if (m_pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) | 92 if (m_pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) |
| 93 embedderDataSlot = pApp->GetFormFillInfo()->m_pJsPlatform->m_v8EmbedderSlot; | 93 embedderDataSlot = pApp->GetFormFillInfo()->m_pJsPlatform->m_v8EmbedderSlot; |
| 94 JS_Initialize(embedderDataSlot); | 94 JS_Initialize(embedderDataSlot); |
| 95 DefineJSObjects(); | 95 DefineJSObjects(); |
| 96 CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE); |
| 96 | 97 |
| 97 CJS_Context* pContext = (CJS_Context*)NewContext(); | 98 CJS_Context* pContext = (CJS_Context*)NewContext(); |
| 98 JS_InitializeRuntime(GetIsolate(), this, pContext, m_context); | 99 JS_InitializeRuntime(GetIsolate(), this, pContext, m_context); |
| 99 ReleaseContext(pContext); | 100 ReleaseContext(pContext); |
| 100 } | 101 } |
| 101 | 102 |
| 102 CJS_Runtime::~CJS_Runtime() { | 103 CJS_Runtime::~CJS_Runtime() { |
| 103 int size = m_ContextArray.GetSize(); | 104 int size = m_ContextArray.GetSize(); |
| 104 for (int i = 0; i < size; i++) | 105 for (int i = 0; i < size; i++) |
| 105 delete m_ContextArray.GetAt(i); | 106 delete m_ContextArray.GetAt(i); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 // v8::Local<v8::Context>::New(GetIsolate(), m_context); | 338 // v8::Local<v8::Context>::New(GetIsolate(), m_context); |
| 338 v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New( | 339 v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New( |
| 339 GetIsolate(), ((CFXJSE_Value*)hValue)->DirectGetValue()); | 340 GetIsolate(), ((CFXJSE_Value*)hValue)->DirectGetValue()); |
| 340 context->Global()->Set( | 341 context->Global()->Set( |
| 341 v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString, | 342 v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString, |
| 342 utf8Name.GetLength()), | 343 utf8Name.GetLength()), |
| 343 propvalue); | 344 propvalue); |
| 344 | 345 |
| 345 return TRUE; | 346 return TRUE; |
| 346 } | 347 } |
| OLD | NEW |