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 "../../../third_party/base/nonstd_unique_ptr.h" | 7 #include "../../../third_party/base/nonstd_unique_ptr.h" |
8 #include "../../include/javascript/JavaScript.h" | 8 #include "../../include/javascript/JavaScript.h" |
9 #include "../../include/javascript/IJavaScript.h" | 9 #include "../../include/javascript/IJavaScript.h" |
10 #include "../../include/javascript/JS_Define.h" | 10 #include "../../include/javascript/JS_Define.h" |
11 #include "../../include/javascript/JS_Object.h" | 11 #include "../../include/javascript/JS_Object.h" |
12 #include "../../include/javascript/JS_Value.h" | 12 #include "../../include/javascript/JS_Value.h" |
13 #include "../../include/javascript/app.h" | 13 #include "../../include/javascript/app.h" |
14 #include "../../include/javascript/JS_EventHandler.h" | 14 #include "../../include/javascript/JS_EventHandler.h" |
15 #include "../../include/javascript/resource.h" | 15 #include "../../include/javascript/resource.h" |
16 #include "../../include/javascript/JS_Context.h" | 16 #include "../../include/javascript/JS_Context.h" |
17 #include "../../include/javascript/JS_Runtime.h" | 17 #include "../../include/javascript/JS_Runtime.h" |
18 #include "../../include/javascript/Document.h" | 18 #include "../../include/javascript/Document.h" |
19 | 19 |
20 static v8::Isolate* GetIsolate(IFXJS_Context* cc) { | 20 static v8::Isolate* GetIsolate(IFXJS_Context* cc) { |
21 CJS_Context* pContext = (CJS_Context*)cc; | 21 CJS_Context* pContext = (CJS_Context*)cc; |
22 ASSERT(pContext != NULL); | |
23 | |
24 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 22 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
25 ASSERT(pRuntime != NULL); | |
26 | |
27 return pRuntime->GetIsolate(); | 23 return pRuntime->GetIsolate(); |
28 } | 24 } |
29 | 25 |
30 /* ---------------------------- TimerObj ---------------------------- */ | |
31 | |
32 BEGIN_JS_STATIC_CONST(CJS_TimerObj) | 26 BEGIN_JS_STATIC_CONST(CJS_TimerObj) |
33 END_JS_STATIC_CONST() | 27 END_JS_STATIC_CONST() |
34 | 28 |
35 BEGIN_JS_STATIC_PROP(CJS_TimerObj) | 29 BEGIN_JS_STATIC_PROP(CJS_TimerObj) |
36 END_JS_STATIC_PROP() | 30 END_JS_STATIC_PROP() |
37 | 31 |
38 BEGIN_JS_STATIC_METHOD(CJS_TimerObj) | 32 BEGIN_JS_STATIC_METHOD(CJS_TimerObj) |
39 END_JS_STATIC_METHOD() | 33 END_JS_STATIC_METHOD() |
40 | 34 |
41 IMPLEMENT_JS_CLASS(CJS_TimerObj, TimerObj) | 35 IMPLEMENT_JS_CLASS(CJS_TimerObj, TimerObj) |
42 | 36 |
43 TimerObj::TimerObj(CJS_Object* pJSObject) | 37 TimerObj::TimerObj(CJS_Object* pJSObject) |
44 : CJS_EmbedObj(pJSObject), m_pTimer(NULL) {} | 38 : CJS_EmbedObj(pJSObject), m_pTimer(NULL) {} |
45 | 39 |
46 TimerObj::~TimerObj() {} | 40 TimerObj::~TimerObj() {} |
47 | 41 |
48 void TimerObj::SetTimer(CJS_Timer* pTimer) { | 42 void TimerObj::SetTimer(CJS_Timer* pTimer) { |
49 m_pTimer = pTimer; | 43 m_pTimer = pTimer; |
50 } | 44 } |
51 | 45 |
52 CJS_Timer* TimerObj::GetTimer() const { | 46 CJS_Timer* TimerObj::GetTimer() const { |
53 return m_pTimer; | 47 return m_pTimer; |
54 } | 48 } |
55 | 49 |
56 #define JS_STR_VIEWERTYPE_READER L"Reader" | 50 #define JS_STR_VIEWERTYPE L"pdfium" |
Lei Zhang
2015/09/08 23:21:36
Ah, these are the standard return values for Acrob
| |
57 #define JS_STR_VIEWERTYPE_STANDARD L"Exchange" | |
58 #define JS_STR_VIEWERVARIATION L"Full" | 51 #define JS_STR_VIEWERVARIATION L"Full" |
59 #define JS_STR_PLATFORM L"WIN" | 52 #define JS_STR_PLATFORM L"WIN" |
60 #define JS_STR_LANGUANGE L"ENU" | 53 #define JS_STR_LANGUANGE L"ENU" |
61 #define JS_STR_VIEWERVERSION 8 | 54 #define JS_NUM_VIEWERVERSION 8 |
62 #define JS_NUM_FORMSVERSION 7 | 55 #define JS_NUM_FORMSVERSION 7 |
63 | 56 |
64 #define JS_FILEPATH_MAXLEN 2000 | |
65 | |
66 /* ---------------------------- app ---------------------------- */ | |
67 | |
68 BEGIN_JS_STATIC_CONST(CJS_App) | 57 BEGIN_JS_STATIC_CONST(CJS_App) |
69 END_JS_STATIC_CONST() | 58 END_JS_STATIC_CONST() |
70 | 59 |
71 BEGIN_JS_STATIC_PROP(CJS_App) | 60 BEGIN_JS_STATIC_PROP(CJS_App) |
72 JS_STATIC_PROP_ENTRY(activeDocs) | 61 JS_STATIC_PROP_ENTRY(activeDocs) |
73 JS_STATIC_PROP_ENTRY(calculate) | 62 JS_STATIC_PROP_ENTRY(calculate) |
74 JS_STATIC_PROP_ENTRY(formsVersion) | 63 JS_STATIC_PROP_ENTRY(formsVersion) |
75 JS_STATIC_PROP_ENTRY(fs) | 64 JS_STATIC_PROP_ENTRY(fs) |
76 JS_STATIC_PROP_ENTRY(fullscreen) | 65 JS_STATIC_PROP_ENTRY(fullscreen) |
77 JS_STATIC_PROP_ENTRY(language) | 66 JS_STATIC_PROP_ENTRY(language) |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 return TRUE; | 170 return TRUE; |
182 } | 171 } |
183 | 172 |
184 return FALSE; | 173 return FALSE; |
185 } | 174 } |
186 | 175 |
187 FX_BOOL app::viewerType(IFXJS_Context* cc, | 176 FX_BOOL app::viewerType(IFXJS_Context* cc, |
188 CJS_PropValue& vp, | 177 CJS_PropValue& vp, |
189 CFX_WideString& sError) { | 178 CFX_WideString& sError) { |
190 if (vp.IsGetting()) { | 179 if (vp.IsGetting()) { |
191 vp << L"pdfium"; | 180 vp << JS_STR_VIEWERTYPE; |
192 return TRUE; | 181 return TRUE; |
193 } | 182 } |
194 | 183 |
195 return FALSE; | 184 return FALSE; |
196 } | 185 } |
197 | 186 |
198 FX_BOOL app::viewerVariation(IFXJS_Context* cc, | 187 FX_BOOL app::viewerVariation(IFXJS_Context* cc, |
199 CJS_PropValue& vp, | 188 CJS_PropValue& vp, |
200 CFX_WideString& sError) { | 189 CFX_WideString& sError) { |
201 if (vp.IsGetting()) { | 190 if (vp.IsGetting()) { |
202 vp << JS_STR_VIEWERVARIATION; | 191 vp << JS_STR_VIEWERVARIATION; |
203 return TRUE; | 192 return TRUE; |
204 } | 193 } |
205 | 194 |
206 return FALSE; | 195 return FALSE; |
207 } | 196 } |
208 | 197 |
209 FX_BOOL app::viewerVersion(IFXJS_Context* cc, | 198 FX_BOOL app::viewerVersion(IFXJS_Context* cc, |
210 CJS_PropValue& vp, | 199 CJS_PropValue& vp, |
211 CFX_WideString& sError) { | 200 CFX_WideString& sError) { |
212 if (vp.IsGetting()) { | 201 if (vp.IsGetting()) { |
213 vp << JS_STR_VIEWERVERSION; | 202 vp << JS_NUM_VIEWERVERSION; |
214 return TRUE; | 203 return TRUE; |
215 } | 204 } |
216 | 205 |
217 return FALSE; | 206 return FALSE; |
218 } | 207 } |
219 | 208 |
220 FX_BOOL app::platform(IFXJS_Context* cc, | 209 FX_BOOL app::platform(IFXJS_Context* cc, |
221 CJS_PropValue& vp, | 210 CJS_PropValue& vp, |
222 CFX_WideString& sError) { | 211 CFX_WideString& sError) { |
223 if (vp.IsGetting()) { | 212 if (vp.IsGetting()) { |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 CFX_WideString& sError) { | 845 CFX_WideString& sError) { |
857 return FALSE; | 846 return FALSE; |
858 } | 847 } |
859 | 848 |
860 FX_BOOL app::execDialog(IFXJS_Context* cc, | 849 FX_BOOL app::execDialog(IFXJS_Context* cc, |
861 const CJS_Parameters& params, | 850 const CJS_Parameters& params, |
862 CJS_Value& vRet, | 851 CJS_Value& vRet, |
863 CFX_WideString& sError) { | 852 CFX_WideString& sError) { |
864 return TRUE; | 853 return TRUE; |
865 } | 854 } |
OLD | NEW |