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/time/time.h" | 19 #include "base/time/time.h" |
19 #include "pdf/document_loader.h" | 20 #include "pdf/document_loader.h" |
20 #include "pdf/pdf_engine.h" | 21 #include "pdf/pdf_engine.h" |
21 #include "pdf/pdfium/pdfium_page.h" | 22 #include "pdf/pdfium/pdfium_page.h" |
22 #include "pdf/pdfium/pdfium_range.h" | 23 #include "pdf/pdfium/pdfium_range.h" |
23 #include "ppapi/cpp/completion_callback.h" | 24 #include "ppapi/cpp/completion_callback.h" |
24 #include "ppapi/cpp/dev/buffer_dev.h" | 25 #include "ppapi/cpp/dev/buffer_dev.h" |
25 #include "ppapi/cpp/image_data.h" | 26 #include "ppapi/cpp/image_data.h" |
26 #include "ppapi/cpp/point.h" | 27 #include "ppapi/cpp/point.h" |
27 #include "ppapi/cpp/var_array.h" | 28 #include "ppapi/cpp/var_array.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 // document size. | 242 // document size. |
242 void LoadPageInfo(bool reload); | 243 void LoadPageInfo(bool reload); |
243 | 244 |
244 // Calculates which pages should be displayed right now. | 245 // Calculates which pages should be displayed right now. |
245 void CalculateVisiblePages(); | 246 void CalculateVisiblePages(); |
246 | 247 |
247 // Returns true iff the given page index is visible. CalculateVisiblePages | 248 // Returns true iff the given page index is visible. CalculateVisiblePages |
248 // must have been called first. | 249 // must have been called first. |
249 bool IsPageVisible(int index) const; | 250 bool IsPageVisible(int index) const; |
250 | 251 |
| 252 // Internal interface that caches the page index requested by the PDFium |
| 253 // engine |
| 254 // to be used during the interval the client has not finished handling it. |
| 255 void ScrollToPage(int page); |
| 256 |
251 // Checks if a page is now available, and if so marks it as such and returns | 257 // Checks if a page is now available, and if so marks it as such and returns |
252 // true. Otherwise, it will return false and will add the index to the given | 258 // true. Otherwise, it will return false and will add the index to the given |
253 // array if it's not already there. | 259 // array if it's not already there. |
254 bool CheckPageAvailable(int index, std::vector<int>* pending); | 260 bool CheckPageAvailable(int index, std::vector<int>* pending); |
255 | 261 |
256 // Helper function to get a given page's size in pixels. This is not part of | 262 // Helper function to get a given page's size in pixels. This is not part of |
257 // PDFiumPage because we might not have that structure when we need this. | 263 // PDFiumPage because we might not have that structure when we need this. |
258 pp::Size GetPageSize(int index); | 264 pp::Size GetPageSize(int index); |
259 | 265 |
260 void GetAllScreenRectsUnion(std::vector<PDFiumRange>* rect_range, | 266 void GetAllScreenRectsUnion(std::vector<PDFiumRange>* rect_range, |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 std::map<int, std::pair<int, TimerCallback> > timers_; | 676 std::map<int, std::pair<int, TimerCallback> > timers_; |
671 int next_timer_id_; | 677 int next_timer_id_; |
672 | 678 |
673 // Holds the page index of the last page that the mouse clicked on. | 679 // Holds the page index of the last page that the mouse clicked on. |
674 int last_page_mouse_down_; | 680 int last_page_mouse_down_; |
675 | 681 |
676 // Holds the page index of the most visible page; refreshed by calling | 682 // Holds the page index of the most visible page; refreshed by calling |
677 // CalculateVisiblePages() | 683 // CalculateVisiblePages() |
678 int most_visible_page_; | 684 int most_visible_page_; |
679 | 685 |
| 686 // Holds the page index requested by PDFium while there are in-flight |
| 687 // messages being sent by the Browser <-> PDFium engine. |
| 688 base::Optional<int> in_flight_visible_page_; |
| 689 |
680 // Set to true after FORM_DoDocumentJSAction/FORM_DoDocumentOpenAction have | 690 // Set to true after FORM_DoDocumentJSAction/FORM_DoDocumentOpenAction have |
681 // been called. Only after that can we call FORM_DoPageAAction. | 691 // been called. Only after that can we call FORM_DoPageAAction. |
682 bool called_do_document_action_; | 692 bool called_do_document_action_; |
683 | 693 |
684 // Records parts of form fields that need to be highlighted at next paint, in | 694 // Records parts of form fields that need to be highlighted at next paint, in |
685 // screen coordinates. | 695 // screen coordinates. |
686 std::vector<pp::Rect> form_highlights_; | 696 std::vector<pp::Rect> form_highlights_; |
687 | 697 |
688 // Whether to render in grayscale or in color. | 698 // Whether to render in grayscale or in color. |
689 bool render_grayscale_; | 699 bool render_grayscale_; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 bool GetPDFPageSizeByIndex(const void* pdf_buffer, | 764 bool GetPDFPageSizeByIndex(const void* pdf_buffer, |
755 int pdf_buffer_size, | 765 int pdf_buffer_size, |
756 int page_number, | 766 int page_number, |
757 double* width, | 767 double* width, |
758 double* height) override; | 768 double* height) override; |
759 }; | 769 }; |
760 | 770 |
761 } // namespace chrome_pdf | 771 } // namespace chrome_pdf |
762 | 772 |
763 #endif // PDF_PDFIUM_PDFIUM_ENGINE_H_ | 773 #endif // PDF_PDFIUM_PDFIUM_ENGINE_H_ |
OLD | NEW |