| 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 // static | 
|   32 IJS_Runtime* IJS_Runtime::Create(CPDFDoc_Environment* pEnv) { |   33 IJS_Runtime* IJS_Runtime::Create(CPDFDoc_Environment* pEnv) { | 
|   33   return new CJS_Runtime(pEnv); |   34   return new CJS_Runtime(pEnv); | 
|   34 } |   35 } | 
|   35  |   36  | 
 |   37 // static | 
 |   38 CJS_Runtime* CJS_Runtime::FromContext(const IJS_Context* cc) { | 
 |   39   const CJS_Context* pContext = static_cast<const CJS_Context*>(cc); | 
 |   40   return pContext->GetJSRuntime(); | 
 |   41 } | 
 |   42  | 
|   36 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) |   43 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) | 
|   37     : m_pApp(pApp), |   44     : m_pApp(pApp), | 
|   38       m_pDocument(NULL), |   45       m_pDocument(NULL), | 
|   39       m_bBlocking(FALSE), |   46       m_bBlocking(FALSE), | 
|   40       m_isolate(NULL), |   47       m_isolate(NULL), | 
|   41       m_isolateManaged(false) { |   48       m_isolateManaged(false) { | 
|   42   IPDF_JSPLATFORM* pPlatform = m_pApp->GetFormFillInfo()->m_pJsPlatform; |   49   IPDF_JSPLATFORM* pPlatform = m_pApp->GetFormFillInfo()->m_pJsPlatform; | 
|   43   if (pPlatform->version <= 2) { |   50   if (pPlatform->version <= 2) { | 
|   44     unsigned int embedderDataSlot = 0; |   51     unsigned int embedderDataSlot = 0; | 
|   45     v8::Isolate* pExternalIsolate = nullptr; |   52     v8::Isolate* pExternalIsolate = nullptr; | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  108   CJS_Event::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |  115   CJS_Event::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); | 
|  109   CJS_Field::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |  116   CJS_Field::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); | 
|  110  |  117  | 
|  111   // ObjDefIDs 15 - 17 |  118   // ObjDefIDs 15 - 17 | 
|  112   CJS_Global::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |  119   CJS_Global::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); | 
|  113   CJS_Icon::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |  120   CJS_Icon::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); | 
|  114   CJS_Util::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); |  121   CJS_Util::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC); | 
|  115  |  122  | 
|  116   // ObjDefIDs 18 - 20 (these can't fail, return void). |  123   // ObjDefIDs 18 - 20 (these can't fail, return void). | 
|  117   CJS_PublicMethods::DefineJSObjects(GetIsolate()); |  124   CJS_PublicMethods::DefineJSObjects(GetIsolate()); | 
|  118   CJS_GlobalConsts::DefineJSObjects(GetIsolate()); |  125   CJS_GlobalConsts::DefineJSObjects(this); | 
|  119   CJS_GlobalArrays::DefineJSObjects(GetIsolate()); |  126   CJS_GlobalArrays::DefineJSObjects(this); | 
|  120  |  127  | 
|  121   // ObjDefIDs 21 - 22. |  128   // ObjDefIDs 21 - 22. | 
|  122   CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |  129   CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); | 
|  123   CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); |  130   CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC); | 
|  124 } |  131 } | 
|  125  |  132  | 
|  126 IJS_Context* CJS_Runtime::NewContext() { |  133 IJS_Context* CJS_Runtime::NewContext() { | 
|  127   CJS_Context* p = new CJS_Context(this); |  134   CJS_Context* p = new CJS_Context(this); | 
|  128   m_ContextArray.Add(p); |  135   m_ContextArray.Add(p); | 
|  129   return p; |  136   return p; | 
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  191 void CJS_Runtime::RemoveObserver(Observer* observer) { |  198 void CJS_Runtime::RemoveObserver(Observer* observer) { | 
|  192   ASSERT(m_observers.find(observer) != m_observers.end()); |  199   ASSERT(m_observers.find(observer) != m_observers.end()); | 
|  193   m_observers.erase(observer); |  200   m_observers.erase(observer); | 
|  194 } |  201 } | 
|  195  |  202  | 
|  196 CFX_WideString ChangeObjName(const CFX_WideString& str) { |  203 CFX_WideString ChangeObjName(const CFX_WideString& str) { | 
|  197   CFX_WideString sRet = str; |  204   CFX_WideString sRet = str; | 
|  198   sRet.Replace(L"_", L"."); |  205   sRet.Replace(L"_", L"."); | 
|  199   return sRet; |  206   return sRet; | 
|  200 } |  207 } | 
| OLD | NEW |