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

Side by Side Diff: pdf/pdfium/pdfium_engine.cc

Issue 705823002: Add pdf layer code for PDFium XFA module (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Indent Created 6 years, 1 month 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
« pdf/pdfium/pdfium_engine.h ('K') | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium 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 #include "pdf/pdfium/pdfium_engine.h" 5 #include "pdf/pdfium/pdfium_engine.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 FPDF_FORMFILLINFO::FFI_KillTimer = Form_KillTimer; 607 FPDF_FORMFILLINFO::FFI_KillTimer = Form_KillTimer;
608 FPDF_FORMFILLINFO::FFI_GetLocalTime = Form_GetLocalTime; 608 FPDF_FORMFILLINFO::FFI_GetLocalTime = Form_GetLocalTime;
609 FPDF_FORMFILLINFO::FFI_OnChange = Form_OnChange; 609 FPDF_FORMFILLINFO::FFI_OnChange = Form_OnChange;
610 FPDF_FORMFILLINFO::FFI_GetPage = Form_GetPage; 610 FPDF_FORMFILLINFO::FFI_GetPage = Form_GetPage;
611 FPDF_FORMFILLINFO::FFI_GetCurrentPage = Form_GetCurrentPage; 611 FPDF_FORMFILLINFO::FFI_GetCurrentPage = Form_GetCurrentPage;
612 FPDF_FORMFILLINFO::FFI_GetRotation = Form_GetRotation; 612 FPDF_FORMFILLINFO::FFI_GetRotation = Form_GetRotation;
613 FPDF_FORMFILLINFO::FFI_ExecuteNamedAction = Form_ExecuteNamedAction; 613 FPDF_FORMFILLINFO::FFI_ExecuteNamedAction = Form_ExecuteNamedAction;
614 FPDF_FORMFILLINFO::FFI_SetTextFieldFocus = Form_SetTextFieldFocus; 614 FPDF_FORMFILLINFO::FFI_SetTextFieldFocus = Form_SetTextFieldFocus;
615 FPDF_FORMFILLINFO::FFI_DoURIAction = Form_DoURIAction; 615 FPDF_FORMFILLINFO::FFI_DoURIAction = Form_DoURIAction;
616 FPDF_FORMFILLINFO::FFI_DoGoToAction = Form_DoGoToAction; 616 FPDF_FORMFILLINFO::FFI_DoGoToAction = Form_DoGoToAction;
617 617 #ifdef _PDF_USE_XFA_
618 FPDF_FORMFILLINFO::FFI_EmailTo = Form_EmailTo;
619 FPDF_FORMFILLINFO::FFI_DisplayCaret = Form_DisplayCaret;
620 FPDF_FORMFILLINFO::FFI_SetCurrentPage = Form_SetCurrentPage;
621 FPDF_FORMFILLINFO::FFI_GetCurrentPageIndex = Form_GetCurrentPageIndex;
622 FPDF_FORMFILLINFO::FFI_GetPageViewRect = Form_GetPageViewRect;
623 FPDF_FORMFILLINFO::FFI_GetPlatform = Form_GetPlatform;
624 FPDF_FORMFILLINFO::FFI_PopupMenu = Form_PopupMenu;
625 FPDF_FORMFILLINFO::FFI_PostRequestURL = Form_PostRequestURL;
626 FPDF_FORMFILLINFO::FFI_PutRequestURL = Form_PutRequestURL;
627 FPDF_FORMFILLINFO::FFI_UploadTo = Form_UploadTo;
628 FPDF_FORMFILLINFO::FFI_DownloadFromURL = Form_DownloadFromURL;
629 FPDF_FORMFILLINFO::FFI_OpenFile = Form_OpenFile;
630 FPDF_FORMFILLINFO::FFI_GotoURL = Form_GotoURL;
631 FPDF_FORMFILLINFO::FFI_GetLanguage = Form_GetLanguage;
632 #endif // _PDF_USE_XFA_
618 IPDF_JSPLATFORM::version = 1; 633 IPDF_JSPLATFORM::version = 1;
619 IPDF_JSPLATFORM::app_alert = Form_Alert; 634 IPDF_JSPLATFORM::app_alert = Form_Alert;
620 IPDF_JSPLATFORM::app_beep = Form_Beep; 635 IPDF_JSPLATFORM::app_beep = Form_Beep;
621 IPDF_JSPLATFORM::app_response = Form_Response; 636 IPDF_JSPLATFORM::app_response = Form_Response;
622 IPDF_JSPLATFORM::Doc_getFilePath = Form_GetFilePath; 637 IPDF_JSPLATFORM::Doc_getFilePath = Form_GetFilePath;
623 IPDF_JSPLATFORM::Doc_mail = Form_Mail; 638 IPDF_JSPLATFORM::Doc_mail = Form_Mail;
624 IPDF_JSPLATFORM::Doc_print = Form_Print; 639 IPDF_JSPLATFORM::Doc_print = Form_Print;
625 IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm; 640 IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm;
626 IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage; 641 IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage;
627 IPDF_JSPLATFORM::Field_browse = Form_Browse; 642 IPDF_JSPLATFORM::Field_browse = Form_Browse;
628 643
629 IFSDK_PAUSE::version = 1; 644 IFSDK_PAUSE::version = 1;
630 IFSDK_PAUSE::user = NULL; 645 IFSDK_PAUSE::user = NULL;
631 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow; 646 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow;
632 } 647 }
633 648
634 PDFiumEngine::~PDFiumEngine() { 649 PDFiumEngine::~PDFiumEngine() {
635 for (size_t i = 0; i < pages_.size(); ++i) 650 for (size_t i = 0; i < pages_.size(); ++i)
636 pages_[i]->Unload(); 651 pages_[i]->Unload();
637 652
638 if (doc_) { 653 if (doc_) {
639 if (form_) { 654 if (form_) {
640 FORM_DoDocumentAAction(form_, FPDFDOC_AACTION_WC); 655 FORM_DoDocumentAAction(form_, FPDFDOC_AACTION_WC);
656 }
657 FPDF_CloseDocument(doc_);
658 if (form_) {
641 FPDFDOC_ExitFormFillEnviroument(form_); 659 FPDFDOC_ExitFormFillEnviroument(form_);
Lei Zhang 2014/11/06 04:08:08 Can you explain why we have to do this after calli
Bo Xu 2014/11/06 05:43:51 XFA document is independent from PDF even it can b
Lei Zhang 2014/11/06 19:15:29 I just want to make sure it works with or without
642 } 660 }
643 FPDF_CloseDocument(doc_);
644 } 661 }
645 662
646 if (fpdf_availability_) 663 if (fpdf_availability_)
647 FPDFAvail_Destroy(fpdf_availability_); 664 FPDFAvail_Destroy(fpdf_availability_);
648 665
649 STLDeleteElements(&pages_); 666 STLDeleteElements(&pages_);
650 } 667 }
651 668
669 #ifdef _PDF_USE_XFA_
670
671 #if defined(WIN32)
Lei Zhang 2014/11/06 04:08:08 Please add a comment to mention this is just here
672 #define XFA_TESTFILE(filename) "E:/"#filename
673 #else
674 #define XFA_TESTFILE(filename) "/home/"#filename
675 #endif
676
677 typedef struct _FPDF_FILE {
Lei Zhang 2014/11/06 04:08:08 You can just declare struct FPDF_FILE { .. }; dire
678 FPDF_FILEHANDLER fileHandler;
679 FILE* file;
680 }FPDF_FILE;
681
682 void Sample_Release(FPDF_LPVOID clientData) {
683 if (!clientData)
684 return;
685 fclose(((FPDF_FILE*)clientData)->file);
Lei Zhang 2014/11/06 04:08:08 Maybe just declare a new pointer and only cast |cl
686 delete ((FPDF_FILE*)clientData);
687 }
688
689 FPDF_DWORD Sample_GetSize(FPDF_LPVOID clientData) {
690 if (!clientData)
691 return 0;
692 long curPos = ftell(((FPDF_FILE*)clientData)->file);
693 fseek(((FPDF_FILE*)clientData)->file, 0, SEEK_END);
694 long size = ftell(((FPDF_FILE*)clientData)->file);
695 fseek(((FPDF_FILE*)clientData)->file, curPos, SEEK_SET);
696 return (FPDF_DWORD)size;
697 }
698
699 FPDF_RESULT Sample_ReadBlock(FPDF_LPVOID clientData,
700 FPDF_DWORD offset,
701 FPDF_LPVOID buffer,
702 FPDF_DWORD size) {
703 if (!clientData)
704 return -1;
705 fseek(((FPDF_FILE*)clientData)->file, (long)offset, SEEK_SET);
706 size_t readSize = fread(buffer, 1, size, ((FPDF_FILE*)clientData)->file);
707 return readSize == size ? 0 : -1;
708 }
709
710 FPDF_RESULT Sample_WriteBlock(FPDF_LPVOID clientData,
711 FPDF_DWORD offset,
712 FPDF_LPCVOID buffer,
713 FPDF_DWORD size) {
714 if (!clientData)
715 return -1;
716 fseek(((FPDF_FILE*)clientData)->file, (long)offset, SEEK_SET);
717 //Write data
Lei Zhang 2014/11/06 04:08:08 nit: space after //
718 size_t writeSize = fwrite(buffer, 1, size, ((FPDF_FILE*)clientData)->file);
719 return writeSize == size ? 0 : -1;
720 }
721
722 FPDF_RESULT Sample_Flush(FPDF_LPVOID clientData) {
723 if (!clientData)
724 return -1;
725 //Flush file
726 fflush(((FPDF_FILE*)clientData)->file);
727 return 0;
728 }
729
730 FPDF_RESULT Sample_Truncate(FPDF_LPVOID clientData, FPDF_DWORD size) {
731 return 0;
732 }
733
734 void PDFiumEngine::Form_EmailTo(FPDF_FORMFILLINFO* pThis,
735 FPDF_FILEHANDLER* fileHandler,
736 FPDF_WIDESTRING to,
737 FPDF_WIDESTRING subject,
738 FPDF_WIDESTRING cc,
739 FPDF_WIDESTRING bcc,
740 FPDF_WIDESTRING message) {
741 std::string to_str =
742 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(to));
743 std::string subject_str =
744 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(subject));
745 std::string cc_str =
746 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(cc));
747 std::string bcc_str =
748 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(bcc));
749 std::string message_str =
750 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(message));
751
752 PDFiumEngine* engine = static_cast<PDFiumEngine*>(pThis);
753 engine->client_->Email(to_str, cc_str, bcc_str, subject_str, message_str);
754 }
755
756 void PDFiumEngine::Form_DisplayCaret(FPDF_FORMFILLINFO* pThis,
757 FPDF_PAGE page,
758 FPDF_BOOL bVisible,
759 double left,
760 double top,
761 double right,
762 double bottom) {
763 PDFiumEngine* engine = static_cast<PDFiumEngine*>(pThis);
764 engine->client_->UpdateCursor(PP_CURSORTYPE_IBEAM);
765 std::vector<pp::Rect> tickmarks;
766 pp::Rect rect(left, top, right, bottom);
767 tickmarks.push_back(rect);
768 engine->client_->UpdateTickMarks(tickmarks);
769 }
770
771 void PDFiumEngine::Form_SetCurrentPage(FPDF_FORMFILLINFO* pThis,
772 FPDF_DOCUMENT document,
773 int iCurPage) {
774 PDFiumEngine* engine = static_cast<PDFiumEngine*>(pThis);
775 pp::Rect pageViewRect = engine->GetPageContentsRect(iCurPage);
776 engine->ScrolledToYPosition(pageViewRect.height());
777 pp::Point pos(1, pageViewRect.height());
778 engine->SetScrollPosition(pos);
779 }
780
781 int PDFiumEngine::Form_GetCurrentPageIndex(FPDF_FORMFILLINFO* pThis,
782 FPDF_DOCUMENT document) {
783 int pageIndex = -1;
784 PDFiumEngine* engine = static_cast<PDFiumEngine*>(pThis);
785 pageIndex = engine->GetMostVisiblePage();
786 return pageIndex;
787 }
788
789 void PDFiumEngine::Form_GetPageViewRect(FPDF_FORMFILLINFO* pThis,
790 FPDF_PAGE page,
791 double* left,
792 double* top,
793 double* right,
794 double* bottom) {
795 PDFiumEngine* engine = static_cast<PDFiumEngine*>(pThis);
796 int page_index = engine->GetMostVisiblePage();
797 pp::Rect pageViewRect = engine->GetPageContentsRect(page_index);
798
799 *left = pageViewRect.x();
800 *right = pageViewRect.width() + pageViewRect.x();
801 *top = pageViewRect.y();
802 *bottom = pageViewRect.height();
803
804 std::string javascript = "alert(\"PageViewRect:"
805 + base::DoubleToString(*left) + ","
806 + base::DoubleToString(*right) + ","
807 + base::DoubleToString(*top) + ","
808 + base::DoubleToString(*bottom) + ","
809 + "\")";
810 }
811
812 int PDFiumEngine::Form_GetPlatform(FPDF_FORMFILLINFO* pThis,
813 void* platform,
814 int length) {
815 int platform_flag = -1;
816
817 #if defined(WIN32)
818 platform_flag = 0;
819 #elif defined(__linux__)
820 platform_flag = 1;
821 #else
822 platform_flag = 2;
823 #endif
824
825 std::string javascript = "alert(\"Platform:"
826 + base::DoubleToString(platform_flag)
827 + "\")";
828 //platform = new char[3];
Lei Zhang 2014/11/06 04:08:08 There's still some commented out code here.
829 //char tem[10] = "WIN";
830 //strncpy((char*)platform, tem, 3);
831 return 3;
832 }
833
834 FPDF_BOOL PDFiumEngine::Form_PopupMenu(FPDF_FORMFILLINFO* pThis,
835 FPDF_PAGE page,
836 FPDF_WIDGET hWidget,
837 int menuFlag,
838 float x,
839 float y) {
840 return false;
841 }
842
843 FPDF_BOOL PDFiumEngine::Form_PostRequestURL(FPDF_FORMFILLINFO* pThis,
844 FPDF_WIDESTRING wsURL,
845 FPDF_WIDESTRING wsData,
846 FPDF_WIDESTRING wsContentType,
847 FPDF_WIDESTRING wsEncode,
848 FPDF_WIDESTRING wsHeader,
849 FPDF_BSTR* respone) {
Lei Zhang 2014/11/06 04:08:08 typo: response ?
850 std::string url_str =
851 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(wsURL));
852 std::string data_str =
853 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(wsData));
854 std::string content_type_str =
855 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(wsContentType));
856 std::string encode_str =
857 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(wsEncode));
858 std::string header_str =
859 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(wsHeader));
860
861 std::string javascript = "alert(\"Post:"
Lei Zhang 2014/11/06 04:08:08 variable is not used for anything?
862 + url_str + "," + data_str + "," + content_type_str + ","
863 + encode_str + "," + header_str
864 + "\")";
865 return true;
866 }
867
868 FPDF_BOOL PDFiumEngine::Form_PutRequestURL(FPDF_FORMFILLINFO* pThis,
869 FPDF_WIDESTRING wsURL,
870 FPDF_WIDESTRING wsData,
871 FPDF_WIDESTRING wsEncode) {
872 std::string url_str =
873 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(wsURL));
874 std::string data_str =
875 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(wsData));
876 std::string encode_str =
877 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(wsEncode));
878
879 std::string javascript = "alert(\"Put:"
880 + url_str + "," + data_str + "," + encode_str
881 + "\")";
882
883 return true;
884 }
885
886 void PDFiumEngine::Form_UploadTo(FPDF_FORMFILLINFO* pThis,
887 FPDF_FILEHANDLER* fileHandler,
888 int fileFlag,
889 FPDF_WIDESTRING uploadTo) {
890 std::string to_str =
891 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(uploadTo));
892 }
893
894 FPDF_LPFILEHANDLER PDFiumEngine::Form_DownloadFromURL(FPDF_FORMFILLINFO* pThis,
895 FPDF_WIDESTRING URL) {
Lei Zhang 2014/11/06 04:08:08 URL should be lower case.
896 std::string url_str =
897 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(URL));
898
899 // Get URL data...
900 FILE* file = fopen(XFA_TESTFILE("downloadtest.tem"), "w");
901 FPDF_FILE* pFileHander = new FPDF_FILE;
902 pFileHander->file = file;
903 pFileHander->fileHandler.clientData = pFileHander;
904 pFileHander->fileHandler.Flush = Sample_Flush;
905 pFileHander->fileHandler.GetSize = Sample_GetSize;
906 pFileHander->fileHandler.ReadBlock = Sample_ReadBlock;
907 pFileHander->fileHandler.Release = Sample_Release;
908 pFileHander->fileHandler.Truncate = Sample_Truncate;
909 pFileHander->fileHandler.WriteBlock = Sample_WriteBlock;
910
911 return &pFileHander->fileHandler;
912 }
913
914 FPDF_FILEHANDLER* PDFiumEngine::Form_OpenFile(FPDF_FORMFILLINFO* pThis,
915 int fileFlag,
916 FPDF_WIDESTRING wsURL,
917 const char* mode) {
918 std::string url_str = "NULL";
Lei Zhang 2014/11/06 04:08:08 This variable is being set but not used for anythi
919 if (wsURL != NULL) {
920 url_str =
921 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(wsURL));
922 }
923 if (strncmp(mode, "wb", 2) == 0) {
924 FILE* file = fopen(XFA_TESTFILE("tem.txt"), mode);
925 FPDF_FILE* pFileHander = new FPDF_FILE;
926 pFileHander->file = file;
927 pFileHander->fileHandler.clientData = pFileHander;
928 pFileHander->fileHandler.Flush = Sample_Flush;
929 pFileHander->fileHandler.GetSize = Sample_GetSize;
930 pFileHander->fileHandler.ReadBlock = Sample_ReadBlock;
931 pFileHander->fileHandler.Release = Sample_Release;
932 pFileHander->fileHandler.Truncate = Sample_Truncate;
933 pFileHander->fileHandler.WriteBlock = Sample_WriteBlock;
934 return &pFileHander->fileHandler;
935 } else {
936 url_str = base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(wsURL));
937 }
938 return NULL;
939 }
940
941 void PDFiumEngine::Form_GotoURL(FPDF_FORMFILLINFO* pThis,
942 FPDF_DOCUMENT document,
943 FPDF_WIDESTRING wsURL) {
944 std::string url_str =
945 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(wsURL));
946 }
947
948 int PDFiumEngine::Form_GetLanguage(FPDF_FORMFILLINFO* pThis,
949 void* language,
950 int length) {
951 return 0;
952 }
953
954 #endif // _PDF_USE_XFA_
955
652 int PDFiumEngine::GetBlock(void* param, unsigned long position, 956 int PDFiumEngine::GetBlock(void* param, unsigned long position,
653 unsigned char* buffer, unsigned long size) { 957 unsigned char* buffer, unsigned long size) {
654 DocumentLoader* loader = static_cast<DocumentLoader*>(param); 958 DocumentLoader* loader = static_cast<DocumentLoader*>(param);
655 return loader->GetBlock(position, size, buffer); 959 return loader->GetBlock(position, size, buffer);
656 } 960 }
657 961
658 bool PDFiumEngine::IsDataAvail(FX_FILEAVAIL* param, 962 bool PDFiumEngine::IsDataAvail(FX_FILEAVAIL* param,
659 size_t offset, size_t size) { 963 size_t offset, size_t size) {
660 PDFiumEngine::FileAvail* file_avail = 964 PDFiumEngine::FileAvail* file_avail =
661 static_cast<PDFiumEngine::FileAvail*>(param); 965 static_cast<PDFiumEngine::FileAvail*>(param);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 FORM_DoPageAAction(new_page, form_, FPDFPAGE_AACTION_OPEN); 1217 FORM_DoPageAAction(new_page, form_, FPDFPAGE_AACTION_OPEN);
914 } 1218 }
915 1219
916 if (doc_) // This can only happen if loading |doc_| fails. 1220 if (doc_) // This can only happen if loading |doc_| fails.
917 client_->DocumentLoadComplete(pages_.size()); 1221 client_->DocumentLoadComplete(pages_.size());
918 } 1222 }
919 1223
920 void PDFiumEngine::UnsupportedFeature(int type) { 1224 void PDFiumEngine::UnsupportedFeature(int type) {
921 std::string feature; 1225 std::string feature;
922 switch (type) { 1226 switch (type) {
1227 #ifndef _PDF_USE_XFA_
923 case FPDF_UNSP_DOC_XFAFORM: 1228 case FPDF_UNSP_DOC_XFAFORM:
924 feature = "XFA"; 1229 feature = "XFA";
925 break; 1230 break;
1231 #endif
926 case FPDF_UNSP_DOC_PORTABLECOLLECTION: 1232 case FPDF_UNSP_DOC_PORTABLECOLLECTION:
927 feature = "Portfolios_Packages"; 1233 feature = "Portfolios_Packages";
928 break; 1234 break;
929 case FPDF_UNSP_DOC_ATTACHMENT: 1235 case FPDF_UNSP_DOC_ATTACHMENT:
930 case FPDF_UNSP_ANNOT_ATTACHMENT: 1236 case FPDF_UNSP_ANNOT_ATTACHMENT:
931 feature = "Attachment"; 1237 feature = "Attachment";
932 break; 1238 break;
933 case FPDF_UNSP_DOC_SECURITY: 1239 case FPDF_UNSP_DOC_SECURITY:
934 feature = "Rights_Management"; 1240 feature = "Rights_Management";
935 break; 1241 break;
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 if (page_index != -1) { 1647 if (page_index != -1) {
1342 last_page_mouse_down_ = page_index; 1648 last_page_mouse_down_ = page_index;
1343 double page_x, page_y; 1649 double page_x, page_y;
1344 pp::Point point = event.GetPosition(); 1650 pp::Point point = event.GetPosition();
1345 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y); 1651 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y);
1346 1652
1347 FORM_OnLButtonDown(form_, pages_[page_index]->GetPage(), 0, page_x, page_y); 1653 FORM_OnLButtonDown(form_, pages_[page_index]->GetPage(), 0, page_x, page_y);
1348 int control = FPDPage_HasFormFieldAtPoint( 1654 int control = FPDPage_HasFormFieldAtPoint(
1349 form_, pages_[page_index]->GetPage(), page_x, page_y); 1655 form_, pages_[page_index]->GetPage(), page_x, page_y);
1350 if (control > FPDF_FORMFIELD_UNKNOWN) { // returns -1 sometimes... 1656 if (control > FPDF_FORMFIELD_UNKNOWN) { // returns -1 sometimes...
1351 client_->FormTextFieldFocusChange(control == FPDF_FORMFIELD_TEXTFIELD || 1657 #ifdef _PDF_USE_XFA_
1352 control == FPDF_FORMFIELD_COMBOBOX); 1658 client_->FormTextFieldFocusChange(control == FPDF_FORMFIELD_TEXTFIELD ||
1659 control == FPDF_FORMFIELD_COMBOBOX || control == FPDF_FORMFIELD_XFA);
1660 #else
1661 client_->FormTextFieldFocusChange(control == FPDF_FORMFIELD_TEXTFIELD ||
1662 control == FPDF_FORMFIELD_COMBOBOX);
1663 #endif
1353 return true; // Return now before we get into the selection code. 1664 return true; // Return now before we get into the selection code.
1354 } 1665 }
1355 } 1666 }
1356 1667
1357 client_->FormTextFieldFocusChange(false); 1668 client_->FormTextFieldFocusChange(false);
1358 1669
1359 if (area != PDFiumPage::TEXT_AREA) 1670 if (area != PDFiumPage::TEXT_AREA)
1360 return true; // Return true so WebKit doesn't do its own highlighting. 1671 return true; // Return true so WebKit doesn't do its own highlighting.
1361 1672
1362 if (event.GetClickCount() == 1) { 1673 if (event.GetClickCount() == 1) {
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
2227 if (!form_) { 2538 if (!form_) {
2228 // Only returns 0 when data isn't available. If form data is downloaded, or 2539 // Only returns 0 when data isn't available. If form data is downloaded, or
2229 // if this isn't a form, returns positive values. 2540 // if this isn't a form, returns positive values.
2230 if (!doc_loader_.IsDocumentComplete() && 2541 if (!doc_loader_.IsDocumentComplete() &&
2231 !FPDFAvail_IsFormAvail(fpdf_availability_, &download_hints_)) { 2542 !FPDFAvail_IsFormAvail(fpdf_availability_, &download_hints_)) {
2232 return; 2543 return;
2233 } 2544 }
2234 2545
2235 form_ = FPDFDOC_InitFormFillEnviroument( 2546 form_ = FPDFDOC_InitFormFillEnviroument(
2236 doc_, static_cast<FPDF_FORMFILLINFO*>(this)); 2547 doc_, static_cast<FPDF_FORMFILLINFO*>(this));
2548 #ifdef _PDF_USE_XFA_
2549 FPDF_LoadXFA(doc_);
2550 #endif
2551
2237 FPDF_SetFormFieldHighlightColor(form_, 0, kFormHighlightColor); 2552 FPDF_SetFormFieldHighlightColor(form_, 0, kFormHighlightColor);
2238 FPDF_SetFormFieldHighlightAlpha(form_, kFormHighlightAlpha); 2553 FPDF_SetFormFieldHighlightAlpha(form_, kFormHighlightAlpha);
2239 } 2554 }
2240 2555
2241 if (!doc_loader_.IsDocumentComplete()) { 2556 if (!doc_loader_.IsDocumentComplete()) {
2242 // Check if the first page is available. In a linearized PDF, that is not 2557 // Check if the first page is available. In a linearized PDF, that is not
2243 // always page 0. Doing this gives us the default page size, since when the 2558 // always page 0. Doing this gives us the default page size, since when the
2244 // document is available, the first page is available as well. 2559 // document is available, the first page is available as well.
2245 CheckPageAvailable(FPDFAvail_GetFirstPageNum(doc_), &pending_pages_); 2560 CheckPageAvailable(FPDFAvail_GetFirstPageNum(doc_), &pending_pages_);
2246 } 2561 }
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
3536 double* height) { 3851 double* height) {
3537 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); 3852 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
3538 if (!doc) 3853 if (!doc)
3539 return false; 3854 return false;
3540 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3855 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3541 FPDF_CloseDocument(doc); 3856 FPDF_CloseDocument(doc);
3542 return success; 3857 return success;
3543 } 3858 }
3544 3859
3545 } // namespace chrome_pdf 3860 } // namespace chrome_pdf
OLDNEW
« pdf/pdfium/pdfium_engine.h ('K') | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698