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

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

Issue 2870303002: PDF: React to doc links on mouse up instead of mouse down. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 int page_index = -1; 1699 int page_index = -1;
1700 int char_index = -1; 1700 int char_index = -1;
1701 int form_type = FPDF_FORMFIELD_UNKNOWN; 1701 int form_type = FPDF_FORMFIELD_UNKNOWN;
1702 PDFiumPage::LinkTarget target; 1702 PDFiumPage::LinkTarget target;
1703 PDFiumPage::Area area = 1703 PDFiumPage::Area area =
1704 GetCharIndex(event, &page_index, &char_index, &form_type, &target); 1704 GetCharIndex(event, &page_index, &char_index, &form_type, &target);
1705 mouse_down_state_.Set(area, target); 1705 mouse_down_state_.Set(area, target);
1706 1706
1707 // Decide whether to open link or not based on user action in mouse up and 1707 // Decide whether to open link or not based on user action in mouse up and
1708 // mouse move events. 1708 // mouse move events.
1709 if (area == PDFiumPage::WEBLINK_AREA) 1709 if (area == PDFiumPage::WEBLINK_AREA || area == PDFiumPage::DOCLINK_AREA)
1710 return true; 1710 return true;
1711 1711
1712 // Prevent middle mouse button from selecting texts. 1712 // Prevent middle mouse button from selecting texts.
1713 if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE) 1713 if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE)
1714 return false; 1714 return false;
1715 1715
1716 if (area == PDFiumPage::DOCLINK_AREA) {
1717 client_->ScrollToPage(target.page);
1718 client_->FormTextFieldFocusChange(false);
1719 return true;
1720 }
1721
1722 if (page_index != -1) { 1716 if (page_index != -1) {
1723 last_page_mouse_down_ = page_index; 1717 last_page_mouse_down_ = page_index;
1724 double page_x, page_y; 1718 double page_x, page_y;
1725 pp::Point point = event.GetPosition(); 1719 pp::Point point = event.GetPosition();
1726 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y); 1720 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y);
1727 1721
1728 FORM_OnLButtonDown(form_, pages_[page_index]->GetPage(), 0, page_x, page_y); 1722 FORM_OnLButtonDown(form_, pages_[page_index]->GetPage(), 0, page_x, page_y);
1729 if (form_type > FPDF_FORMFIELD_UNKNOWN) { // returns -1 sometimes... 1723 if (form_type > FPDF_FORMFIELD_UNKNOWN) { // returns -1 sometimes...
1730 mouse_down_state_.Set(PDFiumPage::NONSELECTABLE_AREA, target); 1724 mouse_down_state_.Set(PDFiumPage::NONSELECTABLE_AREA, target);
1731 bool is_valid_control = (form_type == FPDF_FORMFIELD_TEXTFIELD || 1725 bool is_valid_control = (form_type == FPDF_FORMFIELD_TEXTFIELD ||
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1809 bool meta_key = !!(modifiers & PP_INPUTEVENT_MODIFIER_METAKEY); 1803 bool meta_key = !!(modifiers & PP_INPUTEVENT_MODIFIER_METAKEY);
1810 bool shift_key = !!(modifiers & PP_INPUTEVENT_MODIFIER_SHIFTKEY); 1804 bool shift_key = !!(modifiers & PP_INPUTEVENT_MODIFIER_SHIFTKEY);
1811 1805
1812 WindowOpenDisposition disposition = ui::DispositionFromClick( 1806 WindowOpenDisposition disposition = ui::DispositionFromClick(
1813 middle_button, alt_key, ctrl_key, meta_key, shift_key); 1807 middle_button, alt_key, ctrl_key, meta_key, shift_key);
1814 1808
1815 client_->NavigateTo(target.url, disposition); 1809 client_->NavigateTo(target.url, disposition);
1816 client_->FormTextFieldFocusChange(false); 1810 client_->FormTextFieldFocusChange(false);
1817 return true; 1811 return true;
1818 } 1812 }
1813 if (area == PDFiumPage::DOCLINK_AREA) {
1814 client_->ScrollToPage(target.page);
1815 client_->FormTextFieldFocusChange(false);
1816 return true;
1817 }
1819 } 1818 }
1820 1819
1821 // Prevent middle mouse button from selecting texts. 1820 // Prevent middle mouse button from selecting texts.
1822 if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE) 1821 if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE)
1823 return false; 1822 return false;
1824 1823
1825 if (page_index != -1) { 1824 if (page_index != -1) {
1826 double page_x, page_y; 1825 double page_x, page_y;
1827 pp::Point point = event.GetPosition(); 1826 pp::Point point = event.GetPosition();
1828 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y); 1827 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y);
(...skipping 2290 matching lines...) Expand 10 before | Expand all | Expand 10 after
4119 FPDF_DOCUMENT doc = 4118 FPDF_DOCUMENT doc =
4120 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); 4119 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
4121 if (!doc) 4120 if (!doc)
4122 return false; 4121 return false;
4123 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 4122 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
4124 FPDF_CloseDocument(doc); 4123 FPDF_CloseDocument(doc);
4125 return success; 4124 return success;
4126 } 4125 }
4127 4126
4128 } // namespace chrome_pdf 4127 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698