| 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/fpdfxfa/include/fpdfxfa_app.h" | 7 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" |
| 8 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" | 8 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
| 9 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" | 9 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" |
| 10 #include "fpdfsdk/include/fsdk_define.h" | 10 #include "fpdfsdk/include/fsdk_define.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 void CPDFXFA_App::ReleaseInstance() { | 26 void CPDFXFA_App::ReleaseInstance() { |
| 27 delete g_pApp; | 27 delete g_pApp; |
| 28 g_pApp = NULL; | 28 g_pApp = NULL; |
| 29 } | 29 } |
| 30 | 30 |
| 31 CPDFXFA_App::CPDFXFA_App() | 31 CPDFXFA_App::CPDFXFA_App() |
| 32 : m_bJavaScriptInitialized(FALSE), | 32 : m_bJavaScriptInitialized(FALSE), |
| 33 m_pXFAApp(NULL), | 33 m_pXFAApp(NULL), |
| 34 m_pIsolate(nullptr), | 34 m_pIsolate(nullptr), |
| 35 m_csAppType(JS_STR_VIEWERTYPE_STANDARD), | 35 m_csAppType(JS_STR_VIEWERTYPE_STANDARD) { |
| 36 m_bOwnedRuntime(false) { | |
| 37 m_pEnvList.RemoveAll(); | 36 m_pEnvList.RemoveAll(); |
| 38 } | 37 } |
| 39 | 38 |
| 40 CPDFXFA_App::~CPDFXFA_App() { | 39 CPDFXFA_App::~CPDFXFA_App() { |
| 41 delete m_pXFAApp; | 40 delete m_pXFAApp; |
| 42 m_pXFAApp = NULL; | 41 m_pXFAApp = NULL; |
| 43 | 42 |
| 44 #ifdef PDF_ENABLE_XFA | 43 FXJSE_Runtime_Release(m_pIsolate); |
| 45 FXJSE_Runtime_Release(m_pIsolate, m_bOwnedRuntime); | |
| 46 m_pIsolate = nullptr; | 44 m_pIsolate = nullptr; |
| 47 | 45 |
| 48 FXJSE_Finalize(); | 46 FXJSE_Finalize(); |
| 49 BC_Library_Destory(); | 47 BC_Library_Destory(); |
| 50 #endif | |
| 51 } | 48 } |
| 52 | 49 |
| 53 FX_BOOL CPDFXFA_App::Initialize(v8::Isolate* pIsolate) { | 50 FX_BOOL CPDFXFA_App::Initialize(v8::Isolate* pIsolate) { |
| 54 #ifdef PDF_ENABLE_XFA | |
| 55 BC_Library_Init(); | 51 BC_Library_Init(); |
| 56 FXJSE_Initialize(); | 52 FXJSE_Initialize(); |
| 57 | 53 |
| 58 m_bOwnedRuntime = !pIsolate; | 54 m_pIsolate = pIsolate ? pIsolate : FXJSE_Runtime_Create_Own(); |
| 59 m_pIsolate = pIsolate ? pIsolate : FXJSE_Runtime_Create(); | |
| 60 if (!m_pIsolate) | 55 if (!m_pIsolate) |
| 61 return FALSE; | 56 return FALSE; |
| 62 | 57 |
| 63 m_pXFAApp = new CXFA_FFApp(this); | 58 m_pXFAApp = new CXFA_FFApp(this); |
| 64 m_pXFAApp->SetDefaultFontMgr( | 59 m_pXFAApp->SetDefaultFontMgr( |
| 65 std::unique_ptr<CXFA_DefFontMgr>(new CXFA_DefFontMgr)); | 60 std::unique_ptr<CXFA_DefFontMgr>(new CXFA_DefFontMgr)); |
| 66 #endif | 61 |
| 67 return TRUE; | 62 return TRUE; |
| 68 } | 63 } |
| 69 | 64 |
| 70 FX_BOOL CPDFXFA_App::AddFormFillEnv(CPDFDoc_Environment* pEnv) { | 65 FX_BOOL CPDFXFA_App::AddFormFillEnv(CPDFDoc_Environment* pEnv) { |
| 71 if (!pEnv) | 66 if (!pEnv) |
| 72 return FALSE; | 67 return FALSE; |
| 73 | 68 |
| 74 m_pEnvList.Add(pEnv); | 69 m_pEnvList.Add(pEnv); |
| 75 return TRUE; | 70 return TRUE; |
| 76 } | 71 } |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 } | 506 } |
| 512 } | 507 } |
| 513 | 508 |
| 514 IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr() { | 509 IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr() { |
| 515 CXFA_FWLAdapterTimerMgr* pAdapter = NULL; | 510 CXFA_FWLAdapterTimerMgr* pAdapter = NULL; |
| 516 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 511 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); |
| 517 if (pEnv) | 512 if (pEnv) |
| 518 pAdapter = new CXFA_FWLAdapterTimerMgr(pEnv); | 513 pAdapter = new CXFA_FWLAdapterTimerMgr(pEnv); |
| 519 return pAdapter; | 514 return pAdapter; |
| 520 } | 515 } |
| OLD | NEW |