| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 v8::Isolate::Scope isolate_scope(isolate); | 63 v8::Isolate::Scope isolate_scope(isolate); |
| 64 v8::Locker locker(isolate); | 64 v8::Locker locker(isolate); |
| 65 v8::HandleScope handle_scope(isolate); | 65 v8::HandleScope handle_scope(isolate); |
| 66 if (CPDFXFA_App::GetInstance()->IsJavaScriptInitialized()) { | 66 if (CPDFXFA_App::GetInstance()->IsJavaScriptInitialized()) { |
| 67 CJS_Context* pContext = (CJS_Context*)NewContext(); | 67 CJS_Context* pContext = (CJS_Context*)NewContext(); |
| 68 FXJS_InitializeRuntime(GetIsolate(), this, pContext, m_context); | 68 FXJS_InitializeRuntime(GetIsolate(), this, pContext, m_context); |
| 69 ReleaseContext(pContext); | 69 ReleaseContext(pContext); |
| 70 return; | 70 return; |
| 71 } | 71 } |
| 72 | 72 |
| 73 DefineJSObjects(); | 73 if (m_isolateManaged || FXJS_GlobalIsolateRefCount() == 0) |
| 74 DefineJSObjects(); |
| 75 |
| 74 CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE); | 76 CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE); |
| 75 | 77 |
| 76 CJS_Context* pContext = (CJS_Context*)NewContext(); | 78 CJS_Context* pContext = (CJS_Context*)NewContext(); |
| 77 FXJS_InitializeRuntime(GetIsolate(), this, pContext, m_context); | 79 FXJS_InitializeRuntime(GetIsolate(), this, pContext, m_context); |
| 78 ReleaseContext(pContext); | 80 ReleaseContext(pContext); |
| 79 } | 81 } |
| 80 | 82 |
| 81 CJS_Runtime::~CJS_Runtime() { | 83 CJS_Runtime::~CJS_Runtime() { |
| 82 for (auto* obs : m_observers) | 84 for (auto* obs : m_observers) |
| 83 obs->OnDestroyed(); | 85 obs->OnDestroyed(); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 265 |
| 264 void CJS_Runtime::AddObserver(Observer* observer) { | 266 void CJS_Runtime::AddObserver(Observer* observer) { |
| 265 ASSERT(m_observers.find(observer) == m_observers.end()); | 267 ASSERT(m_observers.find(observer) == m_observers.end()); |
| 266 m_observers.insert(observer); | 268 m_observers.insert(observer); |
| 267 } | 269 } |
| 268 | 270 |
| 269 void CJS_Runtime::RemoveObserver(Observer* observer) { | 271 void CJS_Runtime::RemoveObserver(Observer* observer) { |
| 270 ASSERT(m_observers.find(observer) != m_observers.end()); | 272 ASSERT(m_observers.find(observer) != m_observers.end()); |
| 271 m_observers.erase(observer); | 273 m_observers.erase(observer); |
| 272 } | 274 } |
| OLD | NEW |