Chromium Code Reviews| 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 void OnSelectionChanged(); | 431 void OnSelectionChanged(); |
| 435 | 432 |
| 436 // Common code shared by RotateClockwise() and RotateCounterclockwise(). | 433 // Common code shared by RotateClockwise() and RotateCounterclockwise(). |
| 437 void RotateInternal(); | 434 void RotateInternal(); |
| 438 | 435 |
| 439 // Setting selection status of document. | 436 // Setting selection status of document. |
| 440 void SetSelecting(bool selecting); | 437 void SetSelecting(bool selecting); |
| 441 | 438 |
| 442 bool PageIndexInBounds(int index) const; | 439 bool PageIndexInBounds(int index) const; |
| 443 | 440 |
| 441 void ScheduleTouchTimer(const pp::TouchInputEvent& event); | |
| 442 void KillTouchTimer(int timer_id); | |
| 443 void HandleLongPress(const pp::TouchInputEvent& event); | |
| 444 | |
| 444 // FPDF_FORMFILLINFO callbacks. | 445 // FPDF_FORMFILLINFO callbacks. |
| 445 static void Form_Invalidate(FPDF_FORMFILLINFO* param, | 446 static void Form_Invalidate(FPDF_FORMFILLINFO* param, |
| 446 FPDF_PAGE page, | 447 FPDF_PAGE page, |
| 447 double left, | 448 double left, |
| 448 double top, | 449 double top, |
| 449 double right, | 450 double right, |
| 450 double bottom); | 451 double bottom); |
| 451 static void Form_OutputSelectedRect(FPDF_FORMFILLINFO* param, | 452 static void Form_OutputSelectedRect(FPDF_FORMFILLINFO* param, |
| 452 FPDF_PAGE page, | 453 FPDF_PAGE page, |
| 453 double left, | 454 double left, |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 667 FileAvail file_availability_; | 668 FileAvail file_availability_; |
| 668 // Interface structure to request data chunks from the document stream. | 669 // Interface structure to request data chunks from the document stream. |
| 669 DownloadHints download_hints_; | 670 DownloadHints download_hints_; |
| 670 // Pointer to the document availability interface. | 671 // Pointer to the document availability interface. |
| 671 FPDF_AVAIL fpdf_availability_; | 672 FPDF_AVAIL fpdf_availability_; |
| 672 | 673 |
| 673 pp::Size default_page_size_; | 674 pp::Size default_page_size_; |
| 674 | 675 |
| 675 // Used to manage timers that form fill API needs. The pair holds the timer | 676 // Used to manage timers that form fill API needs. The pair holds the timer |
| 676 // period, in ms, and the callback function. | 677 // period, in ms, and the callback function. |
| 677 std::map<int, std::pair<int, TimerCallback> > timers_; | 678 std::map<int, std::pair<int, TimerCallback>> formfill_timers_; |
| 678 int next_timer_id_; | 679 int next_formfill_timer_id_; |
| 680 | |
| 681 // Used to manage timers for touch long press. | |
| 682 std::map<int, pp::TouchInputEvent> touch_timers_; | |
| 683 int next_touch_timer_id_; | |
|
Lei Zhang
2017/05/03 01:52:53
This isn't initialized?
dsinclair
2017/05/03 14:18:41
Done.
| |
| 679 | 684 |
| 680 // Holds the zero-based page index of the last page that the mouse clicked on. | 685 // Holds the zero-based page index of the last page that the mouse clicked on. |
| 681 int last_page_mouse_down_; | 686 int last_page_mouse_down_; |
| 682 | 687 |
| 683 // Holds the zero-based page index of the most visible page; refreshed by | 688 // Holds the zero-based page index of the most visible page; refreshed by |
| 684 // calling CalculateVisiblePages() | 689 // calling CalculateVisiblePages() |
| 685 int most_visible_page_; | 690 int most_visible_page_; |
| 686 | 691 |
| 687 // Holds the page index requested by PDFium while the scroll operation | 692 // Holds the page index requested by PDFium while the scroll operation |
| 688 // is being handled (asynchronously). | 693 // is being handled (asynchronously). |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 789 bool GetPDFPageSizeByIndex(const void* pdf_buffer, | 794 bool GetPDFPageSizeByIndex(const void* pdf_buffer, |
| 790 int pdf_buffer_size, | 795 int pdf_buffer_size, |
| 791 int page_number, | 796 int page_number, |
| 792 double* width, | 797 double* width, |
| 793 double* height) override; | 798 double* height) override; |
| 794 }; | 799 }; |
| 795 | 800 |
| 796 } // namespace chrome_pdf | 801 } // namespace chrome_pdf |
| 797 | 802 |
| 798 #endif // PDF_PDFIUM_PDFIUM_ENGINE_H_ | 803 #endif // PDF_PDFIUM_PDFIUM_ENGINE_H_ |
| OLD | NEW |