Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(846)

Side by Side Diff: pdf/pdfium/pdfium_engine.cc

Issue 814573004: Fix for Multipage selection by dragging mouse in OOP case in PDF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nit. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 OnSingleClick(page_index, char_index); 1725 OnSingleClick(page_index, char_index);
1726 } else if (event.GetClickCount() == 2 || 1726 } else if (event.GetClickCount() == 2 ||
1727 event.GetClickCount() == 3) { 1727 event.GetClickCount() == 3) {
1728 OnMultipleClick(event.GetClickCount(), page_index, char_index); 1728 OnMultipleClick(event.GetClickCount(), page_index, char_index);
1729 } 1729 }
1730 1730
1731 return true; 1731 return true;
1732 } 1732 }
1733 1733
1734 void PDFiumEngine::OnSingleClick(int page_index, int char_index) { 1734 void PDFiumEngine::OnSingleClick(int page_index, int char_index) {
1735 selecting_ = true; 1735 SetSelecting(true);
1736 selection_.push_back(PDFiumRange(pages_[page_index], char_index, 0)); 1736 selection_.push_back(PDFiumRange(pages_[page_index], char_index, 0));
1737 } 1737 }
1738 1738
1739 void PDFiumEngine::OnMultipleClick(int click_count, 1739 void PDFiumEngine::OnMultipleClick(int click_count,
1740 int page_index, 1740 int page_index,
1741 int char_index) { 1741 int char_index) {
1742 // It would be more efficient if the SDK could support finding a space, but 1742 // It would be more efficient if the SDK could support finding a space, but
1743 // now it doesn't. 1743 // now it doesn't.
1744 int start_index = char_index; 1744 int start_index = char_index;
1745 do { 1745 do {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 double page_x, page_y; 1788 double page_x, page_y;
1789 pp::Point point = event.GetPosition(); 1789 pp::Point point = event.GetPosition();
1790 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y); 1790 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y);
1791 FORM_OnLButtonUp( 1791 FORM_OnLButtonUp(
1792 form_, pages_[page_index]->GetPage(), 0, page_x, page_y); 1792 form_, pages_[page_index]->GetPage(), 0, page_x, page_y);
1793 } 1793 }
1794 1794
1795 if (!selecting_) 1795 if (!selecting_)
1796 return false; 1796 return false;
1797 1797
1798 selecting_ = false; 1798 SetSelecting(false);
1799 return true; 1799 return true;
1800 } 1800 }
1801 1801
1802 bool PDFiumEngine::OnMouseMove(const pp::MouseInputEvent& event) { 1802 bool PDFiumEngine::OnMouseMove(const pp::MouseInputEvent& event) {
1803 int page_index = -1; 1803 int page_index = -1;
1804 int char_index = -1; 1804 int char_index = -1;
1805 PDFiumPage::LinkTarget target; 1805 PDFiumPage::LinkTarget target;
1806 PDFiumPage::Area area = 1806 PDFiumPage::Area area =
1807 GetCharIndex(event, &page_index, &char_index, &target); 1807 GetCharIndex(event, &page_index, &char_index, &target);
1808 1808
(...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after
3472 3472
3473 InvalidateAllPages(); 3473 InvalidateAllPages();
3474 3474
3475 if (!current_find_text.empty()) { 3475 if (!current_find_text.empty()) {
3476 // Clear the UI. 3476 // Clear the UI.
3477 client_->NotifyNumberOfFindResultsChanged(0, false); 3477 client_->NotifyNumberOfFindResultsChanged(0, false);
3478 StartFind(current_find_text.c_str(), false); 3478 StartFind(current_find_text.c_str(), false);
3479 } 3479 }
3480 } 3480 }
3481 3481
3482 void PDFiumEngine::SetSelecting(bool selecting) {
3483 bool was_selecting = selecting_;
3484 selecting_ = selecting;
3485 if (selecting_ != was_selecting)
3486 client_->IsSelectingChanged(selecting);
3487 }
3488
3482 void PDFiumEngine::Form_Invalidate(FPDF_FORMFILLINFO* param, 3489 void PDFiumEngine::Form_Invalidate(FPDF_FORMFILLINFO* param,
3483 FPDF_PAGE page, 3490 FPDF_PAGE page,
3484 double left, 3491 double left,
3485 double top, 3492 double top,
3486 double right, 3493 double right,
3487 double bottom) { 3494 double bottom) {
3488 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); 3495 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
3489 int page_index = engine->GetVisiblePageIndex(page); 3496 int page_index = engine->GetVisiblePageIndex(page);
3490 if (page_index == -1) { 3497 if (page_index == -1) {
3491 // This can sometime happen when the page is closed because it went off 3498 // 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
4028 double* height) { 4035 double* height) {
4029 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); 4036 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
4030 if (!doc) 4037 if (!doc)
4031 return false; 4038 return false;
4032 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 4039 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
4033 FPDF_CloseDocument(doc); 4040 FPDF_CloseDocument(doc);
4034 return success; 4041 return success;
4035 } 4042 }
4036 4043
4037 } // namespace chrome_pdf 4044 } // namespace chrome_pdf
OLDNEW
« chrome/browser/resources/pdf/pdf.js ('K') | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698