| 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 "../../public/fpdf_ext.h" | 7 #include "../../public/fpdf_ext.h" |
| 8 #include "../../third_party/base/nonstd_unique_ptr.h" | 8 #include "../../third_party/base/nonstd_unique_ptr.h" |
| 9 #include "../include/fsdk_define.h" | 9 #include "../include/fsdk_define.h" |
| 10 #include "../include/fsdk_mgr.h" | 10 #include "../include/fsdk_mgr.h" |
| 11 #include "../include/formfiller/FFL_FormFiller.h" | 11 #include "../include/formfiller/FFL_FormFiller.h" |
| 12 #include "../include/javascript/IJavaScript.h" | 12 #include "../include/javascript/IJavaScript.h" |
| 13 #include "../include/javascript/JS_Runtime.h" |
| 13 | 14 |
| 14 #if _FX_OS_ == _FX_ANDROID_ | 15 #if _FX_OS_ == _FX_ANDROID_ |
| 15 #include "time.h" | 16 #include "time.h" |
| 16 #else | 17 #else |
| 17 #include <ctime> | 18 #include <ctime> |
| 18 #endif | 19 #endif |
| 19 | 20 |
| 20 class CFX_SystemHandler : public IFX_SystemHandler { | 21 class CFX_SystemHandler : public IFX_SystemHandler { |
| 21 public: | 22 public: |
| 22 CFX_SystemHandler(CPDFDoc_Environment* pEnv) : m_pEnv(pEnv), m_nCharSet(-1) {} | 23 CFX_SystemHandler(CPDFDoc_Environment* pEnv) : m_pEnv(pEnv), m_nCharSet(-1) {} |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 return m_pEnv->FFI_SetTimer(uElapse, lpTimerFunc); | 197 return m_pEnv->FFI_SetTimer(uElapse, lpTimerFunc); |
| 197 } | 198 } |
| 198 void CFX_SystemHandler::KillTimer(int32_t nID) { | 199 void CFX_SystemHandler::KillTimer(int32_t nID) { |
| 199 m_pEnv->FFI_KillTimer(nID); | 200 m_pEnv->FFI_KillTimer(nID); |
| 200 } | 201 } |
| 201 | 202 |
| 202 FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime() { | 203 FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime() { |
| 203 return m_pEnv->FFI_GetLocalTime(); | 204 return m_pEnv->FFI_GetLocalTime(); |
| 204 } | 205 } |
| 205 | 206 |
| 206 CJS_RuntimeFactory* GetJSRuntimeFactory() { | |
| 207 static CJS_RuntimeFactory s_JSRuntimeFactory; | |
| 208 return &s_JSRuntimeFactory; | |
| 209 } | |
| 210 | |
| 211 CPDFDoc_Environment::CPDFDoc_Environment(CPDF_Document* pDoc, | 207 CPDFDoc_Environment::CPDFDoc_Environment(CPDF_Document* pDoc, |
| 212 FPDF_FORMFILLINFO* pFFinfo) | 208 FPDF_FORMFILLINFO* pFFinfo) |
| 213 : m_pAnnotHandlerMgr(NULL), | 209 : m_pAnnotHandlerMgr(NULL), |
| 214 m_pActionHandler(NULL), | 210 m_pActionHandler(NULL), |
| 215 m_pJSRuntime(NULL), | |
| 216 m_pInfo(pFFinfo), | 211 m_pInfo(pFFinfo), |
| 217 m_pSDKDoc(NULL), | 212 m_pSDKDoc(NULL), |
| 218 m_pPDFDoc(pDoc), | 213 m_pPDFDoc(pDoc), |
| 219 m_pIFormFiller(NULL) { | 214 m_pIFormFiller(NULL) { |
| 220 m_pSysHandler = new CFX_SystemHandler(this); | 215 m_pSysHandler = new CFX_SystemHandler(this); |
| 221 m_pJSRuntimeFactory = GetJSRuntimeFactory(); | |
| 222 m_pJSRuntimeFactory->AddRef(); | |
| 223 } | 216 } |
| 224 | 217 |
| 225 CPDFDoc_Environment::~CPDFDoc_Environment() { | 218 CPDFDoc_Environment::~CPDFDoc_Environment() { |
| 226 delete m_pIFormFiller; | 219 delete m_pIFormFiller; |
| 227 m_pIFormFiller = NULL; | 220 m_pIFormFiller = NULL; |
| 228 if (m_pJSRuntime && m_pJSRuntimeFactory) | |
| 229 m_pJSRuntimeFactory->DeleteJSRuntime(m_pJSRuntime); | |
| 230 m_pJSRuntimeFactory->Release(); | |
| 231 | 221 |
| 232 delete m_pSysHandler; | 222 delete m_pSysHandler; |
| 233 m_pSysHandler = NULL; | 223 m_pSysHandler = NULL; |
| 234 | 224 |
| 235 delete m_pAnnotHandlerMgr; | 225 delete m_pAnnotHandlerMgr; |
| 236 m_pAnnotHandlerMgr = NULL; | 226 m_pAnnotHandlerMgr = NULL; |
| 237 delete m_pActionHandler; | 227 delete m_pActionHandler; |
| 238 m_pActionHandler = NULL; | 228 m_pActionHandler = NULL; |
| 239 } | 229 } |
| 240 | 230 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 bsBcc.ReleaseBuffer(); | 367 bsBcc.ReleaseBuffer(); |
| 378 bsSubject.ReleaseBuffer(); | 368 bsSubject.ReleaseBuffer(); |
| 379 bsMsg.ReleaseBuffer(); | 369 bsMsg.ReleaseBuffer(); |
| 380 } | 370 } |
| 381 } | 371 } |
| 382 | 372 |
| 383 IFXJS_Runtime* CPDFDoc_Environment::GetJSRuntime() { | 373 IFXJS_Runtime* CPDFDoc_Environment::GetJSRuntime() { |
| 384 if (!IsJSInitiated()) | 374 if (!IsJSInitiated()) |
| 385 return NULL; | 375 return NULL; |
| 386 if (!m_pJSRuntime) | 376 if (!m_pJSRuntime) |
| 387 m_pJSRuntime = m_pJSRuntimeFactory->NewJSRuntime(this); | 377 m_pJSRuntime.reset(new CJS_Runtime(this)); |
| 388 return m_pJSRuntime; | 378 return m_pJSRuntime.get(); |
| 389 } | 379 } |
| 390 | 380 |
| 391 CPDFSDK_AnnotHandlerMgr* CPDFDoc_Environment::GetAnnotHandlerMgr() { | 381 CPDFSDK_AnnotHandlerMgr* CPDFDoc_Environment::GetAnnotHandlerMgr() { |
| 392 if (!m_pAnnotHandlerMgr) | 382 if (!m_pAnnotHandlerMgr) |
| 393 m_pAnnotHandlerMgr = new CPDFSDK_AnnotHandlerMgr(this); | 383 m_pAnnotHandlerMgr = new CPDFSDK_AnnotHandlerMgr(this); |
| 394 return m_pAnnotHandlerMgr; | 384 return m_pAnnotHandlerMgr; |
| 395 } | 385 } |
| 396 | 386 |
| 397 CPDFSDK_ActionHandler* CPDFDoc_Environment::GetActionHander() { | 387 CPDFSDK_ActionHandler* CPDFDoc_Environment::GetActionHander() { |
| 398 if (!m_pActionHandler) | 388 if (!m_pActionHandler) |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 if (!pFocusAnnot) | 988 if (!pFocusAnnot) |
| 999 return NULL; | 989 return NULL; |
| 1000 | 990 |
| 1001 for (int i = 0; i < m_fxAnnotArray.GetSize(); i++) { | 991 for (int i = 0; i < m_fxAnnotArray.GetSize(); i++) { |
| 1002 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | 992 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); |
| 1003 if (pAnnot == pFocusAnnot) | 993 if (pAnnot == pFocusAnnot) |
| 1004 return pAnnot; | 994 return pAnnot; |
| 1005 } | 995 } |
| 1006 return NULL; | 996 return NULL; |
| 1007 } | 997 } |
| OLD | NEW |