| 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 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 class ShadowMatrix; | 41 class ShadowMatrix; |
| 42 | 42 |
| 43 class PDFiumEngine : public PDFEngine, | 43 class PDFiumEngine : public PDFEngine, |
| 44 public DocumentLoader::Client, | 44 public DocumentLoader::Client, |
| 45 public FPDF_FORMFILLINFO, | 45 public FPDF_FORMFILLINFO, |
| 46 public IPDF_JSPLATFORM, | 46 public IPDF_JSPLATFORM, |
| 47 public IFSDK_PAUSE { | 47 public IFSDK_PAUSE { |
| 48 public: | 48 public: |
| 49 explicit PDFiumEngine(PDFEngine::Client* client); | 49 explicit PDFiumEngine(PDFEngine::Client* client); |
| 50 virtual ~PDFiumEngine(); | 50 ~PDFiumEngine() override; |
| 51 | 51 |
| 52 // PDFEngine implementation. | 52 // PDFEngine implementation. |
| 53 virtual bool New(const char* url, const char* headers); | 53 bool New(const char* url, const char* headers) override; |
| 54 virtual void PageOffsetUpdated(const pp::Point& page_offset); | 54 void PageOffsetUpdated(const pp::Point& page_offset) override; |
| 55 virtual void PluginSizeUpdated(const pp::Size& size); | 55 void PluginSizeUpdated(const pp::Size& size) override; |
| 56 virtual void ScrolledToXPosition(int position); | 56 void ScrolledToXPosition(int position) override; |
| 57 virtual void ScrolledToYPosition(int position); | 57 void ScrolledToYPosition(int position) override; |
| 58 virtual void PrePaint(); | 58 void PrePaint() override; |
| 59 virtual void Paint(const pp::Rect& rect, | 59 void Paint(const pp::Rect& rect, |
| 60 pp::ImageData* image_data, | 60 pp::ImageData* image_data, |
| 61 std::vector<pp::Rect>* ready, | 61 std::vector<pp::Rect>* ready, |
| 62 std::vector<pp::Rect>* pending); | 62 std::vector<pp::Rect>* pending) override; |
| 63 virtual void PostPaint(); | 63 void PostPaint() override; |
| 64 virtual bool HandleDocumentLoad(const pp::URLLoader& loader); | 64 bool HandleDocumentLoad(const pp::URLLoader& loader) override; |
| 65 virtual bool HandleEvent(const pp::InputEvent& event); | 65 bool HandleEvent(const pp::InputEvent& event) override; |
| 66 virtual uint32_t QuerySupportedPrintOutputFormats(); | 66 uint32_t QuerySupportedPrintOutputFormats() override; |
| 67 virtual void PrintBegin(); | 67 void PrintBegin() override; |
| 68 virtual pp::Resource PrintPages( | 68 pp::Resource PrintPages(const PP_PrintPageNumberRange_Dev* page_ranges, |
| 69 const PP_PrintPageNumberRange_Dev* page_ranges, | 69 uint32_t page_range_count, |
| 70 uint32_t page_range_count, | 70 const PP_PrintSettings_Dev& print_settings) override; |
| 71 const PP_PrintSettings_Dev& print_settings); | 71 void PrintEnd() override; |
| 72 virtual void PrintEnd(); | 72 void StartFind(const std::string& text, bool case_sensitive) override; |
| 73 virtual void StartFind(const std::string& text, bool case_sensitive); | 73 bool SelectFindResult(bool forward) override; |
| 74 virtual bool SelectFindResult(bool forward); | 74 void StopFind() override; |
| 75 virtual void StopFind(); | 75 void ZoomUpdated(double new_zoom_level) override; |
| 76 virtual void ZoomUpdated(double new_zoom_level); | 76 void RotateClockwise() override; |
| 77 virtual void RotateClockwise(); | 77 void RotateCounterclockwise() override; |
| 78 virtual void RotateCounterclockwise(); | 78 std::string GetSelectedText() override; |
| 79 virtual std::string GetSelectedText(); | 79 std::string GetLinkAtPosition(const pp::Point& point) override; |
| 80 virtual std::string GetLinkAtPosition(const pp::Point& point); | 80 bool IsSelecting() override; |
| 81 virtual bool IsSelecting(); | 81 bool HasPermission(DocumentPermission permission) const override; |
| 82 virtual bool HasPermission(DocumentPermission permission) const; | 82 void SelectAll() override; |
| 83 virtual void SelectAll(); | 83 int GetNumberOfPages() override; |
| 84 virtual int GetNumberOfPages(); | 84 pp::VarArray GetBookmarks() override; |
| 85 virtual pp::VarArray GetBookmarks(); | 85 int GetNamedDestinationPage(const std::string& destination) override; |
| 86 virtual int GetNamedDestinationPage(const std::string& destination); | 86 int GetFirstVisiblePage() override; |
| 87 virtual int GetFirstVisiblePage(); | 87 int GetMostVisiblePage() override; |
| 88 virtual int GetMostVisiblePage(); | 88 pp::Rect GetPageRect(int index) override; |
| 89 virtual pp::Rect GetPageRect(int index); | 89 pp::Rect GetPageContentsRect(int index) override; |
| 90 virtual pp::Rect GetPageContentsRect(int index); | 90 pp::Rect GetPageScreenRect(int page_index) const override; |
| 91 virtual pp::Rect GetPageScreenRect(int page_index) const; | 91 int GetVerticalScrollbarYPosition() override { return position_.y(); } |
| 92 virtual int GetVerticalScrollbarYPosition() { return position_.y(); } | 92 void PaintThumbnail(pp::ImageData* image_data, int index) override; |
| 93 virtual void PaintThumbnail(pp::ImageData* image_data, int index); | 93 void SetGrayscale(bool grayscale) override; |
| 94 virtual void SetGrayscale(bool grayscale); | 94 void OnCallback(int id) override; |
| 95 virtual void OnCallback(int id); | 95 std::string GetPageAsJSON(int index) override; |
| 96 virtual std::string GetPageAsJSON(int index); | 96 bool GetPrintScaling() override; |
| 97 virtual bool GetPrintScaling(); | 97 int GetCopiesToPrint() override; |
| 98 virtual int GetCopiesToPrint(); | 98 int GetDuplexType() override; |
| 99 virtual int GetDuplexType(); | 99 bool GetPageSizeAndUniformity(pp::Size* size) override; |
| 100 virtual bool GetPageSizeAndUniformity(pp::Size* size); | 100 void AppendBlankPages(int num_pages) override; |
| 101 virtual void AppendBlankPages(int num_pages); | 101 void AppendPage(PDFEngine* engine, int index) override; |
| 102 virtual void AppendPage(PDFEngine* engine, int index); | 102 pp::Point GetScrollPosition() override; |
| 103 virtual pp::Point GetScrollPosition(); | 103 void SetScrollPosition(const pp::Point& position) override; |
| 104 virtual void SetScrollPosition(const pp::Point& position); | 104 bool IsProgressiveLoad() override; |
| 105 virtual bool IsProgressiveLoad(); | 105 std::string GetMetadata(const std::string& key) override; |
| 106 virtual std::string GetMetadata(const std::string& key); | |
| 107 | 106 |
| 108 // DocumentLoader::Client implementation. | 107 // DocumentLoader::Client implementation. |
| 109 virtual pp::Instance* GetPluginInstance(); | 108 pp::Instance* GetPluginInstance() override; |
| 110 virtual pp::URLLoader CreateURLLoader(); | 109 pp::URLLoader CreateURLLoader() override; |
| 111 virtual void OnPartialDocumentLoaded(); | 110 void OnPartialDocumentLoaded() override; |
| 112 virtual void OnPendingRequestComplete(); | 111 void OnPendingRequestComplete() override; |
| 113 virtual void OnNewDataAvailable(); | 112 void OnNewDataAvailable() override; |
| 114 virtual void OnDocumentComplete(); | 113 void OnDocumentComplete() override; |
| 115 | 114 |
| 116 void UnsupportedFeature(int type); | 115 void UnsupportedFeature(int type); |
| 117 | 116 |
| 118 std::string current_find_text() const { return current_find_text_; } | 117 std::string current_find_text() const { return current_find_text_; } |
| 119 | 118 |
| 120 FPDF_DOCUMENT doc() { return doc_; } | 119 FPDF_DOCUMENT doc() { return doc_; } |
| 121 FPDF_FORMHANDLE form() { return form_; } | 120 FPDF_FORMHANDLE form() { return form_; } |
| 122 | 121 |
| 123 private: | 122 private: |
| 124 // This helper class is used to detect the difference in selection between | 123 // This helper class is used to detect the difference in selection between |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 FPDF_DOCUMENT document, | 570 FPDF_DOCUMENT document, |
| 572 FPDF_WIDESTRING url); | 571 FPDF_WIDESTRING url); |
| 573 static int Form_GetLanguage(FPDF_FORMFILLINFO* param, | 572 static int Form_GetLanguage(FPDF_FORMFILLINFO* param, |
| 574 void* language, | 573 void* language, |
| 575 int length); | 574 int length); |
| 576 #endif // PDF_USE_XFA | 575 #endif // PDF_USE_XFA |
| 577 | 576 |
| 578 // IFSDK_PAUSE callbacks | 577 // IFSDK_PAUSE callbacks |
| 579 static FPDF_BOOL Pause_NeedToPauseNow(IFSDK_PAUSE* param); | 578 static FPDF_BOOL Pause_NeedToPauseNow(IFSDK_PAUSE* param); |
| 580 | 579 |
| 581 PDFEngine::Client* client_; | 580 PDFEngine::Client* const client_; |
| 582 pp::Size document_size_; // Size of document in pixels. | 581 pp::Size document_size_; // Size of document in pixels. |
| 583 | 582 |
| 584 // The scroll position in screen coordinates. | 583 // The scroll position in screen coordinates. |
| 585 pp::Point position_; | 584 pp::Point position_; |
| 586 // The offset of the page into the viewport. | 585 // The offset of the page into the viewport. |
| 587 pp::Point page_offset_; | 586 pp::Point page_offset_; |
| 588 // The plugin size in screen coordinates. | 587 // The plugin size in screen coordinates. |
| 589 pp::Size plugin_size_; | 588 pp::Size plugin_size_; |
| 590 double current_zoom_; | 589 double current_zoom_; |
| 591 unsigned int current_rotation_; | 590 unsigned int current_rotation_; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 explicit ScopedUnsupportedFeature(PDFiumEngine* engine); | 727 explicit ScopedUnsupportedFeature(PDFiumEngine* engine); |
| 729 ~ScopedUnsupportedFeature(); | 728 ~ScopedUnsupportedFeature(); |
| 730 private: | 729 private: |
| 731 PDFiumEngine* engine_; | 730 PDFiumEngine* engine_; |
| 732 PDFiumEngine* old_engine_; | 731 PDFiumEngine* old_engine_; |
| 733 }; | 732 }; |
| 734 | 733 |
| 735 class PDFiumEngineExports : public PDFEngineExports { | 734 class PDFiumEngineExports : public PDFEngineExports { |
| 736 public: | 735 public: |
| 737 PDFiumEngineExports() {} | 736 PDFiumEngineExports() {} |
| 737 |
| 738 // PDFEngineExports: |
| 738 #if defined(OS_WIN) | 739 #if defined(OS_WIN) |
| 739 // See the definition of RenderPDFPageToDC in pdf.cc for details. | 740 bool RenderPDFPageToDC(const void* pdf_buffer, |
| 740 virtual bool RenderPDFPageToDC(const void* pdf_buffer, | 741 int buffer_size, |
| 741 int buffer_size, | 742 int page_number, |
| 742 int page_number, | 743 const RenderingSettings& settings, |
| 743 const RenderingSettings& settings, | 744 HDC dc) override; |
| 744 HDC dc); | 745 #endif // defined(OS_WIN) |
| 745 #endif // OS_WIN | 746 bool RenderPDFPageToBitmap(const void* pdf_buffer, |
| 746 virtual bool RenderPDFPageToBitmap(const void* pdf_buffer, | 747 int pdf_buffer_size, |
| 747 int pdf_buffer_size, | 748 int page_number, |
| 748 int page_number, | 749 const RenderingSettings& settings, |
| 749 const RenderingSettings& settings, | 750 void* bitmap_buffer) override; |
| 750 void* bitmap_buffer); | 751 bool GetPDFDocInfo(const void* pdf_buffer, |
| 751 | 752 int buffer_size, |
| 752 virtual bool GetPDFDocInfo(const void* pdf_buffer, | 753 int* page_count, |
| 753 int buffer_size, | 754 double* max_page_width) override; |
| 754 int* page_count, | 755 bool GetPDFPageSizeByIndex(const void* pdf_buffer, |
| 755 double* max_page_width); | 756 int pdf_buffer_size, |
| 756 | 757 int page_number, |
| 757 // See the definition of GetPDFPageSizeByIndex in pdf.cc for details. | 758 double* width, |
| 758 virtual bool GetPDFPageSizeByIndex(const void* pdf_buffer, | 759 double* height) override; |
| 759 int pdf_buffer_size, int page_number, | |
| 760 double* width, double* height); | |
| 761 }; | 760 }; |
| 762 | 761 |
| 763 } // namespace chrome_pdf | 762 } // namespace chrome_pdf |
| 764 | 763 |
| 765 #endif // PDF_PDFIUM_PDFIUM_ENGINE_H_ | 764 #endif // PDF_PDFIUM_PDFIUM_ENGINE_H_ |
| OLD | NEW |