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

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

Issue 722863002: Add pdf layer code for PDFium XFA module. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « 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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 FPDF_FORMFILLINFO::FFI_KillTimer = Form_KillTimer; 605 FPDF_FORMFILLINFO::FFI_KillTimer = Form_KillTimer;
606 FPDF_FORMFILLINFO::FFI_GetLocalTime = Form_GetLocalTime; 606 FPDF_FORMFILLINFO::FFI_GetLocalTime = Form_GetLocalTime;
607 FPDF_FORMFILLINFO::FFI_OnChange = Form_OnChange; 607 FPDF_FORMFILLINFO::FFI_OnChange = Form_OnChange;
608 FPDF_FORMFILLINFO::FFI_GetPage = Form_GetPage; 608 FPDF_FORMFILLINFO::FFI_GetPage = Form_GetPage;
609 FPDF_FORMFILLINFO::FFI_GetCurrentPage = Form_GetCurrentPage; 609 FPDF_FORMFILLINFO::FFI_GetCurrentPage = Form_GetCurrentPage;
610 FPDF_FORMFILLINFO::FFI_GetRotation = Form_GetRotation; 610 FPDF_FORMFILLINFO::FFI_GetRotation = Form_GetRotation;
611 FPDF_FORMFILLINFO::FFI_ExecuteNamedAction = Form_ExecuteNamedAction; 611 FPDF_FORMFILLINFO::FFI_ExecuteNamedAction = Form_ExecuteNamedAction;
612 FPDF_FORMFILLINFO::FFI_SetTextFieldFocus = Form_SetTextFieldFocus; 612 FPDF_FORMFILLINFO::FFI_SetTextFieldFocus = Form_SetTextFieldFocus;
613 FPDF_FORMFILLINFO::FFI_DoURIAction = Form_DoURIAction; 613 FPDF_FORMFILLINFO::FFI_DoURIAction = Form_DoURIAction;
614 FPDF_FORMFILLINFO::FFI_DoGoToAction = Form_DoGoToAction; 614 FPDF_FORMFILLINFO::FFI_DoGoToAction = Form_DoGoToAction;
615 615 #ifdef PDF_USE_XFA
616 FPDF_FORMFILLINFO::version = 2;
617 FPDF_FORMFILLINFO::FFI_EmailTo = Form_EmailTo;
618 FPDF_FORMFILLINFO::FFI_DisplayCaret = Form_DisplayCaret;
619 FPDF_FORMFILLINFO::FFI_SetCurrentPage = Form_SetCurrentPage;
620 FPDF_FORMFILLINFO::FFI_GetCurrentPageIndex = Form_GetCurrentPageIndex;
621 FPDF_FORMFILLINFO::FFI_GetPageViewRect = Form_GetPageViewRect;
622 FPDF_FORMFILLINFO::FFI_GetPlatform = Form_GetPlatform;
623 FPDF_FORMFILLINFO::FFI_PopupMenu = Form_PopupMenu;
624 FPDF_FORMFILLINFO::FFI_PostRequestURL = Form_PostRequestURL;
625 FPDF_FORMFILLINFO::FFI_PutRequestURL = Form_PutRequestURL;
626 FPDF_FORMFILLINFO::FFI_UploadTo = Form_UploadTo;
627 FPDF_FORMFILLINFO::FFI_DownloadFromURL = Form_DownloadFromURL;
628 FPDF_FORMFILLINFO::FFI_OpenFile = Form_OpenFile;
629 FPDF_FORMFILLINFO::FFI_GotoURL = Form_GotoURL;
630 FPDF_FORMFILLINFO::FFI_GetLanguage = Form_GetLanguage;
631 #endif // PDF_USE_XFA
616 IPDF_JSPLATFORM::version = 1; 632 IPDF_JSPLATFORM::version = 1;
617 IPDF_JSPLATFORM::app_alert = Form_Alert; 633 IPDF_JSPLATFORM::app_alert = Form_Alert;
618 IPDF_JSPLATFORM::app_beep = Form_Beep; 634 IPDF_JSPLATFORM::app_beep = Form_Beep;
619 IPDF_JSPLATFORM::app_response = Form_Response; 635 IPDF_JSPLATFORM::app_response = Form_Response;
620 IPDF_JSPLATFORM::Doc_getFilePath = Form_GetFilePath; 636 IPDF_JSPLATFORM::Doc_getFilePath = Form_GetFilePath;
621 IPDF_JSPLATFORM::Doc_mail = Form_Mail; 637 IPDF_JSPLATFORM::Doc_mail = Form_Mail;
622 IPDF_JSPLATFORM::Doc_print = Form_Print; 638 IPDF_JSPLATFORM::Doc_print = Form_Print;
623 IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm; 639 IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm;
624 IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage; 640 IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage;
625 IPDF_JSPLATFORM::Field_browse = Form_Browse; 641 IPDF_JSPLATFORM::Field_browse = Form_Browse;
626 642
627 IFSDK_PAUSE::version = 1; 643 IFSDK_PAUSE::version = 1;
628 IFSDK_PAUSE::user = NULL; 644 IFSDK_PAUSE::user = NULL;
629 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow; 645 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow;
630 } 646 }
631 647
632 PDFiumEngine::~PDFiumEngine() { 648 PDFiumEngine::~PDFiumEngine() {
633 for (size_t i = 0; i < pages_.size(); ++i) 649 for (size_t i = 0; i < pages_.size(); ++i)
634 pages_[i]->Unload(); 650 pages_[i]->Unload();
635 651
636 if (doc_) { 652 if (doc_) {
637 if (form_) { 653 if (form_) {
638 FORM_DoDocumentAAction(form_, FPDFDOC_AACTION_WC); 654 FORM_DoDocumentAAction(form_, FPDFDOC_AACTION_WC);
655 }
656 FPDF_CloseDocument(doc_);
657 if (form_) {
639 FPDFDOC_ExitFormFillEnviroument(form_); 658 FPDFDOC_ExitFormFillEnviroument(form_);
640 } 659 }
641 FPDF_CloseDocument(doc_);
642 } 660 }
643 661
644 if (fpdf_availability_) 662 if (fpdf_availability_)
645 FPDFAvail_Destroy(fpdf_availability_); 663 FPDFAvail_Destroy(fpdf_availability_);
646 664
647 STLDeleteElements(&pages_); 665 STLDeleteElements(&pages_);
648 } 666 }
649 667
668 #ifdef PDF_USE_XFA
669
670 // This is just for testing, needs to be removed later
671 #if defined(WIN32)
672 #define XFA_TESTFILE(filename) "E:/"#filename
673 #else
674 #define XFA_TESTFILE(filename) "/home/"#filename
675 #endif
676
677 struct FPDF_FILE {
678 FPDF_FILEHANDLER file_handler;
679 FILE* file;
680 };
681
682 void Sample_Release(FPDF_LPVOID client_data) {
683 if (!client_data)
684 return;
685 FPDF_FILE* file_wrapper = (FPDF_FILE*)client_data;
686 fclose(file_wrapper->file);
687 delete file_wrapper;
688 }
689
690 FPDF_DWORD Sample_GetSize(FPDF_LPVOID client_data) {
691 if (!client_data)
692 return 0;
693 FPDF_FILE* file_wrapper = (FPDF_FILE*)client_data;
694 long cur_pos = ftell(file_wrapper->file);
695 if (cur_pos == -1)
696 return 0;
697 if (fseek(file_wrapper->file, 0, SEEK_END))
698 return 0;
699 long size = ftell(file_wrapper->file);
700 fseek(file_wrapper->file, cur_pos, SEEK_SET);
701 return (FPDF_DWORD)size;
702 }
703
704 FPDF_RESULT Sample_ReadBlock(FPDF_LPVOID client_data,
705 FPDF_DWORD offset,
706 FPDF_LPVOID buffer,
707 FPDF_DWORD size) {
708 if (!client_data)
709 return -1;
710 FPDF_FILE* file_wrapper = (FPDF_FILE*)client_data;
711 if (fseek(file_wrapper->file, (long)offset, SEEK_SET))
712 return -1;
713 size_t read_size = fread(buffer, 1, size, file_wrapper->file);
714 return read_size == size ? 0 : -1;
715 }
716
717 FPDF_RESULT Sample_WriteBlock(FPDF_LPVOID client_data,
718 FPDF_DWORD offset,
719 FPDF_LPCVOID buffer,
720 FPDF_DWORD size) {
721 if (!client_data)
722 return -1;
723 FPDF_FILE* file_wrapper = (FPDF_FILE*)client_data;
724 if (fseek(file_wrapper->file, (long)offset, SEEK_SET))
725 return -1;
726 // Write data
727 size_t write_size = fwrite(buffer, 1, size, file_wrapper->file);
728 return write_size == size ? 0 : -1;
729 }
730
731 FPDF_RESULT Sample_Flush(FPDF_LPVOID client_data) {
732 if (!client_data)
733 return -1;
734 // Flush file
735 fflush(((FPDF_FILE*)client_data)->file);
736 return 0;
737 }
738
739 FPDF_RESULT Sample_Truncate(FPDF_LPVOID client_data, FPDF_DWORD size) {
740 return 0;
741 }
742
743 void PDFiumEngine::Form_EmailTo(FPDF_FORMFILLINFO* param,
744 FPDF_FILEHANDLER* file_handler,
745 FPDF_WIDESTRING to,
746 FPDF_WIDESTRING subject,
747 FPDF_WIDESTRING cc,
748 FPDF_WIDESTRING bcc,
749 FPDF_WIDESTRING message) {
750 std::string to_str =
751 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(to));
752 std::string subject_str =
753 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(subject));
754 std::string cc_str =
755 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(cc));
756 std::string bcc_str =
757 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(bcc));
758 std::string message_str =
759 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(message));
760
761 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
762 engine->client_->Email(to_str, cc_str, bcc_str, subject_str, message_str);
763 }
764
765 void PDFiumEngine::Form_DisplayCaret(FPDF_FORMFILLINFO* param,
766 FPDF_PAGE page,
767 FPDF_BOOL visible,
768 double left,
769 double top,
770 double right,
771 double bottom) {
772 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
773 engine->client_->UpdateCursor(PP_CURSORTYPE_IBEAM);
774 std::vector<pp::Rect> tickmarks;
775 pp::Rect rect(left, top, right, bottom);
776 tickmarks.push_back(rect);
777 engine->client_->UpdateTickMarks(tickmarks);
778 }
779
780 void PDFiumEngine::Form_SetCurrentPage(FPDF_FORMFILLINFO* param,
781 FPDF_DOCUMENT document,
782 int page) {
783 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
784 pp::Rect page_view_rect = engine->GetPageContentsRect(page);
785 engine->ScrolledToYPosition(page_view_rect.height());
786 pp::Point pos(1, page_view_rect.height());
787 engine->SetScrollPosition(pos);
788 }
789
790 int PDFiumEngine::Form_GetCurrentPageIndex(FPDF_FORMFILLINFO* param,
791 FPDF_DOCUMENT document) {
792 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
793 return engine->GetMostVisiblePage();
794 }
795
796 void PDFiumEngine::Form_GetPageViewRect(FPDF_FORMFILLINFO* param,
797 FPDF_PAGE page,
798 double* left,
799 double* top,
800 double* right,
801 double* bottom) {
802 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
803 int page_index = engine->GetMostVisiblePage();
804 pp::Rect page_view_rect = engine->GetPageContentsRect(page_index);
805
806 *left = page_view_rect.x();
807 *right = page_view_rect.right();
808 *top = page_view_rect.y();
809 *bottom = page_view_rect.bottom();
810 }
811
812 int PDFiumEngine::Form_GetPlatform(FPDF_FORMFILLINFO* param,
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
829 return platform_flag;
830 }
831
832 FPDF_BOOL PDFiumEngine::Form_PopupMenu(FPDF_FORMFILLINFO* param,
833 FPDF_PAGE page,
834 FPDF_WIDGET widget,
835 int menu_flag,
836 float x,
837 float y) {
838 return false;
839 }
840
841 FPDF_BOOL PDFiumEngine::Form_PostRequestURL(FPDF_FORMFILLINFO* param,
842 FPDF_WIDESTRING url,
843 FPDF_WIDESTRING data,
844 FPDF_WIDESTRING content_type,
845 FPDF_WIDESTRING encode,
846 FPDF_WIDESTRING header,
847 FPDF_BSTR* response) {
848 std::string url_str =
849 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(url));
850 std::string data_str =
851 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(data));
852 std::string content_type_str =
853 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(content_type));
854 std::string encode_str =
855 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(encode));
856 std::string header_str =
857 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(header));
858
859 std::string javascript = "alert(\"Post:"
860 + url_str + "," + data_str + "," + content_type_str + ","
861 + encode_str + "," + header_str
862 + "\")";
863 return true;
864 }
865
866 FPDF_BOOL PDFiumEngine::Form_PutRequestURL(FPDF_FORMFILLINFO* param,
867 FPDF_WIDESTRING url,
868 FPDF_WIDESTRING data,
869 FPDF_WIDESTRING encode) {
870 std::string url_str =
871 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(url));
872 std::string data_str =
873 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(data));
874 std::string encode_str =
875 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(encode));
876
877 std::string javascript = "alert(\"Put:"
878 + url_str + "," + data_str + "," + encode_str
879 + "\")";
880
881 return true;
882 }
883
884 void PDFiumEngine::Form_UploadTo(FPDF_FORMFILLINFO* param,
885 FPDF_FILEHANDLER* file_handle,
886 int file_flag,
887 FPDF_WIDESTRING to) {
888 std::string to_str =
889 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(to));
890 // TODO: needs the full implementation of form uploading
891 }
892
893 FPDF_LPFILEHANDLER PDFiumEngine::Form_DownloadFromURL(FPDF_FORMFILLINFO* param,
894 FPDF_WIDESTRING url) {
895 std::string url_str =
896 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(url));
897
898 // Now should get data from url.
899 // For testing purpose, use data read from file
900 // TODO: needs the full implementation here
901 FILE* file = fopen(XFA_TESTFILE("downloadtest.tem"), "w");
902
903 FPDF_FILE* file_wrapper = new FPDF_FILE;
904 file_wrapper->file = file;
905 file_wrapper->file_handler.clientData = file_wrapper;
906 file_wrapper->file_handler.Flush = Sample_Flush;
907 file_wrapper->file_handler.GetSize = Sample_GetSize;
908 file_wrapper->file_handler.ReadBlock = Sample_ReadBlock;
909 file_wrapper->file_handler.Release = Sample_Release;
910 file_wrapper->file_handler.Truncate = Sample_Truncate;
911 file_wrapper->file_handler.WriteBlock = Sample_WriteBlock;
912
913 return &file_wrapper->file_handler;
914 }
915
916 FPDF_FILEHANDLER* PDFiumEngine::Form_OpenFile(FPDF_FORMFILLINFO* param,
917 int file_flag,
918 FPDF_WIDESTRING url,
919 const char* mode) {
920 std::string url_str = "NULL";
921 if (url != NULL) {
922 url_str =
923 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(url));
924 }
925 // TODO: need to implement open file from the url
926 // Use a file path for the ease of testing
927 FILE* file = fopen(XFA_TESTFILE("tem.txt"), mode);
928 FPDF_FILE* file_wrapper = new FPDF_FILE;
929 file_wrapper->file = file;
930 file_wrapper->file_handler.clientData = file_wrapper;
931 file_wrapper->file_handler.Flush = Sample_Flush;
932 file_wrapper->file_handler.GetSize = Sample_GetSize;
933 file_wrapper->file_handler.ReadBlock = Sample_ReadBlock;
934 file_wrapper->file_handler.Release = Sample_Release;
935 file_wrapper->file_handler.Truncate = Sample_Truncate;
936 file_wrapper->file_handler.WriteBlock = Sample_WriteBlock;
937 return &file_wrapper->file_handler;
938 }
939
940 void PDFiumEngine::Form_GotoURL(FPDF_FORMFILLINFO* param,
941 FPDF_DOCUMENT document,
942 FPDF_WIDESTRING url) {
943 std::string url_str =
944 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(url));
945 // TODO: needs to implement GOTO URL action
946 }
947
948 int PDFiumEngine::Form_GetLanguage(FPDF_FORMFILLINFO* param,
949 void* language,
950 int length) {
951 return 0;
952 }
953
954 #endif // PDF_USE_XFA
955
650 int PDFiumEngine::GetBlock(void* param, unsigned long position, 956 int PDFiumEngine::GetBlock(void* param, unsigned long position,
651 unsigned char* buffer, unsigned long size) { 957 unsigned char* buffer, unsigned long size) {
652 DocumentLoader* loader = static_cast<DocumentLoader*>(param); 958 DocumentLoader* loader = static_cast<DocumentLoader*>(param);
653 return loader->GetBlock(position, size, buffer); 959 return loader->GetBlock(position, size, buffer);
654 } 960 }
655 961
656 bool PDFiumEngine::IsDataAvail(FX_FILEAVAIL* param, 962 bool PDFiumEngine::IsDataAvail(FX_FILEAVAIL* param,
657 size_t offset, size_t size) { 963 size_t offset, size_t size) {
658 PDFiumEngine::FileAvail* file_avail = 964 PDFiumEngine::FileAvail* file_avail =
659 static_cast<PDFiumEngine::FileAvail*>(param); 965 static_cast<PDFiumEngine::FileAvail*>(param);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 FORM_DoPageAAction(new_page, form_, FPDFPAGE_AACTION_OPEN); 1217 FORM_DoPageAAction(new_page, form_, FPDFPAGE_AACTION_OPEN);
912 } 1218 }
913 1219
914 if (doc_) // This can only happen if loading |doc_| fails. 1220 if (doc_) // This can only happen if loading |doc_| fails.
915 client_->DocumentLoadComplete(pages_.size()); 1221 client_->DocumentLoadComplete(pages_.size());
916 } 1222 }
917 1223
918 void PDFiumEngine::UnsupportedFeature(int type) { 1224 void PDFiumEngine::UnsupportedFeature(int type) {
919 std::string feature; 1225 std::string feature;
920 switch (type) { 1226 switch (type) {
1227 #ifndef PDF_USE_XFA
921 case FPDF_UNSP_DOC_XFAFORM: 1228 case FPDF_UNSP_DOC_XFAFORM:
922 feature = "XFA"; 1229 feature = "XFA";
923 break; 1230 break;
1231 #endif
924 case FPDF_UNSP_DOC_PORTABLECOLLECTION: 1232 case FPDF_UNSP_DOC_PORTABLECOLLECTION:
925 feature = "Portfolios_Packages"; 1233 feature = "Portfolios_Packages";
926 break; 1234 break;
927 case FPDF_UNSP_DOC_ATTACHMENT: 1235 case FPDF_UNSP_DOC_ATTACHMENT:
928 case FPDF_UNSP_ANNOT_ATTACHMENT: 1236 case FPDF_UNSP_ANNOT_ATTACHMENT:
929 feature = "Attachment"; 1237 feature = "Attachment";
930 break; 1238 break;
931 case FPDF_UNSP_DOC_SECURITY: 1239 case FPDF_UNSP_DOC_SECURITY:
932 feature = "Rights_Management"; 1240 feature = "Rights_Management";
933 break; 1241 break;
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 if (page_index != -1) { 1647 if (page_index != -1) {
1340 last_page_mouse_down_ = page_index; 1648 last_page_mouse_down_ = page_index;
1341 double page_x, page_y; 1649 double page_x, page_y;
1342 pp::Point point = event.GetPosition(); 1650 pp::Point point = event.GetPosition();
1343 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y); 1651 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y);
1344 1652
1345 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);
1346 int control = FPDPage_HasFormFieldAtPoint( 1654 int control = FPDPage_HasFormFieldAtPoint(
1347 form_, pages_[page_index]->GetPage(), page_x, page_y); 1655 form_, pages_[page_index]->GetPage(), page_x, page_y);
1348 if (control > FPDF_FORMFIELD_UNKNOWN) { // returns -1 sometimes... 1656 if (control > FPDF_FORMFIELD_UNKNOWN) { // returns -1 sometimes...
1349 client_->FormTextFieldFocusChange(control == FPDF_FORMFIELD_TEXTFIELD || 1657 #ifdef PDF_USE_XFA
1350 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
1351 return true; // Return now before we get into the selection code. 1664 return true; // Return now before we get into the selection code.
1352 } 1665 }
1353 } 1666 }
1354 1667
1355 client_->FormTextFieldFocusChange(false); 1668 client_->FormTextFieldFocusChange(false);
1356 1669
1357 if (area != PDFiumPage::TEXT_AREA) 1670 if (area != PDFiumPage::TEXT_AREA)
1358 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.
1359 1672
1360 if (event.GetClickCount() == 1) { 1673 if (event.GetClickCount() == 1) {
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 if (!form_) { 2535 if (!form_) {
2223 // Only returns 0 when data isn't available. If form data is downloaded, or 2536 // Only returns 0 when data isn't available. If form data is downloaded, or
2224 // if this isn't a form, returns positive values. 2537 // if this isn't a form, returns positive values.
2225 if (!doc_loader_.IsDocumentComplete() && 2538 if (!doc_loader_.IsDocumentComplete() &&
2226 !FPDFAvail_IsFormAvail(fpdf_availability_, &download_hints_)) { 2539 !FPDFAvail_IsFormAvail(fpdf_availability_, &download_hints_)) {
2227 return; 2540 return;
2228 } 2541 }
2229 2542
2230 form_ = FPDFDOC_InitFormFillEnviroument( 2543 form_ = FPDFDOC_InitFormFillEnviroument(
2231 doc_, static_cast<FPDF_FORMFILLINFO*>(this)); 2544 doc_, static_cast<FPDF_FORMFILLINFO*>(this));
2545 #ifdef PDF_USE_XFA
2546 FPDF_LoadXFA(doc_);
2547 #endif
2548
2232 FPDF_SetFormFieldHighlightColor(form_, 0, kFormHighlightColor); 2549 FPDF_SetFormFieldHighlightColor(form_, 0, kFormHighlightColor);
2233 FPDF_SetFormFieldHighlightAlpha(form_, kFormHighlightAlpha); 2550 FPDF_SetFormFieldHighlightAlpha(form_, kFormHighlightAlpha);
2234 } 2551 }
2235 2552
2236 if (!doc_loader_.IsDocumentComplete()) { 2553 if (!doc_loader_.IsDocumentComplete()) {
2237 // Check if the first page is available. In a linearized PDF, that is not 2554 // Check if the first page is available. In a linearized PDF, that is not
2238 // always page 0. Doing this gives us the default page size, since when the 2555 // always page 0. Doing this gives us the default page size, since when the
2239 // document is available, the first page is available as well. 2556 // document is available, the first page is available as well.
2240 CheckPageAvailable(FPDFAvail_GetFirstPageNum(doc_), &pending_pages_); 2557 CheckPageAvailable(FPDFAvail_GetFirstPageNum(doc_), &pending_pages_);
2241 } 2558 }
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
3575 double* height) { 3892 double* height) {
3576 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); 3893 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
3577 if (!doc) 3894 if (!doc)
3578 return false; 3895 return false;
3579 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3896 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3580 FPDF_CloseDocument(doc); 3897 FPDF_CloseDocument(doc);
3581 return success; 3898 return success;
3582 } 3899 }
3583 3900
3584 } // namespace chrome_pdf 3901 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698