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 "JS_Runtime.h" | 7 #include "JS_Runtime.h" |
8 | 8 |
9 #include "../../../xfa/src/fxjse/src/value.h" | 9 #include "../../../xfa/src/fxjse/src/value.h" |
10 #include "../../include/fpdfxfa/fpdfxfa_app.h" | 10 #include "../../include/fpdfxfa/fpdfxfa_app.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 m_isolateManaged = FXJS_GetIsolate(&m_isolate); | 71 m_isolateManaged = FXJS_GetIsolate(&m_isolate); |
72 } | 72 } |
73 | 73 |
74 v8::Isolate* isolate = m_isolate; | 74 v8::Isolate* isolate = m_isolate; |
75 v8::Isolate::Scope isolate_scope(isolate); | 75 v8::Isolate::Scope isolate_scope(isolate); |
76 v8::Locker locker(isolate); | 76 v8::Locker locker(isolate); |
77 v8::HandleScope handle_scope(isolate); | 77 v8::HandleScope handle_scope(isolate); |
78 if (CPDFXFA_App::GetInstance()->IsJavaScriptInitialized()) { | 78 if (CPDFXFA_App::GetInstance()->IsJavaScriptInitialized()) { |
79 CJS_Context* pContext = (CJS_Context*)NewContext(); | 79 CJS_Context* pContext = (CJS_Context*)NewContext(); |
80 FXJS_InitializeRuntime(GetIsolate(), this, m_context); | 80 FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects); |
81 ReleaseContext(pContext); | 81 ReleaseContext(pContext); |
82 return; | 82 return; |
83 } | 83 } |
84 | 84 |
85 if (m_isolateManaged || FXJS_GlobalIsolateRefCount() == 0) | 85 if (m_isolateManaged || FXJS_GlobalIsolateRefCount() == 0) |
86 DefineJSObjects(); | 86 DefineJSObjects(); |
87 | 87 |
88 CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE); | 88 CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE); |
89 | 89 |
90 CJS_Context* pContext = (CJS_Context*)NewContext(); | 90 CJS_Context* pContext = (CJS_Context*)NewContext(); |
91 FXJS_InitializeRuntime(GetIsolate(), this, m_context); | 91 FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects); |
92 ReleaseContext(pContext); | 92 ReleaseContext(pContext); |
93 } | 93 } |
94 | 94 |
95 CJS_Runtime::~CJS_Runtime() { | 95 CJS_Runtime::~CJS_Runtime() { |
96 for (auto* obs : m_observers) | 96 for (auto* obs : m_observers) |
97 obs->OnDestroyed(); | 97 obs->OnDestroyed(); |
98 | 98 |
99 int size = m_ContextArray.GetSize(); | 99 int size = m_ContextArray.GetSize(); |
100 for (int i = 0; i < size; i++) | 100 for (int i = 0; i < size; i++) |
101 delete m_ContextArray.GetAt(i); | 101 delete m_ContextArray.GetAt(i); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 300 |
301 void CJS_Runtime::AddObserver(Observer* observer) { | 301 void CJS_Runtime::AddObserver(Observer* observer) { |
302 ASSERT(m_observers.find(observer) == m_observers.end()); | 302 ASSERT(m_observers.find(observer) == m_observers.end()); |
303 m_observers.insert(observer); | 303 m_observers.insert(observer); |
304 } | 304 } |
305 | 305 |
306 void CJS_Runtime::RemoveObserver(Observer* observer) { | 306 void CJS_Runtime::RemoveObserver(Observer* observer) { |
307 ASSERT(m_observers.find(observer) != m_observers.end()); | 307 ASSERT(m_observers.find(observer) != m_observers.end()); |
308 m_observers.erase(observer); | 308 m_observers.erase(observer); |
309 } | 309 } |
OLD | NEW |