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 "fxjs/include/fxjs_v8.h" | 15 #include "fxjs/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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 public: | 71 public: |
70 CJS_Timer(CJS_EmbedObj* pObj, | 72 CJS_Timer(CJS_EmbedObj* pObj, |
71 CPDFDoc_Environment* pApp, | 73 CPDFDoc_Environment* pApp, |
72 CJS_Runtime* pRuntime, | 74 CJS_Runtime* pRuntime, |
73 int nType, | 75 int nType, |
74 const CFX_WideString& script, | 76 const CFX_WideString& script, |
75 uint32_t dwElapse, | 77 uint32_t dwElapse, |
76 uint32_t dwTimeOut); | 78 uint32_t dwTimeOut); |
77 ~CJS_Timer() override; | 79 ~CJS_Timer() override; |
78 | 80 |
79 void KillJSTimer(); | 81 static void Trigger(int nTimerID); |
82 static void Cancel(int nTimerID); | |
80 | 83 |
81 int GetType() const { return m_nType; } | 84 bool IsOneTime() const { return m_nType == 1; } |
Lei Zhang
2016/08/05 22:29:55
Maybe IsOneShot() ?
Tom Sepez
2016/08/05 23:11:42
Done.
| |
82 uint32_t GetTimeOut() const { return m_dwTimeOut; } | 85 uint32_t GetTimeOut() const { return m_dwTimeOut; } |
86 int GetTimerID() const { return m_nTimerID; } | |
83 CJS_Runtime* GetRuntime() const { return m_bValid ? m_pRuntime : nullptr; } | 87 CJS_Runtime* GetRuntime() const { return m_bValid ? m_pRuntime : nullptr; } |
84 CFX_WideString GetJScript() const { return m_swJScript; } | 88 CFX_WideString GetJScript() const { return m_swJScript; } |
85 | 89 |
86 static void TimerProc(int idEvent); | |
87 | |
88 private: | 90 private: |
89 using TimerMap = std::map<FX_UINT, CJS_Timer*>; | 91 using TimerMap = std::map<FX_UINT, CJS_Timer*>; |
90 static TimerMap* GetGlobalTimerMap(); | 92 static TimerMap* GetGlobalTimerMap(); |
91 | 93 |
92 // CJS_Runtime::Observer | 94 // CJS_Runtime::Observer |
93 void OnDestroyed() override; | 95 void OnDestroyed() override; |
94 | 96 |
95 uint32_t m_nTimerID; | 97 uint32_t m_nTimerID; |
96 CJS_EmbedObj* const m_pEmbedObj; | 98 CJS_EmbedObj* const m_pEmbedObj; |
97 bool m_bProcessing; | 99 bool m_bProcessing; |
98 bool m_bValid; | 100 bool m_bValid; |
99 | 101 |
100 // data | 102 // data |
101 const int m_nType; // 0:Interval; 1:TimeOut | 103 const int m_nType; // 0:Interval; 1:TimeOut |
102 const uint32_t m_dwTimeOut; | 104 const uint32_t m_dwTimeOut; |
103 const CFX_WideString m_swJScript; | 105 const CFX_WideString m_swJScript; |
104 CJS_Runtime* const m_pRuntime; | 106 CJS_Runtime* const m_pRuntime; |
105 CPDFDoc_Environment* const m_pApp; | 107 CPDFDoc_Environment* const m_pApp; |
106 }; | 108 }; |
107 | 109 |
108 #endif // FPDFSDK_JAVASCRIPT_JS_OBJECT_H_ | 110 #endif // FPDFSDK_JAVASCRIPT_JS_OBJECT_H_ |
OLD | NEW |