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

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 553433002: PDF Viewer - Links should open on mouse up (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback (rebase, nit fix) Created 6 years, 3 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 | « pdf/pdfium/pdfium_engine.h ('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 f0fe1b26a5b03b6257e60d2ab7a3f04b8c27f49f..28fca4406d64aba87f784e22b07e636837a981ba 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -1291,12 +1291,12 @@ bool PDFiumEngine::OnMouseDown(const pp::MouseInputEvent& event) {
PDFiumPage::LinkTarget target;
PDFiumPage::Area area = GetCharIndex(event, &page_index,
&char_index, &target);
- if (area == PDFiumPage::WEBLINK_AREA) {
- bool open_in_new_tab = !!(event.GetModifiers() & kDefaultKeyModifier);
- client_->NavigateTo(target.url, open_in_new_tab);
- client_->FormTextFieldFocusChange(false);
+ mouse_down_state_ = MouseDownState(area, target);
+
+ // Decide whether to open link or not based on user action in mouse up and
+ // mouse move events.
+ if (area == PDFiumPage::WEBLINK_AREA)
return true;
- }
if (area == PDFiumPage::DOCLINK_AREA) {
client_->ScrollToPage(target.page);
@@ -1374,7 +1374,20 @@ bool PDFiumEngine::OnMouseUp(const pp::MouseInputEvent& event) {
int page_index = -1;
int char_index = -1;
- GetCharIndex(event, &page_index, &char_index, NULL);
+ PDFiumPage::LinkTarget target;
+ PDFiumPage::Area area =
+ GetCharIndex(event, &page_index, &char_index, &target);
+
+ // Open link on mouse up for same link for which mouse down happened earlier.
+ if (mouse_down_state_ == MouseDownState(area, target)) {
+ if (area == PDFiumPage::WEBLINK_AREA) {
+ bool open_in_new_tab = !!(event.GetModifiers() & kDefaultKeyModifier);
+ client_->NavigateTo(target.url, open_in_new_tab);
+ client_->FormTextFieldFocusChange(false);
+ return true;
+ }
+ }
+
if (page_index != -1) {
double page_x, page_y;
pp::Point point = event.GetPosition();
@@ -1393,7 +1406,15 @@ bool PDFiumEngine::OnMouseUp(const pp::MouseInputEvent& event) {
bool PDFiumEngine::OnMouseMove(const pp::MouseInputEvent& event) {
int page_index = -1;
int char_index = -1;
- PDFiumPage::Area area = GetCharIndex(event, &page_index, &char_index, NULL);
+ PDFiumPage::LinkTarget target;
+ PDFiumPage::Area area =
+ GetCharIndex(event, &page_index, &char_index, &target);
+
+ // Clear |mouse_down_state_| if mouse moves away from where the mouse down
+ // happened.
+ if (mouse_down_state_ != MouseDownState(area, target))
+ mouse_down_state_ = MouseDownState();
+
if (!selecting_) {
PP_CursorType_Dev cursor;
switch (area) {
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698