| 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 "app.h" | 7 #include "app.h" |
| 8 | 8 |
| 9 #include "../../../third_party/base/nonstd_unique_ptr.h" | 9 #include "../../../third_party/base/nonstd_unique_ptr.h" |
| 10 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. | 10 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. |
| 11 #include "../../include/javascript/IJavaScript.h" | 11 #include "../../include/javascript/IJavaScript.h" |
| 12 #include "Document.h" | 12 #include "Document.h" |
| 13 #include "JS_Context.h" | 13 #include "JS_Context.h" |
| 14 #include "JS_Define.h" | 14 #include "JS_Define.h" |
| 15 #include "JS_EventHandler.h" | 15 #include "JS_EventHandler.h" |
| 16 #include "JS_Object.h" | 16 #include "JS_Object.h" |
| 17 #include "JS_Runtime.h" | 17 #include "JS_Runtime.h" |
| 18 #include "JS_Value.h" | 18 #include "JS_Value.h" |
| 19 #include "resource.h" | 19 #include "resource.h" |
| 20 | 20 |
| 21 static v8::Isolate* GetIsolate(IFXJS_Context* cc) { | 21 static v8::Isolate* GetIsolate(IJS_Context* cc) { |
| 22 CJS_Context* pContext = (CJS_Context*)cc; | 22 CJS_Context* pContext = (CJS_Context*)cc; |
| 23 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 23 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 24 return pRuntime->GetIsolate(); | 24 return pRuntime->GetIsolate(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 BEGIN_JS_STATIC_CONST(CJS_TimerObj) | 27 BEGIN_JS_STATIC_CONST(CJS_TimerObj) |
| 28 END_JS_STATIC_CONST() | 28 END_JS_STATIC_CONST() |
| 29 | 29 |
| 30 BEGIN_JS_STATIC_PROP(CJS_TimerObj) | 30 BEGIN_JS_STATIC_PROP(CJS_TimerObj) |
| 31 END_JS_STATIC_PROP() | 31 END_JS_STATIC_PROP() |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 app::app(CJS_Object* pJSObject) | 103 app::app(CJS_Object* pJSObject) |
| 104 : CJS_EmbedObj(pJSObject), m_bCalculate(true), m_bRuntimeHighLight(false) {} | 104 : CJS_EmbedObj(pJSObject), m_bCalculate(true), m_bRuntimeHighLight(false) {} |
| 105 | 105 |
| 106 app::~app() { | 106 app::~app() { |
| 107 for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) | 107 for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) |
| 108 delete m_aTimer[i]; | 108 delete m_aTimer[i]; |
| 109 | 109 |
| 110 m_aTimer.RemoveAll(); | 110 m_aTimer.RemoveAll(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 FX_BOOL app::activeDocs(IFXJS_Context* cc, | 113 FX_BOOL app::activeDocs(IJS_Context* cc, |
| 114 CJS_PropValue& vp, | 114 CJS_PropValue& vp, |
| 115 CFX_WideString& sError) { | 115 CFX_WideString& sError) { |
| 116 if (!vp.IsGetting()) | 116 if (!vp.IsGetting()) |
| 117 return FALSE; | 117 return FALSE; |
| 118 | 118 |
| 119 CJS_Context* pContext = (CJS_Context*)cc; | 119 CJS_Context* pContext = (CJS_Context*)cc; |
| 120 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 120 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 121 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 121 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 122 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); | 122 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); |
| 123 CJS_Array aDocs(pRuntime->GetIsolate()); | 123 CJS_Array aDocs(pRuntime->GetIsolate()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 138 aDocs.SetElement(0, CJS_Value(pRuntime->GetIsolate(), pJSDocument)); | 138 aDocs.SetElement(0, CJS_Value(pRuntime->GetIsolate(), pJSDocument)); |
| 139 } | 139 } |
| 140 if (aDocs.GetLength() > 0) | 140 if (aDocs.GetLength() > 0) |
| 141 vp << aDocs; | 141 vp << aDocs; |
| 142 else | 142 else |
| 143 vp.SetNull(); | 143 vp.SetNull(); |
| 144 | 144 |
| 145 return TRUE; | 145 return TRUE; |
| 146 } | 146 } |
| 147 | 147 |
| 148 FX_BOOL app::calculate(IFXJS_Context* cc, | 148 FX_BOOL app::calculate(IJS_Context* cc, |
| 149 CJS_PropValue& vp, | 149 CJS_PropValue& vp, |
| 150 CFX_WideString& sError) { | 150 CFX_WideString& sError) { |
| 151 if (vp.IsSetting()) { | 151 if (vp.IsSetting()) { |
| 152 bool bVP; | 152 bool bVP; |
| 153 vp >> bVP; | 153 vp >> bVP; |
| 154 m_bCalculate = (FX_BOOL)bVP; | 154 m_bCalculate = (FX_BOOL)bVP; |
| 155 | 155 |
| 156 CJS_Context* pContext = (CJS_Context*)cc; | 156 CJS_Context* pContext = (CJS_Context*)cc; |
| 157 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 157 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
| 158 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 158 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 159 CJS_Array aDocs(pRuntime->GetIsolate()); | 159 CJS_Array aDocs(pRuntime->GetIsolate()); |
| 160 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) | 160 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) |
| 161 pDoc->GetInterForm()->EnableCalculate((FX_BOOL)m_bCalculate); | 161 pDoc->GetInterForm()->EnableCalculate((FX_BOOL)m_bCalculate); |
| 162 } else { | 162 } else { |
| 163 vp << (bool)m_bCalculate; | 163 vp << (bool)m_bCalculate; |
| 164 } | 164 } |
| 165 return TRUE; | 165 return TRUE; |
| 166 } | 166 } |
| 167 | 167 |
| 168 FX_BOOL app::formsVersion(IFXJS_Context* cc, | 168 FX_BOOL app::formsVersion(IJS_Context* cc, |
| 169 CJS_PropValue& vp, | 169 CJS_PropValue& vp, |
| 170 CFX_WideString& sError) { | 170 CFX_WideString& sError) { |
| 171 if (vp.IsGetting()) { | 171 if (vp.IsGetting()) { |
| 172 vp << JS_NUM_FORMSVERSION; | 172 vp << JS_NUM_FORMSVERSION; |
| 173 return TRUE; | 173 return TRUE; |
| 174 } | 174 } |
| 175 | 175 |
| 176 return FALSE; | 176 return FALSE; |
| 177 } | 177 } |
| 178 | 178 |
| 179 FX_BOOL app::viewerType(IFXJS_Context* cc, | 179 FX_BOOL app::viewerType(IJS_Context* cc, |
| 180 CJS_PropValue& vp, | 180 CJS_PropValue& vp, |
| 181 CFX_WideString& sError) { | 181 CFX_WideString& sError) { |
| 182 if (vp.IsGetting()) { | 182 if (vp.IsGetting()) { |
| 183 vp << JS_STR_VIEWERTYPE; | 183 vp << JS_STR_VIEWERTYPE; |
| 184 return TRUE; | 184 return TRUE; |
| 185 } | 185 } |
| 186 | 186 |
| 187 return FALSE; | 187 return FALSE; |
| 188 } | 188 } |
| 189 | 189 |
| 190 FX_BOOL app::viewerVariation(IFXJS_Context* cc, | 190 FX_BOOL app::viewerVariation(IJS_Context* cc, |
| 191 CJS_PropValue& vp, | 191 CJS_PropValue& vp, |
| 192 CFX_WideString& sError) { | 192 CFX_WideString& sError) { |
| 193 if (vp.IsGetting()) { | 193 if (vp.IsGetting()) { |
| 194 vp << JS_STR_VIEWERVARIATION; | 194 vp << JS_STR_VIEWERVARIATION; |
| 195 return TRUE; | 195 return TRUE; |
| 196 } | 196 } |
| 197 | 197 |
| 198 return FALSE; | 198 return FALSE; |
| 199 } | 199 } |
| 200 | 200 |
| 201 FX_BOOL app::viewerVersion(IFXJS_Context* cc, | 201 FX_BOOL app::viewerVersion(IJS_Context* cc, |
| 202 CJS_PropValue& vp, | 202 CJS_PropValue& vp, |
| 203 CFX_WideString& sError) { | 203 CFX_WideString& sError) { |
| 204 if (!vp.IsGetting()) | 204 if (!vp.IsGetting()) |
| 205 return FALSE; | 205 return FALSE; |
| 206 | 206 |
| 207 CJS_Context* pContext = (CJS_Context*)cc; | 207 CJS_Context* pContext = (CJS_Context*)cc; |
| 208 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); | 208 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); |
| 209 CPDFXFA_Document* pDoc = pCurDoc->GetDocument(); | 209 CPDFXFA_Document* pDoc = pCurDoc->GetDocument(); |
| 210 if (pDoc->GetDocType() == 1 || pDoc->GetDocType() == 2) | 210 if (pDoc->GetDocType() == 1 || pDoc->GetDocType() == 2) |
| 211 vp << JS_NUM_VIEWERVERSION_XFA; | 211 vp << JS_NUM_VIEWERVERSION_XFA; |
| 212 else | 212 else |
| 213 vp << JS_NUM_VIEWERVERSION; | 213 vp << JS_NUM_VIEWERVERSION; |
| 214 | 214 |
| 215 return TRUE; | 215 return TRUE; |
| 216 } | 216 } |
| 217 | 217 |
| 218 FX_BOOL app::platform(IFXJS_Context* cc, | 218 FX_BOOL app::platform(IJS_Context* cc, |
| 219 CJS_PropValue& vp, | 219 CJS_PropValue& vp, |
| 220 CFX_WideString& sError) { | 220 CFX_WideString& sError) { |
| 221 if (vp.IsGetting()) { | 221 if (vp.IsGetting()) { |
| 222 vp << JS_STR_PLATFORM; | 222 vp << JS_STR_PLATFORM; |
| 223 return TRUE; | 223 return TRUE; |
| 224 } | 224 } |
| 225 | 225 |
| 226 return FALSE; | 226 return FALSE; |
| 227 } | 227 } |
| 228 | 228 |
| 229 FX_BOOL app::language(IFXJS_Context* cc, | 229 FX_BOOL app::language(IJS_Context* cc, |
| 230 CJS_PropValue& vp, | 230 CJS_PropValue& vp, |
| 231 CFX_WideString& sError) { | 231 CFX_WideString& sError) { |
| 232 if (vp.IsGetting()) { | 232 if (vp.IsGetting()) { |
| 233 vp << JS_STR_LANGUANGE; | 233 vp << JS_STR_LANGUANGE; |
| 234 return TRUE; | 234 return TRUE; |
| 235 } | 235 } |
| 236 | 236 |
| 237 return FALSE; | 237 return FALSE; |
| 238 } | 238 } |
| 239 | 239 |
| 240 // creates a new fdf object that contains no data | 240 // creates a new fdf object that contains no data |
| 241 // comment: need reader support | 241 // comment: need reader support |
| 242 // note: | 242 // note: |
| 243 // CFDF_Document * CPDFDoc_Environment::NewFDF(); | 243 // CFDF_Document * CPDFDoc_Environment::NewFDF(); |
| 244 FX_BOOL app::newFDF(IFXJS_Context* cc, | 244 FX_BOOL app::newFDF(IJS_Context* cc, |
| 245 const CJS_Parameters& params, | 245 const CJS_Parameters& params, |
| 246 CJS_Value& vRet, | 246 CJS_Value& vRet, |
| 247 CFX_WideString& sError) { | 247 CFX_WideString& sError) { |
| 248 return TRUE; | 248 return TRUE; |
| 249 } | 249 } |
| 250 // opens a specified pdf document and returns its document object | 250 // opens a specified pdf document and returns its document object |
| 251 // comment:need reader support | 251 // comment:need reader support |
| 252 // note: as defined in js reference, the proto of this function's fourth | 252 // note: as defined in js reference, the proto of this function's fourth |
| 253 // parmeters, how old an fdf document while do not show it. | 253 // parmeters, how old an fdf document while do not show it. |
| 254 // CFDF_Document * CPDFDoc_Environment::OpenFDF(string strPath,bool bUserConv); | 254 // CFDF_Document * CPDFDoc_Environment::OpenFDF(string strPath,bool bUserConv); |
| 255 | 255 |
| 256 FX_BOOL app::openFDF(IFXJS_Context* cc, | 256 FX_BOOL app::openFDF(IJS_Context* cc, |
| 257 const CJS_Parameters& params, | 257 const CJS_Parameters& params, |
| 258 CJS_Value& vRet, | 258 CJS_Value& vRet, |
| 259 CFX_WideString& sError) { | 259 CFX_WideString& sError) { |
| 260 return TRUE; | 260 return TRUE; |
| 261 } | 261 } |
| 262 | 262 |
| 263 FX_BOOL app::alert(IFXJS_Context* cc, | 263 FX_BOOL app::alert(IJS_Context* cc, |
| 264 const CJS_Parameters& params, | 264 const CJS_Parameters& params, |
| 265 CJS_Value& vRet, | 265 CJS_Value& vRet, |
| 266 CFX_WideString& sError) { | 266 CFX_WideString& sError) { |
| 267 int iSize = params.size(); | 267 int iSize = params.size(); |
| 268 if (iSize < 1) | 268 if (iSize < 1) |
| 269 return FALSE; | 269 return FALSE; |
| 270 | 270 |
| 271 CFX_WideString swMsg = L""; | 271 CFX_WideString swMsg = L""; |
| 272 CFX_WideString swTitle = L""; | 272 CFX_WideString swTitle = L""; |
| 273 int iIcon = 0; | 273 int iIcon = 0; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 352 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 353 ASSERT(pRuntime != NULL); | 353 ASSERT(pRuntime != NULL); |
| 354 pRuntime->BeginBlock(); | 354 pRuntime->BeginBlock(); |
| 355 vRet = MsgBox(pRuntime->GetReaderApp(), swMsg.c_str(), swTitle.c_str(), iType, | 355 vRet = MsgBox(pRuntime->GetReaderApp(), swMsg.c_str(), swTitle.c_str(), iType, |
| 356 iIcon); | 356 iIcon); |
| 357 pRuntime->EndBlock(); | 357 pRuntime->EndBlock(); |
| 358 | 358 |
| 359 return TRUE; | 359 return TRUE; |
| 360 } | 360 } |
| 361 | 361 |
| 362 FX_BOOL app::beep(IFXJS_Context* cc, | 362 FX_BOOL app::beep(IJS_Context* cc, |
| 363 const CJS_Parameters& params, | 363 const CJS_Parameters& params, |
| 364 CJS_Value& vRet, | 364 CJS_Value& vRet, |
| 365 CFX_WideString& sError) { | 365 CFX_WideString& sError) { |
| 366 if (params.size() == 1) { | 366 if (params.size() == 1) { |
| 367 CJS_Context* pContext = (CJS_Context*)cc; | 367 CJS_Context* pContext = (CJS_Context*)cc; |
| 368 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 368 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 369 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); | 369 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); |
| 370 pEnv->JS_appBeep(params[0].ToInt()); | 370 pEnv->JS_appBeep(params[0].ToInt()); |
| 371 return TRUE; | 371 return TRUE; |
| 372 } | 372 } |
| 373 | 373 |
| 374 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); | 374 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); |
| 375 return FALSE; | 375 return FALSE; |
| 376 } | 376 } |
| 377 | 377 |
| 378 FX_BOOL app::findComponent(IFXJS_Context* cc, | 378 FX_BOOL app::findComponent(IJS_Context* cc, |
| 379 const CJS_Parameters& params, | 379 const CJS_Parameters& params, |
| 380 CJS_Value& vRet, | 380 CJS_Value& vRet, |
| 381 CFX_WideString& sError) { | 381 CFX_WideString& sError) { |
| 382 return TRUE; | 382 return TRUE; |
| 383 } | 383 } |
| 384 | 384 |
| 385 FX_BOOL app::popUpMenuEx(IFXJS_Context* cc, | 385 FX_BOOL app::popUpMenuEx(IJS_Context* cc, |
| 386 const CJS_Parameters& params, | 386 const CJS_Parameters& params, |
| 387 CJS_Value& vRet, | 387 CJS_Value& vRet, |
| 388 CFX_WideString& sError) { | 388 CFX_WideString& sError) { |
| 389 return FALSE; | 389 return FALSE; |
| 390 } | 390 } |
| 391 | 391 |
| 392 FX_BOOL app::fs(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { | 392 FX_BOOL app::fs(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
| 393 return FALSE; | 393 return FALSE; |
| 394 } | 394 } |
| 395 | 395 |
| 396 FX_BOOL app::setInterval(IFXJS_Context* cc, | 396 FX_BOOL app::setInterval(IJS_Context* cc, |
| 397 const CJS_Parameters& params, | 397 const CJS_Parameters& params, |
| 398 CJS_Value& vRet, | 398 CJS_Value& vRet, |
| 399 CFX_WideString& sError) { | 399 CFX_WideString& sError) { |
| 400 CJS_Context* pContext = (CJS_Context*)cc; | 400 CJS_Context* pContext = (CJS_Context*)cc; |
| 401 if (params.size() > 2 || params.size() == 0) { | 401 if (params.size() > 2 || params.size() == 0) { |
| 402 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 402 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 403 return FALSE; | 403 return FALSE; |
| 404 } | 404 } |
| 405 | 405 |
| 406 CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString() : L""; | 406 CFX_WideString script = params.size() > 0 ? params[0].ToCFXWideString() : L""; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 422 pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID); | 422 pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID); |
| 423 CJS_TimerObj* pJS_TimerObj = | 423 CJS_TimerObj* pJS_TimerObj = |
| 424 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); | 424 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); |
| 425 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); | 425 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); |
| 426 pTimerObj->SetTimer(pTimer); | 426 pTimerObj->SetTimer(pTimer); |
| 427 | 427 |
| 428 vRet = pRetObj; | 428 vRet = pRetObj; |
| 429 return TRUE; | 429 return TRUE; |
| 430 } | 430 } |
| 431 | 431 |
| 432 FX_BOOL app::setTimeOut(IFXJS_Context* cc, | 432 FX_BOOL app::setTimeOut(IJS_Context* cc, |
| 433 const CJS_Parameters& params, | 433 const CJS_Parameters& params, |
| 434 CJS_Value& vRet, | 434 CJS_Value& vRet, |
| 435 CFX_WideString& sError) { | 435 CFX_WideString& sError) { |
| 436 if (params.size() > 2 || params.size() == 0) { | 436 if (params.size() > 2 || params.size() == 0) { |
| 437 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); | 437 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); |
| 438 return FALSE; | 438 return FALSE; |
| 439 } | 439 } |
| 440 | 440 |
| 441 CJS_Context* pContext = (CJS_Context*)cc; | 441 CJS_Context* pContext = (CJS_Context*)cc; |
| 442 ASSERT(pContext != NULL); | 442 ASSERT(pContext != NULL); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 463 pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID); | 463 pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID); |
| 464 CJS_TimerObj* pJS_TimerObj = | 464 CJS_TimerObj* pJS_TimerObj = |
| 465 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); | 465 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); |
| 466 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); | 466 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); |
| 467 pTimerObj->SetTimer(pTimer); | 467 pTimerObj->SetTimer(pTimer); |
| 468 | 468 |
| 469 vRet = pRetObj; | 469 vRet = pRetObj; |
| 470 return TRUE; | 470 return TRUE; |
| 471 } | 471 } |
| 472 | 472 |
| 473 FX_BOOL app::clearTimeOut(IFXJS_Context* cc, | 473 FX_BOOL app::clearTimeOut(IJS_Context* cc, |
| 474 const CJS_Parameters& params, | 474 const CJS_Parameters& params, |
| 475 CJS_Value& vRet, | 475 CJS_Value& vRet, |
| 476 CFX_WideString& sError) { | 476 CFX_WideString& sError) { |
| 477 CJS_Context* pContext = (CJS_Context*)cc; | 477 CJS_Context* pContext = (CJS_Context*)cc; |
| 478 if (params.size() != 1) { | 478 if (params.size() != 1) { |
| 479 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 479 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 480 return FALSE; | 480 return FALSE; |
| 481 } | 481 } |
| 482 | 482 |
| 483 if (params[0].GetType() == CJS_Value::VT_fxobject) { | 483 if (params[0].GetType() == CJS_Value::VT_fxobject) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 499 pTimerObj->SetTimer(NULL); | 499 pTimerObj->SetTimer(NULL); |
| 500 } | 500 } |
| 501 } | 501 } |
| 502 } | 502 } |
| 503 } | 503 } |
| 504 } | 504 } |
| 505 | 505 |
| 506 return TRUE; | 506 return TRUE; |
| 507 } | 507 } |
| 508 | 508 |
| 509 FX_BOOL app::clearInterval(IFXJS_Context* cc, | 509 FX_BOOL app::clearInterval(IJS_Context* cc, |
| 510 const CJS_Parameters& params, | 510 const CJS_Parameters& params, |
| 511 CJS_Value& vRet, | 511 CJS_Value& vRet, |
| 512 CFX_WideString& sError) { | 512 CFX_WideString& sError) { |
| 513 CJS_Context* pContext = (CJS_Context*)cc; | 513 CJS_Context* pContext = (CJS_Context*)cc; |
| 514 if (params.size() != 1) { | 514 if (params.size() != 1) { |
| 515 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 515 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 516 return FALSE; | 516 return FALSE; |
| 517 } | 517 } |
| 518 | 518 |
| 519 if (params[0].GetType() == CJS_Value::VT_fxobject) { | 519 if (params[0].GetType() == CJS_Value::VT_fxobject) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 535 pTimerObj->SetTimer(NULL); | 535 pTimerObj->SetTimer(NULL); |
| 536 } | 536 } |
| 537 } | 537 } |
| 538 } | 538 } |
| 539 } | 539 } |
| 540 } | 540 } |
| 541 | 541 |
| 542 return TRUE; | 542 return TRUE; |
| 543 } | 543 } |
| 544 | 544 |
| 545 FX_BOOL app::execMenuItem(IFXJS_Context* cc, | 545 FX_BOOL app::execMenuItem(IJS_Context* cc, |
| 546 const CJS_Parameters& params, | 546 const CJS_Parameters& params, |
| 547 CJS_Value& vRet, | 547 CJS_Value& vRet, |
| 548 CFX_WideString& sError) { | 548 CFX_WideString& sError) { |
| 549 return FALSE; | 549 return FALSE; |
| 550 } | 550 } |
| 551 | 551 |
| 552 void app::TimerProc(CJS_Timer* pTimer) { | 552 void app::TimerProc(CJS_Timer* pTimer) { |
| 553 ASSERT(pTimer != NULL); | 553 ASSERT(pTimer != NULL); |
| 554 | 554 |
| 555 CJS_Runtime* pRuntime = pTimer->GetRuntime(); | 555 CJS_Runtime* pRuntime = pTimer->GetRuntime(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 566 pTimer->KillJSTimer(); | 566 pTimer->KillJSTimer(); |
| 567 } | 567 } |
| 568 break; | 568 break; |
| 569 } | 569 } |
| 570 } | 570 } |
| 571 | 571 |
| 572 void app::RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript) { | 572 void app::RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript) { |
| 573 ASSERT(pRuntime != NULL); | 573 ASSERT(pRuntime != NULL); |
| 574 | 574 |
| 575 if (!pRuntime->IsBlocking()) { | 575 if (!pRuntime->IsBlocking()) { |
| 576 IFXJS_Context* pContext = pRuntime->NewContext(); | 576 IJS_Context* pContext = pRuntime->NewContext(); |
| 577 ASSERT(pContext != NULL); | 577 ASSERT(pContext != NULL); |
| 578 pContext->OnExternal_Exec(); | 578 pContext->OnExternal_Exec(); |
| 579 CFX_WideString wtInfo; | 579 CFX_WideString wtInfo; |
| 580 pContext->RunScript(wsScript, wtInfo); | 580 pContext->RunScript(wsScript, wtInfo); |
| 581 pRuntime->ReleaseContext(pContext); | 581 pRuntime->ReleaseContext(pContext); |
| 582 } | 582 } |
| 583 } | 583 } |
| 584 | 584 |
| 585 FX_BOOL app::goBack(IFXJS_Context* cc, | 585 FX_BOOL app::goBack(IJS_Context* cc, |
| 586 const CJS_Parameters& params, | 586 const CJS_Parameters& params, |
| 587 CJS_Value& vRet, | 587 CJS_Value& vRet, |
| 588 CFX_WideString& sError) { | 588 CFX_WideString& sError) { |
| 589 // Not supported. | 589 // Not supported. |
| 590 return TRUE; | 590 return TRUE; |
| 591 } | 591 } |
| 592 | 592 |
| 593 FX_BOOL app::goForward(IFXJS_Context* cc, | 593 FX_BOOL app::goForward(IJS_Context* cc, |
| 594 const CJS_Parameters& params, | 594 const CJS_Parameters& params, |
| 595 CJS_Value& vRet, | 595 CJS_Value& vRet, |
| 596 CFX_WideString& sError) { | 596 CFX_WideString& sError) { |
| 597 // Not supported. | 597 // Not supported. |
| 598 return TRUE; | 598 return TRUE; |
| 599 } | 599 } |
| 600 | 600 |
| 601 FX_BOOL app::mailMsg(IFXJS_Context* cc, | 601 FX_BOOL app::mailMsg(IJS_Context* cc, |
| 602 const CJS_Parameters& params, | 602 const CJS_Parameters& params, |
| 603 CJS_Value& vRet, | 603 CJS_Value& vRet, |
| 604 CFX_WideString& sError) { | 604 CFX_WideString& sError) { |
| 605 CJS_Context* pContext = (CJS_Context*)cc; | 605 CJS_Context* pContext = (CJS_Context*)cc; |
| 606 v8::Isolate* isolate = GetIsolate(cc); | 606 v8::Isolate* isolate = GetIsolate(cc); |
| 607 | 607 |
| 608 FX_BOOL bUI = TRUE; | 608 FX_BOOL bUI = TRUE; |
| 609 CFX_WideString cTo = L""; | 609 CFX_WideString cTo = L""; |
| 610 CFX_WideString cCc = L""; | 610 CFX_WideString cCc = L""; |
| 611 CFX_WideString cBcc = L""; | 611 CFX_WideString cBcc = L""; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 ASSERT(pApp != NULL); | 660 ASSERT(pApp != NULL); |
| 661 | 661 |
| 662 pRuntime->BeginBlock(); | 662 pRuntime->BeginBlock(); |
| 663 pApp->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), | 663 pApp->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), |
| 664 cBcc.c_str(), cMsg.c_str()); | 664 cBcc.c_str(), cMsg.c_str()); |
| 665 pRuntime->EndBlock(); | 665 pRuntime->EndBlock(); |
| 666 | 666 |
| 667 return FALSE; | 667 return FALSE; |
| 668 } | 668 } |
| 669 | 669 |
| 670 FX_BOOL app::launchURL(IFXJS_Context* cc, | 670 FX_BOOL app::launchURL(IJS_Context* cc, |
| 671 const CJS_Parameters& params, | 671 const CJS_Parameters& params, |
| 672 CJS_Value& vRet, | 672 CJS_Value& vRet, |
| 673 CFX_WideString& sError) { | 673 CFX_WideString& sError) { |
| 674 // Unsafe, not supported. | 674 // Unsafe, not supported. |
| 675 return TRUE; | 675 return TRUE; |
| 676 } | 676 } |
| 677 | 677 |
| 678 FX_BOOL app::runtimeHighlight(IFXJS_Context* cc, | 678 FX_BOOL app::runtimeHighlight(IJS_Context* cc, |
| 679 CJS_PropValue& vp, | 679 CJS_PropValue& vp, |
| 680 CFX_WideString& sError) { | 680 CFX_WideString& sError) { |
| 681 if (vp.IsSetting()) { | 681 if (vp.IsSetting()) { |
| 682 vp >> m_bRuntimeHighLight; | 682 vp >> m_bRuntimeHighLight; |
| 683 } else { | 683 } else { |
| 684 vp << m_bRuntimeHighLight; | 684 vp << m_bRuntimeHighLight; |
| 685 } | 685 } |
| 686 | 686 |
| 687 return TRUE; | 687 return TRUE; |
| 688 } | 688 } |
| 689 | 689 |
| 690 FX_BOOL app::fullscreen(IFXJS_Context* cc, | 690 FX_BOOL app::fullscreen(IJS_Context* cc, |
| 691 CJS_PropValue& vp, | 691 CJS_PropValue& vp, |
| 692 CFX_WideString& sError) { | 692 CFX_WideString& sError) { |
| 693 return FALSE; | 693 return FALSE; |
| 694 } | 694 } |
| 695 | 695 |
| 696 FX_BOOL app::popUpMenu(IFXJS_Context* cc, | 696 FX_BOOL app::popUpMenu(IJS_Context* cc, |
| 697 const CJS_Parameters& params, | 697 const CJS_Parameters& params, |
| 698 CJS_Value& vRet, | 698 CJS_Value& vRet, |
| 699 CFX_WideString& sError) { | 699 CFX_WideString& sError) { |
| 700 return FALSE; | 700 return FALSE; |
| 701 } | 701 } |
| 702 | 702 |
| 703 FX_BOOL app::browseForDoc(IFXJS_Context* cc, | 703 FX_BOOL app::browseForDoc(IJS_Context* cc, |
| 704 const CJS_Parameters& params, | 704 const CJS_Parameters& params, |
| 705 CJS_Value& vRet, | 705 CJS_Value& vRet, |
| 706 CFX_WideString& sError) { | 706 CFX_WideString& sError) { |
| 707 // Unsafe, not supported. | 707 // Unsafe, not supported. |
| 708 return TRUE; | 708 return TRUE; |
| 709 } | 709 } |
| 710 | 710 |
| 711 CFX_WideString app::SysPathToPDFPath(const CFX_WideString& sOldPath) { | 711 CFX_WideString app::SysPathToPDFPath(const CFX_WideString& sOldPath) { |
| 712 CFX_WideString sRet = L"/"; | 712 CFX_WideString sRet = L"/"; |
| 713 | 713 |
| 714 for (int i = 0, sz = sOldPath.GetLength(); i < sz; i++) { | 714 for (int i = 0, sz = sOldPath.GetLength(); i < sz; i++) { |
| 715 wchar_t c = sOldPath.GetAt(i); | 715 wchar_t c = sOldPath.GetAt(i); |
| 716 if (c == L':') { | 716 if (c == L':') { |
| 717 } else { | 717 } else { |
| 718 if (c == L'\\') { | 718 if (c == L'\\') { |
| 719 sRet += L"/"; | 719 sRet += L"/"; |
| 720 } else { | 720 } else { |
| 721 sRet += c; | 721 sRet += c; |
| 722 } | 722 } |
| 723 } | 723 } |
| 724 } | 724 } |
| 725 | 725 |
| 726 return sRet; | 726 return sRet; |
| 727 } | 727 } |
| 728 | 728 |
| 729 FX_BOOL app::newDoc(IFXJS_Context* cc, | 729 FX_BOOL app::newDoc(IJS_Context* cc, |
| 730 const CJS_Parameters& params, | 730 const CJS_Parameters& params, |
| 731 CJS_Value& vRet, | 731 CJS_Value& vRet, |
| 732 CFX_WideString& sError) { | 732 CFX_WideString& sError) { |
| 733 return FALSE; | 733 return FALSE; |
| 734 } | 734 } |
| 735 | 735 |
| 736 FX_BOOL app::openDoc(IFXJS_Context* cc, | 736 FX_BOOL app::openDoc(IJS_Context* cc, |
| 737 const CJS_Parameters& params, | 737 const CJS_Parameters& params, |
| 738 CJS_Value& vRet, | 738 CJS_Value& vRet, |
| 739 CFX_WideString& sError) { | 739 CFX_WideString& sError) { |
| 740 return FALSE; | 740 return FALSE; |
| 741 } | 741 } |
| 742 | 742 |
| 743 FX_BOOL app::response(IFXJS_Context* cc, | 743 FX_BOOL app::response(IJS_Context* cc, |
| 744 const CJS_Parameters& params, | 744 const CJS_Parameters& params, |
| 745 CJS_Value& vRet, | 745 CJS_Value& vRet, |
| 746 CFX_WideString& sError) { | 746 CFX_WideString& sError) { |
| 747 CFX_WideString swQuestion = L""; | 747 CFX_WideString swQuestion = L""; |
| 748 CFX_WideString swLabel = L""; | 748 CFX_WideString swLabel = L""; |
| 749 CFX_WideString swTitle = L"PDF"; | 749 CFX_WideString swTitle = L"PDF"; |
| 750 CFX_WideString swDefault = L""; | 750 CFX_WideString swDefault = L""; |
| 751 bool bPassWord = false; | 751 bool bPassWord = false; |
| 752 | 752 |
| 753 v8::Isolate* isolate = GetIsolate(cc); | 753 v8::Isolate* isolate = GetIsolate(cc); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 return FALSE; | 813 return FALSE; |
| 814 } | 814 } |
| 815 nLengthBytes = std::min(nLengthBytes, MAX_INPUT_BYTES); | 815 nLengthBytes = std::min(nLengthBytes, MAX_INPUT_BYTES); |
| 816 | 816 |
| 817 CFX_WideString ret_string = CFX_WideString::FromUTF16LE( | 817 CFX_WideString ret_string = CFX_WideString::FromUTF16LE( |
| 818 (unsigned short*)pBuff.get(), nLengthBytes / sizeof(unsigned short)); | 818 (unsigned short*)pBuff.get(), nLengthBytes / sizeof(unsigned short)); |
| 819 vRet = ret_string.c_str(); | 819 vRet = ret_string.c_str(); |
| 820 return TRUE; | 820 return TRUE; |
| 821 } | 821 } |
| 822 | 822 |
| 823 FX_BOOL app::media(IFXJS_Context* cc, | 823 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
| 824 CJS_PropValue& vp, | |
| 825 CFX_WideString& sError) { | |
| 826 return FALSE; | 824 return FALSE; |
| 827 } | 825 } |
| 828 | 826 |
| 829 FX_BOOL app::execDialog(IFXJS_Context* cc, | 827 FX_BOOL app::execDialog(IJS_Context* cc, |
| 830 const CJS_Parameters& params, | 828 const CJS_Parameters& params, |
| 831 CJS_Value& vRet, | 829 CJS_Value& vRet, |
| 832 CFX_WideString& sError) { | 830 CFX_WideString& sError) { |
| 833 return TRUE; | 831 return TRUE; |
| 834 } | 832 } |
| OLD | NEW |