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. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 CJS_Array aDocs(pRuntime); | 116 CJS_Array aDocs(pRuntime); |
117 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) { | 117 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) { |
118 CJS_Document* pJSDocument = NULL; | 118 CJS_Document* pJSDocument = NULL; |
119 if (pDoc == pCurDoc) { | 119 if (pDoc == pCurDoc) { |
120 v8::Local<v8::Object> pObj = FXJS_GetThisObj(pRuntime->GetIsolate()); | 120 v8::Local<v8::Object> pObj = FXJS_GetThisObj(pRuntime->GetIsolate()); |
121 if (FXJS_GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) | 121 if (FXJS_GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) |
122 pJSDocument = | 122 pJSDocument = |
123 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); | 123 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); |
124 } else { | 124 } else { |
125 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( | 125 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( |
126 pRuntime->GetIsolate(), pContext, CJS_Document::g_nObjDefnID); | 126 pRuntime->GetIsolate(), pRuntime, CJS_Document::g_nObjDefnID); |
127 pJSDocument = | 127 pJSDocument = |
128 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); | 128 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); |
129 ASSERT(pJSDocument != NULL); | 129 ASSERT(pJSDocument != NULL); |
130 } | 130 } |
131 aDocs.SetElement(0, CJS_Value(pRuntime, pJSDocument)); | 131 aDocs.SetElement(0, CJS_Value(pRuntime, pJSDocument)); |
132 } | 132 } |
133 if (aDocs.GetLength() > 0) | 133 if (aDocs.GetLength() > 0) |
134 vp << aDocs; | 134 vp << aDocs; |
135 else | 135 else |
136 vp.SetNull(); | 136 vp.SetNull(); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 395 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
396 FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000; | 396 FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000; |
397 | 397 |
398 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 398 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
399 ASSERT(pApp); | 399 ASSERT(pApp); |
400 CJS_Timer* pTimer = | 400 CJS_Timer* pTimer = |
401 new CJS_Timer(this, pApp, pRuntime, 0, script, dwInterval, 0); | 401 new CJS_Timer(this, pApp, pRuntime, 0, script, dwInterval, 0); |
402 m_aTimer.Add(pTimer); | 402 m_aTimer.Add(pTimer); |
403 | 403 |
404 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( | 404 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( |
405 pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID); | 405 pRuntime->GetIsolate(), pRuntime, CJS_TimerObj::g_nObjDefnID); |
406 CJS_TimerObj* pJS_TimerObj = | 406 CJS_TimerObj* pJS_TimerObj = |
407 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); | 407 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); |
408 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); | 408 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); |
409 pTimerObj->SetTimer(pTimer); | 409 pTimerObj->SetTimer(pTimer); |
410 | 410 |
411 vRet = pRetObj; | 411 vRet = pRetObj; |
412 return TRUE; | 412 return TRUE; |
413 } | 413 } |
414 | 414 |
415 FX_BOOL app::setTimeOut(IJS_Context* cc, | 415 FX_BOOL app::setTimeOut(IJS_Context* cc, |
(...skipping 20 matching lines...) Expand all Loading... |
436 FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000; | 436 FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000; |
437 | 437 |
438 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); | 438 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); |
439 ASSERT(pApp); | 439 ASSERT(pApp); |
440 | 440 |
441 CJS_Timer* pTimer = | 441 CJS_Timer* pTimer = |
442 new CJS_Timer(this, pApp, pRuntime, 1, script, dwTimeOut, dwTimeOut); | 442 new CJS_Timer(this, pApp, pRuntime, 1, script, dwTimeOut, dwTimeOut); |
443 m_aTimer.Add(pTimer); | 443 m_aTimer.Add(pTimer); |
444 | 444 |
445 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( | 445 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( |
446 pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID); | 446 pRuntime->GetIsolate(), pRuntime, CJS_TimerObj::g_nObjDefnID); |
447 CJS_TimerObj* pJS_TimerObj = | 447 CJS_TimerObj* pJS_TimerObj = |
448 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); | 448 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); |
449 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); | 449 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); |
450 pTimerObj->SetTimer(pTimer); | 450 pTimerObj->SetTimer(pTimer); |
451 | 451 |
452 vRet = pRetObj; | 452 vRet = pRetObj; |
453 return TRUE; | 453 return TRUE; |
454 } | 454 } |
455 | 455 |
456 FX_BOOL app::clearTimeOut(IJS_Context* cc, | 456 FX_BOOL app::clearTimeOut(IJS_Context* cc, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 if (pTimer->GetTimeOut() > 0) { | 546 if (pTimer->GetTimeOut() > 0) { |
547 if (pRuntime) | 547 if (pRuntime) |
548 RunJsScript(pRuntime, pTimer->GetJScript()); | 548 RunJsScript(pRuntime, pTimer->GetJScript()); |
549 pTimer->KillJSTimer(); | 549 pTimer->KillJSTimer(); |
550 } | 550 } |
551 break; | 551 break; |
552 } | 552 } |
553 } | 553 } |
554 | 554 |
555 void app::RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript) { | 555 void app::RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript) { |
556 ASSERT(pRuntime != NULL); | |
557 | |
558 if (!pRuntime->IsBlocking()) { | 556 if (!pRuntime->IsBlocking()) { |
559 IJS_Context* pContext = pRuntime->NewContext(); | 557 IJS_Context* pContext = pRuntime->NewContext(); |
560 ASSERT(pContext != NULL); | |
561 pContext->OnExternal_Exec(); | 558 pContext->OnExternal_Exec(); |
562 CFX_WideString wtInfo; | 559 CFX_WideString wtInfo; |
563 pContext->RunScript(wsScript, wtInfo); | 560 pContext->RunScript(wsScript, &wtInfo); |
564 pRuntime->ReleaseContext(pContext); | 561 pRuntime->ReleaseContext(pContext); |
565 } | 562 } |
566 } | 563 } |
567 | 564 |
568 FX_BOOL app::goBack(IJS_Context* cc, | 565 FX_BOOL app::goBack(IJS_Context* cc, |
569 const CJS_Parameters& params, | 566 const CJS_Parameters& params, |
570 CJS_Value& vRet, | 567 CJS_Value& vRet, |
571 CFX_WideString& sError) { | 568 CFX_WideString& sError) { |
572 // Not supported. | 569 // Not supported. |
573 return TRUE; | 570 return TRUE; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { | 802 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
806 return FALSE; | 803 return FALSE; |
807 } | 804 } |
808 | 805 |
809 FX_BOOL app::execDialog(IJS_Context* cc, | 806 FX_BOOL app::execDialog(IJS_Context* cc, |
810 const CJS_Parameters& params, | 807 const CJS_Parameters& params, |
811 CJS_Value& vRet, | 808 CJS_Value& vRet, |
812 CFX_WideString& sError) { | 809 CFX_WideString& sError) { |
813 return TRUE; | 810 return TRUE; |
814 } | 811 } |
OLD | NEW |