OLD | NEW |
---|---|
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 Loading... | |
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); | |
Lei Zhang
2016/07/25 22:10:02
wonky indent
jaepark
2016/07/25 23:24:13
Done.
| |
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 Loading... | |
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 Loading... | |
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 |
OLD | NEW |