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

Side by Side Diff: sky/engine/core/page/EventHandler.cpp

Issue 874823002: Move GestureEvent to NewEventDispatcher (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Build fixes Created 5 years, 11 months 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
« no previous file with comments | « sky/engine/core/page/EventHandler.h ('k') | sky/engine/core/page/EventWithHitTestResults.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "sky/engine/core/page/ChromeClient.h" 53 #include "sky/engine/core/page/ChromeClient.h"
54 #include "sky/engine/core/page/EditorClient.h" 54 #include "sky/engine/core/page/EditorClient.h"
55 #include "sky/engine/core/page/EventWithHitTestResults.h" 55 #include "sky/engine/core/page/EventWithHitTestResults.h"
56 #include "sky/engine/core/page/FocusController.h" 56 #include "sky/engine/core/page/FocusController.h"
57 #include "sky/engine/core/page/Page.h" 57 #include "sky/engine/core/page/Page.h"
58 #include "sky/engine/core/rendering/HitTestRequest.h" 58 #include "sky/engine/core/rendering/HitTestRequest.h"
59 #include "sky/engine/core/rendering/HitTestResult.h" 59 #include "sky/engine/core/rendering/HitTestResult.h"
60 #include "sky/engine/core/rendering/RenderLayer.h" 60 #include "sky/engine/core/rendering/RenderLayer.h"
61 #include "sky/engine/core/rendering/RenderView.h" 61 #include "sky/engine/core/rendering/RenderView.h"
62 #include "sky/engine/core/rendering/style/RenderStyle.h" 62 #include "sky/engine/core/rendering/style/RenderStyle.h"
63 #include "sky/engine/platform/PlatformGestureEvent.h"
64 #include "sky/engine/platform/PlatformKeyboardEvent.h" 63 #include "sky/engine/platform/PlatformKeyboardEvent.h"
65 #include "sky/engine/platform/TraceEvent.h" 64 #include "sky/engine/platform/TraceEvent.h"
66 #include "sky/engine/platform/WindowsKeyboardCodes.h" 65 #include "sky/engine/platform/WindowsKeyboardCodes.h"
67 #include "sky/engine/platform/geometry/FloatPoint.h" 66 #include "sky/engine/platform/geometry/FloatPoint.h"
68 #include "sky/engine/platform/graphics/Image.h" 67 #include "sky/engine/platform/graphics/Image.h"
69 #include "sky/engine/platform/heap/Handle.h" 68 #include "sky/engine/platform/heap/Handle.h"
70 #include "sky/engine/platform/scroll/ScrollAnimator.h" 69 #include "sky/engine/platform/scroll/ScrollAnimator.h"
71 #include "sky/engine/platform/scroll/Scrollbar.h" 70 #include "sky/engine/platform/scroll/Scrollbar.h"
72 #include "sky/engine/wtf/Assertions.h" 71 #include "sky/engine/wtf/Assertions.h"
73 #include "sky/engine/wtf/CurrentTime.h" 72 #include "sky/engine/wtf/CurrentTime.h"
74 #include "sky/engine/wtf/StdLibExtras.h" 73 #include "sky/engine/wtf/StdLibExtras.h"
75 #include "sky/engine/wtf/TemporaryChange.h" 74 #include "sky/engine/wtf/TemporaryChange.h"
76 75
77 namespace blink { 76 namespace blink {
78 77
79 // The amount of time to wait for a cursor update on style and layout changes 78 // The amount of time to wait for a cursor update on style and layout changes
80 // Set to 50Hz, no need to be faster than common screen refresh rate 79 // Set to 50Hz, no need to be faster than common screen refresh rate
81 static const double cursorUpdateInterval = 0.02; 80 static const double cursorUpdateInterval = 0.02;
82 81
83 static const int maximumCursorSize = 128; 82 static const int maximumCursorSize = 128;
84 83
85 // It's pretty unlikely that a scale of less than one would ever be used. But al l we really 84 // It's pretty unlikely that a scale of less than one would ever be used. But al l we really
86 // need to ensure here is that the scale isn't so small that integer overflow ca n occur when 85 // need to ensure here is that the scale isn't so small that integer overflow ca n occur when
87 // dividing cursor sizes (limited above) by the scale. 86 // dividing cursor sizes (limited above) by the scale.
88 static const double minimumCursorScale = 0.001; 87 static const double minimumCursorScale = 0.001;
89 88
90 // The minimum amount of time an element stays active after a ShowPress
91 // This is roughly 9 frames, which should be long enough to be noticeable.
92 static const double minimumActiveInterval = 0.15;
93
94 enum NoCursorChangeType { NoCursorChange }; 89 enum NoCursorChangeType { NoCursorChange };
95 90
96 class OptionalCursor { 91 class OptionalCursor {
97 public: 92 public:
98 OptionalCursor(NoCursorChangeType) : m_isCursorChange(false) { } 93 OptionalCursor(NoCursorChangeType) : m_isCursorChange(false) { }
99 OptionalCursor(const Cursor& cursor) : m_isCursorChange(true), m_cursor(curs or) { } 94 OptionalCursor(const Cursor& cursor) : m_isCursorChange(true), m_cursor(curs or) { }
100 95
101 bool isCursorChange() const { return m_isCursorChange; } 96 bool isCursorChange() const { return m_isCursorChange; }
102 const Cursor& cursor() const { ASSERT(m_isCursorChange); return m_cursor; } 97 const Cursor& cursor() const { ASSERT(m_isCursorChange); return m_cursor; }
103 98
(...skipping 26 matching lines...) Expand all
130 , m_capturesDragging(false) 125 , m_capturesDragging(false)
131 , m_mouseDownMayStartSelect(false) 126 , m_mouseDownMayStartSelect(false)
132 , m_mouseDownMayStartDrag(false) 127 , m_mouseDownMayStartDrag(false)
133 , m_selectionInitiationState(HaveNotStartedSelection) 128 , m_selectionInitiationState(HaveNotStartedSelection)
134 , m_hoverTimer(this, &EventHandler::hoverTimerFired) 129 , m_hoverTimer(this, &EventHandler::hoverTimerFired)
135 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) 130 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired)
136 , m_mouseDownMayStartAutoscroll(false) 131 , m_mouseDownMayStartAutoscroll(false)
137 , m_clickCount(0) 132 , m_clickCount(0)
138 , m_shouldOnlyFireDragOverEvent(false) 133 , m_shouldOnlyFireDragOverEvent(false)
139 , m_mousePositionIsUnknown(true) 134 , m_mousePositionIsUnknown(true)
140 , m_scrollGestureHandlingNode(nullptr)
141 , m_lastGestureScrollOverWidget(false)
142 , m_maxMouseMovedDuration(0) 135 , m_maxMouseMovedDuration(0)
143 , m_didStartDrag(false) 136 , m_didStartDrag(false)
144 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) 137 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired)
145 , m_lastShowPressTimestamp(0) 138 , m_lastShowPressTimestamp(0)
146 { 139 {
147 } 140 }
148 141
149 EventHandler::~EventHandler() 142 EventHandler::~EventHandler()
150 { 143 {
151 } 144 }
(...skipping 10 matching lines...) Expand all
162 m_clickNode = nullptr; 155 m_clickNode = nullptr;
163 m_dragTarget = nullptr; 156 m_dragTarget = nullptr;
164 m_shouldOnlyFireDragOverEvent = false; 157 m_shouldOnlyFireDragOverEvent = false;
165 m_mousePositionIsUnknown = true; 158 m_mousePositionIsUnknown = true;
166 m_lastKnownMousePosition = IntPoint(); 159 m_lastKnownMousePosition = IntPoint();
167 m_lastKnownMouseGlobalPosition = IntPoint(); 160 m_lastKnownMouseGlobalPosition = IntPoint();
168 m_mousePressNode = nullptr; 161 m_mousePressNode = nullptr;
169 m_mousePressed = false; 162 m_mousePressed = false;
170 m_capturesDragging = false; 163 m_capturesDragging = false;
171 m_previousWheelScrolledNode = nullptr; 164 m_previousWheelScrolledNode = nullptr;
172 m_scrollGestureHandlingNode = nullptr;
173 m_lastGestureScrollOverWidget = false;
174 m_previousGestureScrolledNode = nullptr;
175 m_scrollbarHandlingScrollGesture = nullptr;
176 m_maxMouseMovedDuration = 0; 165 m_maxMouseMovedDuration = 0;
177 m_didStartDrag = false; 166 m_didStartDrag = false;
178 m_mouseDownMayStartSelect = false; 167 m_mouseDownMayStartSelect = false;
179 m_mouseDownMayStartDrag = false; 168 m_mouseDownMayStartDrag = false;
180 m_lastShowPressTimestamp = 0; 169 m_lastShowPressTimestamp = 0;
181 m_lastDeferredTapElement = nullptr; 170 m_lastDeferredTapElement = nullptr;
182 } 171 }
183 172
184 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved) 173 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved)
185 { 174 {
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 if (RenderView* renderView = m_frame->contentRenderer()) { 647 if (RenderView* renderView = m_frame->contentRenderer()) {
659 HitTestRequest request(HitTestRequest::ReadOnly); 648 HitTestRequest request(HitTestRequest::ReadOnly);
660 HitTestResult result(windowPoint); 649 HitTestResult result(windowPoint);
661 renderView->hitTest(request, result); 650 renderView->hitTest(request, result);
662 return result.scrollbar(); 651 return result.scrollbar();
663 } 652 }
664 653
665 return false; 654 return false;
666 } 655 }
667 656
668 bool EventHandler::handleGestureShowPress()
669 {
670 m_lastShowPressTimestamp = WTF::currentTime();
671
672 FrameView* view = m_frame->view();
673 if (!view)
674 return false;
675 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas();
676 if (!areas)
677 return false;
678 for (FrameView::ScrollableAreaSet::const_iterator it = areas->begin(); it != areas->end(); ++it) {
679 ScrollableArea* sa = *it;
680 ScrollAnimator* animator = sa->existingScrollAnimator();
681 if (animator)
682 animator->cancelAnimations();
683 }
684 return false;
685 }
686
687 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
688 {
689 TRACE_EVENT0("input", "EventHandler::handleGestureEvent");
690
691 // Scrolling-related gesture events invoke EventHandler recursively for each frame down
692 // the chain, doing a single-frame hit-test per frame. This matches handleWh eelEvent.
693 // Perhaps we could simplify things by rewriting scroll handling to work inn er frame
694 // out, and then unify with other gesture events.
695 if (gestureEvent.isScrollEvent())
696 return handleGestureScrollEvent(gestureEvent);
697
698 // Non-scrolling related gesture events instead do a single cross-frame hit- test and
699 // jump directly to the inner most frame. This matches handleMousePressEvent etc.
700
701 // Hit test across all frames and do touch adjustment as necessary for the e vent type.
702 GestureEventWithHitTestResults targetedEvent = targetGestureEvent(gestureEve nt);
703
704 // Route to the correct frame.
705 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame())
706 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t);
707
708 // No hit test result, handle in root instance. Perhaps we should just retur n false instead?
709 return handleGestureEventInFrame(targetedEvent);
710 }
711
712 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent)
713 {
714 ASSERT(!targetedEvent.event().isScrollEvent());
715
716 RefPtr<Node> eventTarget = targetedEvent.hitTestResult().targetNode();
717 RefPtr<Scrollbar> scrollbar = targetedEvent.hitTestResult().scrollbar();
718 const PlatformGestureEvent& gestureEvent = targetedEvent.event();
719
720 if (scrollbar) {
721 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent);
722 if (gestureEvent.type() == PlatformEvent::GestureTapDown && eventSwallow ed)
723 m_scrollbarHandlingScrollGesture = scrollbar;
724 if (eventSwallowed)
725 return true;
726 }
727
728 if (eventTarget && eventTarget->dispatchGestureEvent(gestureEvent))
729 return true;
730
731 switch (gestureEvent.type()) {
732 case PlatformEvent::GestureTwoFingerTap: // FIXME(sky): Remove this.
733 case PlatformEvent::GestureTap:
734 return handleGestureTap(targetedEvent);
735 case PlatformEvent::GestureShowPress:
736 return handleGestureShowPress();
737 case PlatformEvent::GestureLongPress:
738 return handleGestureLongPress(targetedEvent);
739 case PlatformEvent::GestureLongTap:
740 return handleGestureLongTap(targetedEvent);
741 case PlatformEvent::GestureTapDown:
742 case PlatformEvent::GesturePinchBegin:
743 case PlatformEvent::GesturePinchEnd:
744 case PlatformEvent::GesturePinchUpdate:
745 case PlatformEvent::GestureTapDownCancel:
746 case PlatformEvent::GestureTapUnconfirmed:
747 break;
748 default:
749 ASSERT_NOT_REACHED();
750 }
751
752 return false;
753 }
754
755 bool EventHandler::handleGestureScrollEvent(const PlatformGestureEvent& gestureE vent)
756 {
757 RefPtr<Node> eventTarget = nullptr;
758 RefPtr<Scrollbar> scrollbar;
759 if (gestureEvent.type() != PlatformEvent::GestureScrollBegin) {
760 scrollbar = m_scrollbarHandlingScrollGesture.get();
761 eventTarget = m_scrollGestureHandlingNode.get();
762 }
763
764 if (!eventTarget) {
765 Document* document = m_frame->document();
766 if (!document->renderView())
767 return false;
768
769 LayoutPoint viewPoint = gestureEvent.position();
770 HitTestRequest request(HitTestRequest::ReadOnly);
771 HitTestResult result(viewPoint);
772 document->renderView()->hitTest(request, result);
773
774 eventTarget = result.innerNode();
775
776 m_lastGestureScrollOverWidget = result.isOverWidget();
777 m_scrollGestureHandlingNode = eventTarget;
778 m_previousGestureScrolledNode = nullptr;
779
780 if (!scrollbar)
781 scrollbar = result.scrollbar();
782 }
783
784 if (scrollbar) {
785 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent);
786 if (gestureEvent.type() == PlatformEvent::GestureScrollEnd
787 || gestureEvent.type() == PlatformEvent::GestureFlingStart
788 || !eventSwallowed) {
789 m_scrollbarHandlingScrollGesture = nullptr;
790 }
791 if (eventSwallowed)
792 return true;
793 }
794
795 if (eventTarget && eventTarget->dispatchGestureEvent(gestureEvent))
796 return true;
797
798 switch (gestureEvent.type()) {
799 case PlatformEvent::GestureScrollBegin:
800 return handleGestureScrollBegin(gestureEvent);
801 case PlatformEvent::GestureScrollUpdate:
802 case PlatformEvent::GestureScrollUpdateWithoutPropagation:
803 return handleGestureScrollUpdate(gestureEvent);
804 case PlatformEvent::GestureScrollEnd:
805 return handleGestureScrollEnd(gestureEvent);
806 case PlatformEvent::GestureFlingStart:
807 case PlatformEvent::GesturePinchBegin:
808 case PlatformEvent::GesturePinchEnd:
809 case PlatformEvent::GesturePinchUpdate:
810 return false;
811 default:
812 ASSERT_NOT_REACHED();
813 return false;
814 }
815 }
816
817 bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target edEvent)
818 {
819 return false;
820 }
821
822 bool EventHandler::handleGestureLongPress(const GestureEventWithHitTestResults& targetedEvent)
823 {
824 const PlatformGestureEvent& gestureEvent = targetedEvent.event();
825
826 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests here (re-using the
827 // supplied HitTestResult), but that will require some overhaul of the touch drag-and-drop code
828 // and LongPress is such a special scenario that it's unlikely to matter muc h in practice.
829
830 IntPoint hitTestPoint = gestureEvent.position();
831 HitTestResult result = hitTestResultAtPoint(hitTestPoint);
832 Node* innerNode = result.targetNode();
833 if (!result.isLiveLink() && innerNode && (innerNode->isContentEditable() || innerNode->isTextNode())) {
834 selectClosestWordFromHitTestResult(result, DontAppendTrailingWhitespace) ;
835 if (m_frame->selection().isRange()) {
836 focusDocumentView();
837 return true;
838 }
839 }
840
841 return true;
842 }
843
844 bool EventHandler::handleGestureLongTap(const GestureEventWithHitTestResults& ta rgetedEvent)
845 {
846 return false;
847 }
848
849 bool EventHandler::passScrollGestureEventToWidget(const PlatformGestureEvent& ge stureEvent, RenderObject* renderer)
850 {
851 ASSERT(gestureEvent.isScrollEvent());
852
853 // FIXME(sky): Remove this.
854 return false;
855 }
856
857 bool EventHandler::handleGestureScrollEnd(const PlatformGestureEvent& gestureEve nt) {
858 RefPtr<Node> node = m_scrollGestureHandlingNode;
859 clearGestureScrollNodes();
860
861 if (node)
862 passScrollGestureEventToWidget(gestureEvent, node->renderer());
863
864 return false;
865 }
866
867 bool EventHandler::handleGestureScrollBegin(const PlatformGestureEvent& gestureE vent)
868 {
869 Document* document = m_frame->document();
870 if (!document->renderView())
871 return false;
872
873 FrameView* view = m_frame->view();
874 if (!view)
875 return false;
876
877 // If there's no renderer on the node, send the event to the nearest ancesto r with a renderer.
878 // Needed for <option> and <optgroup> elements so we can touch scroll <selec t>s
879 while (m_scrollGestureHandlingNode && !m_scrollGestureHandlingNode->renderer ())
880 m_scrollGestureHandlingNode = m_scrollGestureHandlingNode->parentOrShado wHostNode();
881
882 if (!m_scrollGestureHandlingNode)
883 return false;
884
885 passScrollGestureEventToWidget(gestureEvent, m_scrollGestureHandlingNode->re nderer());
886
887 return true;
888 }
889
890 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture Event)
891 {
892 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY());
893 if (delta.isZero())
894 return false;
895
896 Node* node = m_scrollGestureHandlingNode.get();
897 if (!node)
898 return sendScrollEventToView(gestureEvent, delta);
899
900 // Ignore this event if the targeted node does not have a valid renderer.
901 RenderObject* renderer = node->renderer();
902 if (!renderer)
903 return false;
904
905 RefPtr<FrameView> protector(m_frame->view());
906
907 Node* stopNode = 0;
908 bool scrollShouldNotPropagate = gestureEvent.type() == PlatformEvent::Gestur eScrollUpdateWithoutPropagation;
909
910 // Try to send the event to the correct view.
911 if (passScrollGestureEventToWidget(gestureEvent, renderer)) {
912 if(scrollShouldNotPropagate)
913 m_previousGestureScrolledNode = m_scrollGestureHandlingNode;
914
915 return true;
916 }
917
918 if (scrollShouldNotPropagate)
919 stopNode = m_previousGestureScrolledNode.get();
920
921 // First try to scroll the closest scrollable RenderBox ancestor of |node|.
922 ScrollGranularity granularity = ScrollByPixel;
923 bool horizontalScroll = scroll(ScrollLeft, granularity, node, &stopNode, del ta.width());
924 bool verticalScroll = scroll(ScrollUp, granularity, node, &stopNode, delta.h eight());
925
926 if (scrollShouldNotPropagate)
927 m_previousGestureScrolledNode = stopNode;
928
929 if (horizontalScroll || verticalScroll) {
930 return true;
931 }
932
933 // Otherwise try to scroll the view.
934 return sendScrollEventToView(gestureEvent, delta);
935 }
936
937 bool EventHandler::sendScrollEventToView(const PlatformGestureEvent& gestureEven t, const FloatSize& scaledDelta)
938 {
939 return false;
940 }
941
942 void EventHandler::clearGestureScrollNodes()
943 {
944 m_scrollGestureHandlingNode = nullptr;
945 m_previousGestureScrolledNode = nullptr;
946 }
947
948 bool EventHandler::isScrollbarHandlingGestures() const
949 {
950 return m_scrollbarHandlingScrollGesture.get();
951 }
952
953 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly)
954 {
955 // Scrolling events get hit tested per frame (like wheel events do).
956 ASSERT(!gestureEvent.isScrollEvent());
957
958 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type());
959 double activeInterval = 0;
960 bool shouldKeepActiveForMinInterval = false;
961 if (readOnly) {
962 hitType |= HitTestRequest::ReadOnly;
963 } else if (gestureEvent.type() == PlatformEvent::GestureTap) {
964 // If the Tap is received very shortly after ShowPress, we want to
965 // delay clearing of the active state so that it's visible to the user
966 // for at least a couple of frames.
967 activeInterval = WTF::currentTime() - m_lastShowPressTimestamp;
968 shouldKeepActiveForMinInterval = m_lastShowPressTimestamp && activeInter val < minimumActiveInterval;
969 if (shouldKeepActiveForMinInterval)
970 hitType |= HitTestRequest::ReadOnly;
971 }
972
973 // Perform the rect-based hit-test. Note that we don't yet apply hover/activ e state here
974 // because we need to resolve touch adjustment first so that we apply hover/ active it to
975 // the final adjusted node.
976 IntPoint hitTestPoint = gestureEvent.position();
977 IntSize touchRadius = gestureEvent.area();
978 touchRadius.scale(1.f / 2);
979 // FIXME: We should not do a rect-based hit-test if touch adjustment is disa bled.
980 HitTestResult hitTestResult = hitTestResultAtPoint(hitTestPoint, hitType | H itTestRequest::ReadOnly, touchRadius);
981
982 // Now apply hover/active state to the final target.
983 // FIXME: This is supposed to send mouseenter/mouseleave events, but doesn't because we
984 // aren't passing a PlatformMouseEvent.
985 HitTestRequest request(hitType);
986
987 if (shouldKeepActiveForMinInterval) {
988 m_lastDeferredTapElement = hitTestResult.innerElement();
989 m_activeIntervalTimer.startOneShot(minimumActiveInterval - activeInterva l, FROM_HERE);
990 }
991
992 return GestureEventWithHitTestResults(gestureEvent, hitTestResult);
993 }
994
995 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo rmEvent::Type type)
996 {
997 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly;
998 switch (type) {
999 case PlatformEvent::GestureShowPress:
1000 case PlatformEvent::GestureTapUnconfirmed:
1001 return hitType | HitTestRequest::Active;
1002 case PlatformEvent::GestureTapDownCancel:
1003 // A TapDownCancel received when no element is active shouldn't really b e changing hover state.
1004 if (!m_frame->document()->activeHoverElement())
1005 hitType |= HitTestRequest::ReadOnly;
1006 return hitType | HitTestRequest::Release;
1007 case PlatformEvent::GestureTap:
1008 return hitType | HitTestRequest::Release;
1009 case PlatformEvent::GestureTapDown:
1010 case PlatformEvent::GestureLongPress:
1011 case PlatformEvent::GestureLongTap:
1012 case PlatformEvent::GestureTwoFingerTap:
1013 // FIXME: Shouldn't LongTap and TwoFingerTap clear the Active state?
1014 return hitType | HitTestRequest::Active | HitTestRequest::ReadOnly;
1015 default:
1016 ASSERT_NOT_REACHED();
1017 return hitType | HitTestRequest::Active | HitTestRequest::ReadOnly;
1018 }
1019 }
1020
1021 void EventHandler::scheduleHoverStateUpdate() 657 void EventHandler::scheduleHoverStateUpdate()
1022 { 658 {
1023 if (!m_hoverTimer.isActive()) 659 if (!m_hoverTimer.isActive())
1024 m_hoverTimer.startOneShot(0, FROM_HERE); 660 m_hoverTimer.startOneShot(0, FROM_HERE);
1025 } 661 }
1026 662
1027 void EventHandler::scheduleCursorUpdate() 663 void EventHandler::scheduleCursorUpdate()
1028 { 664 {
1029 if (!m_cursorUpdateTimer.isActive()) 665 if (!m_cursorUpdateTimer.isActive())
1030 m_cursorUpdateTimer.startOneShot(cursorUpdateInterval, FROM_HERE); 666 m_cursorUpdateTimer.startOneShot(cursorUpdateInterval, FROM_HERE);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 903
1268 void EventHandler::focusDocumentView() 904 void EventHandler::focusDocumentView()
1269 { 905 {
1270 Page* page = m_frame->page(); 906 Page* page = m_frame->page();
1271 if (!page) 907 if (!page)
1272 return; 908 return;
1273 page->focusController().focusDocumentView(m_frame); 909 page->focusController().focusDocumentView(m_frame);
1274 } 910 }
1275 911
1276 } // namespace blink 912 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/page/EventHandler.h ('k') | sky/engine/core/page/EventWithHitTestResults.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698