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 #include "pdf/pdfium/pdfium_engine.h" | 5 #include "pdf/pdfium/pdfium_engine.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 OnSingleClick(page_index, char_index); | 1723 OnSingleClick(page_index, char_index); |
1724 } else if (event.GetClickCount() == 2 || | 1724 } else if (event.GetClickCount() == 2 || |
1725 event.GetClickCount() == 3) { | 1725 event.GetClickCount() == 3) { |
1726 OnMultipleClick(event.GetClickCount(), page_index, char_index); | 1726 OnMultipleClick(event.GetClickCount(), page_index, char_index); |
1727 } | 1727 } |
1728 | 1728 |
1729 return true; | 1729 return true; |
1730 } | 1730 } |
1731 | 1731 |
1732 void PDFiumEngine::OnSingleClick(int page_index, int char_index) { | 1732 void PDFiumEngine::OnSingleClick(int page_index, int char_index) { |
1733 selecting_ = true; | 1733 SetSelecting(true); |
1734 selection_.push_back(PDFiumRange(pages_[page_index], char_index, 0)); | 1734 selection_.push_back(PDFiumRange(pages_[page_index], char_index, 0)); |
1735 } | 1735 } |
1736 | 1736 |
1737 void PDFiumEngine::OnMultipleClick(int click_count, | 1737 void PDFiumEngine::OnMultipleClick(int click_count, |
1738 int page_index, | 1738 int page_index, |
1739 int char_index) { | 1739 int char_index) { |
1740 // It would be more efficient if the SDK could support finding a space, but | 1740 // It would be more efficient if the SDK could support finding a space, but |
1741 // now it doesn't. | 1741 // now it doesn't. |
1742 int start_index = char_index; | 1742 int start_index = char_index; |
1743 do { | 1743 do { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 double page_x, page_y; | 1786 double page_x, page_y; |
1787 pp::Point point = event.GetPosition(); | 1787 pp::Point point = event.GetPosition(); |
1788 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y); | 1788 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y); |
1789 FORM_OnLButtonUp( | 1789 FORM_OnLButtonUp( |
1790 form_, pages_[page_index]->GetPage(), 0, page_x, page_y); | 1790 form_, pages_[page_index]->GetPage(), 0, page_x, page_y); |
1791 } | 1791 } |
1792 | 1792 |
1793 if (!selecting_) | 1793 if (!selecting_) |
1794 return false; | 1794 return false; |
1795 | 1795 |
1796 selecting_ = false; | 1796 SetSelecting(false); |
1797 return true; | 1797 return true; |
1798 } | 1798 } |
1799 | 1799 |
1800 bool PDFiumEngine::OnMouseMove(const pp::MouseInputEvent& event) { | 1800 bool PDFiumEngine::OnMouseMove(const pp::MouseInputEvent& event) { |
1801 int page_index = -1; | 1801 int page_index = -1; |
1802 int char_index = -1; | 1802 int char_index = -1; |
1803 PDFiumPage::LinkTarget target; | 1803 PDFiumPage::LinkTarget target; |
1804 PDFiumPage::Area area = | 1804 PDFiumPage::Area area = |
1805 GetCharIndex(event, &page_index, &char_index, &target); | 1805 GetCharIndex(event, &page_index, &char_index, &target); |
1806 | 1806 |
(...skipping 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3462 | 3462 |
3463 InvalidateAllPages(); | 3463 InvalidateAllPages(); |
3464 | 3464 |
3465 if (!current_find_text.empty()) { | 3465 if (!current_find_text.empty()) { |
3466 // Clear the UI. | 3466 // Clear the UI. |
3467 client_->NotifyNumberOfFindResultsChanged(0, false); | 3467 client_->NotifyNumberOfFindResultsChanged(0, false); |
3468 StartFind(current_find_text.c_str(), false); | 3468 StartFind(current_find_text.c_str(), false); |
3469 } | 3469 } |
3470 } | 3470 } |
3471 | 3471 |
| 3472 void PDFiumEngine::SetSelecting(bool selecting) { |
| 3473 bool was_selecting = selecting_; |
| 3474 selecting_ = selecting; |
| 3475 if (selecting_ != was_selecting) |
| 3476 client_->IsSelectingChanged(selecting); |
| 3477 } |
| 3478 |
3472 void PDFiumEngine::Form_Invalidate(FPDF_FORMFILLINFO* param, | 3479 void PDFiumEngine::Form_Invalidate(FPDF_FORMFILLINFO* param, |
3473 FPDF_PAGE page, | 3480 FPDF_PAGE page, |
3474 double left, | 3481 double left, |
3475 double top, | 3482 double top, |
3476 double right, | 3483 double right, |
3477 double bottom) { | 3484 double bottom) { |
3478 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); | 3485 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); |
3479 int page_index = engine->GetVisiblePageIndex(page); | 3486 int page_index = engine->GetVisiblePageIndex(page); |
3480 if (page_index == -1) { | 3487 if (page_index == -1) { |
3481 // This can sometime happen when the page is closed because it went off | 3488 // This can sometime happen when the page is closed because it went off |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4018 double* height) { | 4025 double* height) { |
4019 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 4026 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
4020 if (!doc) | 4027 if (!doc) |
4021 return false; | 4028 return false; |
4022 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 4029 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
4023 FPDF_CloseDocument(doc); | 4030 FPDF_CloseDocument(doc); |
4024 return success; | 4031 return success; |
4025 } | 4032 } |
4026 | 4033 |
4027 } // namespace chrome_pdf | 4034 } // namespace chrome_pdf |
OLD | NEW |