| 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" | 7 #include "../../include/javascript/JavaScript.h" |
| 8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.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_Value.h" | 11 #include "../../include/javascript/JS_Value.h" |
| 12 #include "../../include/javascript/app.h" | 12 #include "../../include/javascript/app.h" |
| 13 #include "../../include/javascript/JS_EventHandler.h" | 13 #include "../../include/javascript/JS_EventHandler.h" |
| 14 #include "../../include/javascript/resource.h" | 14 #include "../../include/javascript/resource.h" |
| 15 #include "../../include/javascript/JS_Context.h" | 15 #include "../../include/javascript/JS_Context.h" |
| 16 #include "../../include/javascript/JS_Runtime.h" | 16 #include "../../include/javascript/JS_Runtime.h" |
| 17 #include "../../include/javascript/Document.h" | 17 #include "../../include/javascript/Document.h" |
| 18 | 18 |
| 19 static v8::Isolate* GetIsolate(IFXJS_Context* cc) { | 19 static v8::Isolate* GetIsolate(IFXJS_Context* cc) { |
| 20 CJS_Context* pContext = (CJS_Context*)cc; | 20 CJS_Context* pContext = (CJS_Context*)cc; |
| 21 ASSERT(pContext != NULL); | |
| 22 | |
| 23 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 21 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 24 ASSERT(pRuntime != NULL); | |
| 25 | |
| 26 return pRuntime->GetIsolate(); | 22 return pRuntime->GetIsolate(); |
| 27 } | 23 } |
| 28 | 24 |
| 29 /* ---------------------------- TimerObj ---------------------------- */ | |
| 30 | |
| 31 BEGIN_JS_STATIC_CONST(CJS_TimerObj) | 25 BEGIN_JS_STATIC_CONST(CJS_TimerObj) |
| 32 END_JS_STATIC_CONST() | 26 END_JS_STATIC_CONST() |
| 33 | 27 |
| 34 BEGIN_JS_STATIC_PROP(CJS_TimerObj) | 28 BEGIN_JS_STATIC_PROP(CJS_TimerObj) |
| 35 END_JS_STATIC_PROP() | 29 END_JS_STATIC_PROP() |
| 36 | 30 |
| 37 BEGIN_JS_STATIC_METHOD(CJS_TimerObj) | 31 BEGIN_JS_STATIC_METHOD(CJS_TimerObj) |
| 38 END_JS_STATIC_METHOD() | 32 END_JS_STATIC_METHOD() |
| 39 | 33 |
| 40 IMPLEMENT_JS_CLASS(CJS_TimerObj, TimerObj) | 34 IMPLEMENT_JS_CLASS(CJS_TimerObj, TimerObj) |
| 41 | 35 |
| 42 TimerObj::TimerObj(CJS_Object* pJSObject) | 36 TimerObj::TimerObj(CJS_Object* pJSObject) |
| 43 : CJS_EmbedObj(pJSObject), m_pTimer(NULL) {} | 37 : CJS_EmbedObj(pJSObject), m_pTimer(NULL) {} |
| 44 | 38 |
| 45 TimerObj::~TimerObj() {} | 39 TimerObj::~TimerObj() {} |
| 46 | 40 |
| 47 void TimerObj::SetTimer(CJS_Timer* pTimer) { | 41 void TimerObj::SetTimer(CJS_Timer* pTimer) { |
| 48 m_pTimer = pTimer; | 42 m_pTimer = pTimer; |
| 49 } | 43 } |
| 50 | 44 |
| 51 CJS_Timer* TimerObj::GetTimer() const { | 45 CJS_Timer* TimerObj::GetTimer() const { |
| 52 return m_pTimer; | 46 return m_pTimer; |
| 53 } | 47 } |
| 54 | 48 |
| 55 #define JS_STR_VIEWERTYPE_READER L"Reader" | 49 #define JS_STR_VIEWERTYPE L"pdfium" |
| 56 #define JS_STR_VIEWERTYPE_STANDARD L"Exchange" | |
| 57 #define JS_STR_VIEWERVARIATION L"Full" | 50 #define JS_STR_VIEWERVARIATION L"Full" |
| 58 #define JS_STR_PLATFORM L"WIN" | 51 #define JS_STR_PLATFORM L"WIN" |
| 59 #define JS_STR_LANGUANGE L"ENU" | 52 #define JS_STR_LANGUANGE L"ENU" |
| 60 #define JS_STR_VIEWERVERSION 8 | 53 #define JS_NUM_VIEWERVERSION 8 |
| 61 #define JS_STR_VIEWERVERSION_XFA 11 | 54 #define JS_NUM_VIEWERVERSION_XFA 11 |
| 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 return FALSE; | 202 return FALSE; |
| 214 | 203 |
| 215 CJS_Context* pContext = (CJS_Context*)cc; | 204 CJS_Context* pContext = (CJS_Context*)cc; |
| 216 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); | 205 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); |
| 217 CPDFXFA_Document* pDoc = pCurDoc->GetDocument(); | 206 CPDFXFA_Document* pDoc = pCurDoc->GetDocument(); |
| 218 if (pDoc->GetDocType() == 1 || pDoc->GetDocType() == 2) | 207 if (pDoc->GetDocType() == 1 || pDoc->GetDocType() == 2) |
| 219 vp << JS_STR_VIEWERVERSION_XFA; | 208 vp << JS_NUM_VIEWERVERSION_XFA; |
| 220 else | 209 else |
| 221 vp << JS_STR_VIEWERVERSION; | 210 vp << JS_NUM_VIEWERVERSION; |
| 222 | 211 |
| 223 return TRUE; | 212 return TRUE; |
| 224 } | 213 } |
| 225 | 214 |
| 226 FX_BOOL app::platform(IFXJS_Context* cc, | 215 FX_BOOL app::platform(IFXJS_Context* cc, |
| 227 CJS_PropValue& vp, | 216 CJS_PropValue& vp, |
| 228 CFX_WideString& sError) { | 217 CFX_WideString& sError) { |
| 229 if (vp.IsGetting()) { | 218 if (vp.IsGetting()) { |
| 230 vp << JS_STR_PLATFORM; | 219 vp << JS_STR_PLATFORM; |
| 231 return TRUE; | 220 return TRUE; |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 CFX_WideString& sError) { | 857 CFX_WideString& sError) { |
| 869 return FALSE; | 858 return FALSE; |
| 870 } | 859 } |
| 871 | 860 |
| 872 FX_BOOL app::execDialog(IFXJS_Context* cc, | 861 FX_BOOL app::execDialog(IFXJS_Context* cc, |
| 873 const CJS_Parameters& params, | 862 const CJS_Parameters& params, |
| 874 CJS_Value& vRet, | 863 CJS_Value& vRet, |
| 875 CFX_WideString& sError) { | 864 CFX_WideString& sError) { |
| 876 return TRUE; | 865 return TRUE; |
| 877 } | 866 } |
| OLD | NEW |