OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2010 Igalia S.L | 3 * Copyright (C) 2010 Igalia S.L |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 if (!node) | 537 if (!node) |
538 return; | 538 return; |
539 Frame* frame = node->document()->frame(); | 539 Frame* frame = node->document()->frame(); |
540 if (!frame) | 540 if (!frame) |
541 return; | 541 return; |
542 | 542 |
543 if (!m_hitTestResult.isContentEditable()) { | 543 if (!m_hitTestResult.isContentEditable()) { |
544 FrameLoader* loader = frame->loader(); | 544 FrameLoader* loader = frame->loader(); |
545 KURL linkURL = m_hitTestResult.absoluteLinkURL(); | 545 KURL linkURL = m_hitTestResult.absoluteLinkURL(); |
546 if (!linkURL.isEmpty()) { | 546 if (!linkURL.isEmpty()) { |
547 appendItem(OpenLinkItem, m_contextMenu.get()); | 547 if (loader->client()->canHandleRequest(ResourceRequest(linkURL))) { |
548 appendItem(OpenLinkInNewWindowItem, m_contextMenu.get()); | 548 appendItem(OpenLinkItem, m_contextMenu.get()); |
549 appendItem(DownloadFileItem, m_contextMenu.get()); | 549 appendItem(OpenLinkInNewWindowItem, m_contextMenu.get()); |
| 550 appendItem(DownloadFileItem, m_contextMenu.get()); |
| 551 } |
550 appendItem(CopyLinkItem, m_contextMenu.get()); | 552 appendItem(CopyLinkItem, m_contextMenu.get()); |
551 } | 553 } |
552 | 554 |
553 KURL imageURL = m_hitTestResult.absoluteImageURL(); | 555 KURL imageURL = m_hitTestResult.absoluteImageURL(); |
554 if (!imageURL.isEmpty()) { | 556 if (!imageURL.isEmpty()) { |
555 if (!linkURL.isEmpty()) | 557 if (!linkURL.isEmpty()) |
556 appendItem(*separatorItem(), m_contextMenu.get()); | 558 appendItem(*separatorItem(), m_contextMenu.get()); |
557 | 559 |
558 appendItem(OpenImageInNewWindowItem, m_contextMenu.get()); | 560 appendItem(OpenImageInNewWindowItem, m_contextMenu.get()); |
559 appendItem(DownloadImageItem, m_contextMenu.get()); | 561 appendItem(DownloadImageItem, m_contextMenu.get()); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 if (!dictationAlternatives.isEmpty()) { | 654 if (!dictationAlternatives.isEmpty()) { |
653 for (size_t i = 0; i < dictationAlternatives.size(); ++i) { | 655 for (size_t i = 0; i < dictationAlternatives.size(); ++i) { |
654 ContextMenuItem item(ActionType, ContextMenuItemTagDicta
tionAlternative, dictationAlternatives[i]); | 656 ContextMenuItem item(ActionType, ContextMenuItemTagDicta
tionAlternative, dictationAlternatives[i]); |
655 appendItem(item, m_contextMenu.get()); | 657 appendItem(item, m_contextMenu.get()); |
656 } | 658 } |
657 appendItem(*separatorItem(), m_contextMenu.get()); | 659 appendItem(*separatorItem(), m_contextMenu.get()); |
658 } | 660 } |
659 } | 661 } |
660 } | 662 } |
661 | 663 |
| 664 FrameLoader* loader = frame->loader(); |
662 KURL linkURL = m_hitTestResult.absoluteLinkURL(); | 665 KURL linkURL = m_hitTestResult.absoluteLinkURL(); |
663 if (!linkURL.isEmpty()) { | 666 if (!linkURL.isEmpty()) { |
664 appendItem(OpenLinkItem, m_contextMenu.get()); | 667 if (loader->client()->canHandleRequest(ResourceRequest(linkURL))) { |
665 appendItem(OpenLinkInNewWindowItem, m_contextMenu.get()); | 668 appendItem(OpenLinkItem, m_contextMenu.get()); |
666 appendItem(DownloadFileItem, m_contextMenu.get()); | 669 appendItem(OpenLinkInNewWindowItem, m_contextMenu.get()); |
| 670 appendItem(DownloadFileItem, m_contextMenu.get()); |
| 671 } |
667 appendItem(CopyLinkItem, m_contextMenu.get()); | 672 appendItem(CopyLinkItem, m_contextMenu.get()); |
668 appendItem(*separatorItem(), m_contextMenu.get()); | 673 appendItem(*separatorItem(), m_contextMenu.get()); |
669 } | 674 } |
670 | 675 |
671 if (m_hitTestResult.isSelected() && !inPasswordField && selectionContain
sPossibleWord(frame)) { | 676 if (m_hitTestResult.isSelected() && !inPasswordField && selectionContain
sPossibleWord(frame)) { |
672 appendItem(SearchWebItem, m_contextMenu.get()); | 677 appendItem(SearchWebItem, m_contextMenu.get()); |
673 appendItem(*separatorItem(), m_contextMenu.get()); | 678 appendItem(*separatorItem(), m_contextMenu.get()); |
674 } | 679 } |
675 | 680 |
676 appendItem(CutItem, m_contextMenu.get()); | 681 appendItem(CutItem, m_contextMenu.get()); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 { | 931 { |
927 // Simulate a click in the middle of the accessibility object. | 932 // Simulate a click in the middle of the accessibility object. |
928 PlatformMouseEvent mouseEvent(clickPoint, clickPoint, RightButton, PlatformE
vent::MousePressed, 1, false, false, false, false, currentTime()); | 933 PlatformMouseEvent mouseEvent(clickPoint, clickPoint, RightButton, PlatformE
vent::MousePressed, 1, false, false, false, false, currentTime()); |
929 bool handled = frame->eventHandler()->sendContextMenuEvent(mouseEvent); | 934 bool handled = frame->eventHandler()->sendContextMenuEvent(mouseEvent); |
930 if (handled && client()) | 935 if (handled && client()) |
931 client()->showContextMenu(); | 936 client()->showContextMenu(); |
932 } | 937 } |
933 #endif | 938 #endif |
934 | 939 |
935 } // namespace WebCore | 940 } // namespace WebCore |
OLD | NEW |