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

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 2127383002: Open hyperlinks in PDF in a new tab when middle mouse clicking. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Open hyperlinks in PDF in a new tab when middle mouse clicking. Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/pdf/test-link.pdf ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_engine.cc
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index 08e869de6e40c95f10dd6b9a4b9d46ea3c83b558..d0796a5e4eca0a9a2515f452110d92f5ecea0aad 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -1527,8 +1527,11 @@ bool PDFiumEngine::OnMouseDown(const pp::MouseInputEvent& event) {
selection_.clear();
return true;
}
- if (event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_LEFT)
+
+ if (event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_LEFT &&
+ event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_MIDDLE) {
return false;
+ }
SelectionChangeInvalidator selection_invalidator(this);
selection_.clear();
@@ -1546,6 +1549,10 @@ bool PDFiumEngine::OnMouseDown(const pp::MouseInputEvent& event) {
if (area == PDFiumPage::WEBLINK_AREA)
return true;
+ // Prevent middle mouse button from selecting texts.
+ if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE)
+ return false;
+
if (area == PDFiumPage::DOCLINK_AREA) {
client_->ScrollToPage(target.page);
client_->FormTextFieldFocusChange(false);
@@ -1620,8 +1627,11 @@ void PDFiumEngine::OnMultipleClick(int click_count,
}
bool PDFiumEngine::OnMouseUp(const pp::MouseInputEvent& event) {
- if (event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_LEFT)
+
+ if (event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_LEFT &&
+ event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_MIDDLE) {
return false;
+ }
int page_index = -1;
int char_index = -1;
@@ -1633,13 +1643,18 @@ bool PDFiumEngine::OnMouseUp(const pp::MouseInputEvent& event) {
// Open link on mouse up for same link for which mouse down happened earlier.
if (mouse_down_state_.Matches(area, target)) {
if (area == PDFiumPage::WEBLINK_AREA) {
- bool open_in_new_tab = !!(event.GetModifiers() & kDefaultKeyModifier);
+ bool open_in_new_tab = !!(event.GetModifiers() & kDefaultKeyModifier) ||
+ !!(event.GetModifiers() & PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN);
client_->NavigateTo(target.url, open_in_new_tab);
client_->FormTextFieldFocusChange(false);
return true;
}
}
+ // Prevent middle mouse button from selecting texts.
+ if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE)
+ return false;
+
if (page_index != -1) {
double page_x, page_y;
pp::Point point = event.GetPosition();
« no previous file with comments | « chrome/test/data/pdf/test-link.pdf ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698