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 "../../include/javascript/IJavaScript.h" | 7 #include "../../include/javascript/IJavaScript.h" |
| 8 #include "../../include/javascript/JS_Context.h" |
8 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
9 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
10 #include "../../include/javascript/JS_Context.h" | 11 |
| 12 namespace { |
11 | 13 |
12 int FXJS_MsgBox(CPDFDoc_Environment* pApp, | 14 int FXJS_MsgBox(CPDFDoc_Environment* pApp, |
13 CPDFSDK_PageView* pPageView, | |
14 const FX_WCHAR* swMsg, | 15 const FX_WCHAR* swMsg, |
15 const FX_WCHAR* swTitle, | 16 const FX_WCHAR* swTitle, |
16 FX_UINT nType, | 17 FX_UINT nType, |
17 FX_UINT nIcon) { | 18 FX_UINT nIcon) { |
18 if (!pApp) | 19 if (!pApp) |
19 return 0; | 20 return 0; |
20 | 21 |
21 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) | 22 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) |
22 pDoc->KillFocusAnnot(); | 23 pDoc->KillFocusAnnot(); |
23 | 24 |
24 return pApp->JS_appAlert(swMsg, swTitle, nType, nIcon); | 25 return pApp->JS_appAlert(swMsg, swTitle, nType, nIcon); |
25 } | 26 } |
26 | 27 |
27 CPDFSDK_PageView* FXJS_GetPageView(IFXJS_Context* cc) { | 28 } // namespace |
28 if (CJS_Context* pContext = (CJS_Context*)cc) { | |
29 if (pContext->GetReaderDocument()) | |
30 return NULL; | |
31 } | |
32 return NULL; | |
33 } | |
34 | 29 |
35 CJS_EmbedObj::CJS_EmbedObj(CJS_Object* pJSObject) : m_pJSObject(pJSObject) {} | 30 CJS_EmbedObj::CJS_EmbedObj(CJS_Object* pJSObject) : m_pJSObject(pJSObject) {} |
36 | 31 |
37 CJS_EmbedObj::~CJS_EmbedObj() { | 32 CJS_EmbedObj::~CJS_EmbedObj() { |
38 m_pJSObject = NULL; | 33 m_pJSObject = NULL; |
39 } | 34 } |
40 | 35 |
41 CPDFSDK_PageView* CJS_EmbedObj::JSGetPageView(IFXJS_Context* cc) { | |
42 return FXJS_GetPageView(cc); | |
43 } | |
44 | |
45 int CJS_EmbedObj::MsgBox(CPDFDoc_Environment* pApp, | 36 int CJS_EmbedObj::MsgBox(CPDFDoc_Environment* pApp, |
46 CPDFSDK_PageView* pPageView, | |
47 const FX_WCHAR* swMsg, | 37 const FX_WCHAR* swMsg, |
48 const FX_WCHAR* swTitle, | 38 const FX_WCHAR* swTitle, |
49 FX_UINT nType, | 39 FX_UINT nType, |
50 FX_UINT nIcon) { | 40 FX_UINT nIcon) { |
51 return FXJS_MsgBox(pApp, pPageView, swMsg, swTitle, nType, nIcon); | 41 return FXJS_MsgBox(pApp, swMsg, swTitle, nType, nIcon); |
52 } | 42 } |
53 | 43 |
54 void CJS_EmbedObj::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg) { | 44 void CJS_EmbedObj::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg) { |
55 CJS_Object::Alert(pContext, swMsg); | 45 CJS_Object::Alert(pContext, swMsg); |
56 } | 46 } |
57 | 47 |
58 void FreeObject(const v8::WeakCallbackInfo<CJS_Object>& data) { | 48 void FreeObject(const v8::WeakCallbackInfo<CJS_Object>& data) { |
59 CJS_Object* pJSObj = data.GetParameter(); | 49 CJS_Object* pJSObj = data.GetParameter(); |
60 pJSObj->ExitInstance(); | 50 pJSObj->ExitInstance(); |
61 delete pJSObj; | 51 delete pJSObj; |
(...skipping 16 matching lines...) Expand all Loading... |
78 | 68 |
79 void CJS_Object::MakeWeak() { | 69 void CJS_Object::MakeWeak() { |
80 m_pV8Object.SetWeak(this, DisposeObject, | 70 m_pV8Object.SetWeak(this, DisposeObject, |
81 v8::WeakCallbackType::kInternalFields); | 71 v8::WeakCallbackType::kInternalFields); |
82 } | 72 } |
83 | 73 |
84 void CJS_Object::Dispose() { | 74 void CJS_Object::Dispose() { |
85 m_pV8Object.Reset(); | 75 m_pV8Object.Reset(); |
86 } | 76 } |
87 | 77 |
88 CPDFSDK_PageView* CJS_Object::JSGetPageView(IFXJS_Context* cc) { | |
89 return FXJS_GetPageView(cc); | |
90 } | |
91 | |
92 int CJS_Object::MsgBox(CPDFDoc_Environment* pApp, | 78 int CJS_Object::MsgBox(CPDFDoc_Environment* pApp, |
93 CPDFSDK_PageView* pPageView, | |
94 const FX_WCHAR* swMsg, | 79 const FX_WCHAR* swMsg, |
95 const FX_WCHAR* swTitle, | 80 const FX_WCHAR* swTitle, |
96 FX_UINT nType, | 81 FX_UINT nType, |
97 FX_UINT nIcon) { | 82 FX_UINT nIcon) { |
98 return FXJS_MsgBox(pApp, pPageView, swMsg, swTitle, nType, nIcon); | 83 return FXJS_MsgBox(pApp, swMsg, swTitle, nType, nIcon); |
99 } | 84 } |
100 | 85 |
101 void CJS_Object::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg) { | 86 void CJS_Object::Alert(CJS_Context* pContext, const FX_WCHAR* swMsg) { |
102 ASSERT(pContext != NULL); | 87 ASSERT(pContext != NULL); |
103 | 88 |
104 if (pContext->IsMsgBoxEnabled()) { | 89 if (pContext->IsMsgBoxEnabled()) { |
105 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 90 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
106 if (pApp) | 91 if (pApp) |
107 pApp->JS_appAlert(swMsg, NULL, 0, 3); | 92 pApp->JS_appAlert(swMsg, NULL, 0, 3); |
108 } | 93 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // static | 149 // static |
165 CJS_Timer::TimerMap* CJS_Timer::GetGlobalTimerMap() { | 150 CJS_Timer::TimerMap* CJS_Timer::GetGlobalTimerMap() { |
166 // Leak the timer array at shutdown. | 151 // Leak the timer array at shutdown. |
167 static auto* s_TimerMap = new TimerMap; | 152 static auto* s_TimerMap = new TimerMap; |
168 return s_TimerMap; | 153 return s_TimerMap; |
169 } | 154 } |
170 | 155 |
171 void CJS_Timer::OnDestroyed() { | 156 void CJS_Timer::OnDestroyed() { |
172 m_bValid = false; | 157 m_bValid = false; |
173 } | 158 } |
OLD | NEW |