OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 PageWidgetEventHandler::handleMouseUp(mainFrame, event); | 624 PageWidgetEventHandler::handleMouseUp(mainFrame, event); |
625 | 625 |
626 if (page()->settings().showContextMenuOnMouseUp()) { | 626 if (page()->settings().showContextMenuOnMouseUp()) { |
627 // Dispatch the contextmenu event regardless of if the click was swallow
ed. | 627 // Dispatch the contextmenu event regardless of if the click was swallow
ed. |
628 // On Mac/Linux, we handle it on mouse down, not up. | 628 // On Mac/Linux, we handle it on mouse down, not up. |
629 if (event.button == WebMouseEvent::ButtonRight) | 629 if (event.button == WebMouseEvent::ButtonRight) |
630 mouseContextMenu(event); | 630 mouseContextMenu(event); |
631 } | 631 } |
632 } | 632 } |
633 | 633 |
634 bool WebViewImpl::handleMouseWheel(LocalFrame& mainFrame, const WebMouseWheelEve
nt& event) | 634 WebInputEventResult WebViewImpl::handleMouseWheel(LocalFrame& mainFrame, const W
ebMouseWheelEvent& event) |
635 { | 635 { |
636 hidePopups(); | 636 hidePopups(); |
637 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); | 637 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); |
638 } | 638 } |
639 | 639 |
640 bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& veloci
ty) | 640 bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& veloci
ty) |
641 { | 641 { |
642 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized); | 642 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized); |
643 if (m_flingSourceDevice == WebGestureDeviceTouchpad) { | 643 if (m_flingSourceDevice == WebGestureDeviceTouchpad) { |
644 WebMouseWheelEvent syntheticWheel; | 644 WebMouseWheelEvent syntheticWheel; |
645 const float tickDivisor = WheelEvent::TickMultiplier; | 645 const float tickDivisor = WheelEvent::TickMultiplier; |
646 | 646 |
647 syntheticWheel.deltaX = delta.width; | 647 syntheticWheel.deltaX = delta.width; |
648 syntheticWheel.deltaY = delta.height; | 648 syntheticWheel.deltaY = delta.height; |
649 syntheticWheel.wheelTicksX = delta.width / tickDivisor; | 649 syntheticWheel.wheelTicksX = delta.width / tickDivisor; |
650 syntheticWheel.wheelTicksY = delta.height / tickDivisor; | 650 syntheticWheel.wheelTicksY = delta.height / tickDivisor; |
651 syntheticWheel.hasPreciseScrollingDeltas = true; | 651 syntheticWheel.hasPreciseScrollingDeltas = true; |
652 syntheticWheel.x = m_positionOnFlingStart.x; | 652 syntheticWheel.x = m_positionOnFlingStart.x; |
653 syntheticWheel.y = m_positionOnFlingStart.y; | 653 syntheticWheel.y = m_positionOnFlingStart.y; |
654 syntheticWheel.globalX = m_globalPositionOnFlingStart.x; | 654 syntheticWheel.globalX = m_globalPositionOnFlingStart.x; |
655 syntheticWheel.globalY = m_globalPositionOnFlingStart.y; | 655 syntheticWheel.globalY = m_globalPositionOnFlingStart.y; |
656 syntheticWheel.modifiers = m_flingModifier; | 656 syntheticWheel.modifiers = m_flingModifier; |
657 | 657 |
658 if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame()
&& m_page->deprecatedLocalMainFrame()->view()) | 658 if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame()
&& m_page->deprecatedLocalMainFrame()->view()) |
659 return handleMouseWheel(*m_page->deprecatedLocalMainFrame(), synthet
icWheel); | 659 return handleMouseWheel(*m_page->deprecatedLocalMainFrame(), synthet
icWheel) != WebInputEventResult::NotHandled; |
660 } else { | 660 } else { |
661 WebGestureEvent syntheticGestureEvent; | 661 WebGestureEvent syntheticGestureEvent; |
662 | 662 |
663 syntheticGestureEvent.type = WebInputEvent::GestureScrollUpdate; | 663 syntheticGestureEvent.type = WebInputEvent::GestureScrollUpdate; |
664 syntheticGestureEvent.data.scrollUpdate.preventPropagation = true; | 664 syntheticGestureEvent.data.scrollUpdate.preventPropagation = true; |
665 syntheticGestureEvent.data.scrollUpdate.deltaX = delta.width; | 665 syntheticGestureEvent.data.scrollUpdate.deltaX = delta.width; |
666 syntheticGestureEvent.data.scrollUpdate.deltaY = delta.height; | 666 syntheticGestureEvent.data.scrollUpdate.deltaY = delta.height; |
667 syntheticGestureEvent.data.scrollUpdate.velocityX = velocity.width; | 667 syntheticGestureEvent.data.scrollUpdate.velocityX = velocity.width; |
668 syntheticGestureEvent.data.scrollUpdate.velocityY = velocity.height; | 668 syntheticGestureEvent.data.scrollUpdate.velocityY = velocity.height; |
669 syntheticGestureEvent.x = m_positionOnFlingStart.x; | 669 syntheticGestureEvent.x = m_positionOnFlingStart.x; |
670 syntheticGestureEvent.y = m_positionOnFlingStart.y; | 670 syntheticGestureEvent.y = m_positionOnFlingStart.y; |
671 syntheticGestureEvent.globalX = m_globalPositionOnFlingStart.x; | 671 syntheticGestureEvent.globalX = m_globalPositionOnFlingStart.x; |
672 syntheticGestureEvent.globalY = m_globalPositionOnFlingStart.y; | 672 syntheticGestureEvent.globalY = m_globalPositionOnFlingStart.y; |
673 syntheticGestureEvent.modifiers = m_flingModifier; | 673 syntheticGestureEvent.modifiers = m_flingModifier; |
674 syntheticGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 674 syntheticGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
675 syntheticGestureEvent.data.scrollUpdate.inertial = true; | 675 syntheticGestureEvent.data.scrollUpdate.inertial = true; |
676 | 676 |
677 if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame()
&& m_page->deprecatedLocalMainFrame()->view()) | 677 if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame()
&& m_page->deprecatedLocalMainFrame()->view()) |
678 return handleGestureEvent(syntheticGestureEvent); | 678 return handleGestureEvent(syntheticGestureEvent) != WebInputEventRes
ult::NotHandled; |
679 } | 679 } |
680 return false; | 680 return false; |
681 } | 681 } |
682 | 682 |
683 bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) | 683 WebInputEventResult WebViewImpl::handleGestureEvent(const WebGestureEvent& event
) |
684 { | 684 { |
685 if (!m_client) | 685 if (!m_client) |
686 return false; | 686 return WebInputEventResult::NotHandled; |
687 | 687 |
688 bool eventSwallowed = false; | 688 WebInputEventResult eventResult = WebInputEventResult::NotHandled; |
689 bool eventCancelled = false; // for disambiguation | 689 bool eventCancelled = false; // for disambiguation |
690 | 690 |
691 // Special handling for slow-path fling gestures. | 691 // Special handling for slow-path fling gestures. |
692 switch (event.type) { | 692 switch (event.type) { |
693 case WebInputEvent::GestureFlingStart: { | 693 case WebInputEvent::GestureFlingStart: { |
694 if (mainFrameImpl()->frame()->eventHandler().isScrollbarHandlingGestures
()) | 694 if (mainFrameImpl()->frame()->eventHandler().isScrollbarHandlingGestures
()) |
695 break; | 695 break; |
696 endActiveFlingAnimation(); | 696 endActiveFlingAnimation(); |
697 m_client->cancelScheduledContentIntents(); | 697 m_client->cancelScheduledContentIntents(); |
698 m_positionOnFlingStart = WebPoint(event.x, event.y); | 698 m_positionOnFlingStart = WebPoint(event.x, event.y); |
699 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY); | 699 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY); |
700 m_flingModifier = event.modifiers; | 700 m_flingModifier = event.modifiers; |
701 m_flingSourceDevice = event.sourceDevice; | 701 m_flingSourceDevice = event.sourceDevice; |
702 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized); | 702 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized); |
703 OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->creat
eFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.vel
ocityX, event.data.flingStart.velocityY), WebSize())); | 703 OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->creat
eFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.vel
ocityX, event.data.flingStart.velocityY), WebSize())); |
704 ASSERT(flingCurve); | 704 ASSERT(flingCurve); |
705 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(f
lingCurve.release(), this); | 705 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(f
lingCurve.release(), this); |
706 scheduleAnimation(); | 706 scheduleAnimation(); |
707 eventSwallowed = true; | 707 eventResult = WebInputEventResult::HandledSystem; |
708 | 708 |
709 // Plugins may need to see GestureFlingStart to balance | 709 // Plugins may need to see GestureFlingStart to balance |
710 // GestureScrollBegin (since the former replaces GestureScrollEnd when | 710 // GestureScrollBegin (since the former replaces GestureScrollEnd when |
711 // transitioning to a fling). | 711 // transitioning to a fling). |
712 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(),
event); | 712 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(),
event); |
| 713 // TODO(dtapuska): Why isn't the response used? |
713 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEvent(platfo
rmEvent); | 714 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEvent(platfo
rmEvent); |
714 | 715 |
715 m_client->didHandleGestureEvent(event, eventCancelled); | 716 m_client->didHandleGestureEvent(event, eventCancelled); |
716 return eventSwallowed; | 717 return WebInputEventResult::HandledSystem; |
717 } | 718 } |
718 case WebInputEvent::GestureFlingCancel: | 719 case WebInputEvent::GestureFlingCancel: |
719 if (endActiveFlingAnimation()) | 720 if (endActiveFlingAnimation()) |
720 eventSwallowed = true; | 721 eventResult = WebInputEventResult::HandledSuppressed; |
721 | 722 |
722 m_client->didHandleGestureEvent(event, eventCancelled); | 723 m_client->didHandleGestureEvent(event, eventCancelled); |
723 return eventSwallowed; | 724 return eventResult; |
724 default: | 725 default: |
725 break; | 726 break; |
726 } | 727 } |
727 | 728 |
728 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even
t); | 729 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even
t); |
729 | 730 |
730 // Special handling for double tap and scroll events as we don't want to | 731 // Special handling for double tap and scroll events as we don't want to |
731 // hit test for them. | 732 // hit test for them. |
732 switch (event.type) { | 733 switch (event.type) { |
733 case WebInputEvent::GestureDoubleTap: | 734 case WebInputEvent::GestureDoubleTap: |
734 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor()
!= maximumPageScaleFactor()) { | 735 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor()
!= maximumPageScaleFactor()) { |
735 m_client->cancelScheduledContentIntents(); | 736 m_client->cancelScheduledContentIntents(); |
736 animateDoubleTapZoom(platformEvent.position()); | 737 animateDoubleTapZoom(platformEvent.position()); |
737 } | 738 } |
738 // GestureDoubleTap is currently only used by Android for zooming. For W
ebCore, | 739 // GestureDoubleTap is currently only used by Android for zooming. For W
ebCore, |
739 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub
leTap here. | 740 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub
leTap here. |
740 eventSwallowed = true; | 741 eventResult = WebInputEventResult::HandledSystem; |
741 m_client->didHandleGestureEvent(event, eventCancelled); | 742 m_client->didHandleGestureEvent(event, eventCancelled); |
742 return eventSwallowed; | 743 return eventResult; |
743 case WebInputEvent::GestureScrollBegin: | 744 case WebInputEvent::GestureScrollBegin: |
744 m_client->cancelScheduledContentIntents(); | 745 m_client->cancelScheduledContentIntents(); |
745 case WebInputEvent::GestureScrollEnd: | 746 case WebInputEvent::GestureScrollEnd: |
746 case WebInputEvent::GestureScrollUpdate: | 747 case WebInputEvent::GestureScrollUpdate: |
747 case WebInputEvent::GestureFlingStart: | 748 case WebInputEvent::GestureFlingStart: |
748 // Scrolling-related gesture events invoke EventHandler recursively for
each frame down | 749 // Scrolling-related gesture events invoke EventHandler recursively for
each frame down |
749 // the chain, doing a single-frame hit-test per frame. This matches hand
leWheelEvent. | 750 // the chain, doing a single-frame hit-test per frame. This matches hand
leWheelEvent. |
750 // Perhaps we could simplify things by rewriting scroll handling to work
inner frame | 751 // Perhaps we could simplify things by rewriting scroll handling to work
inner frame |
751 // out, and then unify with other gesture events. | 752 // out, and then unify with other gesture events. |
752 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureS
crollEvent(platformEvent); | 753 eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureScro
llEvent(platformEvent); |
753 m_client->didHandleGestureEvent(event, eventCancelled); | 754 m_client->didHandleGestureEvent(event, eventCancelled); |
754 return eventSwallowed; | 755 return eventResult; |
755 case WebInputEvent::GesturePinchBegin: | 756 case WebInputEvent::GesturePinchBegin: |
756 case WebInputEvent::GesturePinchEnd: | 757 case WebInputEvent::GesturePinchEnd: |
757 case WebInputEvent::GesturePinchUpdate: | 758 case WebInputEvent::GesturePinchUpdate: |
758 return false; | 759 return WebInputEventResult::NotHandled; |
759 default: | 760 default: |
760 break; | 761 break; |
761 } | 762 } |
762 | 763 |
763 // Hit test across all frames and do touch adjustment as necessary for the e
vent type. | 764 // Hit test across all frames and do touch adjustment as necessary for the e
vent type. |
764 GestureEventWithHitTestResults targetedEvent = | 765 GestureEventWithHitTestResults targetedEvent = |
765 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(pl
atformEvent); | 766 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(pl
atformEvent); |
766 | 767 |
767 // Handle link highlighting outside the main switch to avoid getting lost in
the | 768 // Handle link highlighting outside the main switch to avoid getting lost in
the |
768 // complicated set of cases handled below. | 769 // complicated set of cases handled below. |
(...skipping 16 matching lines...) Expand all Loading... |
785 case WebInputEvent::GestureTap: { | 786 case WebInputEvent::GestureTap: { |
786 // If there is a popup open, close it as the user is clicking on the pag
e | 787 // If there is a popup open, close it as the user is clicking on the pag
e |
787 // (outside of the popup). We also save it so we can prevent a tap on an | 788 // (outside of the popup). We also save it so we can prevent a tap on an |
788 // element from immediately reopening the same popup. | 789 // element from immediately reopening the same popup. |
789 RefPtr<WebPagePopupImpl> pagePopup = m_pagePopup; | 790 RefPtr<WebPagePopupImpl> pagePopup = m_pagePopup; |
790 hidePopups(); | 791 hidePopups(); |
791 ASSERT(!m_pagePopup); | 792 ASSERT(!m_pagePopup); |
792 | 793 |
793 m_client->cancelScheduledContentIntents(); | 794 m_client->cancelScheduledContentIntents(); |
794 if (detectContentOnTouch(targetedEvent)) { | 795 if (detectContentOnTouch(targetedEvent)) { |
795 eventSwallowed = true; | 796 eventResult = WebInputEventResult::HandledSystem; |
796 break; | 797 break; |
797 } | 798 } |
798 | 799 |
799 // Don't trigger a disambiguation popup on sites designed for mobile dev
ices. | 800 // Don't trigger a disambiguation popup on sites designed for mobile dev
ices. |
800 // Instead, assume that the page has been designed with big enough butto
ns and links. | 801 // Instead, assume that the page has been designed with big enough butto
ns and links. |
801 // Don't trigger a disambiguation popup when screencasting, since it's i
mplemented outside of | 802 // Don't trigger a disambiguation popup when screencasting, since it's i
mplemented outside of |
802 // compositor pipeline and is not being screencasted itself. This leads
to bad user experience. | 803 // compositor pipeline and is not being screencasted itself. This leads
to bad user experience. |
803 WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl(); | 804 WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl(); |
804 VisualViewport& visualViewport = page()->frameHost().visualViewport(); | 805 VisualViewport& visualViewport = page()->frameHost().visualViewport(); |
805 bool screencastEnabled = devTools && devTools->screencastEnabled(); | 806 bool screencastEnabled = devTools && devTools->screencastEnabled(); |
(...skipping 13 matching lines...) Expand all Loading... |
819 WillBeHeapVector<RawPtrWillBeMember<Node>> highlightNodes; | 820 WillBeHeapVector<RawPtrWillBeMember<Node>> highlightNodes; |
820 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), good
Targets, highlightNodes); | 821 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), good
Targets, highlightNodes); |
821 // FIXME: replace touch adjustment code when numberOfGoodTargets
== 1? | 822 // FIXME: replace touch adjustment code when numberOfGoodTargets
== 1? |
822 // Single candidate case is currently handled by: https://bugs.w
ebkit.org/show_bug.cgi?id=85101 | 823 // Single candidate case is currently handled by: https://bugs.w
ebkit.org/show_bug.cgi?id=85101 |
823 if (goodTargets.size() >= 2 && m_client | 824 if (goodTargets.size() >= 2 && m_client |
824 && m_client->didTapMultipleTargets(visualViewportOffset, bou
ndingBox, goodTargets)) { | 825 && m_client->didTapMultipleTargets(visualViewportOffset, bou
ndingBox, goodTargets)) { |
825 | 826 |
826 enableTapHighlights(highlightNodes); | 827 enableTapHighlights(highlightNodes); |
827 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 828 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
828 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); | 829 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); |
829 eventSwallowed = true; | 830 eventResult = WebInputEventResult::HandledSystem; |
830 eventCancelled = true; | 831 eventCancelled = true; |
831 break; | 832 break; |
832 } | 833 } |
833 } | 834 } |
834 } | 835 } |
835 | 836 |
836 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE
vent(targetedEvent); | 837 eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEven
t(targetedEvent); |
837 | 838 |
838 if (m_pagePopup && pagePopup && m_pagePopup->hasSamePopupClient(pagePopu
p.get())) { | 839 if (m_pagePopup && pagePopup && m_pagePopup->hasSamePopupClient(pagePopu
p.get())) { |
839 // The tap triggered a page popup that is the same as the one we jus
t closed. | 840 // The tap triggered a page popup that is the same as the one we jus
t closed. |
840 // It needs to be closed. | 841 // It needs to be closed. |
841 cancelPagePopup(); | 842 cancelPagePopup(); |
842 } | 843 } |
843 break; | 844 break; |
844 } | 845 } |
845 case WebInputEvent::GestureTwoFingerTap: | 846 case WebInputEvent::GestureTwoFingerTap: |
846 case WebInputEvent::GestureLongPress: | 847 case WebInputEvent::GestureLongPress: |
847 case WebInputEvent::GestureLongTap: { | 848 case WebInputEvent::GestureLongTap: { |
848 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 849 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
849 break; | 850 break; |
850 | 851 |
851 m_client->cancelScheduledContentIntents(); | 852 m_client->cancelScheduledContentIntents(); |
852 m_page->contextMenuController().clearContextMenu(); | 853 m_page->contextMenuController().clearContextMenu(); |
853 { | 854 { |
854 ContextMenuAllowedScope scope; | 855 ContextMenuAllowedScope scope; |
855 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGest
ureEvent(targetedEvent); | 856 eventResult = mainFrameImpl()->frame()->eventHandler().handleGesture
Event(targetedEvent); |
856 } | 857 } |
857 | 858 |
858 break; | 859 break; |
859 } | 860 } |
860 case WebInputEvent::GestureShowPress: | 861 case WebInputEvent::GestureShowPress: |
861 m_client->cancelScheduledContentIntents(); | 862 m_client->cancelScheduledContentIntents(); |
862 case WebInputEvent::GestureTapDown: | 863 case WebInputEvent::GestureTapDown: |
863 case WebInputEvent::GestureTapCancel: | 864 case WebInputEvent::GestureTapCancel: |
864 case WebInputEvent::GestureTapUnconfirmed: { | 865 case WebInputEvent::GestureTapUnconfirmed: { |
865 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE
vent(targetedEvent); | 866 eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEven
t(targetedEvent); |
866 break; | 867 break; |
867 } | 868 } |
868 default: | 869 default: |
869 ASSERT_NOT_REACHED(); | 870 ASSERT_NOT_REACHED(); |
870 } | 871 } |
871 m_client->didHandleGestureEvent(event, eventCancelled); | 872 m_client->didHandleGestureEvent(event, eventCancelled); |
872 return eventSwallowed; | 873 return eventResult; |
873 } | 874 } |
874 | 875 |
875 bool WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent(const WebGestureEve
nt& pinchEvent) | 876 WebInputEventResult WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent(cons
t WebGestureEvent& pinchEvent) |
876 { | 877 { |
877 ASSERT(pinchEvent.type == WebInputEvent::GesturePinchUpdate); | 878 ASSERT(pinchEvent.type == WebInputEvent::GesturePinchUpdate); |
878 | 879 |
879 // Touchscreen pinch events should not reach Blink. | 880 // Touchscreen pinch events should not reach Blink. |
880 ASSERT(pinchEvent.sourceDevice == WebGestureDeviceTouchpad); | 881 ASSERT(pinchEvent.sourceDevice == WebGestureDeviceTouchpad); |
881 | 882 |
882 // For pinch gesture events, match typical trackpad behavior on Windows by s
ending fake | 883 // For pinch gesture events, match typical trackpad behavior on Windows by s
ending fake |
883 // wheel events with the ctrl modifier set when we see trackpad pinch gestur
es. Ideally | 884 // wheel events with the ctrl modifier set when we see trackpad pinch gestur
es. Ideally |
884 // we'd someday get a platform 'pinch' event and send that instead. | 885 // we'd someday get a platform 'pinch' event and send that instead. |
885 WebMouseWheelEvent wheelEvent; | 886 WebMouseWheelEvent wheelEvent; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 } | 1015 } |
1015 | 1016 |
1016 void WebViewImpl::acceptLanguagesChanged() | 1017 void WebViewImpl::acceptLanguagesChanged() |
1017 { | 1018 { |
1018 if (!page()) | 1019 if (!page()) |
1019 return; | 1020 return; |
1020 | 1021 |
1021 page()->acceptLanguagesChanged(); | 1022 page()->acceptLanguagesChanged(); |
1022 } | 1023 } |
1023 | 1024 |
1024 bool WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event) | 1025 WebInputEventResult WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event) |
1025 { | 1026 { |
1026 ASSERT((event.type == WebInputEvent::RawKeyDown) | 1027 ASSERT((event.type == WebInputEvent::RawKeyDown) |
1027 || (event.type == WebInputEvent::KeyDown) | 1028 || (event.type == WebInputEvent::KeyDown) |
1028 || (event.type == WebInputEvent::KeyUp)); | 1029 || (event.type == WebInputEvent::KeyUp)); |
1029 TRACE_EVENT2("input", "WebViewImpl::handleKeyEvent", | 1030 TRACE_EVENT2("input", "WebViewImpl::handleKeyEvent", |
1030 "type", inputTypeToName(event.type), | 1031 "type", inputTypeToName(event.type), |
1031 "text", String(event.text).utf8()); | 1032 "text", String(event.text).utf8()); |
1032 | 1033 |
1033 // Halt an in-progress fling on a key event. | 1034 // Halt an in-progress fling on a key event. |
1034 endActiveFlingAnimation(); | 1035 endActiveFlingAnimation(); |
1035 | 1036 |
1036 // Please refer to the comments explaining the m_suppressNextKeypressEvent | 1037 // Please refer to the comments explaining the m_suppressNextKeypressEvent |
1037 // member. | 1038 // member. |
1038 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by | 1039 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by |
1039 // Webkit. A keyDown event is typically associated with a keyPress(char) | 1040 // Webkit. A keyDown event is typically associated with a keyPress(char) |
1040 // event and a keyUp event. We reset this flag here as this is a new keyDown | 1041 // event and a keyUp event. We reset this flag here as this is a new keyDown |
1041 // event. | 1042 // event. |
1042 m_suppressNextKeypressEvent = false; | 1043 m_suppressNextKeypressEvent = false; |
1043 | 1044 |
1044 // If there is a popup, it should be the one processing the event, not the | 1045 // If there is a popup, it should be the one processing the event, not the |
1045 // page. | 1046 // page. |
1046 if (m_pagePopup) { | 1047 if (m_pagePopup) { |
1047 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); | 1048 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); |
1048 // We need to ignore the next Char event after this otherwise pressing | 1049 // We need to ignore the next Char event after this otherwise pressing |
1049 // enter when selecting an item in the popup will go to the page. | 1050 // enter when selecting an item in the popup will go to the page. |
1050 if (WebInputEvent::RawKeyDown == event.type) | 1051 if (WebInputEvent::RawKeyDown == event.type) |
1051 m_suppressNextKeypressEvent = true; | 1052 m_suppressNextKeypressEvent = true; |
1052 return true; | 1053 return WebInputEventResult::HandledSystem; |
1053 } | 1054 } |
1054 | 1055 |
1055 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame(); | 1056 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame(); |
1056 if (focusedFrame && focusedFrame->isRemoteFrame()) { | 1057 if (focusedFrame && focusedFrame->isRemoteFrame()) { |
1057 WebRemoteFrameImpl* webFrame = WebRemoteFrameImpl::fromFrame(*toRemoteFr
ame(focusedFrame.get())); | 1058 WebRemoteFrameImpl* webFrame = WebRemoteFrameImpl::fromFrame(*toRemoteFr
ame(focusedFrame.get())); |
1058 webFrame->client()->forwardInputEvent(&event); | 1059 webFrame->client()->forwardInputEvent(&event); |
1059 return true; | 1060 return WebInputEventResult::HandledSystem; |
1060 } | 1061 } |
1061 | 1062 |
1062 if (!focusedFrame || !focusedFrame->isLocalFrame()) | 1063 if (!focusedFrame || !focusedFrame->isLocalFrame()) |
1063 return false; | 1064 return WebInputEventResult::NotHandled; |
1064 | 1065 |
1065 LocalFrame* frame = toLocalFrame(focusedFrame.get()); | 1066 LocalFrame* frame = toLocalFrame(focusedFrame.get()); |
1066 | 1067 |
1067 PlatformKeyboardEventBuilder evt(event); | 1068 PlatformKeyboardEventBuilder evt(event); |
1068 | 1069 |
1069 if (frame->eventHandler().keyEvent(evt)) { | 1070 WebInputEventResult result = frame->eventHandler().keyEvent(evt); |
| 1071 if (result != WebInputEventResult::NotHandled) { |
1070 if (WebInputEvent::RawKeyDown == event.type) { | 1072 if (WebInputEvent::RawKeyDown == event.type) { |
1071 // Suppress the next keypress event unless the focused node is a plu
gin node. | 1073 // Suppress the next keypress event unless the focused node is a plu
gin node. |
1072 // (Flash needs these keypress events to handle non-US keyboards.) | 1074 // (Flash needs these keypress events to handle non-US keyboards.) |
1073 Element* element = focusedElement(); | 1075 Element* element = focusedElement(); |
1074 if (element && element->layoutObject() && element->layoutObject()->i
sEmbeddedObject()) { | 1076 if (element && element->layoutObject() && element->layoutObject()->i
sEmbeddedObject()) { |
1075 if (event.windowsKeyCode == VKEY_TAB) { | 1077 if (event.windowsKeyCode == VKEY_TAB) { |
1076 // If the plugin supports keyboard focus then we should not
send a tab keypress event. | 1078 // If the plugin supports keyboard focus then we should not
send a tab keypress event. |
1077 Widget* widget = toLayoutPart(element->layoutObject())->widg
et(); | 1079 Widget* widget = toLayoutPart(element->layoutObject())->widg
et(); |
1078 if (widget && widget->isPluginContainer()) { | 1080 if (widget && widget->isPluginContainer()) { |
1079 WebPluginContainerImpl* plugin = toWebPluginContainerImp
l(widget); | 1081 WebPluginContainerImpl* plugin = toWebPluginContainerImp
l(widget); |
1080 if (plugin && plugin->supportsKeyboardFocus()) | 1082 if (plugin && plugin->supportsKeyboardFocus()) |
1081 m_suppressNextKeypressEvent = true; | 1083 m_suppressNextKeypressEvent = true; |
1082 } | 1084 } |
1083 } | 1085 } |
1084 } else { | 1086 } else { |
1085 m_suppressNextKeypressEvent = true; | 1087 m_suppressNextKeypressEvent = true; |
1086 } | 1088 } |
1087 } | 1089 } |
1088 return true; | 1090 return result; |
1089 } | 1091 } |
1090 | 1092 |
1091 #if !OS(MACOSX) | 1093 #if !OS(MACOSX) |
1092 const WebInputEvent::Type contextMenuTriggeringEventType = | 1094 const WebInputEvent::Type contextMenuTriggeringEventType = |
1093 #if OS(WIN) | 1095 #if OS(WIN) |
1094 WebInputEvent::KeyUp; | 1096 WebInputEvent::KeyUp; |
1095 #else | 1097 #else |
1096 WebInputEvent::RawKeyDown; | 1098 WebInputEvent::RawKeyDown; |
1097 #endif | 1099 #endif |
1098 | 1100 |
1099 bool isUnmodifiedMenuKey = !(event.modifiers & WebInputEvent::InputModifiers
) && event.windowsKeyCode == VKEY_APPS; | 1101 bool isUnmodifiedMenuKey = !(event.modifiers & WebInputEvent::InputModifiers
) && event.windowsKeyCode == VKEY_APPS; |
1100 bool isShiftF10 = event.modifiers == WebInputEvent::ShiftKey && event.window
sKeyCode == VKEY_F10; | 1102 bool isShiftF10 = event.modifiers == WebInputEvent::ShiftKey && event.window
sKeyCode == VKEY_F10; |
1101 if ((isUnmodifiedMenuKey || isShiftF10) && event.type == contextMenuTriggeri
ngEventType) { | 1103 if ((isUnmodifiedMenuKey || isShiftF10) && event.type == contextMenuTriggeri
ngEventType) { |
1102 sendContextMenuEvent(event); | 1104 sendContextMenuEvent(event); |
1103 return true; | 1105 return WebInputEventResult::HandledSystem; |
1104 } | 1106 } |
1105 #endif // !OS(MACOSX) | 1107 #endif // !OS(MACOSX) |
1106 | 1108 |
1107 return keyEventDefault(event); | 1109 if (keyEventDefault(event)) |
| 1110 return WebInputEventResult::HandledSystem; |
| 1111 return WebInputEventResult::NotHandled; |
1108 } | 1112 } |
1109 | 1113 |
1110 bool WebViewImpl::handleCharEvent(const WebKeyboardEvent& event) | 1114 WebInputEventResult WebViewImpl::handleCharEvent(const WebKeyboardEvent& event) |
1111 { | 1115 { |
1112 ASSERT(event.type == WebInputEvent::Char); | 1116 ASSERT(event.type == WebInputEvent::Char); |
1113 TRACE_EVENT1("input", "WebViewImpl::handleCharEvent", | 1117 TRACE_EVENT1("input", "WebViewImpl::handleCharEvent", |
1114 "text", String(event.text).utf8()); | 1118 "text", String(event.text).utf8()); |
1115 | 1119 |
1116 // Please refer to the comments explaining the m_suppressNextKeypressEvent | 1120 // Please refer to the comments explaining the m_suppressNextKeypressEvent |
1117 // member. The m_suppressNextKeypressEvent is set if the KeyDown is | 1121 // member. The m_suppressNextKeypressEvent is set if the KeyDown is |
1118 // handled by Webkit. A keyDown event is typically associated with a | 1122 // handled by Webkit. A keyDown event is typically associated with a |
1119 // keyPress(char) event and a keyUp event. We reset this flag here as it | 1123 // keyPress(char) event and a keyUp event. We reset this flag here as it |
1120 // only applies to the current keyPress event. | 1124 // only applies to the current keyPress event. |
1121 bool suppress = m_suppressNextKeypressEvent; | 1125 bool suppress = m_suppressNextKeypressEvent; |
1122 m_suppressNextKeypressEvent = false; | 1126 m_suppressNextKeypressEvent = false; |
1123 | 1127 |
1124 // If there is a popup, it should be the one processing the event, not the | 1128 // If there is a popup, it should be the one processing the event, not the |
1125 // page. | 1129 // page. |
1126 if (m_pagePopup) | 1130 if (m_pagePopup) |
1127 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); | 1131 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); |
1128 | 1132 |
1129 LocalFrame* frame = toLocalFrame(focusedCoreFrame()); | 1133 LocalFrame* frame = toLocalFrame(focusedCoreFrame()); |
1130 if (!frame) | 1134 if (!frame) |
1131 return suppress; | 1135 return suppress ? WebInputEventResult::HandledSuppressed : WebInputEvent
Result::NotHandled; |
1132 | 1136 |
1133 EventHandler& handler = frame->eventHandler(); | 1137 EventHandler& handler = frame->eventHandler(); |
1134 | 1138 |
1135 PlatformKeyboardEventBuilder evt(event); | 1139 PlatformKeyboardEventBuilder evt(event); |
1136 if (!evt.isCharacterKey()) | 1140 if (!evt.isCharacterKey()) |
1137 return true; | 1141 return WebInputEventResult::HandledSuppressed; |
1138 | 1142 |
1139 // Accesskeys are triggered by char events and can't be suppressed. | 1143 // Accesskeys are triggered by char events and can't be suppressed. |
1140 if (handler.handleAccessKey(evt)) | 1144 if (handler.handleAccessKey(evt)) |
1141 return true; | 1145 return WebInputEventResult::HandledSystem; |
1142 | 1146 |
1143 // Safari 3.1 does not pass off windows system key messages (WM_SYSCHAR) to | 1147 // Safari 3.1 does not pass off windows system key messages (WM_SYSCHAR) to |
1144 // the eventHandler::keyEvent. We mimic this behavior on all platforms since | 1148 // the eventHandler::keyEvent. We mimic this behavior on all platforms since |
1145 // for now we are converting other platform's key events to windows key | 1149 // for now we are converting other platform's key events to windows key |
1146 // events. | 1150 // events. |
1147 if (evt.isSystemKey()) | 1151 if (evt.isSystemKey()) |
1148 return false; | 1152 return WebInputEventResult::NotHandled; |
1149 | 1153 |
1150 if (!suppress && !handler.keyEvent(evt)) | 1154 if (suppress) |
1151 return keyEventDefault(event); | 1155 return WebInputEventResult::HandledSuppressed; |
1152 | 1156 |
1153 return true; | 1157 WebInputEventResult result = handler.keyEvent(evt); |
| 1158 if (result != WebInputEventResult::NotHandled) |
| 1159 return result; |
| 1160 if (keyEventDefault(event)) |
| 1161 return WebInputEventResult::HandledSystem; |
| 1162 |
| 1163 return WebInputEventResult::NotHandled; |
1154 } | 1164 } |
1155 | 1165 |
1156 WebRect WebViewImpl::computeBlockBound(const WebPoint& pointInRootFrame, bool ig
noreClipping) | 1166 WebRect WebViewImpl::computeBlockBound(const WebPoint& pointInRootFrame, bool ig
noreClipping) |
1157 { | 1167 { |
1158 if (!mainFrameImpl()) | 1168 if (!mainFrameImpl()) |
1159 return WebRect(); | 1169 return WebRect(); |
1160 | 1170 |
1161 // Use the point-based hit test to find the node. | 1171 // Use the point-based hit test to find the node. |
1162 IntPoint point = mainFrameImpl()->frameView()->rootFrameToContents(IntPoint(
pointInRootFrame.x, pointInRootFrame.y)); | 1172 IntPoint point = mainFrameImpl()->frameView()->rootFrameToContents(IntPoint(
pointInRootFrame.x, pointInRootFrame.y)); |
1163 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); | 1173 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 } | 1481 } |
1472 | 1482 |
1473 bool WebViewImpl::hasTouchEventHandlersAt(const WebPoint& point) | 1483 bool WebViewImpl::hasTouchEventHandlersAt(const WebPoint& point) |
1474 { | 1484 { |
1475 // FIXME: Implement this. Note that the point must be divided by pageScaleFa
ctor. | 1485 // FIXME: Implement this. Note that the point must be divided by pageScaleFa
ctor. |
1476 return true; | 1486 return true; |
1477 } | 1487 } |
1478 | 1488 |
1479 #if !OS(MACOSX) | 1489 #if !OS(MACOSX) |
1480 // Mac has no way to open a context menu based on a keyboard event. | 1490 // Mac has no way to open a context menu based on a keyboard event. |
1481 bool WebViewImpl::sendContextMenuEvent(const WebKeyboardEvent& event) | 1491 WebInputEventResult WebViewImpl::sendContextMenuEvent(const WebKeyboardEvent& ev
ent) |
1482 { | 1492 { |
1483 // The contextMenuController() holds onto the last context menu that was | 1493 // The contextMenuController() holds onto the last context menu that was |
1484 // popped up on the page until a new one is created. We need to clear | 1494 // popped up on the page until a new one is created. We need to clear |
1485 // this menu before propagating the event through the DOM so that we can | 1495 // this menu before propagating the event through the DOM so that we can |
1486 // detect if we create a new menu for this event, since we won't create | 1496 // detect if we create a new menu for this event, since we won't create |
1487 // a new menu if the DOM swallows the event and the defaultEventHandler does | 1497 // a new menu if the DOM swallows the event and the defaultEventHandler does |
1488 // not run. | 1498 // not run. |
1489 page()->contextMenuController().clearContextMenu(); | 1499 page()->contextMenuController().clearContextMenu(); |
1490 | 1500 |
1491 bool handled; | |
1492 { | 1501 { |
1493 ContextMenuAllowedScope scope; | 1502 ContextMenuAllowedScope scope; |
1494 Frame* focusedFrame = page()->focusController().focusedOrMainFrame(); | 1503 Frame* focusedFrame = page()->focusController().focusedOrMainFrame(); |
1495 if (!focusedFrame->isLocalFrame()) | 1504 if (!focusedFrame->isLocalFrame()) |
1496 return false; | 1505 return WebInputEventResult::NotHandled; |
1497 handled = toLocalFrame(focusedFrame)->eventHandler().sendContextMenuEven
tForKey(nullptr); | 1506 return toLocalFrame(focusedFrame)->eventHandler().sendContextMenuEventFo
rKey(nullptr); |
1498 } | 1507 } |
1499 return handled; | |
1500 } | 1508 } |
1501 #endif | 1509 #endif |
1502 | 1510 |
1503 void WebViewImpl::showContextMenuAtPoint(float x, float y, PassRefPtrWillBeRawPt
r<ContextMenuProvider> menuProvider) | 1511 void WebViewImpl::showContextMenuAtPoint(float x, float y, PassRefPtrWillBeRawPt
r<ContextMenuProvider> menuProvider) |
1504 { | 1512 { |
1505 if (!page()->mainFrame()->isLocalFrame()) | 1513 if (!page()->mainFrame()->isLocalFrame()) |
1506 return; | 1514 return; |
1507 { | 1515 { |
1508 ContextMenuAllowedScope scope; | 1516 ContextMenuAllowedScope scope; |
1509 page()->contextMenuController().clearContextMenu(); | 1517 page()->contextMenuController().clearContextMenu(); |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2025 return mainFrameImpl()->frameView()->horizontalScrollbar(); | 2033 return mainFrameImpl()->frameView()->horizontalScrollbar(); |
2026 } | 2034 } |
2027 | 2035 |
2028 bool WebViewImpl::hasVerticalScrollbar() | 2036 bool WebViewImpl::hasVerticalScrollbar() |
2029 { | 2037 { |
2030 return mainFrameImpl()->frameView()->verticalScrollbar(); | 2038 return mainFrameImpl()->frameView()->verticalScrollbar(); |
2031 } | 2039 } |
2032 | 2040 |
2033 const WebInputEvent* WebViewImpl::m_currentInputEvent = nullptr; | 2041 const WebInputEvent* WebViewImpl::m_currentInputEvent = nullptr; |
2034 | 2042 |
2035 bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent) | 2043 WebInputEventResult WebViewImpl::handleInputEvent(const WebInputEvent& inputEven
t) |
2036 { | 2044 { |
2037 // TODO(dcheng): The fact that this is getting called when there is no local | 2045 // TODO(dcheng): The fact that this is getting called when there is no local |
2038 // main frame is problematic and probably indicates a bug in the input event | 2046 // main frame is problematic and probably indicates a bug in the input event |
2039 // routing code. | 2047 // routing code. |
2040 if (!mainFrameImpl()) | 2048 if (!mainFrameImpl()) |
2041 return false; | 2049 return WebInputEventResult::NotHandled; |
2042 | 2050 |
2043 WebAutofillClient* autofillClient = mainFrameImpl()->autofillClient(); | 2051 WebAutofillClient* autofillClient = mainFrameImpl()->autofillClient(); |
2044 UserGestureNotifier notifier(autofillClient, &m_userGestureObserved); | 2052 UserGestureNotifier notifier(autofillClient, &m_userGestureObserved); |
2045 // On the first input event since page load, |notifier| instructs the | 2053 // On the first input event since page load, |notifier| instructs the |
2046 // autofill client to unblock values of password input fields of any forms | 2054 // autofill client to unblock values of password input fields of any forms |
2047 // on the page. There is a single input event, GestureTap, which can both | 2055 // on the page. There is a single input event, GestureTap, which can both |
2048 // be the first event after page load, and cause a form submission. In that | 2056 // be the first event after page load, and cause a form submission. In that |
2049 // case, the form submission happens before the autofill client is told | 2057 // case, the form submission happens before the autofill client is told |
2050 // to unblock the password values, and so the password values are not | 2058 // to unblock the password values, and so the password values are not |
2051 // submitted. To avoid that, GestureTap is handled explicitly: | 2059 // submitted. To avoid that, GestureTap is handled explicitly: |
2052 if (inputEvent.type == WebInputEvent::GestureTap && autofillClient) { | 2060 if (inputEvent.type == WebInputEvent::GestureTap && autofillClient) { |
2053 m_userGestureObserved = true; | 2061 m_userGestureObserved = true; |
2054 autofillClient->firstUserGestureObserved(); | 2062 autofillClient->firstUserGestureObserved(); |
2055 } | 2063 } |
2056 | 2064 |
2057 page()->frameHost().visualViewport().startTrackingPinchStats(); | 2065 page()->frameHost().visualViewport().startTrackingPinchStats(); |
2058 | 2066 |
2059 TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputTypeToNa
me(inputEvent.type)); | 2067 TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputTypeToNa
me(inputEvent.type)); |
2060 // If we've started a drag and drop operation, ignore input events until | 2068 // If we've started a drag and drop operation, ignore input events until |
2061 // we're done. | 2069 // we're done. |
2062 if (m_doingDragAndDrop) | 2070 if (m_doingDragAndDrop) |
2063 return true; | 2071 return WebInputEventResult::HandledSuppressed; |
2064 | 2072 |
2065 if (m_devToolsEmulator->handleInputEvent(inputEvent)) | 2073 if (m_devToolsEmulator->handleInputEvent(inputEvent)) |
2066 return true; | 2074 return WebInputEventResult::HandledSuppressed; |
2067 | 2075 |
2068 if (InspectorOverlay* overlay = inspectorOverlay()) { | 2076 if (InspectorOverlay* overlay = inspectorOverlay()) { |
2069 if (overlay->handleInputEvent(inputEvent)) | 2077 if (overlay->handleInputEvent(inputEvent)) |
2070 return true; | 2078 return WebInputEventResult::HandledSuppressed; |
2071 } | 2079 } |
2072 | 2080 |
2073 if (inputEvent.modifiers & WebInputEvent::IsTouchAccessibility | 2081 if (inputEvent.modifiers & WebInputEvent::IsTouchAccessibility |
2074 && WebInputEvent::isMouseEventType(inputEvent.type)) { | 2082 && WebInputEvent::isMouseEventType(inputEvent.type)) { |
2075 PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), static_cast<
const WebMouseEvent&>(inputEvent)); | 2083 PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), static_cast<
const WebMouseEvent&>(inputEvent)); |
2076 | 2084 |
2077 // Find the right target frame. See issue 1186900. | 2085 // Find the right target frame. See issue 1186900. |
2078 HitTestResult result = hitTestResultForRootFramePos(pme.position()); | 2086 HitTestResult result = hitTestResultForRootFramePos(pme.position()); |
2079 Frame* targetFrame; | 2087 Frame* targetFrame; |
2080 if (result.innerNodeOrImageMapImage()) | 2088 if (result.innerNodeOrImageMapImage()) |
2081 targetFrame = result.innerNodeOrImageMapImage()->document().frame(); | 2089 targetFrame = result.innerNodeOrImageMapImage()->document().frame(); |
2082 else | 2090 else |
2083 targetFrame = m_page->focusController().focusedOrMainFrame(); | 2091 targetFrame = m_page->focusController().focusedOrMainFrame(); |
2084 | 2092 |
2085 if (targetFrame->isLocalFrame()) { | 2093 if (targetFrame->isLocalFrame()) { |
2086 LocalFrame* targetLocalFrame = toLocalFrame(targetFrame); | 2094 LocalFrame* targetLocalFrame = toLocalFrame(targetFrame); |
2087 Document* document = targetLocalFrame->document(); | 2095 Document* document = targetLocalFrame->document(); |
2088 if (document) { | 2096 if (document) { |
2089 AXObjectCache* cache = document->existingAXObjectCache(); | 2097 AXObjectCache* cache = document->existingAXObjectCache(); |
2090 if (cache) | 2098 if (cache) |
2091 cache->onTouchAccessibilityHover(pme.position()); | 2099 cache->onTouchAccessibilityHover(pme.position()); |
2092 } | 2100 } |
2093 } | 2101 } |
2094 } | 2102 } |
2095 | 2103 |
2096 // Report the event to be NOT processed by WebKit, so that the browser can h
andle it appropriately. | 2104 // Report the event to be NOT processed by WebKit, so that the browser can h
andle it appropriately. |
2097 if (m_ignoreInputEvents) | 2105 if (m_ignoreInputEvents) |
2098 return false; | 2106 return WebInputEventResult::NotHandled; |
2099 | 2107 |
2100 TemporaryChange<const WebInputEvent*> currentEventChange(m_currentInputEvent
, &inputEvent); | 2108 TemporaryChange<const WebInputEvent*> currentEventChange(m_currentInputEvent
, &inputEvent); |
2101 UIEventWithKeyState::clearNewTabModifierSetFromIsolatedWorld(); | 2109 UIEventWithKeyState::clearNewTabModifierSetFromIsolatedWorld(); |
2102 | 2110 |
2103 if (isPointerLocked() && WebInputEvent::isMouseEventType(inputEvent.type)) { | 2111 if (isPointerLocked() && WebInputEvent::isMouseEventType(inputEvent.type)) { |
2104 pointerLockMouseEvent(inputEvent); | 2112 pointerLockMouseEvent(inputEvent); |
2105 return true; | 2113 return WebInputEventResult::HandledSystem; |
2106 } | 2114 } |
2107 | 2115 |
2108 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type))
{ | 2116 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type))
{ |
2109 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type); | 2117 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type); |
2110 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. | 2118 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. |
2111 RefPtrWillBeRawPtr<Node> node = m_mouseCaptureNode; | 2119 RefPtrWillBeRawPtr<Node> node = m_mouseCaptureNode; |
2112 | 2120 |
2113 // Not all platforms call mouseCaptureLost() directly. | 2121 // Not all platforms call mouseCaptureLost() directly. |
2114 if (inputEvent.type == WebInputEvent::MouseUp) | 2122 if (inputEvent.type == WebInputEvent::MouseUp) |
2115 mouseCaptureLost(); | 2123 mouseCaptureLost(); |
(...skipping 17 matching lines...) Expand all Loading... |
2133 eventType = EventTypeNames::mouseup; | 2141 eventType = EventTypeNames::mouseup; |
2134 gestureIndicator = adoptPtr(new UserGestureIndicator(m_mouseCaptureG
estureToken.release())); | 2142 gestureIndicator = adoptPtr(new UserGestureIndicator(m_mouseCaptureG
estureToken.release())); |
2135 break; | 2143 break; |
2136 default: | 2144 default: |
2137 ASSERT_NOT_REACHED(); | 2145 ASSERT_NOT_REACHED(); |
2138 } | 2146 } |
2139 | 2147 |
2140 node->dispatchMouseEvent( | 2148 node->dispatchMouseEvent( |
2141 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), static_cast<
const WebMouseEvent&>(inputEvent)), | 2149 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), static_cast<
const WebMouseEvent&>(inputEvent)), |
2142 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount)
; | 2150 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount)
; |
2143 return true; | 2151 return WebInputEventResult::HandledSystem; |
2144 } | 2152 } |
2145 | 2153 |
2146 // FIXME: This should take in the intended frame, not the local frame root. | 2154 // FIXME: This should take in the intended frame, not the local frame root. |
2147 if (PageWidgetDelegate::handleInputEvent(*this, inputEvent, mainFrameImpl()-
>frame())) | 2155 WebInputEventResult result = PageWidgetDelegate::handleInputEvent(*this, inp
utEvent, mainFrameImpl()->frame()); |
2148 return true; | 2156 if (result != WebInputEventResult::NotHandled) |
| 2157 return result; |
2149 | 2158 |
2150 // Unhandled touchpad gesture pinch events synthesize mouse wheel events. | 2159 // Unhandled touchpad gesture pinch events synthesize mouse wheel events. |
2151 if (inputEvent.type == WebInputEvent::GesturePinchUpdate) { | 2160 if (inputEvent.type == WebInputEvent::GesturePinchUpdate) { |
2152 const WebGestureEvent& pinchEvent = static_cast<const WebGestureEvent&>(
inputEvent); | 2161 const WebGestureEvent& pinchEvent = static_cast<const WebGestureEvent&>(
inputEvent); |
2153 | 2162 |
2154 // First, synthesize a Windows-like wheel event to send to any handlers
that may exist. | 2163 // First, synthesize a Windows-like wheel event to send to any handlers
that may exist. |
2155 if (handleSyntheticWheelFromTouchpadPinchEvent(pinchEvent)) | 2164 result = handleSyntheticWheelFromTouchpadPinchEvent(pinchEvent); |
2156 return true; | 2165 if (result != WebInputEventResult::NotHandled) |
| 2166 return result; |
2157 | 2167 |
2158 if (pinchEvent.data.pinchUpdate.zoomDisabled) | 2168 if (pinchEvent.data.pinchUpdate.zoomDisabled) |
2159 return false; | 2169 return WebInputEventResult::NotHandled; |
2160 | 2170 |
2161 if (page()->frameHost().visualViewport().magnifyScaleAroundAnchor(pinchE
vent.data.pinchUpdate.scale, FloatPoint(pinchEvent.x, pinchEvent.y))) | 2171 if (page()->frameHost().visualViewport().magnifyScaleAroundAnchor(pinchE
vent.data.pinchUpdate.scale, FloatPoint(pinchEvent.x, pinchEvent.y))) |
2162 return true; | 2172 return WebInputEventResult::HandledSystem; |
2163 } | 2173 } |
2164 | 2174 |
2165 return false; | 2175 return WebInputEventResult::NotHandled; |
2166 } | 2176 } |
2167 | 2177 |
2168 void WebViewImpl::setCursorVisibilityState(bool isVisible) | 2178 void WebViewImpl::setCursorVisibilityState(bool isVisible) |
2169 { | 2179 { |
2170 if (m_page) | 2180 if (m_page) |
2171 m_page->setIsCursorVisible(isVisible); | 2181 m_page->setIsCursorVisible(isVisible); |
2172 } | 2182 } |
2173 | 2183 |
2174 void WebViewImpl::mouseCaptureLost() | 2184 void WebViewImpl::mouseCaptureLost() |
2175 { | 2185 { |
(...skipping 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4452 if (m_pageColorOverlay) | 4462 if (m_pageColorOverlay) |
4453 m_pageColorOverlay->update(); | 4463 m_pageColorOverlay->update(); |
4454 if (InspectorOverlay* overlay = inspectorOverlay()) { | 4464 if (InspectorOverlay* overlay = inspectorOverlay()) { |
4455 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); | 4465 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); |
4456 if (inspectorPageOverlay) | 4466 if (inspectorPageOverlay) |
4457 inspectorPageOverlay->update(); | 4467 inspectorPageOverlay->update(); |
4458 } | 4468 } |
4459 } | 4469 } |
4460 | 4470 |
4461 } // namespace blink | 4471 } // namespace blink |
OLD | NEW |