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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 // rectangles, in screen coordinates. | 124 // rectangles, in screen coordinates. |
125 void GetVisibleSelectionsScreenRects(std::vector<pp::Rect>* rects); | 125 void GetVisibleSelectionsScreenRects(std::vector<pp::Rect>* rects); |
126 | 126 |
127 PDFiumEngine* engine_; | 127 PDFiumEngine* engine_; |
128 // Screen rectangles that were selected on construction. | 128 // Screen rectangles that were selected on construction. |
129 std::vector<pp::Rect> old_selections_; | 129 std::vector<pp::Rect> old_selections_; |
130 // The origin at the time this object was constructed. | 130 // The origin at the time this object was constructed. |
131 pp::Point previous_origin_; | 131 pp::Point previous_origin_; |
132 }; | 132 }; |
133 | 133 |
134 // Used to store mouse down state to handle it in other mouse event handlers. | |
135 class MouseDownState { | |
136 public: | |
137 MouseDownState(const PDFiumPage::Area& area, | |
138 const PDFiumPage::LinkTarget& target); | |
139 ~MouseDownState(); | |
140 | |
141 void Set(const PDFiumPage::Area& area, | |
142 const PDFiumPage::LinkTarget& target); | |
143 void Reset(); | |
144 bool Matches(const PDFiumPage::Area& area, | |
145 const PDFiumPage::LinkTarget& target) const; | |
146 | |
147 private: | |
148 PDFiumPage::Area area_; | |
149 PDFiumPage::LinkTarget target_; | |
150 | |
151 DISALLOW_COPY_AND_ASSIGN(MouseDownState); | |
152 }; | |
153 | |
134 friend class SelectionChangeInvalidator; | 154 friend class SelectionChangeInvalidator; |
135 | 155 |
136 struct FileAvail : public FX_FILEAVAIL { | 156 struct FileAvail : public FX_FILEAVAIL { |
137 DocumentLoader* loader; | 157 DocumentLoader* loader; |
138 }; | 158 }; |
139 | 159 |
140 struct DownloadHints : public FX_DOWNLOADHINTS { | 160 struct DownloadHints : public FX_DOWNLOADHINTS { |
141 DocumentLoader* loader; | 161 DocumentLoader* loader; |
142 }; | 162 }; |
143 | 163 |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
502 // code still has a pointer to it. | 522 // code still has a pointer to it. |
503 bool defer_page_unload_; | 523 bool defer_page_unload_; |
504 std::vector<int> deferred_page_unloads_; | 524 std::vector<int> deferred_page_unloads_; |
505 | 525 |
506 // Used for selection. There could be more than one range if selection spans | 526 // Used for selection. There could be more than one range if selection spans |
507 // more than one page. | 527 // more than one page. |
508 std::vector<PDFiumRange> selection_; | 528 std::vector<PDFiumRange> selection_; |
509 // True if we're in the middle of selection. | 529 // True if we're in the middle of selection. |
510 bool selecting_; | 530 bool selecting_; |
511 | 531 |
512 // Used to store mouse down state to handle it in other mouse event handlers. | |
513 struct MouseDownState { | |
Lei Zhang
2014/09/12 22:49:04
non-trivial struct/class -> class
| |
514 MouseDownState() {}; | |
Lei Zhang
2014/09/12 22:49:04
didn't initialize |area_| or |target_| -> :(
| |
515 MouseDownState(PDFiumPage::Area area, PDFiumPage::LinkTarget target) | |
516 : area_(area), target_(target) {}; | |
517 PDFiumPage::Area area_; | |
518 PDFiumPage::LinkTarget target_; | |
519 | |
520 bool operator==(const MouseDownState& rhs) const { | |
521 return (area_ == rhs.area_) && (target_.url == rhs.target_.url); | |
Lei Zhang
2014/09/12 22:49:04
what about target_.page ??
| |
522 } | |
523 | |
524 bool operator!=(const MouseDownState rhs) const { | |
Lei Zhang
2014/09/12 22:49:04
const ref
| |
525 return (area_ != rhs.area_) || (target_.url != rhs.target_.url); | |
Lei Zhang
2014/09/12 22:49:04
As written, this could have just been: return !(*t
| |
526 } | |
527 }; | |
528 MouseDownState mouse_down_state_; | 532 MouseDownState mouse_down_state_; |
529 | 533 |
530 // Used for searching. | 534 // Used for searching. |
531 typedef std::vector<PDFiumRange> FindResults; | 535 typedef std::vector<PDFiumRange> FindResults; |
532 FindResults find_results_; | 536 FindResults find_results_; |
533 // Which page to search next. | 537 // Which page to search next. |
534 int next_page_to_search_; | 538 int next_page_to_search_; |
535 // Where to stop searching. | 539 // Where to stop searching. |
536 int last_page_to_search_; | 540 int last_page_to_search_; |
537 int last_character_index_to_search_; // -1 if search until end of page. | 541 int last_character_index_to_search_; // -1 if search until end of page. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
643 | 647 |
644 // See the definition of GetPDFPageSizeByIndex in pdf.cc for details. | 648 // See the definition of GetPDFPageSizeByIndex in pdf.cc for details. |
645 virtual bool GetPDFPageSizeByIndex(const void* pdf_buffer, | 649 virtual bool GetPDFPageSizeByIndex(const void* pdf_buffer, |
646 int pdf_buffer_size, int page_number, | 650 int pdf_buffer_size, int page_number, |
647 double* width, double* height); | 651 double* width, double* height); |
648 }; | 652 }; |
649 | 653 |
650 } // namespace chrome_pdf | 654 } // namespace chrome_pdf |
651 | 655 |
652 #endif // PDF_PDFIUM_PDFIUM_ENGINE_H_ | 656 #endif // PDF_PDFIUM_PDFIUM_ENGINE_H_ |
OLD | NEW |