Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: fpdfsdk/src/javascript/app.cpp

Issue 1394993006: Merge to XFA: Pass IJS_Runtime, not IJS_Context, to native object constructors. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/javascript/JS_Runtime_Stub.cpp ('k') | fpdfsdk/src/javascript/global.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 CJS_Array aDocs(pRuntime); 117 CJS_Array aDocs(pRuntime);
118 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) { 118 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) {
119 CJS_Document* pJSDocument = NULL; 119 CJS_Document* pJSDocument = NULL;
120 if (pDoc == pCurDoc) { 120 if (pDoc == pCurDoc) {
121 v8::Local<v8::Object> pObj = FXJS_GetThisObj(pRuntime->GetIsolate()); 121 v8::Local<v8::Object> pObj = FXJS_GetThisObj(pRuntime->GetIsolate());
122 if (FXJS_GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) 122 if (FXJS_GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID)
123 pJSDocument = 123 pJSDocument =
124 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); 124 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
125 } else { 125 } else {
126 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( 126 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
127 pRuntime->GetIsolate(), pContext, CJS_Document::g_nObjDefnID); 127 pRuntime->GetIsolate(), pRuntime, CJS_Document::g_nObjDefnID);
128 pJSDocument = 128 pJSDocument =
129 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); 129 (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
130 ASSERT(pJSDocument != NULL); 130 ASSERT(pJSDocument != NULL);
131 } 131 }
132 aDocs.SetElement(0, CJS_Value(pRuntime, pJSDocument)); 132 aDocs.SetElement(0, CJS_Value(pRuntime, pJSDocument));
133 } 133 }
134 if (aDocs.GetLength() > 0) 134 if (aDocs.GetLength() > 0)
135 vp << aDocs; 135 vp << aDocs;
136 else 136 else
137 vp.SetNull(); 137 vp.SetNull();
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 402 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
403 FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000; 403 FX_DWORD dwInterval = params.size() > 1 ? params[1].ToInt() : 1000;
404 404
405 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); 405 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp();
406 ASSERT(pApp); 406 ASSERT(pApp);
407 CJS_Timer* pTimer = 407 CJS_Timer* pTimer =
408 new CJS_Timer(this, pApp, pRuntime, 0, script, dwInterval, 0); 408 new CJS_Timer(this, pApp, pRuntime, 0, script, dwInterval, 0);
409 m_aTimer.Add(pTimer); 409 m_aTimer.Add(pTimer);
410 410
411 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( 411 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
412 pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID); 412 pRuntime->GetIsolate(), pRuntime, CJS_TimerObj::g_nObjDefnID);
413 CJS_TimerObj* pJS_TimerObj = 413 CJS_TimerObj* pJS_TimerObj =
414 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); 414 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj);
415 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); 415 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject();
416 pTimerObj->SetTimer(pTimer); 416 pTimerObj->SetTimer(pTimer);
417 417
418 vRet = pRetObj; 418 vRet = pRetObj;
419 return TRUE; 419 return TRUE;
420 } 420 }
421 421
422 FX_BOOL app::setTimeOut(IJS_Context* cc, 422 FX_BOOL app::setTimeOut(IJS_Context* cc,
(...skipping 20 matching lines...) Expand all
443 FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000; 443 FX_DWORD dwTimeOut = params.size() > 1 ? params[1].ToInt() : 1000;
444 444
445 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp(); 445 CPDFDoc_Environment* pApp = pRuntime->GetReaderApp();
446 ASSERT(pApp); 446 ASSERT(pApp);
447 447
448 CJS_Timer* pTimer = 448 CJS_Timer* pTimer =
449 new CJS_Timer(this, pApp, pRuntime, 1, script, dwTimeOut, dwTimeOut); 449 new CJS_Timer(this, pApp, pRuntime, 1, script, dwTimeOut, dwTimeOut);
450 m_aTimer.Add(pTimer); 450 m_aTimer.Add(pTimer);
451 451
452 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( 452 v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
453 pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID); 453 pRuntime->GetIsolate(), pRuntime, CJS_TimerObj::g_nObjDefnID);
454 CJS_TimerObj* pJS_TimerObj = 454 CJS_TimerObj* pJS_TimerObj =
455 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); 455 (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj);
456 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); 456 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject();
457 pTimerObj->SetTimer(pTimer); 457 pTimerObj->SetTimer(pTimer);
458 458
459 vRet = pRetObj; 459 vRet = pRetObj;
460 return TRUE; 460 return TRUE;
461 } 461 }
462 462
463 FX_BOOL app::clearTimeOut(IJS_Context* cc, 463 FX_BOOL app::clearTimeOut(IJS_Context* cc,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 if (pTimer->GetTimeOut() > 0) { 553 if (pTimer->GetTimeOut() > 0) {
554 if (pRuntime) 554 if (pRuntime)
555 RunJsScript(pRuntime, pTimer->GetJScript()); 555 RunJsScript(pRuntime, pTimer->GetJScript());
556 pTimer->KillJSTimer(); 556 pTimer->KillJSTimer();
557 } 557 }
558 break; 558 break;
559 } 559 }
560 } 560 }
561 561
562 void app::RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript) { 562 void app::RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript) {
563 ASSERT(pRuntime != NULL);
564
565 if (!pRuntime->IsBlocking()) { 563 if (!pRuntime->IsBlocking()) {
566 IJS_Context* pContext = pRuntime->NewContext(); 564 IJS_Context* pContext = pRuntime->NewContext();
567 ASSERT(pContext != NULL);
568 pContext->OnExternal_Exec(); 565 pContext->OnExternal_Exec();
569 CFX_WideString wtInfo; 566 CFX_WideString wtInfo;
570 pContext->RunScript(wsScript, wtInfo); 567 pContext->RunScript(wsScript, &wtInfo);
571 pRuntime->ReleaseContext(pContext); 568 pRuntime->ReleaseContext(pContext);
572 } 569 }
573 } 570 }
574 571
575 FX_BOOL app::goBack(IJS_Context* cc, 572 FX_BOOL app::goBack(IJS_Context* cc,
576 const CJS_Parameters& params, 573 const CJS_Parameters& params,
577 CJS_Value& vRet, 574 CJS_Value& vRet,
578 CFX_WideString& sError) { 575 CFX_WideString& sError) {
579 // Not supported. 576 // Not supported.
580 return TRUE; 577 return TRUE;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { 809 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
813 return FALSE; 810 return FALSE;
814 } 811 }
815 812
816 FX_BOOL app::execDialog(IJS_Context* cc, 813 FX_BOOL app::execDialog(IJS_Context* cc,
817 const CJS_Parameters& params, 814 const CJS_Parameters& params,
818 CJS_Value& vRet, 815 CJS_Value& vRet,
819 CFX_WideString& sError) { 816 CFX_WideString& sError) {
820 return TRUE; 817 return TRUE;
821 } 818 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/JS_Runtime_Stub.cpp ('k') | fpdfsdk/src/javascript/global.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698