| 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/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" |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 if (script.IsEmpty()) { | 407 if (script.IsEmpty()) { |
| 408 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE); | 408 sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE); |
| 409 return TRUE; | 409 return TRUE; |
| 410 } | 410 } |
| 411 | 411 |
| 412 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 412 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 413 FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000; | 413 FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000; |
| 414 | 414 |
| 415 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 415 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
| 416 ASSERT(pApp); | 416 ASSERT(pApp); |
| 417 CJS_Timer* pTimer = new CJS_Timer(this, pApp); | 417 CJS_Timer* pTimer = |
| 418 new CJS_Timer(this, pApp, pRuntime, 0, script, dwInterval, 0); |
| 418 m_aTimer.Add(pTimer); | 419 m_aTimer.Add(pTimer); |
| 419 | 420 |
| 420 pTimer->SetType(0); | |
| 421 pTimer->SetRuntime(pRuntime); | |
| 422 pTimer->SetJScript(script); | |
| 423 pTimer->SetTimeOut(0); | |
| 424 // pTimer->SetStartTime(GetTickCount()); | |
| 425 pTimer->SetJSTimer(dwInterval); | |
| 426 | |
| 427 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( | 421 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( |
| 428 pRuntime->GetIsolate(), pContext, | 422 pRuntime->GetIsolate(), pContext, |
| 429 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj")); | 423 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj")); |
| 430 | 424 |
| 431 CJS_TimerObj* pJS_TimerObj = | 425 CJS_TimerObj* pJS_TimerObj = |
| 432 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); | 426 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); |
| 433 ASSERT(pJS_TimerObj != NULL); | 427 ASSERT(pJS_TimerObj != NULL); |
| 434 | 428 |
| 435 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); | 429 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); |
| 436 ASSERT(pTimerObj != NULL); | 430 ASSERT(pTimerObj != NULL); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 461 sError = | 455 sError = |
| 462 JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMBER_KEYSTROKE); | 456 JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSAFNUMBER_KEYSTROKE); |
| 463 return TRUE; | 457 return TRUE; |
| 464 } | 458 } |
| 465 | 459 |
| 466 FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000; | 460 FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000; |
| 467 | 461 |
| 468 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 462 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
| 469 ASSERT(pApp); | 463 ASSERT(pApp); |
| 470 | 464 |
| 471 CJS_Timer* pTimer = new CJS_Timer(this, pApp); | 465 CJS_Timer* pTimer = |
| 466 new CJS_Timer(this, pApp, pRuntime, 1, script, dwTimeOut, dwTimeOut); |
| 472 m_aTimer.Add(pTimer); | 467 m_aTimer.Add(pTimer); |
| 473 | 468 |
| 474 pTimer->SetType(1); | |
| 475 pTimer->SetRuntime(pRuntime); | |
| 476 pTimer->SetJScript(script); | |
| 477 pTimer->SetTimeOut(dwTimeOut); | |
| 478 pTimer->SetJSTimer(dwTimeOut); | |
| 479 | |
| 480 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( | 469 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( |
| 481 pRuntime->GetIsolate(), pContext, | 470 pRuntime->GetIsolate(), pContext, |
| 482 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj")); | 471 FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj")); |
| 483 | 472 |
| 484 CJS_TimerObj* pJS_TimerObj = | 473 CJS_TimerObj* pJS_TimerObj = |
| 485 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); | 474 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); |
| 486 ASSERT(pJS_TimerObj != NULL); | 475 ASSERT(pJS_TimerObj != NULL); |
| 487 | 476 |
| 488 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); | 477 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); |
| 489 ASSERT(pTimerObj != NULL); | 478 ASSERT(pTimerObj != NULL); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 FX_BOOL app::execMenuItem(IFXJS_Context* cc, | 573 FX_BOOL app::execMenuItem(IFXJS_Context* cc, |
| 585 const CJS_Parameters& params, | 574 const CJS_Parameters& params, |
| 586 CJS_Value& vRet, | 575 CJS_Value& vRet, |
| 587 CFX_WideString& sError) { | 576 CFX_WideString& sError) { |
| 588 return FALSE; | 577 return FALSE; |
| 589 } | 578 } |
| 590 | 579 |
| 591 void app::TimerProc(CJS_Timer* pTimer) { | 580 void app::TimerProc(CJS_Timer* pTimer) { |
| 592 ASSERT(pTimer != NULL); | 581 ASSERT(pTimer != NULL); |
| 593 | 582 |
| 583 CJS_Runtime* pRuntime = pTimer->GetRuntime(); |
| 584 |
| 594 switch (pTimer->GetType()) { | 585 switch (pTimer->GetType()) { |
| 595 case 0: // interval | 586 case 0: // interval |
| 596 RunJsScript(pTimer->GetRuntime(), pTimer->GetJScript()); | 587 if (pRuntime) |
| 588 RunJsScript(pRuntime, pTimer->GetJScript()); |
| 597 break; | 589 break; |
| 598 case 1: | 590 case 1: |
| 599 if (pTimer->GetTimeOut() > 0) { | 591 if (pTimer->GetTimeOut() > 0) { |
| 600 RunJsScript(pTimer->GetRuntime(), pTimer->GetJScript()); | 592 if (pRuntime) |
| 593 RunJsScript(pRuntime, pTimer->GetJScript()); |
| 601 pTimer->KillJSTimer(); | 594 pTimer->KillJSTimer(); |
| 602 } | 595 } |
| 603 break; | 596 break; |
| 604 } | 597 } |
| 605 } | 598 } |
| 606 | 599 |
| 607 void app::RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript) { | 600 void app::RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript) { |
| 608 ASSERT(pRuntime != NULL); | 601 ASSERT(pRuntime != NULL); |
| 609 | 602 |
| 610 if (!pRuntime->IsBlocking()) { | 603 if (!pRuntime->IsBlocking()) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 CFX_WideString& sError) { | 853 CFX_WideString& sError) { |
| 861 return FALSE; | 854 return FALSE; |
| 862 } | 855 } |
| 863 | 856 |
| 864 FX_BOOL app::execDialog(IFXJS_Context* cc, | 857 FX_BOOL app::execDialog(IFXJS_Context* cc, |
| 865 const CJS_Parameters& params, | 858 const CJS_Parameters& params, |
| 866 CJS_Value& vRet, | 859 CJS_Value& vRet, |
| 867 CFX_WideString& sError) { | 860 CFX_WideString& sError) { |
| 868 return TRUE; | 861 return TRUE; |
| 869 } | 862 } |
| OLD | NEW |