| 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 "fpdfsdk/javascript/cjs_runtime.h" | 7 #include "fpdfsdk/javascript/cjs_runtime.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "fpdfsdk/include/fsdk_mgr.h" | 11 #include "fpdfsdk/include/fsdk_mgr.h" |
| 12 #include "fpdfsdk/javascript/Annot.h" |
| 12 #include "fpdfsdk/javascript/Consts.h" | 13 #include "fpdfsdk/javascript/Consts.h" |
| 13 #include "fpdfsdk/javascript/Document.h" | 14 #include "fpdfsdk/javascript/Document.h" |
| 14 #include "fpdfsdk/javascript/Field.h" | 15 #include "fpdfsdk/javascript/Field.h" |
| 15 #include "fpdfsdk/javascript/Icon.h" | 16 #include "fpdfsdk/javascript/Icon.h" |
| 16 #include "fpdfsdk/javascript/JS_Define.h" | 17 #include "fpdfsdk/javascript/JS_Define.h" |
| 17 #include "fpdfsdk/javascript/JS_EventHandler.h" | 18 #include "fpdfsdk/javascript/JS_EventHandler.h" |
| 18 #include "fpdfsdk/javascript/JS_GlobalData.h" | 19 #include "fpdfsdk/javascript/JS_GlobalData.h" |
| 19 #include "fpdfsdk/javascript/JS_Object.h" | 20 #include "fpdfsdk/javascript/JS_Object.h" |
| 20 #include "fpdfsdk/javascript/JS_Value.h" | 21 #include "fpdfsdk/javascript/JS_Value.h" |
| 21 #include "fpdfsdk/javascript/PublicMethods.h" | 22 #include "fpdfsdk/javascript/PublicMethods.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // ObjDefIDs 15 - 17 | 169 // ObjDefIDs 15 - 17 |
| 169 CJS_Global::DefineJSObjects(this, FXJSOBJTYPE_STATIC); | 170 CJS_Global::DefineJSObjects(this, FXJSOBJTYPE_STATIC); |
| 170 CJS_Icon::DefineJSObjects(this, FXJSOBJTYPE_DYNAMIC); | 171 CJS_Icon::DefineJSObjects(this, FXJSOBJTYPE_DYNAMIC); |
| 171 CJS_Util::DefineJSObjects(this, FXJSOBJTYPE_STATIC); | 172 CJS_Util::DefineJSObjects(this, FXJSOBJTYPE_STATIC); |
| 172 | 173 |
| 173 // ObjDefIDs 18 - 20 (these can't fail, return void). | 174 // ObjDefIDs 18 - 20 (these can't fail, return void). |
| 174 CJS_PublicMethods::DefineJSObjects(this); | 175 CJS_PublicMethods::DefineJSObjects(this); |
| 175 CJS_GlobalConsts::DefineJSObjects(this); | 176 CJS_GlobalConsts::DefineJSObjects(this); |
| 176 CJS_GlobalArrays::DefineJSObjects(this); | 177 CJS_GlobalArrays::DefineJSObjects(this); |
| 177 | 178 |
| 178 // ObjDefIDs 21 - 22. | 179 // ObjDefIDs 21 - 23. |
| 179 CJS_TimerObj::DefineJSObjects(this, FXJSOBJTYPE_DYNAMIC); | 180 CJS_TimerObj::DefineJSObjects(this, FXJSOBJTYPE_DYNAMIC); |
| 180 CJS_PrintParamsObj::DefineJSObjects(this, FXJSOBJTYPE_DYNAMIC); | 181 CJS_PrintParamsObj::DefineJSObjects(this, FXJSOBJTYPE_DYNAMIC); |
| 182 CJS_Annot::DefineJSObjects(this, FXJSOBJTYPE_DYNAMIC); |
| 181 } | 183 } |
| 182 | 184 |
| 183 IJS_Context* CJS_Runtime::NewContext() { | 185 IJS_Context* CJS_Runtime::NewContext() { |
| 184 m_ContextArray.push_back(std::unique_ptr<CJS_Context>(new CJS_Context(this))); | 186 m_ContextArray.push_back(std::unique_ptr<CJS_Context>(new CJS_Context(this))); |
| 185 return m_ContextArray.back().get(); | 187 return m_ContextArray.back().get(); |
| 186 } | 188 } |
| 187 | 189 |
| 188 void CJS_Runtime::ReleaseContext(IJS_Context* pContext) { | 190 void CJS_Runtime::ReleaseContext(IJS_Context* pContext) { |
| 189 for (auto it = m_ContextArray.begin(); it != m_ContextArray.end(); ++it) { | 191 for (auto it = m_ContextArray.begin(); it != m_ContextArray.end(); ++it) { |
| 190 if (it->get() == static_cast<CJS_Context*>(pContext)) { | 192 if (it->get() == static_cast<CJS_Context*>(pContext)) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // v8::Local<v8::Context>::New(GetIsolate(), m_context); | 316 // v8::Local<v8::Context>::New(GetIsolate(), m_context); |
| 315 v8::Local<v8::Value> propvalue = | 317 v8::Local<v8::Value> propvalue = |
| 316 v8::Local<v8::Value>::New(GetIsolate(), pValue->DirectGetValue()); | 318 v8::Local<v8::Value>::New(GetIsolate(), pValue->DirectGetValue()); |
| 317 context->Global()->Set( | 319 context->Global()->Set( |
| 318 v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString, | 320 v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString, |
| 319 utf8Name.GetLength()), | 321 utf8Name.GetLength()), |
| 320 propvalue); | 322 propvalue); |
| 321 return TRUE; | 323 return TRUE; |
| 322 } | 324 } |
| 323 #endif | 325 #endif |
| OLD | NEW |