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

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

Issue 1334833003: Merge to XFA: Remove some abstractions in fxjs_v8.h. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 3 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_Value.cpp ('k') | fpdfsdk/src/javascript/global.cpp » ('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 "../../include/javascript/JavaScript.h" 7 #include "../../include/javascript/JavaScript.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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return FALSE; 115 return FALSE;
116 116
117 CJS_Context* pContext = (CJS_Context*)cc; 117 CJS_Context* pContext = (CJS_Context*)cc;
118 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); 118 CPDFDoc_Environment* pApp = pContext->GetReaderApp();
119 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 119 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
120 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument(); 120 CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument();
121 CJS_Array aDocs(pRuntime->GetIsolate()); 121 CJS_Array aDocs(pRuntime->GetIsolate());
122 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) { 122 if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) {
123 CJS_Document* pJSDocument = NULL; 123 CJS_Document* pJSDocument = NULL;
124 if (pDoc == pCurDoc) { 124 if (pDoc == pCurDoc) {
125 JSFXObject pObj = JS_GetThisObj(*pRuntime); 125 v8::Local<v8::Object> pObj = JS_GetThisObj(pRuntime->GetIsolate());
126 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"Document")) 126 if (JS_GetObjDefnID(pObj) ==
127 JS_GetObjDefnID(pRuntime->GetIsolate(), L"Document"))
127 pJSDocument = 128 pJSDocument =
128 (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(), pObj); 129 (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(), pObj);
129 } else { 130 } else {
130 JSFXObject pObj = JS_NewFxDynamicObj( 131 v8::Local<v8::Object> pObj = JS_NewFxDynamicObj(
131 *pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Document")); 132 pRuntime->GetIsolate(), pContext,
133 JS_GetObjDefnID(pRuntime->GetIsolate(), L"Document"));
132 pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(), pObj); 134 pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(), pObj);
133 ASSERT(pJSDocument != NULL); 135 ASSERT(pJSDocument != NULL);
134 } 136 }
135 aDocs.SetElement(0, CJS_Value(pRuntime->GetIsolate(), pJSDocument)); 137 aDocs.SetElement(0, CJS_Value(pRuntime->GetIsolate(), pJSDocument));
136 } 138 }
137 if (aDocs.GetLength() > 0) 139 if (aDocs.GetLength() > 0)
138 vp << aDocs; 140 vp << aDocs;
139 else 141 else
140 vp.SetNull(); 142 vp.SetNull();
141 143
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 269
268 CFX_WideString swMsg = L""; 270 CFX_WideString swMsg = L"";
269 CFX_WideString swTitle = L""; 271 CFX_WideString swTitle = L"";
270 int iIcon = 0; 272 int iIcon = 0;
271 int iType = 0; 273 int iType = 0;
272 274
273 v8::Isolate* isolate = GetIsolate(cc); 275 v8::Isolate* isolate = GetIsolate(cc);
274 276
275 if (iSize == 1) { 277 if (iSize == 1) {
276 if (params[0].GetType() == VT_object) { 278 if (params[0].GetType() == VT_object) {
277 JSObject pObj = params[0].ToV8Object(); 279 v8::Local<v8::Object> pObj = params[0].ToV8Object();
278 { 280 {
279 v8::Local<v8::Value> pValue = 281 v8::Local<v8::Value> pValue =
280 JS_GetObjectElement(isolate, pObj, L"cMsg"); 282 JS_GetObjectElement(isolate, pObj, L"cMsg");
281 swMsg = CJS_Value(isolate, pValue, VT_unknown).ToCFXWideString(); 283 swMsg = CJS_Value(isolate, pValue, VT_unknown).ToCFXWideString();
282 284
283 pValue = JS_GetObjectElement(isolate, pObj, L"cTitle"); 285 pValue = JS_GetObjectElement(isolate, pObj, L"cTitle");
284 swTitle = CJS_Value(isolate, pValue, VT_unknown).ToCFXWideString(); 286 swTitle = CJS_Value(isolate, pValue, VT_unknown).ToCFXWideString();
285 287
286 pValue = JS_GetObjectElement(isolate, pObj, L"nIcon"); 288 pValue = JS_GetObjectElement(isolate, pObj, L"nIcon");
287 iIcon = CJS_Value(isolate, pValue, VT_unknown).ToInt(); 289 iIcon = CJS_Value(isolate, pValue, VT_unknown).ToInt();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 CJS_Timer* pTimer = new CJS_Timer(this, pApp); 414 CJS_Timer* pTimer = new CJS_Timer(this, pApp);
413 m_aTimer.Add(pTimer); 415 m_aTimer.Add(pTimer);
414 416
415 pTimer->SetType(0); 417 pTimer->SetType(0);
416 pTimer->SetRuntime(pRuntime); 418 pTimer->SetRuntime(pRuntime);
417 pTimer->SetJScript(script); 419 pTimer->SetJScript(script);
418 pTimer->SetTimeOut(0); 420 pTimer->SetTimeOut(0);
419 // pTimer->SetStartTime(GetTickCount()); 421 // pTimer->SetStartTime(GetTickCount());
420 pTimer->SetJSTimer(dwInterval); 422 pTimer->SetJSTimer(dwInterval);
421 423
422 JSFXObject pRetObj = JS_NewFxDynamicObj( 424 v8::Local<v8::Object> pRetObj =
423 *pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"TimerObj")); 425 JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext,
426 JS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj"));
424 427
425 CJS_TimerObj* pJS_TimerObj = 428 CJS_TimerObj* pJS_TimerObj =
426 (CJS_TimerObj*)JS_GetPrivate(pRuntime->GetIsolate(), pRetObj); 429 (CJS_TimerObj*)JS_GetPrivate(pRuntime->GetIsolate(), pRetObj);
427 ASSERT(pJS_TimerObj != NULL); 430 ASSERT(pJS_TimerObj != NULL);
428 431
429 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); 432 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject();
430 ASSERT(pTimerObj != NULL); 433 ASSERT(pTimerObj != NULL);
431 434
432 pTimerObj->SetTimer(pTimer); 435 pTimerObj->SetTimer(pTimer);
433 436
(...skipping 30 matching lines...) Expand all
464 467
465 CJS_Timer* pTimer = new CJS_Timer(this, pApp); 468 CJS_Timer* pTimer = new CJS_Timer(this, pApp);
466 m_aTimer.Add(pTimer); 469 m_aTimer.Add(pTimer);
467 470
468 pTimer->SetType(1); 471 pTimer->SetType(1);
469 pTimer->SetRuntime(pRuntime); 472 pTimer->SetRuntime(pRuntime);
470 pTimer->SetJScript(script); 473 pTimer->SetJScript(script);
471 pTimer->SetTimeOut(dwTimeOut); 474 pTimer->SetTimeOut(dwTimeOut);
472 pTimer->SetJSTimer(dwTimeOut); 475 pTimer->SetJSTimer(dwTimeOut);
473 476
474 JSFXObject pRetObj = JS_NewFxDynamicObj( 477 v8::Local<v8::Object> pRetObj =
475 *pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"TimerObj")); 478 JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext,
479 JS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj"));
476 480
477 CJS_TimerObj* pJS_TimerObj = 481 CJS_TimerObj* pJS_TimerObj =
478 (CJS_TimerObj*)JS_GetPrivate(pRuntime->GetIsolate(), pRetObj); 482 (CJS_TimerObj*)JS_GetPrivate(pRuntime->GetIsolate(), pRetObj);
479 ASSERT(pJS_TimerObj != NULL); 483 ASSERT(pJS_TimerObj != NULL);
480 484
481 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); 485 TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject();
482 ASSERT(pTimerObj != NULL); 486 ASSERT(pTimerObj != NULL);
483 487
484 pTimerObj->SetTimer(pTimer); 488 pTimerObj->SetTimer(pTimer);
485 489
(...skipping 10 matching lines...) Expand all
496 ASSERT(pContext != NULL); 500 ASSERT(pContext != NULL);
497 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 501 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
498 ASSERT(pRuntime != NULL); 502 ASSERT(pRuntime != NULL);
499 503
500 if (params.size() != 1) { 504 if (params.size() != 1) {
501 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); 505 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR);
502 return FALSE; 506 return FALSE;
503 } 507 }
504 508
505 if (params[0].GetType() == VT_fxobject) { 509 if (params[0].GetType() == VT_fxobject) {
506 JSFXObject pObj = params[0].ToV8Object(); 510 v8::Local<v8::Object> pObj = params[0].ToV8Object();
507 { 511 {
508 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"TimerObj")) { 512 if (JS_GetObjDefnID(pObj) ==
513 JS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj")) {
509 if (CJS_Object* pJSObj = params[0].ToCJSObject()) { 514 if (CJS_Object* pJSObj = params[0].ToCJSObject()) {
510 if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject()) { 515 if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject()) {
511 if (CJS_Timer* pTimer = pTimerObj->GetTimer()) { 516 if (CJS_Timer* pTimer = pTimerObj->GetTimer()) {
512 pTimer->KillJSTimer(); 517 pTimer->KillJSTimer();
513 518
514 for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) { 519 for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) {
515 if (m_aTimer[i] == pTimer) { 520 if (m_aTimer[i] == pTimer) {
516 m_aTimer.RemoveAt(i); 521 m_aTimer.RemoveAt(i);
517 break; 522 break;
518 } 523 }
(...skipping 19 matching lines...) Expand all
538 ASSERT(pContext != NULL); 543 ASSERT(pContext != NULL);
539 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 544 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
540 ASSERT(pRuntime != NULL); 545 ASSERT(pRuntime != NULL);
541 546
542 if (params.size() != 1) { 547 if (params.size() != 1) {
543 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR); 548 sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR);
544 return FALSE; 549 return FALSE;
545 } 550 }
546 551
547 if (params[0].GetType() == VT_fxobject) { 552 if (params[0].GetType() == VT_fxobject) {
548 JSFXObject pObj = params[0].ToV8Object(); 553 v8::Local<v8::Object> pObj = params[0].ToV8Object();
549 { 554 {
550 if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"TimerObj")) { 555 if (JS_GetObjDefnID(pObj) ==
556 JS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj")) {
551 if (CJS_Object* pJSObj = params[0].ToCJSObject()) { 557 if (CJS_Object* pJSObj = params[0].ToCJSObject()) {
552 if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject()) { 558 if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject()) {
553 if (CJS_Timer* pTimer = pTimerObj->GetTimer()) { 559 if (CJS_Timer* pTimer = pTimerObj->GetTimer()) {
554 pTimer->KillJSTimer(); 560 pTimer->KillJSTimer();
555 561
556 for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) { 562 for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) {
557 if (m_aTimer[i] == pTimer) { 563 if (m_aTimer[i] == pTimer) {
558 m_aTimer.RemoveAt(i); 564 m_aTimer.RemoveAt(i);
559 break; 565 break;
560 } 566 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 CFX_WideString cTo = L""; 641 CFX_WideString cTo = L"";
636 CFX_WideString cCc = L""; 642 CFX_WideString cCc = L"";
637 CFX_WideString cBcc = L""; 643 CFX_WideString cBcc = L"";
638 CFX_WideString cSubject = L""; 644 CFX_WideString cSubject = L"";
639 CFX_WideString cMsg = L""; 645 CFX_WideString cMsg = L"";
640 646
641 if (params.size() < 1) 647 if (params.size() < 1)
642 return FALSE; 648 return FALSE;
643 649
644 if (params[0].GetType() == VT_object) { 650 if (params[0].GetType() == VT_object) {
645 JSObject pObj = params[0].ToV8Object(); 651 v8::Local<v8::Object> pObj = params[0].ToV8Object();
646 652
647 v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"bUI"); 653 v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"bUI");
648 bUI = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); 654 bUI = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool();
649 655
650 pValue = JS_GetObjectElement(isolate, pObj, L"cTo"); 656 pValue = JS_GetObjectElement(isolate, pObj, L"cTo");
651 cTo = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); 657 cTo = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
652 658
653 pValue = JS_GetObjectElement(isolate, pObj, L"cCc"); 659 pValue = JS_GetObjectElement(isolate, pObj, L"cCc");
654 cCc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); 660 cCc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
655 661
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 CFX_WideString swQuestion = L""; 779 CFX_WideString swQuestion = L"";
774 CFX_WideString swLabel = L""; 780 CFX_WideString swLabel = L"";
775 CFX_WideString swTitle = L"PDF"; 781 CFX_WideString swTitle = L"PDF";
776 CFX_WideString swDefault = L""; 782 CFX_WideString swDefault = L"";
777 bool bPassWord = false; 783 bool bPassWord = false;
778 784
779 v8::Isolate* isolate = GetIsolate(cc); 785 v8::Isolate* isolate = GetIsolate(cc);
780 786
781 int iLength = params.size(); 787 int iLength = params.size();
782 if (iLength > 0 && params[0].GetType() == VT_object) { 788 if (iLength > 0 && params[0].GetType() == VT_object) {
783 JSObject pObj = params[0].ToV8Object(); 789 v8::Local<v8::Object> pObj = params[0].ToV8Object();
784 v8::Local<v8::Value> pValue = 790 v8::Local<v8::Value> pValue =
785 JS_GetObjectElement(isolate, pObj, L"cQuestion"); 791 JS_GetObjectElement(isolate, pObj, L"cQuestion");
786 swQuestion = 792 swQuestion =
787 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); 793 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
788 794
789 pValue = JS_GetObjectElement(isolate, pObj, L"cTitle"); 795 pValue = JS_GetObjectElement(isolate, pObj, L"cTitle");
790 swTitle = 796 swTitle =
791 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); 797 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
792 798
793 pValue = JS_GetObjectElement(isolate, pObj, L"cDefault"); 799 pValue = JS_GetObjectElement(isolate, pObj, L"cDefault");
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 CFX_WideString& sError) { 863 CFX_WideString& sError) {
858 return FALSE; 864 return FALSE;
859 } 865 }
860 866
861 FX_BOOL app::execDialog(IFXJS_Context* cc, 867 FX_BOOL app::execDialog(IFXJS_Context* cc,
862 const CJS_Parameters& params, 868 const CJS_Parameters& params,
863 CJS_Value& vRet, 869 CJS_Value& vRet,
864 CFX_WideString& sError) { 870 CFX_WideString& sError) {
865 return TRUE; 871 return TRUE;
866 } 872 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/JS_Value.cpp ('k') | fpdfsdk/src/javascript/global.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698