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

Side by Side Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

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

Powered by Google App Engine
This is Rietveld 408576698