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

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

Issue 2166193002: Handle ctrl + shift + left click on links in PDF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handle ctrl + shift + left click on links in PDF. 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 unified diff | Download patch
« no previous file with comments | « pdf/pdf_engine.h ('k') | pdf/preview_mode_client.h » ('j') | 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 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 int page_index = -1; 1636 int page_index = -1;
1637 int char_index = -1; 1637 int char_index = -1;
1638 int form_type = FPDF_FORMFIELD_UNKNOWN; 1638 int form_type = FPDF_FORMFIELD_UNKNOWN;
1639 PDFiumPage::LinkTarget target; 1639 PDFiumPage::LinkTarget target;
1640 PDFiumPage::Area area = 1640 PDFiumPage::Area area =
1641 GetCharIndex(event, &page_index, &char_index, &form_type, &target); 1641 GetCharIndex(event, &page_index, &char_index, &form_type, &target);
1642 1642
1643 // Open link on mouse up for same link for which mouse down happened earlier. 1643 // Open link on mouse up for same link for which mouse down happened earlier.
1644 if (mouse_down_state_.Matches(area, target)) { 1644 if (mouse_down_state_.Matches(area, target)) {
1645 if (area == PDFiumPage::WEBLINK_AREA) { 1645 if (area == PDFiumPage::WEBLINK_AREA) {
1646 bool open_in_new_tab = !!(event.GetModifiers() & kDefaultKeyModifier) || 1646 uint32_t modifiers = event.GetModifiers();
1647 !!(event.GetModifiers() & PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN); 1647 bool middle_button =
1648 client_->NavigateTo(target.url, open_in_new_tab); 1648 !!(modifiers & PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN);
1649 bool alt_key = !!(modifiers & PP_INPUTEVENT_MODIFIER_ALTKEY);
1650 bool ctrl_key = !!(modifiers & PP_INPUTEVENT_MODIFIER_CONTROLKEY);
1651 bool meta_key = !!(modifiers & PP_INPUTEVENT_MODIFIER_METAKEY);
1652 bool shift_key = !!(modifiers & PP_INPUTEVENT_MODIFIER_SHIFTKEY);
1653
1654 WindowOpenDisposition disposition =
1655 ui::DispositionFromClick(middle_button, alt_key, ctrl_key, meta_key,
1656 shift_key);
1657
1658 client_->NavigateTo(target.url, disposition);
1649 client_->FormTextFieldFocusChange(false); 1659 client_->FormTextFieldFocusChange(false);
1650 return true; 1660 return true;
1651 } 1661 }
1652 } 1662 }
1653 1663
1654 // Prevent middle mouse button from selecting texts. 1664 // Prevent middle mouse button from selecting texts.
1655 if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE) 1665 if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE)
1656 return false; 1666 return false;
1657 1667
1658 if (page_index != -1) { 1668 if (page_index != -1) {
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after
3517 FPDF_WIDESTRING value, 3527 FPDF_WIDESTRING value,
3518 FPDF_DWORD valueLen, 3528 FPDF_DWORD valueLen,
3519 FPDF_BOOL is_focus) { 3529 FPDF_BOOL is_focus) {
3520 // Do nothing for now. 3530 // Do nothing for now.
3521 // TODO(gene): use this signal to trigger OSK. 3531 // TODO(gene): use this signal to trigger OSK.
3522 } 3532 }
3523 3533
3524 void PDFiumEngine::Form_DoURIAction(FPDF_FORMFILLINFO* param, 3534 void PDFiumEngine::Form_DoURIAction(FPDF_FORMFILLINFO* param,
3525 FPDF_BYTESTRING uri) { 3535 FPDF_BYTESTRING uri) {
3526 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); 3536 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
3527 engine->client_->NavigateTo(std::string(uri), false); 3537 engine->client_->NavigateTo(std::string(uri), CURRENT_TAB);
3528 } 3538 }
3529 3539
3530 void PDFiumEngine::Form_DoGoToAction(FPDF_FORMFILLINFO* param, 3540 void PDFiumEngine::Form_DoGoToAction(FPDF_FORMFILLINFO* param,
3531 int page_index, 3541 int page_index,
3532 int zoom_mode, 3542 int zoom_mode,
3533 float* position_array, 3543 float* position_array,
3534 int size_of_array) { 3544 int size_of_array) {
3535 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); 3545 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
3536 engine->client_->ScrollToPage(page_index); 3546 engine->client_->ScrollToPage(page_index);
3537 } 3547 }
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
3908 FPDF_DOCUMENT doc = 3918 FPDF_DOCUMENT doc =
3909 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); 3919 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
3910 if (!doc) 3920 if (!doc)
3911 return false; 3921 return false;
3912 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3922 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3913 FPDF_CloseDocument(doc); 3923 FPDF_CloseDocument(doc);
3914 return success; 3924 return success;
3915 } 3925 }
3916 3926
3917 } // namespace chrome_pdf 3927 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/pdf_engine.h ('k') | pdf/preview_mode_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698