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

Side by Side Diff: fpdfsdk/javascript/Document.cpp

Issue 2154503002: Remove type info from CJS_Value, interrogate v8 instead (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: No need to special case CJS_Document, its a CJS_Object already Created 4 years, 5 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 | « no previous file | fpdfsdk/javascript/JS_Define.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 "fpdfsdk/javascript/Document.h" 7 #include "fpdfsdk/javascript/Document.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 int nStart = 0; 404 int nStart = 0;
405 int nEnd = 0; 405 int nEnd = 0;
406 FX_BOOL bSilent = FALSE; 406 FX_BOOL bSilent = FALSE;
407 FX_BOOL bShrinkToFit = FALSE; 407 FX_BOOL bShrinkToFit = FALSE;
408 FX_BOOL bPrintAsImage = FALSE; 408 FX_BOOL bPrintAsImage = FALSE;
409 FX_BOOL bReverse = FALSE; 409 FX_BOOL bReverse = FALSE;
410 FX_BOOL bAnnotations = FALSE; 410 FX_BOOL bAnnotations = FALSE;
411 411
412 int nlength = params.size(); 412 int nlength = params.size();
413 if (nlength == 9) { 413 if (nlength == 9) {
414 if (params[8].GetType() == CJS_Value::VT_fxobject) { 414 if (params[8].GetType() == CJS_Value::VT_object) {
415 v8::Local<v8::Object> pObj = params[8].ToV8Object(); 415 v8::Local<v8::Object> pObj = params[8].ToV8Object();
416 {
417 if (FXJS_GetObjDefnID(pObj) == CJS_PrintParamsObj::g_nObjDefnID) { 416 if (FXJS_GetObjDefnID(pObj) == CJS_PrintParamsObj::g_nObjDefnID) {
Lei Zhang 2016/07/15 23:08:23 Weird indentation.
Tom Sepez 2016/07/15 23:12:48 git cl format didn't catch this. wow. Done.
418 if (CJS_Object* pJSObj = params[8].ToCJSObject()) { 417 if (CJS_Object* pJSObj = params[8].ToCJSObject()) {
419 if (PrintParamsObj* pprintparamsObj = 418 if (PrintParamsObj* pprintparamsObj =
420 (PrintParamsObj*)pJSObj->GetEmbedObject()) { 419 (PrintParamsObj*)pJSObj->GetEmbedObject()) {
421 bUI = pprintparamsObj->bUI; 420 bUI = pprintparamsObj->bUI;
422 nStart = pprintparamsObj->nStart; 421 nStart = pprintparamsObj->nStart;
423 nEnd = pprintparamsObj->nEnd; 422 nEnd = pprintparamsObj->nEnd;
424 bSilent = pprintparamsObj->bSilent; 423 bSilent = pprintparamsObj->bSilent;
425 bShrinkToFit = pprintparamsObj->bShrinkToFit; 424 bShrinkToFit = pprintparamsObj->bShrinkToFit;
426 bPrintAsImage = pprintparamsObj->bPrintAsImage; 425 bPrintAsImage = pprintparamsObj->bPrintAsImage;
427 bReverse = pprintparamsObj->bReverse; 426 bReverse = pprintparamsObj->bReverse;
428 bAnnotations = pprintparamsObj->bAnnotations; 427 bAnnotations = pprintparamsObj->bAnnotations;
429 } 428 }
430 } 429 }
431 }
432 } 430 }
433 } 431 }
434 } else { 432 } else {
435 if (nlength >= 1) 433 if (nlength >= 1)
436 bUI = params[0].ToBool(); 434 bUI = params[0].ToBool();
437 if (nlength >= 2) 435 if (nlength >= 2)
438 nStart = params[1].ToInt(); 436 nStart = params[1].ToInt();
439 if (nlength >= 3) 437 if (nlength >= 3)
440 nEnd = params[2].ToInt(); 438 nEnd = params[2].ToInt();
441 if (nlength >= 4) 439 if (nlength >= 4)
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 if (nSize > 1) 583 if (nSize > 1)
586 bFDF = params[1].ToBool(); 584 bFDF = params[1].ToBool();
587 if (nSize > 2) 585 if (nSize > 2)
588 bEmpty = params[2].ToBool(); 586 bEmpty = params[2].ToBool();
589 if (nSize > 3) 587 if (nSize > 3)
590 aFields.Attach(params[3].ToV8Array()); 588 aFields.Attach(params[3].ToV8Array());
591 } else if (v.GetType() == CJS_Value::VT_object) { 589 } else if (v.GetType() == CJS_Value::VT_object) {
592 v8::Local<v8::Object> pObj = params[0].ToV8Object(); 590 v8::Local<v8::Object> pObj = params[0].ToV8Object();
593 v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"cURL"); 591 v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"cURL");
594 if (!pValue.IsEmpty()) 592 if (!pValue.IsEmpty())
595 strURL = 593 strURL = CJS_Value(pRuntime, pValue).ToCFXWideString();
596 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
597 594
598 pValue = FXJS_GetObjectElement(isolate, pObj, L"bFDF"); 595 pValue = FXJS_GetObjectElement(isolate, pObj, L"bFDF");
599 bFDF = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToBool(); 596 bFDF = CJS_Value(pRuntime, pValue).ToBool();
600 597
601 pValue = FXJS_GetObjectElement(isolate, pObj, L"bEmpty"); 598 pValue = FXJS_GetObjectElement(isolate, pObj, L"bEmpty");
602 bEmpty = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToBool(); 599 bEmpty = CJS_Value(pRuntime, pValue).ToBool();
603 600
604 pValue = FXJS_GetObjectElement(isolate, pObj, L"aFields"); 601 pValue = FXJS_GetObjectElement(isolate, pObj, L"aFields");
605 aFields.Attach( 602 aFields.Attach(CJS_Value(pRuntime, pValue).ToV8Array());
606 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToV8Array());
607 } 603 }
608 604
609 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); 605 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm();
610 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); 606 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
611 if (aFields.GetLength() == 0 && bEmpty) { 607 if (aFields.GetLength() == 0 && bEmpty) {
612 if (pPDFInterForm->CheckRequiredFields(nullptr, true)) { 608 if (pPDFInterForm->CheckRequiredFields(nullptr, true)) {
613 pRuntime->BeginBlock(); 609 pRuntime->BeginBlock();
614 pInterForm->SubmitForm(strURL, FALSE); 610 pInterForm->SubmitForm(strURL, FALSE);
615 pRuntime->EndBlock(); 611 pRuntime->EndBlock();
616 } 612 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 if (params.size() >= 6) 675 if (params.size() >= 6)
680 cMsg = params[5].ToCFXWideString(); 676 cMsg = params[5].ToCFXWideString();
681 677
682 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 678 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
683 v8::Isolate* isolate = pRuntime->GetIsolate(); 679 v8::Isolate* isolate = pRuntime->GetIsolate();
684 680
685 if (params.size() >= 1 && params[0].GetType() == CJS_Value::VT_object) { 681 if (params.size() >= 1 && params[0].GetType() == CJS_Value::VT_object) {
686 v8::Local<v8::Object> pObj = params[0].ToV8Object(); 682 v8::Local<v8::Object> pObj = params[0].ToV8Object();
687 683
688 v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"bUI"); 684 v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"bUI");
689 bUI = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToInt(); 685 bUI = CJS_Value(pRuntime, pValue).ToInt();
690 686
691 pValue = FXJS_GetObjectElement(isolate, pObj, L"cTo"); 687 pValue = FXJS_GetObjectElement(isolate, pObj, L"cTo");
692 cTo = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); 688 cTo = CJS_Value(pRuntime, pValue).ToCFXWideString();
693 689
694 pValue = FXJS_GetObjectElement(isolate, pObj, L"cCc"); 690 pValue = FXJS_GetObjectElement(isolate, pObj, L"cCc");
695 cCc = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); 691 cCc = CJS_Value(pRuntime, pValue).ToCFXWideString();
696 692
697 pValue = FXJS_GetObjectElement(isolate, pObj, L"cBcc"); 693 pValue = FXJS_GetObjectElement(isolate, pObj, L"cBcc");
698 cBcc = 694 cBcc = CJS_Value(pRuntime, pValue).ToCFXWideString();
699 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
700 695
701 pValue = FXJS_GetObjectElement(isolate, pObj, L"cSubject"); 696 pValue = FXJS_GetObjectElement(isolate, pObj, L"cSubject");
702 cSubject = 697 cSubject = CJS_Value(pRuntime, pValue).ToCFXWideString();
703 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
704 698
705 pValue = FXJS_GetObjectElement(isolate, pObj, L"cMsg"); 699 pValue = FXJS_GetObjectElement(isolate, pObj, L"cMsg");
706 cMsg = 700 cMsg = CJS_Value(pRuntime, pValue).ToCFXWideString();
707 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
708 } 701 }
709 702
710 pRuntime->BeginBlock(); 703 pRuntime->BeginBlock();
711 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); 704 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp();
712 pEnv->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(), cSubject.c_str(), 705 pEnv->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(), cSubject.c_str(),
713 cCc.c_str(), cBcc.c_str(), cMsg.c_str()); 706 cCc.c_str(), cBcc.c_str(), cMsg.c_str());
714 pRuntime->EndBlock(); 707 pRuntime->EndBlock();
715 708
716 return TRUE; 709 return TRUE;
717 } 710 }
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 } 1566 }
1574 } 1567 }
1575 1568
1576 for (const auto& pData : DelayDataForFieldAndControlIndex) 1569 for (const auto& pData : DelayDataForFieldAndControlIndex)
1577 Field::DoDelay(m_pDocument, pData.get()); 1570 Field::DoDelay(m_pDocument, pData.get());
1578 } 1571 }
1579 1572
1580 CJS_Document* Document::GetCJSDoc() const { 1573 CJS_Document* Document::GetCJSDoc() const {
1581 return static_cast<CJS_Document*>(m_pJSObject); 1574 return static_cast<CJS_Document*>(m_pJSObject);
1582 } 1575 }
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/javascript/JS_Define.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698