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