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

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: 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
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 NavigateOption option = OPEN_IN_CURRENT_TAB;
Lei Zhang 2016/07/21 05:34:28 No need to initialize since all the cases are cove
jaepark 2016/07/21 22:34:33 Done.
1647 bool ctrl = !!(event.GetModifiers() & kDefaultKeyModifier) ||
Lei Zhang 2016/07/21 05:34:28 Maybe control can stay as open_in_new_tab?
jaepark 2016/07/21 22:34:33 Done.
1647 !!(event.GetModifiers() & PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN); 1648 !!(event.GetModifiers() & PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN);
1648 client_->NavigateTo(target.url, open_in_new_tab); 1649
1650 bool shift = !!(event.GetModifiers() & PP_INPUTEVENT_MODIFIER_SHIFTKEY);
1651
1652 if (ctrl) {
1653 if (shift)
1654 option = OPEN_IN_NEW_FOREGROUND_TAB;
1655 else
1656 option = OPEN_IN_NEW_BACKGROUND_TAB;
1657 } else {
1658 if (shift)
1659 option = OPEN_IN_NEW_WINDOW;
1660 else
1661 option = OPEN_IN_CURRENT_TAB;
1662 }
1663
1664 client_->NavigateTo(target.url, option);
1649 client_->FormTextFieldFocusChange(false); 1665 client_->FormTextFieldFocusChange(false);
1650 return true; 1666 return true;
1651 } 1667 }
1652 } 1668 }
1653 1669
1654 // Prevent middle mouse button from selecting texts. 1670 // Prevent middle mouse button from selecting texts.
1655 if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE) 1671 if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE)
1656 return false; 1672 return false;
1657 1673
1658 if (page_index != -1) { 1674 if (page_index != -1) {
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after
3517 FPDF_WIDESTRING value, 3533 FPDF_WIDESTRING value,
3518 FPDF_DWORD valueLen, 3534 FPDF_DWORD valueLen,
3519 FPDF_BOOL is_focus) { 3535 FPDF_BOOL is_focus) {
3520 // Do nothing for now. 3536 // Do nothing for now.
3521 // TODO(gene): use this signal to trigger OSK. 3537 // TODO(gene): use this signal to trigger OSK.
3522 } 3538 }
3523 3539
3524 void PDFiumEngine::Form_DoURIAction(FPDF_FORMFILLINFO* param, 3540 void PDFiumEngine::Form_DoURIAction(FPDF_FORMFILLINFO* param,
3525 FPDF_BYTESTRING uri) { 3541 FPDF_BYTESTRING uri) {
3526 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); 3542 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
3527 engine->client_->NavigateTo(std::string(uri), false); 3543 engine->client_->NavigateTo(std::string(uri), OPEN_IN_CURRENT_TAB);
3528 } 3544 }
3529 3545
3530 void PDFiumEngine::Form_DoGoToAction(FPDF_FORMFILLINFO* param, 3546 void PDFiumEngine::Form_DoGoToAction(FPDF_FORMFILLINFO* param,
3531 int page_index, 3547 int page_index,
3532 int zoom_mode, 3548 int zoom_mode,
3533 float* position_array, 3549 float* position_array,
3534 int size_of_array) { 3550 int size_of_array) {
3535 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); 3551 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param);
3536 engine->client_->ScrollToPage(page_index); 3552 engine->client_->ScrollToPage(page_index);
3537 } 3553 }
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
3908 FPDF_DOCUMENT doc = 3924 FPDF_DOCUMENT doc =
3909 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); 3925 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
3910 if (!doc) 3926 if (!doc)
3911 return false; 3927 return false;
3912 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3928 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3913 FPDF_CloseDocument(doc); 3929 FPDF_CloseDocument(doc);
3914 return success; 3930 return success;
3915 } 3931 }
3916 3932
3917 } // namespace chrome_pdf 3933 } // namespace chrome_pdf
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698