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