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

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: Change verion to 2 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 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::version = 2;
619 FPDF_FORMFILLINFO::FFI_EmailTo = Form_EmailTo;
620 FPDF_FORMFILLINFO::FFI_DisplayCaret = Form_DisplayCaret;
621 FPDF_FORMFILLINFO::FFI_SetCurrentPage = Form_SetCurrentPage;
622 FPDF_FORMFILLINFO::FFI_GetCurrentPageIndex = Form_GetCurrentPageIndex;
623 FPDF_FORMFILLINFO::FFI_GetPageViewRect = Form_GetPageViewRect;
624 FPDF_FORMFILLINFO::FFI_GetPlatform = Form_GetPlatform;
625 FPDF_FORMFILLINFO::FFI_PopupMenu = Form_PopupMenu;
626 FPDF_FORMFILLINFO::FFI_PostRequestURL = Form_PostRequestURL;
627 FPDF_FORMFILLINFO::FFI_PutRequestURL = Form_PutRequestURL;
628 FPDF_FORMFILLINFO::FFI_UploadTo = Form_UploadTo;
629 FPDF_FORMFILLINFO::FFI_DownloadFromURL = Form_DownloadFromURL;
630 FPDF_FORMFILLINFO::FFI_OpenFile = Form_OpenFile;
631 FPDF_FORMFILLINFO::FFI_GotoURL = Form_GotoURL;
632 FPDF_FORMFILLINFO::FFI_GetLanguage = Form_GetLanguage;
633 #endif // PDF_USE_XFA
618 IPDF_JSPLATFORM::version = 1; 634 IPDF_JSPLATFORM::version = 1;
619 IPDF_JSPLATFORM::app_alert = Form_Alert; 635 IPDF_JSPLATFORM::app_alert = Form_Alert;
620 IPDF_JSPLATFORM::app_beep = Form_Beep; 636 IPDF_JSPLATFORM::app_beep = Form_Beep;
621 IPDF_JSPLATFORM::app_response = Form_Response; 637 IPDF_JSPLATFORM::app_response = Form_Response;
622 IPDF_JSPLATFORM::Doc_getFilePath = Form_GetFilePath; 638 IPDF_JSPLATFORM::Doc_getFilePath = Form_GetFilePath;
623 IPDF_JSPLATFORM::Doc_mail = Form_Mail; 639 IPDF_JSPLATFORM::Doc_mail = Form_Mail;
624 IPDF_JSPLATFORM::Doc_print = Form_Print; 640 IPDF_JSPLATFORM::Doc_print = Form_Print;
625 IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm; 641 IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm;
626 IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage; 642 IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage;
627 IPDF_JSPLATFORM::Field_browse = Form_Browse; 643 IPDF_JSPLATFORM::Field_browse = Form_Browse;
628 644
629 IFSDK_PAUSE::version = 1; 645 IFSDK_PAUSE::version = 1;
630 IFSDK_PAUSE::user = NULL; 646 IFSDK_PAUSE::user = NULL;
631 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow; 647 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow;
632 } 648 }
633 649
634 PDFiumEngine::~PDFiumEngine() { 650 PDFiumEngine::~PDFiumEngine() {
635 for (size_t i = 0; i < pages_.size(); ++i) 651 for (size_t i = 0; i < pages_.size(); ++i)
636 pages_[i]->Unload(); 652 pages_[i]->Unload();
637 653
638 if (doc_) { 654 if (doc_) {
639 if (form_) { 655 if (form_) {
640 FORM_DoDocumentAAction(form_, FPDFDOC_AACTION_WC); 656 FORM_DoDocumentAAction(form_, FPDFDOC_AACTION_WC);
657 }
658 FPDF_CloseDocument(doc_);
659 if (form_) {
641 FPDFDOC_ExitFormFillEnviroument(form_); 660 FPDFDOC_ExitFormFillEnviroument(form_);
642 } 661 }
643 FPDF_CloseDocument(doc_);
644 } 662 }
645 663
646 if (fpdf_availability_) 664 if (fpdf_availability_)
647 FPDFAvail_Destroy(fpdf_availability_); 665 FPDFAvail_Destroy(fpdf_availability_);
648 666
649 STLDeleteElements(&pages_); 667 STLDeleteElements(&pages_);
650 } 668 }
651 669
670 #ifdef PDF_USE_XFA
671
672 // This is just for testing, needs to be removed later
673 #if defined(WIN32)
674 #define XFA_TESTFILE(filename) "E:/"#filename
675 #else
676 #define XFA_TESTFILE(filename) "/home/"#filename
677 #endif
678
679 struct FPDF_FILE {
680 FPDF_FILEHANDLER file_handler;
681 FILE* file;
682 };
683
684 void Sample_Release(FPDF_LPVOID client_data) {
685 if (!client_data)
686 return;
687 FPDF_FILE* file_wrapper = (FPDF_FILE*)client_data;
688 fclose(file_wrapper->file);
689 delete file_wrapper;
690 }
691
692 FPDF_DWORD Sample_GetSize(FPDF_LPVOID client_data) {
693 if (!client_data)
694 return 0;
695 FPDF_FILE* file_wrapper = (FPDF_FILE*)client_data;
696 long cur_pos = ftell(file_wrapper->file);
697 if (cur_pos == -1)
698 return 0;
699 if (fseek(file_wrapper->file, 0, SEEK_END))
700 return 0;
701 long size = ftell(file_wrapper->file);
702 fseek(file_wrapper->file, cur_pos, SEEK_SET);
703 return (FPDF_DWORD)size;
704 }
705
706 FPDF_RESULT Sample_ReadBlock(FPDF_LPVOID client_data,
707 FPDF_DWORD offset,
708 FPDF_LPVOID buffer,
709 FPDF_DWORD size) {
710 if (!client_data)
711 return -1;
712 FPDF_FILE* file_wrapper = (FPDF_FILE*)client_data;
713 if (fseek(file_wrapper->file, (long)offset, SEEK_SET))
714 return -1;
715 size_t read_size = fread(buffer, 1, size, file_wrapper->file);
716 return read_size == size ? 0 : -1;
717 }
718
719 FPDF_RESULT Sample_WriteBlock(FPDF_LPVOID client_data,
720 FPDF_DWORD offset,
721 FPDF_LPCVOID buffer,
722 FPDF_DWORD size) {
723 if (!client_data)
724 return -1;
725 FPDF_FILE* file_wrapper = (FPDF_FILE*)client_data;
726 if (fseek(file_wrapper->file, (long)offset, SEEK_SET))
727 return -1;
728 // Write data
729 size_t write_size = fwrite(buffer, 1, size, file_wrapper->file);
730 return write_size == size ? 0 : -1;
731 }
732
733 FPDF_RESULT Sample_Flush(FPDF_LPVOID client_data) {
734 if (!client_data)
735 return -1;
736 // Flush file
737 fflush(((FPDF_FILE*)client_data)->file);
738 return 0;
739 }
740
741 FPDF_RESULT Sample_Truncate(FPDF_LPVOID client_data, FPDF_DWORD size) {
742 return 0;
743 }
744
745 void PDFiumEngine::Form_EmailTo(FPDF_FORMFILLINFO* param,
746 FPDF_FILEHANDLER* file_handler,
747 FPDF_WIDESTRING to,
748 FPDF_WIDESTRING subject,
749 FPDF_WIDESTRING cc,
750 FPDF_WIDESTRING bcc,
751 FPDF_WIDESTRING message) {
752 std::string to_str =
753 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(to));
754 std::string subject_str =
755 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(subject));
756 std::string cc_str =
757 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(cc));
758 std::string bcc_str =
759 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(bcc));
760 std::string message_str =
761 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(message));
762
763 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
764 engine->client_->Email(to_str, cc_str, bcc_str, subject_str, message_str);
765 }
766
767 void PDFiumEngine::Form_DisplayCaret(FPDF_FORMFILLINFO* param,
768 FPDF_PAGE page,
769 FPDF_BOOL visible,
770 double left,
771 double top,
772 double right,
773 double bottom) {
774 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
775 engine->client_->UpdateCursor(PP_CURSORTYPE_IBEAM);
776 std::vector<pp::Rect> tickmarks;
777 pp::Rect rect(left, top, right, bottom);
778 tickmarks.push_back(rect);
779 engine->client_->UpdateTickMarks(tickmarks);
780 }
781
782 void PDFiumEngine::Form_SetCurrentPage(FPDF_FORMFILLINFO* param,
783 FPDF_DOCUMENT document,
784 int page) {
785 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
786 pp::Rect page_view_rect = engine->GetPageContentsRect(page);
787 engine->ScrolledToYPosition(page_view_rect.height());
788 pp::Point pos(1, page_view_rect.height());
789 engine->SetScrollPosition(pos);
790 }
791
792 int PDFiumEngine::Form_GetCurrentPageIndex(FPDF_FORMFILLINFO* param,
793 FPDF_DOCUMENT document) {
794 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
795 return engine->GetMostVisiblePage();
796 }
797
798 void PDFiumEngine::Form_GetPageViewRect(FPDF_FORMFILLINFO* param,
799 FPDF_PAGE page,
800 double* left,
801 double* top,
802 double* right,
803 double* bottom) {
804 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
805 int page_index = engine->GetMostVisiblePage();
806 pp::Rect page_view_rect = engine->GetPageContentsRect(page_index);
807
808 *left = page_view_rect.x();
809 *right = page_view_rect.right();
810 *top = page_view_rect.y();
811 *bottom = page_view_rect.bottom();
812 }
813
814 int PDFiumEngine::Form_GetPlatform(FPDF_FORMFILLINFO* param,
815 void* platform,
816 int length) {
817 int platform_flag = -1;
818
819 #if defined(WIN32)
820 platform_flag = 0;
821 #elif defined(__linux__)
822 platform_flag = 1;
823 #else
824 platform_flag = 2;
825 #endif
826
827 std::string javascript = "alert(\"Platform:"
828 + base::DoubleToString(platform_flag)
829 + "\")";
830
831 return platform_flag;
832 }
833
834 FPDF_BOOL PDFiumEngine::Form_PopupMenu(FPDF_FORMFILLINFO* param,
835 FPDF_PAGE page,
836 FPDF_WIDGET widget,
837 int menu_flag,
838 float x,
839 float y) {
840 return false;
841 }
842
843 FPDF_BOOL PDFiumEngine::Form_PostRequestURL(FPDF_FORMFILLINFO* param,
844 FPDF_WIDESTRING url,
845 FPDF_WIDESTRING data,
846 FPDF_WIDESTRING content_type,
847 FPDF_WIDESTRING encode,
848 FPDF_WIDESTRING header,
849 FPDF_BSTR* response) {
850 std::string url_str =
851 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(url));
852 std::string data_str =
853 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(data));
854 std::string content_type_str =
855 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(content_type));
856 std::string encode_str =
857 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(encode));
858 std::string header_str =
859 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(header));
860
861 std::string javascript = "alert(\"Post:"
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* param,
869 FPDF_WIDESTRING url,
870 FPDF_WIDESTRING data,
871 FPDF_WIDESTRING encode) {
872 std::string url_str =
873 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(url));
874 std::string data_str =
875 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(data));
876 std::string encode_str =
877 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(encode));
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* param,
887 FPDF_FILEHANDLER* file_handle,
888 int file_flag,
889 FPDF_WIDESTRING to) {
890 std::string to_str =
891 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(to));
892 // TODO: needs the full implementation of form uploading
893 }
894
895 FPDF_LPFILEHANDLER PDFiumEngine::Form_DownloadFromURL(FPDF_FORMFILLINFO* param,
896 FPDF_WIDESTRING url) {
897 std::string url_str =
898 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(url));
899
900 // Now should get data from url.
901 // For testing purpose, use data read from file
902 // TODO: needs the full implementation here
903 FILE* file = fopen(XFA_TESTFILE("downloadtest.tem"), "w");
904
905 FPDF_FILE* file_wrapper = new FPDF_FILE;
906 file_wrapper->file = file;
907 file_wrapper->file_handler.clientData = file_wrapper;
908 file_wrapper->file_handler.Flush = Sample_Flush;
909 file_wrapper->file_handler.GetSize = Sample_GetSize;
910 file_wrapper->file_handler.ReadBlock = Sample_ReadBlock;
911 file_wrapper->file_handler.Release = Sample_Release;
912 file_wrapper->file_handler.Truncate = Sample_Truncate;
913 file_wrapper->file_handler.WriteBlock = Sample_WriteBlock;
914
915 return &file_wrapper->file_handler;
916 }
917
918 FPDF_FILEHANDLER* PDFiumEngine::Form_OpenFile(FPDF_FORMFILLINFO* param,
919 int file_flag,
920 FPDF_WIDESTRING url,
921 const char* mode) {
922 std::string url_str = "NULL";
923 if (url != NULL) {
924 url_str =
925 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(url));
926 }
927 // TODO: need to implement open file from the url
928 // Use a file path for the ease of testing
929 FILE* file = fopen(XFA_TESTFILE("tem.txt"), mode);
930 FPDF_FILE* file_wrapper = new FPDF_FILE;
931 file_wrapper->file = file;
932 file_wrapper->file_handler.clientData = file_wrapper;
933 file_wrapper->file_handler.Flush = Sample_Flush;
934 file_wrapper->file_handler.GetSize = Sample_GetSize;
935 file_wrapper->file_handler.ReadBlock = Sample_ReadBlock;
936 file_wrapper->file_handler.Release = Sample_Release;
937 file_wrapper->file_handler.Truncate = Sample_Truncate;
938 file_wrapper->file_handler.WriteBlock = Sample_WriteBlock;
939 return &file_wrapper->file_handler;
940 }
941
942 void PDFiumEngine::Form_GotoURL(FPDF_FORMFILLINFO* param,
943 FPDF_DOCUMENT document,
944 FPDF_WIDESTRING url) {
945 std::string url_str =
946 base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(url));
947 // TODO: needs to implement GOTO URL action
948 }
949
950 int PDFiumEngine::Form_GetLanguage(FPDF_FORMFILLINFO* param,
951 void* language,
952 int length) {
953 return 0;
954 }
955
956 #endif // PDF_USE_XFA
957
652 int PDFiumEngine::GetBlock(void* param, unsigned long position, 958 int PDFiumEngine::GetBlock(void* param, unsigned long position,
653 unsigned char* buffer, unsigned long size) { 959 unsigned char* buffer, unsigned long size) {
654 DocumentLoader* loader = static_cast<DocumentLoader*>(param); 960 DocumentLoader* loader = static_cast<DocumentLoader*>(param);
655 return loader->GetBlock(position, size, buffer); 961 return loader->GetBlock(position, size, buffer);
656 } 962 }
657 963
658 bool PDFiumEngine::IsDataAvail(FX_FILEAVAIL* param, 964 bool PDFiumEngine::IsDataAvail(FX_FILEAVAIL* param,
659 size_t offset, size_t size) { 965 size_t offset, size_t size) {
660 PDFiumEngine::FileAvail* file_avail = 966 PDFiumEngine::FileAvail* file_avail =
661 static_cast<PDFiumEngine::FileAvail*>(param); 967 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); 1219 FORM_DoPageAAction(new_page, form_, FPDFPAGE_AACTION_OPEN);
914 } 1220 }
915 1221
916 if (doc_) // This can only happen if loading |doc_| fails. 1222 if (doc_) // This can only happen if loading |doc_| fails.
917 client_->DocumentLoadComplete(pages_.size()); 1223 client_->DocumentLoadComplete(pages_.size());
918 } 1224 }
919 1225
920 void PDFiumEngine::UnsupportedFeature(int type) { 1226 void PDFiumEngine::UnsupportedFeature(int type) {
921 std::string feature; 1227 std::string feature;
922 switch (type) { 1228 switch (type) {
1229 #ifndef PDF_USE_XFA
923 case FPDF_UNSP_DOC_XFAFORM: 1230 case FPDF_UNSP_DOC_XFAFORM:
924 feature = "XFA"; 1231 feature = "XFA";
925 break; 1232 break;
1233 #endif
926 case FPDF_UNSP_DOC_PORTABLECOLLECTION: 1234 case FPDF_UNSP_DOC_PORTABLECOLLECTION:
927 feature = "Portfolios_Packages"; 1235 feature = "Portfolios_Packages";
928 break; 1236 break;
929 case FPDF_UNSP_DOC_ATTACHMENT: 1237 case FPDF_UNSP_DOC_ATTACHMENT:
930 case FPDF_UNSP_ANNOT_ATTACHMENT: 1238 case FPDF_UNSP_ANNOT_ATTACHMENT:
931 feature = "Attachment"; 1239 feature = "Attachment";
932 break; 1240 break;
933 case FPDF_UNSP_DOC_SECURITY: 1241 case FPDF_UNSP_DOC_SECURITY:
934 feature = "Rights_Management"; 1242 feature = "Rights_Management";
935 break; 1243 break;
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 if (page_index != -1) { 1649 if (page_index != -1) {
1342 last_page_mouse_down_ = page_index; 1650 last_page_mouse_down_ = page_index;
1343 double page_x, page_y; 1651 double page_x, page_y;
1344 pp::Point point = event.GetPosition(); 1652 pp::Point point = event.GetPosition();
1345 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y); 1653 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y);
1346 1654
1347 FORM_OnLButtonDown(form_, pages_[page_index]->GetPage(), 0, page_x, page_y); 1655 FORM_OnLButtonDown(form_, pages_[page_index]->GetPage(), 0, page_x, page_y);
1348 int control = FPDPage_HasFormFieldAtPoint( 1656 int control = FPDPage_HasFormFieldAtPoint(
1349 form_, pages_[page_index]->GetPage(), page_x, page_y); 1657 form_, pages_[page_index]->GetPage(), page_x, page_y);
1350 if (control > FPDF_FORMFIELD_UNKNOWN) { // returns -1 sometimes... 1658 if (control > FPDF_FORMFIELD_UNKNOWN) { // returns -1 sometimes...
1351 client_->FormTextFieldFocusChange(control == FPDF_FORMFIELD_TEXTFIELD || 1659 #ifdef PDF_USE_XFA
1352 control == FPDF_FORMFIELD_COMBOBOX); 1660 client_->FormTextFieldFocusChange(control == FPDF_FORMFIELD_TEXTFIELD ||
1661 control == FPDF_FORMFIELD_COMBOBOX || control == FPDF_FORMFIELD_XFA);
1662 #else
1663 client_->FormTextFieldFocusChange(control == FPDF_FORMFIELD_TEXTFIELD ||
1664 control == FPDF_FORMFIELD_COMBOBOX);
1665 #endif
1353 return true; // Return now before we get into the selection code. 1666 return true; // Return now before we get into the selection code.
1354 } 1667 }
1355 } 1668 }
1356 1669
1357 client_->FormTextFieldFocusChange(false); 1670 client_->FormTextFieldFocusChange(false);
1358 1671
1359 if (area != PDFiumPage::TEXT_AREA) 1672 if (area != PDFiumPage::TEXT_AREA)
1360 return true; // Return true so WebKit doesn't do its own highlighting. 1673 return true; // Return true so WebKit doesn't do its own highlighting.
1361 1674
1362 if (event.GetClickCount() == 1) { 1675 if (event.GetClickCount() == 1) {
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
2227 if (!form_) { 2540 if (!form_) {
2228 // Only returns 0 when data isn't available. If form data is downloaded, or 2541 // Only returns 0 when data isn't available. If form data is downloaded, or
2229 // if this isn't a form, returns positive values. 2542 // if this isn't a form, returns positive values.
2230 if (!doc_loader_.IsDocumentComplete() && 2543 if (!doc_loader_.IsDocumentComplete() &&
2231 !FPDFAvail_IsFormAvail(fpdf_availability_, &download_hints_)) { 2544 !FPDFAvail_IsFormAvail(fpdf_availability_, &download_hints_)) {
2232 return; 2545 return;
2233 } 2546 }
2234 2547
2235 form_ = FPDFDOC_InitFormFillEnviroument( 2548 form_ = FPDFDOC_InitFormFillEnviroument(
2236 doc_, static_cast<FPDF_FORMFILLINFO*>(this)); 2549 doc_, static_cast<FPDF_FORMFILLINFO*>(this));
2550 #ifdef PDF_USE_XFA
2551 FPDF_LoadXFA(doc_);
2552 #endif
2553
2237 FPDF_SetFormFieldHighlightColor(form_, 0, kFormHighlightColor); 2554 FPDF_SetFormFieldHighlightColor(form_, 0, kFormHighlightColor);
2238 FPDF_SetFormFieldHighlightAlpha(form_, kFormHighlightAlpha); 2555 FPDF_SetFormFieldHighlightAlpha(form_, kFormHighlightAlpha);
2239 } 2556 }
2240 2557
2241 if (!doc_loader_.IsDocumentComplete()) { 2558 if (!doc_loader_.IsDocumentComplete()) {
2242 // Check if the first page is available. In a linearized PDF, that is not 2559 // 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 2560 // 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. 2561 // document is available, the first page is available as well.
2245 CheckPageAvailable(FPDFAvail_GetFirstPageNum(doc_), &pending_pages_); 2562 CheckPageAvailable(FPDFAvail_GetFirstPageNum(doc_), &pending_pages_);
2246 } 2563 }
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
3536 double* height) { 3853 double* height) {
3537 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); 3854 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
3538 if (!doc) 3855 if (!doc)
3539 return false; 3856 return false;
3540 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3857 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3541 FPDF_CloseDocument(doc); 3858 FPDF_CloseDocument(doc);
3542 return success; 3859 return success;
3543 } 3860 }
3544 3861
3545 } // namespace chrome_pdf 3862 } // 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