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_formfill.h" | 7 #include "../../../public/fpdf_formfill.h" |
8 #include "../../include/fsdk_define.h" | 8 #include "../../include/fsdk_define.h" |
9 #include "../../include/fsdk_mgr.h" | 9 #include "../../include/fsdk_mgr.h" |
10 #include "../../include/fpdfxfa/fpdfxfa_doc.h" | 10 #include "../../include/fpdfxfa/fpdfxfa_doc.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 delete g_pApp; | 26 delete g_pApp; |
27 g_pApp = NULL; | 27 g_pApp = NULL; |
28 } | 28 } |
29 | 29 |
30 CJS_RuntimeFactory* g_GetJSRuntimeFactory() { | 30 CJS_RuntimeFactory* g_GetJSRuntimeFactory() { |
31 static CJS_RuntimeFactory g_JSRuntimeFactory; | 31 static CJS_RuntimeFactory g_JSRuntimeFactory; |
32 return &g_JSRuntimeFactory; | 32 return &g_JSRuntimeFactory; |
33 } | 33 } |
34 | 34 |
35 CPDFXFA_App::CPDFXFA_App() | 35 CPDFXFA_App::CPDFXFA_App() |
36 : m_bInitRuntime(FALSE), | 36 : m_bJavaScriptInitialized(FALSE), |
37 m_pXFAApp(NULL), | 37 m_pXFAApp(NULL), |
38 m_pFontMgr(NULL), | 38 m_pFontMgr(NULL), |
39 m_hJSERuntime(NULL), | 39 m_hJSERuntime(NULL), |
40 m_csAppType(JS_STR_VIEWERTYPE_STANDARD) { | 40 m_csAppType(JS_STR_VIEWERTYPE_STANDARD) { |
41 m_pJSRuntimeFactory = g_GetJSRuntimeFactory(); | 41 m_pJSRuntimeFactory = g_GetJSRuntimeFactory(); |
42 m_pJSRuntimeFactory->AddRef(); | 42 m_pJSRuntimeFactory->AddRef(); |
43 m_pEnvList.RemoveAll(); | 43 m_pEnvList.RemoveAll(); |
44 } | 44 } |
45 | 45 |
46 CPDFXFA_App::~CPDFXFA_App() { | 46 CPDFXFA_App::~CPDFXFA_App() { |
(...skipping 24 matching lines...) Expand all Loading... | |
71 return FALSE; | 71 return FALSE; |
72 | 72 |
73 m_pFontMgr = IXFA_FontMgr::CreateDefault(); | 73 m_pFontMgr = IXFA_FontMgr::CreateDefault(); |
74 if (!m_pFontMgr) | 74 if (!m_pFontMgr) |
75 return FALSE; | 75 return FALSE; |
76 | 76 |
77 m_pXFAApp->SetDefaultFontMgr(m_pFontMgr); | 77 m_pXFAApp->SetDefaultFontMgr(m_pFontMgr); |
78 return TRUE; | 78 return TRUE; |
79 } | 79 } |
80 | 80 |
81 FX_BOOL CPDFXFA_App::InitRuntime(FX_BOOL bReset) { | |
82 if (bReset) { | |
83 m_bInitRuntime = FALSE; | |
84 return TRUE; | |
85 } | |
86 if (m_bInitRuntime) { | |
87 return TRUE; | |
88 } | |
89 m_bInitRuntime = TRUE; | |
90 return FALSE; | |
91 } | |
92 | |
93 FX_BOOL CPDFXFA_App::AddFormFillEnv(CPDFDoc_Environment* pEnv) { | 81 FX_BOOL CPDFXFA_App::AddFormFillEnv(CPDFDoc_Environment* pEnv) { |
94 if (!pEnv) | 82 if (!pEnv) |
95 return FALSE; | 83 return FALSE; |
96 | 84 |
97 m_pEnvList.Add(pEnv); | 85 m_pEnvList.Add(pEnv); |
98 return TRUE; | 86 return TRUE; |
99 } | 87 } |
100 | 88 |
101 FX_BOOL CPDFXFA_App::RemoveFormFillEnv(CPDFDoc_Environment* pEnv) { | 89 FX_BOOL CPDFXFA_App::RemoveFormFillEnv(CPDFDoc_Environment* pEnv) { |
102 if (!pEnv) | 90 if (!pEnv) |
103 return FALSE; | 91 return FALSE; |
104 | 92 |
105 int nFind = m_pEnvList.Find(pEnv); | 93 int nFind = m_pEnvList.Find(pEnv); |
106 if (nFind != -1) { | 94 if (nFind != -1) { |
107 m_pEnvList.RemoveAt(nFind); | 95 m_pEnvList.RemoveAt(nFind); |
108 return TRUE; | 96 return TRUE; |
109 } | 97 } |
110 | 98 |
111 return FALSE; | 99 return FALSE; |
112 } | 100 } |
113 void CPDFXFA_App::ReleaseRuntime() { | |
114 v8::Global<v8::Context> context; | |
115 JS_ReleaseRuntime((v8::Isolate*)m_hJSERuntime, context); | |
Tom Sepez
2015/09/17 21:58:39
Different segv, can't pass NULL ctx here. Already
| |
116 } | |
117 | 101 |
118 void CPDFXFA_App::GetAppType(CFX_WideString& wsAppType) { | 102 void CPDFXFA_App::GetAppType(CFX_WideString& wsAppType) { |
119 wsAppType = m_csAppType; | 103 wsAppType = m_csAppType; |
120 } | 104 } |
121 | 105 |
122 void CPDFXFA_App::GetAppName(CFX_WideString& wsName) { | 106 void CPDFXFA_App::GetAppName(CFX_WideString& wsName) { |
123 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 107 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); |
124 if (pEnv) { | 108 if (pEnv) { |
125 wsName = pEnv->FFI_GetAppName(); | 109 wsName = pEnv->FFI_GetAppName(); |
126 } | 110 } |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 return FALSE; | 531 return FALSE; |
548 } | 532 } |
549 | 533 |
550 IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr() { | 534 IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr() { |
551 CXFA_FWLAdapterTimerMgr* pAdapter = NULL; | 535 CXFA_FWLAdapterTimerMgr* pAdapter = NULL; |
552 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); | 536 CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0); |
553 if (pEnv) | 537 if (pEnv) |
554 pAdapter = new CXFA_FWLAdapterTimerMgr(pEnv); | 538 pAdapter = new CXFA_FWLAdapterTimerMgr(pEnv); |
555 return pAdapter; | 539 return pAdapter; |
556 } | 540 } |
OLD | NEW |