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 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 bool open_in_new_tab = !!(event.GetModifiers() & kDefaultKeyModifier) || |
1647 !!(event.GetModifiers() & PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN); | 1647 !!(event.GetModifiers() & PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN); |
1648 client_->NavigateTo(target.url, open_in_new_tab); | 1648 |
| 1649 bool shift = !!(event.GetModifiers() & PP_INPUTEVENT_MODIFIER_SHIFTKEY); |
| 1650 |
| 1651 PDFEngine::Client::NavigateOption option; |
| 1652 if (open_in_new_tab) { |
| 1653 if (shift) { |
| 1654 option = |
| 1655 PDFEngine::Client::NavigateOption::OPEN_IN_NEW_FOREGROUND_TAB; |
| 1656 } else { |
| 1657 option = |
| 1658 PDFEngine::Client::NavigateOption::OPEN_IN_NEW_BACKGROUND_TAB; |
| 1659 } |
| 1660 } else { |
| 1661 if (shift) |
| 1662 option = PDFEngine::Client::NavigateOption::OPEN_IN_NEW_WINDOW; |
| 1663 else |
| 1664 option = PDFEngine::Client::NavigateOption::OPEN_IN_CURRENT_TAB; |
| 1665 } |
| 1666 |
| 1667 client_->NavigateTo(target.url, option); |
1649 client_->FormTextFieldFocusChange(false); | 1668 client_->FormTextFieldFocusChange(false); |
1650 return true; | 1669 return true; |
1651 } | 1670 } |
1652 } | 1671 } |
1653 | 1672 |
1654 // Prevent middle mouse button from selecting texts. | 1673 // Prevent middle mouse button from selecting texts. |
1655 if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE) | 1674 if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE) |
1656 return false; | 1675 return false; |
1657 | 1676 |
1658 if (page_index != -1) { | 1677 if (page_index != -1) { |
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3517 FPDF_WIDESTRING value, | 3536 FPDF_WIDESTRING value, |
3518 FPDF_DWORD valueLen, | 3537 FPDF_DWORD valueLen, |
3519 FPDF_BOOL is_focus) { | 3538 FPDF_BOOL is_focus) { |
3520 // Do nothing for now. | 3539 // Do nothing for now. |
3521 // TODO(gene): use this signal to trigger OSK. | 3540 // TODO(gene): use this signal to trigger OSK. |
3522 } | 3541 } |
3523 | 3542 |
3524 void PDFiumEngine::Form_DoURIAction(FPDF_FORMFILLINFO* param, | 3543 void PDFiumEngine::Form_DoURIAction(FPDF_FORMFILLINFO* param, |
3525 FPDF_BYTESTRING uri) { | 3544 FPDF_BYTESTRING uri) { |
3526 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); | 3545 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); |
3527 engine->client_->NavigateTo(std::string(uri), false); | 3546 engine->client_->NavigateTo( |
| 3547 std::string(uri), |
| 3548 PDFEngine::Client::NavigateOption::OPEN_IN_CURRENT_TAB); |
3528 } | 3549 } |
3529 | 3550 |
3530 void PDFiumEngine::Form_DoGoToAction(FPDF_FORMFILLINFO* param, | 3551 void PDFiumEngine::Form_DoGoToAction(FPDF_FORMFILLINFO* param, |
3531 int page_index, | 3552 int page_index, |
3532 int zoom_mode, | 3553 int zoom_mode, |
3533 float* position_array, | 3554 float* position_array, |
3534 int size_of_array) { | 3555 int size_of_array) { |
3535 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); | 3556 PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); |
3536 engine->client_->ScrollToPage(page_index); | 3557 engine->client_->ScrollToPage(page_index); |
3537 } | 3558 } |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3908 FPDF_DOCUMENT doc = | 3929 FPDF_DOCUMENT doc = |
3909 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); | 3930 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); |
3910 if (!doc) | 3931 if (!doc) |
3911 return false; | 3932 return false; |
3912 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 3933 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
3913 FPDF_CloseDocument(doc); | 3934 FPDF_CloseDocument(doc); |
3914 return success; | 3935 return success; |
3915 } | 3936 } |
3916 | 3937 |
3917 } // namespace chrome_pdf | 3938 } // namespace chrome_pdf |
OLD | NEW |