Chromium Code Reviews| Index: pdf/pdfium/pdfium_engine.cc |
| diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc |
| index 83c83f4fe439c59c8d971de0d1fbe68ba1d1fda5..28ba890b4b7e7b92ef0a94af0dca715c38914a5e 100644 |
| --- a/pdf/pdfium/pdfium_engine.cc |
| +++ b/pdf/pdfium/pdfium_engine.cc |
| @@ -1287,12 +1287,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); |
| @@ -1370,7 +1370,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(); |
| @@ -1389,7 +1402,13 @@ 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); |
| + |
| + if (mouse_down_state_ != MouseDownState(area, target)) |
| + mouse_down_state_ = MouseDownState(); |
|
raymes
2014/09/11 01:23:01
nit: Maybe just add a note of what's happening her
Nikhil
2014/09/12 07:44:12
Done.
|
| + |
| if (!selecting_) { |
| PP_CursorType_Dev cursor; |
| switch (area) { |