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 #ifndef FPDFSDK_JAVASCRIPT_JS_OBJECT_H_ | 7 #ifndef FPDFSDK_JAVASCRIPT_JS_OBJECT_H_ |
8 #define FPDFSDK_JAVASCRIPT_JS_OBJECT_H_ | 8 #define FPDFSDK_JAVASCRIPT_JS_OBJECT_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "fpdfsdk/include/fsdk_define.h" | 13 #include "fpdfsdk/include/fsdk_define.h" |
14 #include "fpdfsdk/javascript/cjs_runtime.h" | 14 #include "fpdfsdk/javascript/cjs_runtime.h" |
15 #include "fpdfsdk/jsapi/include/fxjs_v8.h" | 15 #include "fpdfsdk/jsapi/include/fxjs_v8.h" |
16 | 16 |
17 class CJS_Context; | 17 class CJS_Context; |
18 class CJS_Object; | 18 class CJS_Object; |
19 class CJS_Timer; | 19 class CJS_Timer; |
20 class CPDFDoc_Environment; | 20 class CPDFDoc_Environment; |
| 21 |
21 class CJS_EmbedObj { | 22 class CJS_EmbedObj { |
22 public: | 23 public: |
23 explicit CJS_EmbedObj(CJS_Object* pJSObject); | 24 explicit CJS_EmbedObj(CJS_Object* pJSObject); |
24 virtual ~CJS_EmbedObj(); | 25 virtual ~CJS_EmbedObj(); |
25 | 26 |
26 virtual void TimerProc(CJS_Timer* pTimer) {} | 27 virtual void TimerProc(CJS_Timer* pTimer) {} |
| 28 virtual void CancelProc(CJS_Timer* pTimer) {} |
27 | 29 |
28 CJS_Object* GetJSObject() const { return m_pJSObject; } | 30 CJS_Object* GetJSObject() const { return m_pJSObject; } |
29 | 31 |
30 int MsgBox(CPDFDoc_Environment* pApp, | 32 int MsgBox(CPDFDoc_Environment* pApp, |
31 const FX_WCHAR* swMsg, | 33 const FX_WCHAR* swMsg, |
32 const FX_WCHAR* swTitle, | 34 const FX_WCHAR* swTitle, |
33 FX_UINT nType, | 35 FX_UINT nType, |
34 FX_UINT nIcon); | 36 FX_UINT nIcon); |
35 void Alert(CJS_Context* pContext, const FX_WCHAR* swMsg); | 37 void Alert(CJS_Context* pContext, const FX_WCHAR* swMsg); |
36 | 38 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 public: | 79 public: |
78 CJS_Timer(CJS_EmbedObj* pObj, | 80 CJS_Timer(CJS_EmbedObj* pObj, |
79 CPDFDoc_Environment* pApp, | 81 CPDFDoc_Environment* pApp, |
80 CJS_Runtime* pRuntime, | 82 CJS_Runtime* pRuntime, |
81 int nType, | 83 int nType, |
82 const CFX_WideString& script, | 84 const CFX_WideString& script, |
83 uint32_t dwElapse, | 85 uint32_t dwElapse, |
84 uint32_t dwTimeOut); | 86 uint32_t dwTimeOut); |
85 ~CJS_Timer() override; | 87 ~CJS_Timer() override; |
86 | 88 |
87 void KillJSTimer(); | 89 static void Trigger(int nTimerID); |
| 90 static void Cancel(int nTimerID); |
88 | 91 |
89 int GetType() const { return m_nType; } | 92 bool IsOneShot() const { return m_nType == 1; } |
90 uint32_t GetTimeOut() const { return m_dwTimeOut; } | 93 uint32_t GetTimeOut() const { return m_dwTimeOut; } |
| 94 int GetTimerID() const { return m_nTimerID; } |
91 CJS_Runtime* GetRuntime() const { return m_bValid ? m_pRuntime : nullptr; } | 95 CJS_Runtime* GetRuntime() const { return m_bValid ? m_pRuntime : nullptr; } |
92 CFX_WideString GetJScript() const { return m_swJScript; } | 96 CFX_WideString GetJScript() const { return m_swJScript; } |
93 | 97 |
94 static void TimerProc(int idEvent); | |
95 | |
96 private: | 98 private: |
97 using TimerMap = std::map<FX_UINT, CJS_Timer*>; | 99 using TimerMap = std::map<FX_UINT, CJS_Timer*>; |
98 static TimerMap* GetGlobalTimerMap(); | 100 static TimerMap* GetGlobalTimerMap(); |
99 | 101 |
100 // CJS_Runtime::Observer | 102 // CJS_Runtime::Observer |
101 void OnDestroyed() override; | 103 void OnDestroyed() override; |
102 | 104 |
103 uint32_t m_nTimerID; | 105 uint32_t m_nTimerID; |
104 CJS_EmbedObj* const m_pEmbedObj; | 106 CJS_EmbedObj* const m_pEmbedObj; |
105 bool m_bProcessing; | 107 bool m_bProcessing; |
106 bool m_bValid; | 108 bool m_bValid; |
107 | 109 |
108 // data | 110 // data |
109 const int m_nType; // 0:Interval; 1:TimeOut | 111 const int m_nType; // 0:Interval; 1:TimeOut |
110 const uint32_t m_dwTimeOut; | 112 const uint32_t m_dwTimeOut; |
111 const CFX_WideString m_swJScript; | 113 const CFX_WideString m_swJScript; |
112 CJS_Runtime* const m_pRuntime; | 114 CJS_Runtime* const m_pRuntime; |
113 CPDFDoc_Environment* const m_pApp; | 115 CPDFDoc_Environment* const m_pApp; |
114 }; | 116 }; |
115 | 117 |
116 #endif // FPDFSDK_JAVASCRIPT_JS_OBJECT_H_ | 118 #endif // FPDFSDK_JAVASCRIPT_JS_OBJECT_H_ |
OLD | NEW |