| 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 14 matching lines...) Expand all Loading... |
| 25 #include "color.h" | 25 #include "color.h" |
| 26 #include "console.h" | 26 #include "console.h" |
| 27 #include "event.h" | 27 #include "event.h" |
| 28 #include "global.h" | 28 #include "global.h" |
| 29 #include "report.h" | 29 #include "report.h" |
| 30 #include "util.h" | 30 #include "util.h" |
| 31 | 31 |
| 32 /* ------------------------------ CJS_Runtime ------------------------------ */ | 32 /* ------------------------------ CJS_Runtime ------------------------------ */ |
| 33 v8::Global<v8::ObjectTemplate>& _getGlobalObjectTemplate(v8::Isolate* pIsolate); | 33 v8::Global<v8::ObjectTemplate>& _getGlobalObjectTemplate(v8::Isolate* pIsolate); |
| 34 | 34 |
| 35 // static |
| 35 IJS_Runtime* IJS_Runtime::Create(CPDFDoc_Environment* pEnv) { | 36 IJS_Runtime* IJS_Runtime::Create(CPDFDoc_Environment* pEnv) { |
| 36 return new CJS_Runtime(pEnv); | 37 return new CJS_Runtime(pEnv); |
| 37 } | 38 } |
| 38 | 39 |
| 40 // static |
| 41 CJS_Runtime* CJS_Runtime::FromContext(const IJS_Context* cc) { |
| 42 const CJS_Context* pContext = static_cast<const CJS_Context*>(cc); |
| 43 return pContext->GetJSRuntime(); |
| 44 } |
| 45 |
| 39 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) | 46 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) |
| 40 : m_pApp(pApp), | 47 : m_pApp(pApp), |
| 41 m_pDocument(NULL), | 48 m_pDocument(NULL), |
| 42 m_bBlocking(FALSE), | 49 m_bBlocking(FALSE), |
| 43 m_isolate(NULL), | 50 m_isolate(NULL), |
| 44 m_isolateManaged(false) { | 51 m_isolateManaged(false) { |
| 45 if (CPDFXFA_App::GetInstance()->GetJSERuntime()) { | 52 if (CPDFXFA_App::GetInstance()->GetJSERuntime()) { |
| 46 // TODO(tsepez): CPDFXFA_App should also use the embedder provided isolate. | 53 // TODO(tsepez): CPDFXFA_App should also use the embedder provided isolate. |
| 47 m_isolate = (v8::Isolate*)CPDFXFA_App::GetInstance()->GetJSERuntime(); | 54 m_isolate = (v8::Isolate*)CPDFXFA_App::GetInstance()->GetJSERuntime(); |
| 48 } else { | 55 } else { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 CJS_Event::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); | 137 CJS_Event::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 131 CJS_Field::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); | 138 CJS_Field::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |
| 132 | 139 |
| 133 // ObjDefIDs 15 - 17 | 140 // ObjDefIDs 15 - 17 |
| 134 CJS_Global::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); | 141 CJS_Global::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 135 CJS_Icon::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); | 142 CJS_Icon::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |
| 136 CJS_Util::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); | 143 CJS_Util::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |
| 137 | 144 |
| 138 // ObjDefIDs 18 - 20 (these can't fail, return void). | 145 // ObjDefIDs 18 - 20 (these can't fail, return void). |
| 139 CJS_PublicMethods::DefineJSObjects(GetIsolate()); | 146 CJS_PublicMethods::DefineJSObjects(GetIsolate()); |
| 140 CJS_GlobalConsts::DefineJSObjects(GetIsolate()); | 147 CJS_GlobalConsts::DefineJSObjects(this); |
| 141 CJS_GlobalArrays::DefineJSObjects(GetIsolate()); | 148 CJS_GlobalArrays::DefineJSObjects(this); |
| 142 | 149 |
| 143 // ObjDefIDs 21 - 22. | 150 // ObjDefIDs 21 - 22. |
| 144 CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); | 151 CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |
| 145 CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); | 152 CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |
| 146 } | 153 } |
| 147 | 154 |
| 148 IJS_Context* CJS_Runtime::NewContext() { | 155 IJS_Context* CJS_Runtime::NewContext() { |
| 149 CJS_Context* p = new CJS_Context(this); | 156 CJS_Context* p = new CJS_Context(this); |
| 150 m_ContextArray.Add(p); | 157 m_ContextArray.Add(p); |
| 151 return p; | 158 return p; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 270 |
| 264 void CJS_Runtime::AddObserver(Observer* observer) { | 271 void CJS_Runtime::AddObserver(Observer* observer) { |
| 265 ASSERT(m_observers.find(observer) == m_observers.end()); | 272 ASSERT(m_observers.find(observer) == m_observers.end()); |
| 266 m_observers.insert(observer); | 273 m_observers.insert(observer); |
| 267 } | 274 } |
| 268 | 275 |
| 269 void CJS_Runtime::RemoveObserver(Observer* observer) { | 276 void CJS_Runtime::RemoveObserver(Observer* observer) { |
| 270 ASSERT(m_observers.find(observer) != m_observers.end()); | 277 ASSERT(m_observers.find(observer) != m_observers.end()); |
| 271 m_observers.erase(observer); | 278 m_observers.erase(observer); |
| 272 } | 279 } |
| OLD | NEW |