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