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

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: 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 83c83f4fe439c59c8d971de0d1fbe68ba1d1fda5..8ad0f4b5bfb66741cb1d0c7f9383212783d116dd 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -530,6 +530,7 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client)
form_(NULL),
defer_page_unload_(false),
selecting_(false),
+ open_link_(false),
next_page_to_search_(-1),
last_page_to_search_(-1),
last_character_index_to_search_(-1),
@@ -1288,9 +1289,7 @@ bool PDFiumEngine::OnMouseDown(const pp::MouseInputEvent& event) {
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);
raymes 2014/09/08 01:52:57 Would it be better to store the information relate
Nikhil 2014/09/08 09:44:53 Thanks for your suggestion, I agree that it could
+ open_link_ = true;
return true;
}
@@ -1370,7 +1369,18 @@ 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);
+
+ if (open_link_ && area == PDFiumPage::WEBLINK_AREA) {
+ bool open_in_new_tab = !!(event.GetModifiers() & kDefaultKeyModifier);
+ client_->NavigateTo(target.url, open_in_new_tab);
+ client_->FormTextFieldFocusChange(false);
+ open_link_ = false;
+ return true;
+ }
+
if (page_index != -1) {
double page_x, page_y;
pp::Point point = event.GetPosition();
@@ -1390,6 +1400,10 @@ 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);
+
+ if (open_link_ && area != PDFiumPage::WEBLINK_AREA)
+ open_link_ = false;
+
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