OLD | NEW |
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 #ifndef PDF_PDFIUM_PDFIUM_ENGINE_H_ | 5 #ifndef PDF_PDFIUM_PDFIUM_ENGINE_H_ |
6 #define PDF_PDFIUM_PDFIUM_ENGINE_H_ | 6 #define PDF_PDFIUM_PDFIUM_ENGINE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <memory> | 12 #include <memory> |
13 #include <string> | 13 #include <string> |
14 #include <utility> | 14 #include <utility> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/optional.h" | 18 #include "base/optional.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "pdf/document_loader.h" | 20 #include "pdf/document_loader.h" |
21 #include "pdf/pdf_engine.h" | 21 #include "pdf/pdf_engine.h" |
22 #include "pdf/pdfium/pdfium_page.h" | 22 #include "pdf/pdfium/pdfium_page.h" |
23 #include "pdf/pdfium/pdfium_range.h" | 23 #include "pdf/pdfium/pdfium_range.h" |
24 #include "ppapi/cpp/completion_callback.h" | 24 #include "ppapi/cpp/completion_callback.h" |
25 #include "ppapi/cpp/dev/buffer_dev.h" | 25 #include "ppapi/cpp/dev/buffer_dev.h" |
26 #include "ppapi/cpp/image_data.h" | 26 #include "ppapi/cpp/image_data.h" |
27 #include "ppapi/cpp/input_event.h" | |
28 #include "ppapi/cpp/point.h" | 27 #include "ppapi/cpp/point.h" |
29 #include "ppapi/cpp/var_array.h" | 28 #include "ppapi/cpp/var_array.h" |
30 #include "third_party/pdfium/public/fpdf_dataavail.h" | 29 #include "third_party/pdfium/public/fpdf_dataavail.h" |
31 #include "third_party/pdfium/public/fpdf_formfill.h" | 30 #include "third_party/pdfium/public/fpdf_formfill.h" |
32 #include "third_party/pdfium/public/fpdf_progressive.h" | 31 #include "third_party/pdfium/public/fpdf_progressive.h" |
33 #include "third_party/pdfium/public/fpdfview.h" | 32 #include "third_party/pdfium/public/fpdfview.h" |
34 | 33 |
| 34 namespace pp { |
| 35 class KeyboardInputEvent; |
| 36 class MouseInputEvent; |
| 37 } |
| 38 |
35 namespace chrome_pdf { | 39 namespace chrome_pdf { |
36 | 40 |
37 class ShadowMatrix; | 41 class ShadowMatrix; |
38 | 42 |
39 class PDFiumEngine : public PDFEngine, | 43 class PDFiumEngine : public PDFEngine, |
40 public DocumentLoader::Client, | 44 public DocumentLoader::Client, |
41 public FPDF_FORMFILLINFO, | 45 public FPDF_FORMFILLINFO, |
42 public IPDF_JSPLATFORM, | 46 public IPDF_JSPLATFORM, |
43 public IFSDK_PAUSE { | 47 public IFSDK_PAUSE { |
44 public: | 48 public: |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 pp::VarArray GetBookmarks() override; | 83 pp::VarArray GetBookmarks() override; |
80 int GetNamedDestinationPage(const std::string& destination) override; | 84 int GetNamedDestinationPage(const std::string& destination) override; |
81 int GetMostVisiblePage() override; | 85 int GetMostVisiblePage() override; |
82 pp::Rect GetPageRect(int index) override; | 86 pp::Rect GetPageRect(int index) override; |
83 pp::Rect GetPageBoundsRect(int index) override; | 87 pp::Rect GetPageBoundsRect(int index) override; |
84 pp::Rect GetPageContentsRect(int index) override; | 88 pp::Rect GetPageContentsRect(int index) override; |
85 pp::Rect GetPageScreenRect(int page_index) const override; | 89 pp::Rect GetPageScreenRect(int page_index) const override; |
86 int GetVerticalScrollbarYPosition() override; | 90 int GetVerticalScrollbarYPosition() override; |
87 void SetGrayscale(bool grayscale) override; | 91 void SetGrayscale(bool grayscale) override; |
88 void OnCallback(int id) override; | 92 void OnCallback(int id) override; |
89 void OnTouchTimerCallback(int id) override; | |
90 int GetCharCount(int page_index) override; | 93 int GetCharCount(int page_index) override; |
91 pp::FloatRect GetCharBounds(int page_index, int char_index) override; | 94 pp::FloatRect GetCharBounds(int page_index, int char_index) override; |
92 uint32_t GetCharUnicode(int page_index, int char_index) override; | 95 uint32_t GetCharUnicode(int page_index, int char_index) override; |
93 void GetTextRunInfo(int page_index, | 96 void GetTextRunInfo(int page_index, |
94 int start_char_index, | 97 int start_char_index, |
95 uint32_t* out_len, | 98 uint32_t* out_len, |
96 double* out_font_size, | 99 double* out_font_size, |
97 pp::FloatRect* out_bounds) override; | 100 pp::FloatRect* out_bounds) override; |
98 bool GetPrintScaling() override; | 101 bool GetPrintScaling() override; |
99 int GetCopiesToPrint() override; | 102 int GetCopiesToPrint() override; |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 void OnSelectionChanged(); | 438 void OnSelectionChanged(); |
436 | 439 |
437 // Common code shared by RotateClockwise() and RotateCounterclockwise(). | 440 // Common code shared by RotateClockwise() and RotateCounterclockwise(). |
438 void RotateInternal(); | 441 void RotateInternal(); |
439 | 442 |
440 // Setting selection status of document. | 443 // Setting selection status of document. |
441 void SetSelecting(bool selecting); | 444 void SetSelecting(bool selecting); |
442 | 445 |
443 bool PageIndexInBounds(int index) const; | 446 bool PageIndexInBounds(int index) const; |
444 | 447 |
445 void ScheduleTouchTimer(const pp::TouchInputEvent& event); | |
446 void KillTouchTimer(int timer_id); | |
447 void HandleLongPress(const pp::TouchInputEvent& event); | |
448 | |
449 // FPDF_FORMFILLINFO callbacks. | 448 // FPDF_FORMFILLINFO callbacks. |
450 static void Form_Invalidate(FPDF_FORMFILLINFO* param, | 449 static void Form_Invalidate(FPDF_FORMFILLINFO* param, |
451 FPDF_PAGE page, | 450 FPDF_PAGE page, |
452 double left, | 451 double left, |
453 double top, | 452 double top, |
454 double right, | 453 double right, |
455 double bottom); | 454 double bottom); |
456 static void Form_OutputSelectedRect(FPDF_FORMFILLINFO* param, | 455 static void Form_OutputSelectedRect(FPDF_FORMFILLINFO* param, |
457 FPDF_PAGE page, | 456 FPDF_PAGE page, |
458 double left, | 457 double left, |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 FileAvail file_availability_; | 671 FileAvail file_availability_; |
673 // Interface structure to request data chunks from the document stream. | 672 // Interface structure to request data chunks from the document stream. |
674 DownloadHints download_hints_; | 673 DownloadHints download_hints_; |
675 // Pointer to the document availability interface. | 674 // Pointer to the document availability interface. |
676 FPDF_AVAIL fpdf_availability_; | 675 FPDF_AVAIL fpdf_availability_; |
677 | 676 |
678 pp::Size default_page_size_; | 677 pp::Size default_page_size_; |
679 | 678 |
680 // Used to manage timers that form fill API needs. The pair holds the timer | 679 // Used to manage timers that form fill API needs. The pair holds the timer |
681 // period, in ms, and the callback function. | 680 // period, in ms, and the callback function. |
682 std::map<int, std::pair<int, TimerCallback>> formfill_timers_; | 681 std::map<int, std::pair<int, TimerCallback>> timers_; |
683 int next_formfill_timer_id_; | 682 int next_timer_id_; |
684 | |
685 // Used to manage timers for touch long press. | |
686 std::map<int, pp::TouchInputEvent> touch_timers_; | |
687 int next_touch_timer_id_; | |
688 | 683 |
689 // Holds the zero-based page index of the last page that the mouse clicked on. | 684 // Holds the zero-based page index of the last page that the mouse clicked on. |
690 int last_page_mouse_down_; | 685 int last_page_mouse_down_; |
691 | 686 |
692 // Holds the zero-based page index of the most visible page; refreshed by | 687 // Holds the zero-based page index of the most visible page; refreshed by |
693 // calling CalculateVisiblePages() | 688 // calling CalculateVisiblePages() |
694 int most_visible_page_; | 689 int most_visible_page_; |
695 | 690 |
696 // Holds the page index requested by PDFium while the scroll operation | 691 // Holds the page index requested by PDFium while the scroll operation |
697 // is being handled (asynchronously). | 692 // is being handled (asynchronously). |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 bool GetPDFPageSizeByIndex(const void* pdf_buffer, | 793 bool GetPDFPageSizeByIndex(const void* pdf_buffer, |
799 int pdf_buffer_size, | 794 int pdf_buffer_size, |
800 int page_number, | 795 int page_number, |
801 double* width, | 796 double* width, |
802 double* height) override; | 797 double* height) override; |
803 }; | 798 }; |
804 | 799 |
805 } // namespace chrome_pdf | 800 } // namespace chrome_pdf |
806 | 801 |
807 #endif // PDF_PDFIUM_PDFIUM_ENGINE_H_ | 802 #endif // PDF_PDFIUM_PDFIUM_ENGINE_H_ |
OLD | NEW |