| 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 "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. | 9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. |
| 10 #include "../../include/javascript/IJavaScript.h" | 10 #include "../../include/javascript/IJavaScript.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "app.h" | 22 #include "app.h" |
| 23 #include "color.h" | 23 #include "color.h" |
| 24 #include "console.h" | 24 #include "console.h" |
| 25 #include "event.h" | 25 #include "event.h" |
| 26 #include "global.h" | 26 #include "global.h" |
| 27 #include "report.h" | 27 #include "report.h" |
| 28 #include "util.h" | 28 #include "util.h" |
| 29 | 29 |
| 30 /* ------------------------------ CJS_Runtime ------------------------------ */ | 30 /* ------------------------------ CJS_Runtime ------------------------------ */ |
| 31 | 31 |
| 32 IFXJS_Runtime* IFXJS_Runtime::Create(CPDFDoc_Environment* pEnv) { | 32 IJS_Runtime* IJS_Runtime::Create(CPDFDoc_Environment* pEnv) { |
| 33 return new CJS_Runtime(pEnv); | 33 return new CJS_Runtime(pEnv); |
| 34 } | 34 } |
| 35 | 35 |
| 36 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) | 36 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) |
| 37 : m_pApp(pApp), | 37 : m_pApp(pApp), |
| 38 m_pDocument(NULL), | 38 m_pDocument(NULL), |
| 39 m_bBlocking(FALSE), | 39 m_bBlocking(FALSE), |
| 40 m_isolate(NULL), | 40 m_isolate(NULL), |
| 41 m_isolateManaged(false) { | 41 m_isolateManaged(false) { |
| 42 IPDF_JSPLATFORM* pPlatform = m_pApp->GetFormFillInfo()->m_pJsPlatform; | 42 IPDF_JSPLATFORM* pPlatform = m_pApp->GetFormFillInfo()->m_pJsPlatform; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // ObjDefIDs 18 - 20 (these can't fail, return void). | 116 // ObjDefIDs 18 - 20 (these can't fail, return void). |
| 117 CJS_PublicMethods::DefineJSObjects(GetIsolate()); | 117 CJS_PublicMethods::DefineJSObjects(GetIsolate()); |
| 118 CJS_GlobalConsts::DefineJSObjects(GetIsolate()); | 118 CJS_GlobalConsts::DefineJSObjects(GetIsolate()); |
| 119 CJS_GlobalArrays::DefineJSObjects(GetIsolate()); | 119 CJS_GlobalArrays::DefineJSObjects(GetIsolate()); |
| 120 | 120 |
| 121 // ObjDefIDs 21 - 22. | 121 // ObjDefIDs 21 - 22. |
| 122 CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); | 122 CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |
| 123 CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); | 123 CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |
| 124 } | 124 } |
| 125 | 125 |
| 126 IFXJS_Context* CJS_Runtime::NewContext() { | 126 IJS_Context* CJS_Runtime::NewContext() { |
| 127 CJS_Context* p = new CJS_Context(this); | 127 CJS_Context* p = new CJS_Context(this); |
| 128 m_ContextArray.Add(p); | 128 m_ContextArray.Add(p); |
| 129 return p; | 129 return p; |
| 130 } | 130 } |
| 131 | 131 |
| 132 void CJS_Runtime::ReleaseContext(IFXJS_Context* pContext) { | 132 void CJS_Runtime::ReleaseContext(IJS_Context* pContext) { |
| 133 CJS_Context* pJSContext = (CJS_Context*)pContext; | 133 CJS_Context* pJSContext = (CJS_Context*)pContext; |
| 134 | 134 |
| 135 for (int i = 0, sz = m_ContextArray.GetSize(); i < sz; i++) { | 135 for (int i = 0, sz = m_ContextArray.GetSize(); i < sz; i++) { |
| 136 if (pJSContext == m_ContextArray.GetAt(i)) { | 136 if (pJSContext == m_ContextArray.GetAt(i)) { |
| 137 delete pJSContext; | 137 delete pJSContext; |
| 138 m_ContextArray.RemoveAt(i); | 138 m_ContextArray.RemoveAt(i); |
| 139 break; | 139 break; |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 IFXJS_Context* CJS_Runtime::GetCurrentContext() { | 144 IJS_Context* CJS_Runtime::GetCurrentContext() { |
| 145 if (!m_ContextArray.GetSize()) | 145 if (!m_ContextArray.GetSize()) |
| 146 return NULL; | 146 return NULL; |
| 147 return m_ContextArray.GetAt(m_ContextArray.GetSize() - 1); | 147 return m_ContextArray.GetAt(m_ContextArray.GetSize() - 1); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) { | 150 void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) { |
| 151 if (m_pDocument != pReaderDoc) { | 151 if (m_pDocument != pReaderDoc) { |
| 152 v8::Isolate::Scope isolate_scope(m_isolate); | 152 v8::Isolate::Scope isolate_scope(m_isolate); |
| 153 v8::HandleScope handle_scope(m_isolate); | 153 v8::HandleScope handle_scope(m_isolate); |
| 154 v8::Local<v8::Context> context = | 154 v8::Local<v8::Context> context = |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 void CJS_Runtime::RemoveObserver(Observer* observer) { | 191 void CJS_Runtime::RemoveObserver(Observer* observer) { |
| 192 ASSERT(m_observers.find(observer) != m_observers.end()); | 192 ASSERT(m_observers.find(observer) != m_observers.end()); |
| 193 m_observers.erase(observer); | 193 m_observers.erase(observer); |
| 194 } | 194 } |
| 195 | 195 |
| 196 CFX_WideString ChangeObjName(const CFX_WideString& str) { | 196 CFX_WideString ChangeObjName(const CFX_WideString& str) { |
| 197 CFX_WideString sRet = str; | 197 CFX_WideString sRet = str; |
| 198 sRet.Replace(L"_", L"."); | 198 sRet.Replace(L"_", L"."); |
| 199 return sRet; | 199 return sRet; |
| 200 } | 200 } |
| OLD | NEW |