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

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

Issue 1394053003: Merge to XFA: Wean CJS_Value off of v8::Isolate. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Fix compile 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/Consts.cpp ('k') | fpdfsdk/src/javascript/Field.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 "Document.h" 7 #include "Document.h"
8 8
9 #include "../../../third_party/base/numerics/safe_math.h" 9 #include "../../../third_party/base/numerics/safe_math.h"
10 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. 10 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment.
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 } 559 }
560 560
561 // reset filed values within a document. 561 // reset filed values within a document.
562 // comment: 562 // comment:
563 // note: if the fields names r not rational, aodbe is dumb for it. 563 // note: if the fields names r not rational, aodbe is dumb for it.
564 564
565 FX_BOOL Document::resetForm(IJS_Context* cc, 565 FX_BOOL Document::resetForm(IJS_Context* cc,
566 const CJS_Parameters& params, 566 const CJS_Parameters& params,
567 CJS_Value& vRet, 567 CJS_Value& vRet,
568 CFX_WideString& sError) { 568 CFX_WideString& sError) {
569 ASSERT(m_pDocument != NULL);
570
571 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || 569 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
572 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || 570 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) ||
573 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) 571 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM)))
574 return FALSE; 572 return FALSE;
575 573
576 CPDFSDK_InterForm* pInterForm = 574 CPDFSDK_InterForm* pInterForm =
577 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); 575 (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
578 ASSERT(pInterForm != NULL);
579
580 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); 576 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
581 ASSERT(pPDFForm != NULL); 577 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
582 578 CJS_Array aName(pRuntime);
583 v8::Isolate* isolate = GetIsolate(cc);
584 CJS_Array aName(isolate);
585 579
586 if (params.size() > 0) { 580 if (params.size() > 0) {
587 switch (params[0].GetType()) { 581 switch (params[0].GetType()) {
588 default: 582 default:
589 aName.Attach(params[0].ToV8Array()); 583 aName.Attach(params[0].ToV8Array());
590 break; 584 break;
591 case CJS_Value::VT_string: 585 case CJS_Value::VT_string:
592 aName.SetElement(0, params[0]); 586 aName.SetElement(0, params[0]);
593 break; 587 break;
594 } 588 }
595 589
596 CFX_PtrArray aFields; 590 CFX_PtrArray aFields;
597 591
598 for (int i = 0, isz = aName.GetLength(); i < isz; i++) { 592 for (int i = 0, isz = aName.GetLength(); i < isz; i++) {
599 CJS_Value valElement(isolate); 593 CJS_Value valElement(pRuntime);
600 aName.GetElement(i, valElement); 594 aName.GetElement(i, valElement);
601 CFX_WideString swVal = valElement.ToCFXWideString(); 595 CFX_WideString swVal = valElement.ToCFXWideString();
602
603 for (int j = 0, jsz = pPDFForm->CountFields(swVal); j < jsz; j++) { 596 for (int j = 0, jsz = pPDFForm->CountFields(swVal); j < jsz; j++) {
604 aFields.Add((void*)pPDFForm->GetField(j, swVal)); 597 aFields.Add((void*)pPDFForm->GetField(j, swVal));
605 } 598 }
606 } 599 }
607 600
608 if (aFields.GetSize() > 0) { 601 if (aFields.GetSize() > 0) {
609 pPDFForm->ResetForm(aFields, TRUE, TRUE); 602 pPDFForm->ResetForm(aFields, TRUE, TRUE);
610 m_pDocument->SetChangeMark(); 603 m_pDocument->SetChangeMark();
611 } 604 }
612 } else { 605 } else {
613 pPDFForm->ResetForm(TRUE); 606 pPDFForm->ResetForm(TRUE);
614 m_pDocument->SetChangeMark(); 607 m_pDocument->SetChangeMark();
615 } 608 }
616 609
617 return TRUE; 610 return TRUE;
618 } 611 }
619 612
620 FX_BOOL Document::saveAs(IJS_Context* cc, 613 FX_BOOL Document::saveAs(IJS_Context* cc,
621 const CJS_Parameters& params, 614 const CJS_Parameters& params,
622 CJS_Value& vRet, 615 CJS_Value& vRet,
623 CFX_WideString& sError) { 616 CFX_WideString& sError) {
624 // Unsafe, not supported. 617 // Unsafe, not supported.
625 return TRUE; 618 return TRUE;
626 } 619 }
627 620
628 FX_BOOL Document::submitForm(IJS_Context* cc, 621 FX_BOOL Document::submitForm(IJS_Context* cc,
629 const CJS_Parameters& params, 622 const CJS_Parameters& params,
630 CJS_Value& vRet, 623 CJS_Value& vRet,
631 CFX_WideString& sError) { 624 CFX_WideString& sError) {
632 ASSERT(m_pDocument != NULL);
633 CJS_Context* pContext = (CJS_Context*)cc; 625 CJS_Context* pContext = (CJS_Context*)cc;
634 int nSize = params.size(); 626 int nSize = params.size();
635 if (nSize < 1) { 627 if (nSize < 1) {
636 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 628 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
637 return FALSE; 629 return FALSE;
638 } 630 }
639 631
632 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
633 v8::Isolate* isolate = pRuntime->GetIsolate();
634 CJS_Array aFields(pRuntime);
640 CFX_WideString strURL; 635 CFX_WideString strURL;
641 FX_BOOL bFDF = TRUE; 636 FX_BOOL bFDF = TRUE;
642 FX_BOOL bEmpty = FALSE; 637 FX_BOOL bEmpty = FALSE;
643 v8::Isolate* isolate = GetIsolate(cc);
644 CJS_Array aFields(isolate);
645 638
646 CJS_Value v = params[0]; 639 CJS_Value v = params[0];
647 if (v.GetType() == CJS_Value::VT_string) { 640 if (v.GetType() == CJS_Value::VT_string) {
648 strURL = params[0].ToCFXWideString(); 641 strURL = params[0].ToCFXWideString();
649 if (nSize > 1) 642 if (nSize > 1)
650 bFDF = params[1].ToBool(); 643 bFDF = params[1].ToBool();
651 if (nSize > 2) 644 if (nSize > 2)
652 bEmpty = params[2].ToBool(); 645 bEmpty = params[2].ToBool();
653 if (nSize > 3) 646 if (nSize > 3)
654 aFields.Attach(params[3].ToV8Array()); 647 aFields.Attach(params[3].ToV8Array());
655 } else if (v.GetType() == CJS_Value::VT_object) { 648 } else if (v.GetType() == CJS_Value::VT_object) {
656 v8::Local<v8::Object> pObj = params[0].ToV8Object(); 649 v8::Local<v8::Object> pObj = params[0].ToV8Object();
657 v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"cURL"); 650 v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"cURL");
658 if (!pValue.IsEmpty()) 651 if (!pValue.IsEmpty())
659 strURL = 652 strURL =
660 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); 653 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
654
661 pValue = FXJS_GetObjectElement(isolate, pObj, L"bFDF"); 655 pValue = FXJS_GetObjectElement(isolate, pObj, L"bFDF");
662 bFDF = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); 656 bFDF = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToBool();
657
663 pValue = FXJS_GetObjectElement(isolate, pObj, L"bEmpty"); 658 pValue = FXJS_GetObjectElement(isolate, pObj, L"bEmpty");
664 bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); 659 bEmpty = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToBool();
660
665 pValue = FXJS_GetObjectElement(isolate, pObj, L"aFields"); 661 pValue = FXJS_GetObjectElement(isolate, pObj, L"aFields");
666 aFields.Attach( 662 aFields.Attach(
667 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToV8Array()); 663 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToV8Array());
668 } 664 }
669 665
670 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
671 CPDFSDK_InterForm* pInterForm = 666 CPDFSDK_InterForm* pInterForm =
672 (CPDFSDK_InterForm*)m_pDocument->GetInterForm(); 667 (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
673 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); 668 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
674 FX_BOOL bAll = (aFields.GetLength() == 0); 669 FX_BOOL bAll = (aFields.GetLength() == 0);
675 if (bAll && bEmpty) { 670 if (bAll && bEmpty) {
676 if (pPDFInterForm->CheckRequiredFields()) { 671 if (pPDFInterForm->CheckRequiredFields()) {
677 pRuntime->BeginBlock(); 672 pRuntime->BeginBlock();
678 pInterForm->SubmitForm(strURL, FALSE); 673 pInterForm->SubmitForm(strURL, FALSE);
679 pRuntime->EndBlock(); 674 pRuntime->EndBlock();
680 } 675 }
681 return TRUE; 676 return TRUE;
682 } 677 }
683 678
684 CFX_PtrArray fieldObjects; 679 CFX_PtrArray fieldObjects;
685 for (int i = 0, sz = aFields.GetLength(); i < sz; i++) { 680 for (int i = 0, sz = aFields.GetLength(); i < sz; i++) {
686 CJS_Value valName(isolate); 681 CJS_Value valName(pRuntime);
687 aFields.GetElement(i, valName); 682 aFields.GetElement(i, valName);
688 683
689 CFX_WideString sName = valName.ToCFXWideString(); 684 CFX_WideString sName = valName.ToCFXWideString();
690 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); 685 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
691 for (int j = 0, jsz = pPDFForm->CountFields(sName); j < jsz; ++j) { 686 for (int j = 0, jsz = pPDFForm->CountFields(sName); j < jsz; ++j) {
692 CPDF_FormField* pField = pPDFForm->GetField(j, sName); 687 CPDF_FormField* pField = pPDFForm->GetField(j, sName);
693 if (!bEmpty && pField->GetValue().IsEmpty()) 688 if (!bEmpty && pField->GetValue().IsEmpty())
694 continue; 689 continue;
695 690
696 fieldObjects.Add(pField); 691 fieldObjects.Add(pField);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 FX_BOOL Document::bookmarkRoot(IJS_Context* cc, 723 FX_BOOL Document::bookmarkRoot(IJS_Context* cc,
729 CJS_PropValue& vp, 724 CJS_PropValue& vp,
730 CFX_WideString& sError) { 725 CFX_WideString& sError) {
731 return TRUE; 726 return TRUE;
732 } 727 }
733 728
734 FX_BOOL Document::mailDoc(IJS_Context* cc, 729 FX_BOOL Document::mailDoc(IJS_Context* cc,
735 const CJS_Parameters& params, 730 const CJS_Parameters& params,
736 CJS_Value& vRet, 731 CJS_Value& vRet,
737 CFX_WideString& sError) { 732 CFX_WideString& sError) {
738 ASSERT(m_pDocument != NULL);
739
740 FX_BOOL bUI = TRUE; 733 FX_BOOL bUI = TRUE;
741 CFX_WideString cTo = L""; 734 CFX_WideString cTo = L"";
742 CFX_WideString cCc = L""; 735 CFX_WideString cCc = L"";
743 CFX_WideString cBcc = L""; 736 CFX_WideString cBcc = L"";
744 CFX_WideString cSubject = L""; 737 CFX_WideString cSubject = L"";
745 CFX_WideString cMsg = L""; 738 CFX_WideString cMsg = L"";
746 739
747 if (params.size() >= 1) 740 if (params.size() >= 1)
748 bUI = params[0].ToBool(); 741 bUI = params[0].ToBool();
749 if (params.size() >= 2) 742 if (params.size() >= 2)
750 cTo = params[1].ToCFXWideString(); 743 cTo = params[1].ToCFXWideString();
751 if (params.size() >= 3) 744 if (params.size() >= 3)
752 cCc = params[2].ToCFXWideString(); 745 cCc = params[2].ToCFXWideString();
753 if (params.size() >= 4) 746 if (params.size() >= 4)
754 cBcc = params[3].ToCFXWideString(); 747 cBcc = params[3].ToCFXWideString();
755 if (params.size() >= 5) 748 if (params.size() >= 5)
756 cSubject = params[4].ToCFXWideString(); 749 cSubject = params[4].ToCFXWideString();
757 if (params.size() >= 6) 750 if (params.size() >= 6)
758 cMsg = params[5].ToCFXWideString(); 751 cMsg = params[5].ToCFXWideString();
759 752
760 v8::Isolate* isolate = GetIsolate(cc); 753 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
754 v8::Isolate* isolate = pRuntime->GetIsolate();
761 755
762 if (params.size() >= 1 && params[0].GetType() == CJS_Value::VT_object) { 756 if (params.size() >= 1 && params[0].GetType() == CJS_Value::VT_object) {
763 v8::Local<v8::Object> pObj = params[0].ToV8Object(); 757 v8::Local<v8::Object> pObj = params[0].ToV8Object();
764 758
765 v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"bUI"); 759 v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"bUI");
766 bUI = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToInt(); 760 bUI = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToInt();
767 761
768 pValue = FXJS_GetObjectElement(isolate, pObj, L"cTo"); 762 pValue = FXJS_GetObjectElement(isolate, pObj, L"cTo");
769 cTo = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); 763 cTo = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
770 764
771 pValue = FXJS_GetObjectElement(isolate, pObj, L"cCc"); 765 pValue = FXJS_GetObjectElement(isolate, pObj, L"cCc");
772 cCc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); 766 cCc = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
773 767
774 pValue = FXJS_GetObjectElement(isolate, pObj, L"cBcc"); 768 pValue = FXJS_GetObjectElement(isolate, pObj, L"cBcc");
775 cBcc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); 769 cBcc =
770 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
776 771
777 pValue = FXJS_GetObjectElement(isolate, pObj, L"cSubject"); 772 pValue = FXJS_GetObjectElement(isolate, pObj, L"cSubject");
778 cSubject = 773 cSubject =
779 CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); 774 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
780 775
781 pValue = FXJS_GetObjectElement(isolate, pObj, L"cMsg"); 776 pValue = FXJS_GetObjectElement(isolate, pObj, L"cMsg");
782 cMsg = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); 777 cMsg =
778 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
783 } 779 }
784 780
785 CJS_Context* pContext = (CJS_Context*)cc;
786 ASSERT(pContext != NULL);
787 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
788 ASSERT(pRuntime != NULL);
789
790 pRuntime->BeginBlock(); 781 pRuntime->BeginBlock();
791 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); 782 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp();
792 pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(), 783 pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(),
793 cBcc.c_str(), cMsg.c_str()); 784 cBcc.c_str(), cMsg.c_str());
794 pRuntime->EndBlock(); 785 pRuntime->EndBlock();
795 786
796 return TRUE; 787 return TRUE;
797 } 788 }
798 789
799 FX_BOOL Document::author(IJS_Context* cc, 790 FX_BOOL Document::author(IJS_Context* cc,
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 CJS_Context* pContext = static_cast<CJS_Context*>(cc); 1426 CJS_Context* pContext = static_cast<CJS_Context*>(cc);
1436 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY); 1427 sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
1437 return FALSE; 1428 return FALSE;
1438 } 1429 }
1439 1430
1440 if (!m_pIconTree) { 1431 if (!m_pIconTree) {
1441 vp.SetNull(); 1432 vp.SetNull();
1442 return TRUE; 1433 return TRUE;
1443 } 1434 }
1444 1435
1445 CJS_Array Icons(m_isolate); 1436 CJS_Context* pContext = static_cast<CJS_Context*>(cc);
1437 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
1438 CJS_Array Icons(pRuntime);
1446 IconElement* pIconElement = NULL; 1439 IconElement* pIconElement = NULL;
1447 int iIconTreeLength = m_pIconTree->GetLength(); 1440 int iIconTreeLength = m_pIconTree->GetLength();
1448
1449 CJS_Context* pContext = (CJS_Context*)cc;
1450 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
1451
1452 for (int i = 0; i < iIconTreeLength; i++) { 1441 for (int i = 0; i < iIconTreeLength; i++) {
1453 pIconElement = (*m_pIconTree)[i]; 1442 pIconElement = (*m_pIconTree)[i];
1454 1443
1455 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( 1444 v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
1456 pRuntime->GetIsolate(), pContext, CJS_Icon::g_nObjDefnID); 1445 pRuntime->GetIsolate(), pContext, CJS_Icon::g_nObjDefnID);
1457 if (pObj.IsEmpty()) 1446 if (pObj.IsEmpty())
1458 return FALSE; 1447 return FALSE;
1459 1448
1460 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(m_isolate, pObj); 1449 CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(m_isolate, pObj);
1461 if (!pJS_Icon) 1450 if (!pJS_Icon)
1462 return FALSE; 1451 return FALSE;
1463 1452
1464 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); 1453 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject();
1465 if (!pIcon) 1454 if (!pIcon)
1466 return FALSE; 1455 return FALSE;
1467 1456
1468 pIcon->SetStream(pIconElement->IconStream->GetStream()); 1457 pIcon->SetStream(pIconElement->IconStream->GetStream());
1469 pIcon->SetIconName(pIconElement->IconName); 1458 pIcon->SetIconName(pIconElement->IconName);
1470 Icons.SetElement(i, CJS_Value(m_isolate, pJS_Icon)); 1459 Icons.SetElement(i, CJS_Value(pRuntime, pJS_Icon));
1471 } 1460 }
1472 1461
1473 vp << Icons; 1462 vp << Icons;
1474 return TRUE; 1463 return TRUE;
1475 } 1464 }
1476 1465
1477 FX_BOOL Document::getIcon(IJS_Context* cc, 1466 FX_BOOL Document::getIcon(IJS_Context* cc,
1478 const CJS_Parameters& params, 1467 const CJS_Parameters& params,
1479 CJS_Value& vRet, 1468 CJS_Value& vRet,
1480 CFX_WideString& sError) { 1469 CFX_WideString& sError) {
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 FX_BOOL Document::zoomType(IJS_Context* cc, 1787 FX_BOOL Document::zoomType(IJS_Context* cc,
1799 CJS_PropValue& vp, 1788 CJS_PropValue& vp,
1800 CFX_WideString& sError) { 1789 CFX_WideString& sError) {
1801 return TRUE; 1790 return TRUE;
1802 } 1791 }
1803 1792
1804 FX_BOOL Document::deletePages(IJS_Context* cc, 1793 FX_BOOL Document::deletePages(IJS_Context* cc,
1805 const CJS_Parameters& params, 1794 const CJS_Parameters& params,
1806 CJS_Value& vRet, 1795 CJS_Value& vRet,
1807 CFX_WideString& sError) { 1796 CFX_WideString& sError) {
1808 v8::Isolate* isolate = GetIsolate(cc);
1809 ASSERT(m_pDocument != NULL);
1810
1811 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || 1797 if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
1812 m_pDocument->GetPermissions(FPDFPERM_ASSEMBLE))) 1798 m_pDocument->GetPermissions(FPDFPERM_ASSEMBLE)))
1813 return FALSE; 1799 return FALSE;
1814 1800
1801 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
1802 v8::Isolate* isolate = pRuntime->GetIsolate();
1803
1815 int iSize = params.size(); 1804 int iSize = params.size();
1816
1817 int nStart = 0; 1805 int nStart = 0;
1818 int nEnd = 0; 1806 int nEnd = 0;
1819
1820 if (iSize < 1) { 1807 if (iSize < 1) {
1821 } else if (iSize == 1) { 1808 } else if (iSize == 1) {
1822 if (params[0].GetType() == CJS_Value::VT_object) { 1809 if (params[0].GetType() == CJS_Value::VT_object) {
1823 v8::Local<v8::Object> pObj = params[0].ToV8Object(); 1810 v8::Local<v8::Object> pObj = params[0].ToV8Object();
1824 v8::Local<v8::Value> pValue = 1811 v8::Local<v8::Value> pValue =
1825 FXJS_GetObjectElement(isolate, pObj, L"nStart"); 1812 FXJS_GetObjectElement(isolate, pObj, L"nStart");
1826 nStart = CJS_Value(m_isolate, pValue, GET_VALUE_TYPE(pValue)).ToInt(); 1813 nStart = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToInt();
1827 pValue = FXJS_GetObjectElement(isolate, pObj, L"nEnd"); 1814 pValue = FXJS_GetObjectElement(isolate, pObj, L"nEnd");
1828 nEnd = CJS_Value(m_isolate, pValue, GET_VALUE_TYPE(pValue)).ToInt(); 1815 nEnd = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToInt();
1829 } else { 1816 } else {
1830 nStart = params[0].ToInt(); 1817 nStart = params[0].ToInt();
1831 } 1818 }
1832 } else { 1819 } else {
1833 nStart = params[0].ToInt(); 1820 nStart = params[0].ToInt();
1834 nEnd = params[1].ToInt(); 1821 nEnd = params[1].ToInt();
1835 } 1822 }
1836 1823
1837 int nTotal = m_pDocument->GetPageCount(); 1824 int nTotal = m_pDocument->GetPageCount();
1838
1839 if (nStart < 0) 1825 if (nStart < 0)
1840 nStart = 0; 1826 nStart = 0;
1841 if (nStart >= nTotal) 1827 if (nStart >= nTotal)
1842 nStart = nTotal - 1; 1828 nStart = nTotal - 1;
1843 1829
1844 if (nEnd < 0) 1830 if (nEnd < 0)
1845 nEnd = 0; 1831 nEnd = 0;
1846 if (nEnd >= nTotal) 1832 if (nEnd >= nTotal)
1847 nEnd = nTotal - 1; 1833 nEnd = nTotal - 1;
1848 1834
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 CFX_DWordArray DelArray; 1903 CFX_DWordArray DelArray;
1918 1904
1919 for (int j = DelArray.GetSize() - 1; j >= 0; j--) { 1905 for (int j = DelArray.GetSize() - 1; j >= 0; j--) {
1920 m_DelayData.RemoveAt(DelArray[j]); 1906 m_DelayData.RemoveAt(DelArray[j]);
1921 } 1907 }
1922 } 1908 }
1923 1909
1924 CJS_Document* Document::GetCJSDoc() const { 1910 CJS_Document* Document::GetCJSDoc() const {
1925 return static_cast<CJS_Document*>(m_pJSObject); 1911 return static_cast<CJS_Document*>(m_pJSObject);
1926 } 1912 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/Consts.cpp ('k') | fpdfsdk/src/javascript/Field.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698