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