Chromium Code Reviews| 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 "fpdfsdk/javascript/app.h" | 7 #include "fpdfsdk/javascript/app.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "fpdfsdk/cpdfsdk_document.h" | 12 #include "fpdfsdk/cpdfsdk_document.h" |
| 13 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" | 13 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
| 14 #include "fpdfsdk/cpdfsdk_interform.h" | 14 #include "fpdfsdk/cpdfsdk_interform.h" |
| 15 #include "fpdfsdk/javascript/Document.h" | 15 #include "fpdfsdk/javascript/Document.h" |
| 16 #include "fpdfsdk/javascript/JS_Define.h" | 16 #include "fpdfsdk/javascript/JS_Define.h" |
| 17 #include "fpdfsdk/javascript/JS_EventHandler.h" | 17 #include "fpdfsdk/javascript/JS_EventHandler.h" |
| 18 #include "fpdfsdk/javascript/JS_Object.h" | 18 #include "fpdfsdk/javascript/JS_Object.h" |
| 19 #include "fpdfsdk/javascript/JS_Value.h" | 19 #include "fpdfsdk/javascript/JS_Value.h" |
| 20 #include "fpdfsdk/javascript/cjs_context.h" | 20 #include "fpdfsdk/javascript/cjs_context.h" |
| 21 #include "fpdfsdk/javascript/cjs_runtime.h" | 21 #include "fpdfsdk/javascript/cjs_runtime.h" |
| 22 #include "fpdfsdk/javascript/resource.h" | 22 #include "fpdfsdk/javascript/resource.h" |
| 23 #include "third_party/base/stl_util.h" | 23 #include "third_party/base/stl_util.h" |
| 24 | 24 |
| 25 class GlobalTimer { | 25 class GlobalTimer { |
| 26 public: | 26 public: |
| 27 GlobalTimer(app* pObj, | 27 GlobalTimer(app* pObj, |
| 28 CPDFSDK_FormFillEnvironment* pEnv, | 28 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 29 CJS_Runtime* pRuntime, | 29 CJS_Runtime* pRuntime, |
| 30 int nType, | 30 int nType, |
| 31 const CFX_WideString& script, | 31 const CFX_WideString& script, |
| 32 uint32_t dwElapse, | 32 uint32_t dwElapse, |
| 33 uint32_t dwTimeOut); | 33 uint32_t dwTimeOut); |
| 34 ~GlobalTimer(); | 34 ~GlobalTimer(); |
| 35 | 35 |
| 36 static void Trigger(int nTimerID); | 36 static void Trigger(int nTimerID); |
| 37 static void Cancel(int nTimerID); | 37 static void Cancel(int nTimerID); |
| 38 | 38 |
| 39 bool IsOneShot() const { return m_nType == 1; } | 39 bool IsOneShot() const { return m_nType == 1; } |
| 40 uint32_t GetTimeOut() const { return m_dwTimeOut; } | 40 uint32_t GetTimeOut() const { return m_dwTimeOut; } |
| 41 int GetTimerID() const { return m_nTimerID; } | 41 int GetTimerID() const { return m_nTimerID; } |
| 42 CJS_Runtime* GetRuntime() const { return m_pRuntime.Get(); } | 42 CJS_Runtime* GetRuntime() const { return m_pRuntime.Get(); } |
| 43 CFX_WideString GetJScript() const { return m_swJScript; } | 43 CFX_WideString GetJScript() const { return m_swJScript; } |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 using TimerMap = std::map<uint32_t, GlobalTimer*>; | 46 using TimerMap = std::map<uint32_t, GlobalTimer*>; |
| 47 static TimerMap* GetGlobalTimerMap(); | 47 static TimerMap* GetGlobalTimerMap(); |
| 48 | 48 |
| 49 uint32_t m_nTimerID; | 49 uint32_t m_nTimerID; |
| 50 app* const m_pEmbedObj; | 50 app* const m_pEmbedObj; |
| 51 bool m_bProcessing; | 51 bool m_bProcessing; |
| 52 | 52 |
| 53 // data | 53 // data |
| 54 const int m_nType; // 0:Interval; 1:TimeOut | 54 const int m_nType; // 0:Interval; 1:TimeOut |
| 55 const uint32_t m_dwTimeOut; | 55 const uint32_t m_dwTimeOut; |
| 56 const CFX_WideString m_swJScript; | 56 const CFX_WideString m_swJScript; |
| 57 CJS_Runtime::ObservedPtr m_pRuntime; | 57 CJS_Runtime::ObservedPtr m_pRuntime; |
| 58 CPDFSDK_FormFillEnvironment* const m_pEnv; | 58 CPDFSDK_FormFillEnvironment* const m_pFormFillEnv; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 GlobalTimer::GlobalTimer(app* pObj, | 61 GlobalTimer::GlobalTimer(app* pObj, |
| 62 CPDFSDK_FormFillEnvironment* pEnv, | 62 CPDFSDK_FormFillEnvironment* pFormFillEnv, |
| 63 CJS_Runtime* pRuntime, | 63 CJS_Runtime* pRuntime, |
| 64 int nType, | 64 int nType, |
| 65 const CFX_WideString& script, | 65 const CFX_WideString& script, |
| 66 uint32_t dwElapse, | 66 uint32_t dwElapse, |
| 67 uint32_t dwTimeOut) | 67 uint32_t dwTimeOut) |
| 68 : m_nTimerID(0), | 68 : m_nTimerID(0), |
| 69 m_pEmbedObj(pObj), | 69 m_pEmbedObj(pObj), |
| 70 m_bProcessing(false), | 70 m_bProcessing(false), |
| 71 m_nType(nType), | 71 m_nType(nType), |
| 72 m_dwTimeOut(dwTimeOut), | 72 m_dwTimeOut(dwTimeOut), |
| 73 m_swJScript(script), | 73 m_swJScript(script), |
| 74 m_pRuntime(pRuntime), | 74 m_pRuntime(pRuntime), |
| 75 m_pEnv(pEnv) { | 75 m_pFormFillEnv(pFormFillEnv) { |
| 76 CFX_SystemHandler* pHandler = m_pEnv->GetSysHandler(); | 76 CFX_SystemHandler* pHandler = m_pFormFillEnv->GetSysHandler(); |
| 77 m_nTimerID = pHandler->SetTimer(dwElapse, Trigger); | 77 m_nTimerID = pHandler->SetTimer(dwElapse, Trigger); |
| 78 (*GetGlobalTimerMap())[m_nTimerID] = this; | 78 (*GetGlobalTimerMap())[m_nTimerID] = this; |
| 79 } | 79 } |
| 80 | 80 |
| 81 GlobalTimer::~GlobalTimer() { | 81 GlobalTimer::~GlobalTimer() { |
| 82 if (!m_nTimerID) | 82 if (!m_nTimerID) |
| 83 return; | 83 return; |
| 84 | 84 |
| 85 if (GetRuntime()) | 85 if (GetRuntime()) |
| 86 m_pEnv->GetSysHandler()->KillTimer(m_nTimerID); | 86 m_pFormFillEnv->GetSysHandler()->KillTimer(m_nTimerID); |
| 87 | 87 |
| 88 GetGlobalTimerMap()->erase(m_nTimerID); | 88 GetGlobalTimerMap()->erase(m_nTimerID); |
| 89 } | 89 } |
| 90 | 90 |
| 91 // static | 91 // static |
| 92 void GlobalTimer::Trigger(int nTimerID) { | 92 void GlobalTimer::Trigger(int nTimerID) { |
| 93 auto it = GetGlobalTimerMap()->find(nTimerID); | 93 auto it = GetGlobalTimerMap()->find(nTimerID); |
| 94 if (it == GetGlobalTimerMap()->end()) | 94 if (it == GetGlobalTimerMap()->end()) |
| 95 return; | 95 return; |
| 96 | 96 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 app::~app() { | 210 app::~app() { |
| 211 } | 211 } |
| 212 | 212 |
| 213 FX_BOOL app::activeDocs(IJS_Context* cc, | 213 FX_BOOL app::activeDocs(IJS_Context* cc, |
| 214 CJS_PropValue& vp, | 214 CJS_PropValue& vp, |
| 215 CFX_WideString& sError) { | 215 CFX_WideString& sError) { |
| 216 if (!vp.IsGetting()) | 216 if (!vp.IsGetting()) |
| 217 return FALSE; | 217 return FALSE; |
| 218 | 218 |
| 219 CJS_Context* pContext = (CJS_Context*)cc; | 219 CJS_Context* pContext = (CJS_Context*)cc; |
| 220 CPDFSDK_FormFillEnvironment* pFormFillEnv = pContext->GetFormFillEnv(); | |
| 221 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 220 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 222 CPDFSDK_Document* pCurDoc = pContext->GetJSRuntime()->GetReaderDocument(); | 221 CJS_Document* pJSDocument = nullptr; |
| 222 v8::Local<v8::Object> pObj = pRuntime->GetThisObj(); | |
| 223 if (CFXJS_Engine::GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) { | |
| 224 pJSDocument = static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj)); | |
| 225 } | |
| 226 | |
| 223 CJS_Array aDocs; | 227 CJS_Array aDocs; |
| 224 if (CPDFSDK_Document* pDoc = pFormFillEnv->GetSDKDocument()) { | 228 aDocs.SetElement(pRuntime, 0, CJS_Value(pRuntime, pJSDocument)); |
| 225 CJS_Document* pJSDocument = nullptr; | 229 |
| 226 if (pDoc == pCurDoc) { | |
|
dsinclair
2016/10/11 17:37:45
As far as I can tell, these should always be equal
| |
| 227 v8::Local<v8::Object> pObj = pRuntime->GetThisObj(); | |
| 228 if (CFXJS_Engine::GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) { | |
| 229 pJSDocument = | |
| 230 static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj)); | |
| 231 } | |
| 232 } else { | |
| 233 v8::Local<v8::Object> pObj = | |
| 234 pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID); | |
| 235 pJSDocument = | |
| 236 static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj)); | |
| 237 ASSERT(pJSDocument); | |
| 238 } | |
| 239 aDocs.SetElement(pRuntime, 0, CJS_Value(pRuntime, pJSDocument)); | |
| 240 } | |
| 241 if (aDocs.GetLength(pRuntime) > 0) | 230 if (aDocs.GetLength(pRuntime) > 0) |
| 242 vp << aDocs; | 231 vp << aDocs; |
| 243 else | 232 else |
| 244 vp.GetJSValue()->SetNull(pRuntime); | 233 vp.GetJSValue()->SetNull(pRuntime); |
| 245 | 234 |
| 246 return TRUE; | 235 return TRUE; |
| 247 } | 236 } |
| 248 | 237 |
| 249 FX_BOOL app::calculate(IJS_Context* cc, | 238 FX_BOOL app::calculate(IJS_Context* cc, |
| 250 CJS_PropValue& vp, | 239 CJS_PropValue& vp, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 vp << JS_NUM_VIEWERVERSION; | 304 vp << JS_NUM_VIEWERVERSION; |
| 316 return TRUE; | 305 return TRUE; |
| 317 } | 306 } |
| 318 | 307 |
| 319 FX_BOOL app::platform(IJS_Context* cc, | 308 FX_BOOL app::platform(IJS_Context* cc, |
| 320 CJS_PropValue& vp, | 309 CJS_PropValue& vp, |
| 321 CFX_WideString& sError) { | 310 CFX_WideString& sError) { |
| 322 if (!vp.IsGetting()) | 311 if (!vp.IsGetting()) |
| 323 return FALSE; | 312 return FALSE; |
| 324 #ifdef PDF_ENABLE_XFA | 313 #ifdef PDF_ENABLE_XFA |
| 325 CPDFSDK_FormFillEnvironment* pEnv = | 314 CPDFSDK_FormFillEnvironment* pFormFillEnv = |
| 326 static_cast<CJS_Context*>(cc)->GetJSRuntime()->GetReaderEnv(); | 315 static_cast<CJS_Context*>(cc)->GetJSRuntime()->GetFormFillEnv(); |
| 327 if (!pEnv) | 316 if (!pFormFillEnv) |
| 328 return FALSE; | 317 return FALSE; |
| 329 CFX_WideString platfrom = pEnv->GetPlatform(); | 318 CFX_WideString platfrom = pFormFillEnv->GetPlatform(); |
| 330 if (!platfrom.IsEmpty()) { | 319 if (!platfrom.IsEmpty()) { |
| 331 vp << platfrom; | 320 vp << platfrom; |
| 332 return TRUE; | 321 return TRUE; |
| 333 } | 322 } |
| 334 #endif | 323 #endif |
| 335 vp << JS_STR_PLATFORM; | 324 vp << JS_STR_PLATFORM; |
| 336 return TRUE; | 325 return TRUE; |
| 337 } | 326 } |
| 338 | 327 |
| 339 FX_BOOL app::language(IJS_Context* cc, | 328 FX_BOOL app::language(IJS_Context* cc, |
| 340 CJS_PropValue& vp, | 329 CJS_PropValue& vp, |
| 341 CFX_WideString& sError) { | 330 CFX_WideString& sError) { |
| 342 if (!vp.IsGetting()) | 331 if (!vp.IsGetting()) |
| 343 return FALSE; | 332 return FALSE; |
| 344 #ifdef PDF_ENABLE_XFA | 333 #ifdef PDF_ENABLE_XFA |
| 345 CPDFSDK_FormFillEnvironment* pEnv = | 334 CPDFSDK_FormFillEnvironment* pFormFillEnv = |
| 346 static_cast<CJS_Context*>(cc)->GetJSRuntime()->GetReaderEnv(); | 335 static_cast<CJS_Context*>(cc)->GetJSRuntime()->GetFormFillEnv(); |
| 347 if (!pEnv) | 336 if (!pFormFillEnv) |
| 348 return FALSE; | 337 return FALSE; |
| 349 CFX_WideString language = pEnv->GetLanguage(); | 338 CFX_WideString language = pFormFillEnv->GetLanguage(); |
| 350 if (!language.IsEmpty()) { | 339 if (!language.IsEmpty()) { |
| 351 vp << language; | 340 vp << language; |
| 352 return TRUE; | 341 return TRUE; |
| 353 } | 342 } |
| 354 #endif | 343 #endif |
| 355 vp << JS_STR_LANGUANGE; | 344 vp << JS_STR_LANGUANGE; |
| 356 return TRUE; | 345 return TRUE; |
| 357 } | 346 } |
| 358 | 347 |
| 359 // creates a new fdf object that contains no data | 348 // creates a new fdf object that contains no data |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 386 CFX_WideString& sError) { | 375 CFX_WideString& sError) { |
| 387 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 376 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 388 std::vector<CJS_Value> newParams = JS_ExpandKeywordParams( | 377 std::vector<CJS_Value> newParams = JS_ExpandKeywordParams( |
| 389 pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle"); | 378 pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle"); |
| 390 | 379 |
| 391 if (newParams[0].GetType() == CJS_Value::VT_unknown) { | 380 if (newParams[0].GetType() == CJS_Value::VT_unknown) { |
| 392 sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR); | 381 sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR); |
| 393 return FALSE; | 382 return FALSE; |
| 394 } | 383 } |
| 395 | 384 |
| 396 CPDFSDK_FormFillEnvironment* pEnv = pRuntime->GetReaderEnv(); | 385 CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv(); |
| 397 if (!pEnv) { | 386 if (!pFormFillEnv) { |
| 398 vRet = CJS_Value(pRuntime, 0); | 387 vRet = CJS_Value(pRuntime, 0); |
| 399 return TRUE; | 388 return TRUE; |
| 400 } | 389 } |
| 401 | 390 |
| 402 CFX_WideString swMsg; | 391 CFX_WideString swMsg; |
| 403 if (newParams[0].GetType() == CJS_Value::VT_object) { | 392 if (newParams[0].GetType() == CJS_Value::VT_object) { |
| 404 CJS_Array carray; | 393 CJS_Array carray; |
| 405 if (newParams[0].ConvertToArray(pRuntime, carray)) { | 394 if (newParams[0].ConvertToArray(pRuntime, carray)) { |
| 406 swMsg = L"["; | 395 swMsg = L"["; |
| 407 CJS_Value element(pRuntime); | 396 CJS_Value element(pRuntime); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 427 if (newParams[2].GetType() != CJS_Value::VT_unknown) | 416 if (newParams[2].GetType() != CJS_Value::VT_unknown) |
| 428 iType = newParams[2].ToInt(pRuntime); | 417 iType = newParams[2].ToInt(pRuntime); |
| 429 | 418 |
| 430 CFX_WideString swTitle; | 419 CFX_WideString swTitle; |
| 431 if (newParams[3].GetType() != CJS_Value::VT_unknown) | 420 if (newParams[3].GetType() != CJS_Value::VT_unknown) |
| 432 swTitle = newParams[3].ToCFXWideString(pRuntime); | 421 swTitle = newParams[3].ToCFXWideString(pRuntime); |
| 433 else | 422 else |
| 434 swTitle = JSGetStringFromID(IDS_STRING_JSALERT); | 423 swTitle = JSGetStringFromID(IDS_STRING_JSALERT); |
| 435 | 424 |
| 436 pRuntime->BeginBlock(); | 425 pRuntime->BeginBlock(); |
| 437 pEnv->GetSDKDocument()->KillFocusAnnot(0); | 426 pFormFillEnv->GetSDKDocument()->KillFocusAnnot(0); |
| 438 | 427 |
| 439 vRet = CJS_Value(pRuntime, pEnv->JS_appAlert(swMsg.c_str(), swTitle.c_str(), | 428 vRet = CJS_Value(pRuntime, pFormFillEnv->JS_appAlert( |
| 440 iType, iIcon)); | 429 swMsg.c_str(), swTitle.c_str(), iType, iIcon)); |
| 441 pRuntime->EndBlock(); | 430 pRuntime->EndBlock(); |
| 442 return TRUE; | 431 return TRUE; |
| 443 } | 432 } |
| 444 | 433 |
| 445 FX_BOOL app::beep(IJS_Context* cc, | 434 FX_BOOL app::beep(IJS_Context* cc, |
| 446 const std::vector<CJS_Value>& params, | 435 const std::vector<CJS_Value>& params, |
| 447 CJS_Value& vRet, | 436 CJS_Value& vRet, |
| 448 CFX_WideString& sError) { | 437 CFX_WideString& sError) { |
| 449 if (params.size() == 1) { | 438 if (params.size() == 1) { |
| 450 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 439 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 451 CPDFSDK_FormFillEnvironment* pEnv = pRuntime->GetReaderEnv(); | 440 pRuntime->GetFormFillEnv()->JS_appBeep(params[0].ToInt(pRuntime)); |
| 452 pEnv->JS_appBeep(params[0].ToInt(pRuntime)); | |
| 453 return TRUE; | 441 return TRUE; |
| 454 } | 442 } |
| 455 | 443 |
| 456 sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR); | 444 sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR); |
| 457 return FALSE; | 445 return FALSE; |
| 458 } | 446 } |
| 459 | 447 |
| 460 FX_BOOL app::findComponent(IJS_Context* cc, | 448 FX_BOOL app::findComponent(IJS_Context* cc, |
| 461 const std::vector<CJS_Value>& params, | 449 const std::vector<CJS_Value>& params, |
| 462 CJS_Value& vRet, | 450 CJS_Value& vRet, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 486 | 474 |
| 487 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 475 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 488 CFX_WideString script = | 476 CFX_WideString script = |
| 489 params.size() > 0 ? params[0].ToCFXWideString(pRuntime) : L""; | 477 params.size() > 0 ? params[0].ToCFXWideString(pRuntime) : L""; |
| 490 if (script.IsEmpty()) { | 478 if (script.IsEmpty()) { |
| 491 sError = JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE); | 479 sError = JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE); |
| 492 return TRUE; | 480 return TRUE; |
| 493 } | 481 } |
| 494 | 482 |
| 495 uint32_t dwInterval = params.size() > 1 ? params[1].ToInt(pRuntime) : 1000; | 483 uint32_t dwInterval = params.size() > 1 ? params[1].ToInt(pRuntime) : 1000; |
| 496 CPDFSDK_FormFillEnvironment* pEnv = pRuntime->GetReaderEnv(); | |
| 497 | 484 |
| 498 GlobalTimer* timerRef = | 485 GlobalTimer* timerRef = new GlobalTimer(this, pRuntime->GetFormFillEnv(), |
| 499 new GlobalTimer(this, pEnv, pRuntime, 0, script, dwInterval, 0); | 486 pRuntime, 0, script, dwInterval, 0); |
| 500 m_Timers.insert(std::unique_ptr<GlobalTimer>(timerRef)); | 487 m_Timers.insert(std::unique_ptr<GlobalTimer>(timerRef)); |
| 501 | 488 |
| 502 v8::Local<v8::Object> pRetObj = | 489 v8::Local<v8::Object> pRetObj = |
| 503 pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID); | 490 pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID); |
| 504 CJS_TimerObj* pJS_TimerObj = | 491 CJS_TimerObj* pJS_TimerObj = |
| 505 static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj)); | 492 static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj)); |
| 506 TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject()); | 493 TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject()); |
| 507 pTimerObj->SetTimer(timerRef); | 494 pTimerObj->SetTimer(timerRef); |
| 508 | 495 |
| 509 vRet = CJS_Value(pRuntime, pRetObj); | 496 vRet = CJS_Value(pRuntime, pRetObj); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 520 } | 507 } |
| 521 | 508 |
| 522 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); | 509 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
| 523 CFX_WideString script = params[0].ToCFXWideString(pRuntime); | 510 CFX_WideString script = params[0].ToCFXWideString(pRuntime); |
| 524 if (script.IsEmpty()) { | 511 if (script.IsEmpty()) { |
| 525 sError = JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE); | 512 sError = JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE); |
| 526 return TRUE; | 513 return TRUE; |
| 527 } | 514 } |
| 528 | 515 |
| 529 uint32_t dwTimeOut = params.size() > 1 ? params[1].ToInt(pRuntime) : 1000; | 516 uint32_t dwTimeOut = params.size() > 1 ? params[1].ToInt(pRuntime) : 1000; |
| 530 CPDFSDK_FormFillEnvironment* pEnv = pRuntime->GetReaderEnv(); | |
| 531 | |
| 532 GlobalTimer* timerRef = | 517 GlobalTimer* timerRef = |
| 533 new GlobalTimer(this, pEnv, pRuntime, 1, script, dwTimeOut, dwTimeOut); | 518 new GlobalTimer(this, pRuntime->GetFormFillEnv(), pRuntime, 1, script, |
| 519 dwTimeOut, dwTimeOut); | |
| 534 m_Timers.insert(std::unique_ptr<GlobalTimer>(timerRef)); | 520 m_Timers.insert(std::unique_ptr<GlobalTimer>(timerRef)); |
| 535 | 521 |
| 536 v8::Local<v8::Object> pRetObj = | 522 v8::Local<v8::Object> pRetObj = |
| 537 pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID); | 523 pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID); |
| 538 | 524 |
| 539 CJS_TimerObj* pJS_TimerObj = | 525 CJS_TimerObj* pJS_TimerObj = |
| 540 static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj)); | 526 static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj)); |
| 541 | 527 |
| 542 TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject()); | 528 TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject()); |
| 543 pTimerObj->SetTimer(timerRef); | 529 pTimerObj->SetTimer(timerRef); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 813 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { | 799 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
| 814 return FALSE; | 800 return FALSE; |
| 815 } | 801 } |
| 816 | 802 |
| 817 FX_BOOL app::execDialog(IJS_Context* cc, | 803 FX_BOOL app::execDialog(IJS_Context* cc, |
| 818 const std::vector<CJS_Value>& params, | 804 const std::vector<CJS_Value>& params, |
| 819 CJS_Value& vRet, | 805 CJS_Value& vRet, |
| 820 CFX_WideString& sError) { | 806 CFX_WideString& sError) { |
| 821 return TRUE; | 807 return TRUE; |
| 822 } | 808 } |
| OLD | NEW |