| OLD | NEW |
| 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 27 matching lines...) Expand all Loading... |
| 38 #include "core/dom/TouchList.h" | 38 #include "core/dom/TouchList.h" |
| 39 #include "core/dom/shadow/ComposedTreeTraversal.h" | 39 #include "core/dom/shadow/ComposedTreeTraversal.h" |
| 40 #include "core/dom/shadow/ShadowRoot.h" | 40 #include "core/dom/shadow/ShadowRoot.h" |
| 41 #include "core/editing/Editor.h" | 41 #include "core/editing/Editor.h" |
| 42 #include "core/editing/FrameSelection.h" | 42 #include "core/editing/FrameSelection.h" |
| 43 #include "core/editing/htmlediting.h" | 43 #include "core/editing/htmlediting.h" |
| 44 #include "core/editing/iterators/TextIterator.h" | 44 #include "core/editing/iterators/TextIterator.h" |
| 45 #include "core/events/EventPath.h" | 45 #include "core/events/EventPath.h" |
| 46 #include "core/events/KeyboardEvent.h" | 46 #include "core/events/KeyboardEvent.h" |
| 47 #include "core/events/MouseEvent.h" | 47 #include "core/events/MouseEvent.h" |
| 48 #include "core/events/PointerEvent.h" |
| 48 #include "core/events/TextEvent.h" | 49 #include "core/events/TextEvent.h" |
| 49 #include "core/events/TouchEvent.h" | 50 #include "core/events/TouchEvent.h" |
| 50 #include "core/events/WheelEvent.h" | 51 #include "core/events/WheelEvent.h" |
| 51 #include "core/fetch/ImageResource.h" | 52 #include "core/fetch/ImageResource.h" |
| 52 #include "core/frame/EventHandlerRegistry.h" | 53 #include "core/frame/EventHandlerRegistry.h" |
| 53 #include "core/frame/FrameHost.h" | 54 #include "core/frame/FrameHost.h" |
| 54 #include "core/frame/FrameView.h" | 55 #include "core/frame/FrameView.h" |
| 55 #include "core/frame/LocalFrame.h" | 56 #include "core/frame/LocalFrame.h" |
| 56 #include "core/frame/PinchViewport.h" | 57 #include "core/frame/PinchViewport.h" |
| 57 #include "core/frame/Settings.h" | 58 #include "core/frame/Settings.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire
d) | 231 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire
d) |
| 231 , m_svgPan(false) | 232 , m_svgPan(false) |
| 232 , m_resizeScrollableArea(nullptr) | 233 , m_resizeScrollableArea(nullptr) |
| 233 , m_eventHandlerWillResetCapturingMouseEventsNode(0) | 234 , m_eventHandlerWillResetCapturingMouseEventsNode(0) |
| 234 , m_clickCount(0) | 235 , m_clickCount(0) |
| 235 , m_shouldOnlyFireDragOverEvent(false) | 236 , m_shouldOnlyFireDragOverEvent(false) |
| 236 , m_mousePositionIsUnknown(true) | 237 , m_mousePositionIsUnknown(true) |
| 237 , m_mouseDownTimestamp(0) | 238 , m_mouseDownTimestamp(0) |
| 238 , m_widgetIsLatched(false) | 239 , m_widgetIsLatched(false) |
| 239 , m_touchPressed(false) | 240 , m_touchPressed(false) |
| 241 , m_primaryPointerId(0) |
| 240 , m_scrollGestureHandlingNode(nullptr) | 242 , m_scrollGestureHandlingNode(nullptr) |
| 241 , m_lastGestureScrollOverWidget(false) | 243 , m_lastGestureScrollOverWidget(false) |
| 242 , m_maxMouseMovedDuration(0) | 244 , m_maxMouseMovedDuration(0) |
| 243 , m_longTapShouldInvokeContextMenu(false) | 245 , m_longTapShouldInvokeContextMenu(false) |
| 244 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 246 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
| 245 , m_lastShowPressTimestamp(0) | 247 , m_lastShowPressTimestamp(0) |
| 246 , m_deltaConsumedForScrollSequence(false) | 248 , m_deltaConsumedForScrollSequence(false) |
| 247 { | 249 { |
| 248 } | 250 } |
| 249 | 251 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 m_previousWheelScrolledNode = nullptr; | 312 m_previousWheelScrolledNode = nullptr; |
| 311 m_targetForTouchID.clear(); | 313 m_targetForTouchID.clear(); |
| 312 m_touchSequenceDocument.clear(); | 314 m_touchSequenceDocument.clear(); |
| 313 m_touchSequenceUserGestureToken.clear(); | 315 m_touchSequenceUserGestureToken.clear(); |
| 314 m_scrollGestureHandlingNode = nullptr; | 316 m_scrollGestureHandlingNode = nullptr; |
| 315 m_lastGestureScrollOverWidget = false; | 317 m_lastGestureScrollOverWidget = false; |
| 316 m_previousGestureScrolledNode = nullptr; | 318 m_previousGestureScrolledNode = nullptr; |
| 317 m_scrollbarHandlingScrollGesture = nullptr; | 319 m_scrollbarHandlingScrollGesture = nullptr; |
| 318 m_maxMouseMovedDuration = 0; | 320 m_maxMouseMovedDuration = 0; |
| 319 m_touchPressed = false; | 321 m_touchPressed = false; |
| 322 m_primaryPointerId = 0; |
| 320 m_mouseDownMayStartSelect = false; | 323 m_mouseDownMayStartSelect = false; |
| 321 m_mouseDownMayStartDrag = false; | 324 m_mouseDownMayStartDrag = false; |
| 322 m_lastShowPressTimestamp = 0; | 325 m_lastShowPressTimestamp = 0; |
| 323 m_lastDeferredTapElement = nullptr; | 326 m_lastDeferredTapElement = nullptr; |
| 324 m_eventHandlerWillResetCapturingMouseEventsNode = false; | 327 m_eventHandlerWillResetCapturingMouseEventsNode = false; |
| 325 m_mouseDownWasSingleClickInSelection = false; | 328 m_mouseDownWasSingleClickInSelection = false; |
| 326 m_selectionInitiationState = HaveNotStartedSelection; | 329 m_selectionInitiationState = HaveNotStartedSelection; |
| 327 m_mouseDownMayStartAutoscroll = false; | 330 m_mouseDownMayStartAutoscroll = false; |
| 328 m_svgPan = false; | 331 m_svgPan = false; |
| 329 m_mouseDownPos = IntPoint(); | 332 m_mouseDownPos = IntPoint(); |
| (...skipping 3439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3769 m_lastScrollbarUnderMouse->mouseExited(); | 3772 m_lastScrollbarUnderMouse->mouseExited(); |
| 3770 | 3773 |
| 3771 // Send mouse entered if we're setting a new scrollbar. | 3774 // Send mouse entered if we're setting a new scrollbar. |
| 3772 if (scrollbar && setLast) | 3775 if (scrollbar && setLast) |
| 3773 scrollbar->mouseEntered(); | 3776 scrollbar->mouseEntered(); |
| 3774 | 3777 |
| 3775 m_lastScrollbarUnderMouse = setLast ? scrollbar : nullptr; | 3778 m_lastScrollbarUnderMouse = setLast ? scrollbar : nullptr; |
| 3776 } | 3779 } |
| 3777 } | 3780 } |
| 3778 | 3781 |
| 3779 static const AtomicString& eventNameForTouchPointState(PlatformTouchPoint::State
state) | 3782 static const AtomicString& touchEventNameForTouchPointState(PlatformTouchPoint::
State state) |
| 3780 { | 3783 { |
| 3781 switch (state) { | 3784 switch (state) { |
| 3782 case PlatformTouchPoint::TouchReleased: | 3785 case PlatformTouchPoint::TouchReleased: |
| 3783 return EventTypeNames::touchend; | 3786 return EventTypeNames::touchend; |
| 3784 case PlatformTouchPoint::TouchCancelled: | 3787 case PlatformTouchPoint::TouchCancelled: |
| 3785 return EventTypeNames::touchcancel; | 3788 return EventTypeNames::touchcancel; |
| 3786 case PlatformTouchPoint::TouchPressed: | 3789 case PlatformTouchPoint::TouchPressed: |
| 3787 return EventTypeNames::touchstart; | 3790 return EventTypeNames::touchstart; |
| 3788 case PlatformTouchPoint::TouchMoved: | 3791 case PlatformTouchPoint::TouchMoved: |
| 3789 return EventTypeNames::touchmove; | 3792 return EventTypeNames::touchmove; |
| 3790 case PlatformTouchPoint::TouchStationary: | 3793 case PlatformTouchPoint::TouchStationary: |
| 3791 // TouchStationary state is not converted to touch events, so fall throu
gh to assert. | 3794 // TouchStationary state is not converted to touch events, so fall throu
gh to assert. |
| 3792 default: | 3795 default: |
| 3793 ASSERT_NOT_REACHED(); | 3796 ASSERT_NOT_REACHED(); |
| 3794 return emptyAtom; | 3797 return emptyAtom; |
| 3795 } | 3798 } |
| 3796 } | 3799 } |
| 3797 | 3800 |
| 3801 static const AtomicString& pointerEventNameForTouchPointState(PlatformTouchPoint
::State state) |
| 3802 { |
| 3803 switch (state) { |
| 3804 case PlatformTouchPoint::TouchReleased: |
| 3805 return EventTypeNames::pointerup; |
| 3806 case PlatformTouchPoint::TouchCancelled: |
| 3807 return EventTypeNames::pointercancel; |
| 3808 case PlatformTouchPoint::TouchPressed: |
| 3809 return EventTypeNames::pointerdown; |
| 3810 case PlatformTouchPoint::TouchMoved: |
| 3811 return EventTypeNames::pointermove; |
| 3812 case PlatformTouchPoint::TouchStationary: |
| 3813 // TouchStationary state is not converted to touch events, so fall throu
gh to assert. |
| 3814 default: |
| 3815 ASSERT_NOT_REACHED(); |
| 3816 return emptyAtom; |
| 3817 } |
| 3818 } |
| 3819 |
| 3798 HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const Layout
Point& point, HitTestRequest::HitTestRequestType hitType) | 3820 HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const Layout
Point& point, HitTestRequest::HitTestRequestType hitType) |
| 3799 { | 3821 { |
| 3800 HitTestResult result(HitTestRequest(hitType), point); | 3822 HitTestResult result(HitTestRequest(hitType), point); |
| 3801 | 3823 |
| 3802 if (!frame || !frame->contentLayoutObject()) | 3824 if (!frame || !frame->contentLayoutObject()) |
| 3803 return result; | 3825 return result; |
| 3804 if (frame->view()) { | 3826 if (frame->view()) { |
| 3805 IntRect rect = frame->view()->visibleContentRect(IncludeScrollbars); | 3827 IntRect rect = frame->view()->visibleContentRect(IncludeScrollbars); |
| 3806 if (!rect.contains(roundedIntPoint(point))) | 3828 if (!rect.contains(roundedIntPoint(point))) |
| 3807 return result; | 3829 return result; |
| 3808 } | 3830 } |
| 3809 frame->contentLayoutObject()->hitTest(result); | 3831 frame->contentLayoutObject()->hitTest(result); |
| 3810 return result; | 3832 return result; |
| 3811 } | 3833 } |
| 3812 | 3834 |
| 3813 bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) | 3835 bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) |
| 3814 { | 3836 { |
| 3815 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); | 3837 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); |
| 3816 | 3838 |
| 3817 const Vector<PlatformTouchPoint>& points = event.touchPoints(); | 3839 const Vector<PlatformTouchPoint>& points = event.touchPoints(); |
| 3818 | 3840 |
| 3819 unsigned i; | |
| 3820 bool freshTouchEvents = true; | 3841 bool freshTouchEvents = true; |
| 3821 bool allTouchReleased = true; | 3842 bool allTouchReleased = true; |
| 3822 for (i = 0; i < points.size(); ++i) { | 3843 for (unsigned i = 0; i < points.size(); ++i) { |
| 3823 const PlatformTouchPoint& point = points[i]; | 3844 const PlatformTouchPoint& point = points[i]; |
| 3824 if (point.state() != PlatformTouchPoint::TouchPressed) | 3845 if (point.state() != PlatformTouchPoint::TouchPressed) |
| 3825 freshTouchEvents = false; | 3846 freshTouchEvents = false; |
| 3826 if (point.state() != PlatformTouchPoint::TouchReleased && point.state()
!= PlatformTouchPoint::TouchCancelled) | 3847 if (point.state() != PlatformTouchPoint::TouchReleased && point.state()
!= PlatformTouchPoint::TouchCancelled) |
| 3827 allTouchReleased = false; | 3848 allTouchReleased = false; |
| 3828 } | 3849 } |
| 3829 if (freshTouchEvents) { | 3850 if (freshTouchEvents) { |
| 3830 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should | 3851 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should |
| 3831 // have cleared the active document when we saw the last release. But we | 3852 // have cleared the active document when we saw the last release. But we |
| 3832 // have some tests that violate this, ClusterFuzz could trigger it, and | 3853 // have some tests that violate this, ClusterFuzz could trigger it, and |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3846 m_touchSequenceUserGestureToken = gestureIndicator->currentToken(); | 3867 m_touchSequenceUserGestureToken = gestureIndicator->currentToken(); |
| 3847 | 3868 |
| 3848 ASSERT(m_frame->view()); | 3869 ASSERT(m_frame->view()); |
| 3849 if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touc
hSequenceDocument->frame()->view())) { | 3870 if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touc
hSequenceDocument->frame()->view())) { |
| 3850 // If the active touch document has no frame or view, it's probably bein
g destroyed | 3871 // If the active touch document has no frame or view, it's probably bein
g destroyed |
| 3851 // so we can't dispatch events. | 3872 // so we can't dispatch events. |
| 3852 return false; | 3873 return false; |
| 3853 } | 3874 } |
| 3854 | 3875 |
| 3855 // First do hit tests for any new touch points. | 3876 // First do hit tests for any new touch points. |
| 3856 for (i = 0; i < points.size(); ++i) { | 3877 for (unsigned i = 0; i < points.size(); ++i) { |
| 3857 const PlatformTouchPoint& point = points[i]; | 3878 const PlatformTouchPoint& point = points[i]; |
| 3858 | 3879 |
| 3859 // Touch events implicitly capture to the touched node, and don't change | 3880 // Touch events implicitly capture to the touched node, and don't change |
| 3860 // active/hover states themselves (Gesture events do). So we only need | 3881 // active/hover states themselves (Gesture events do). So we only need |
| 3861 // to hit-test on touchstart, and it can be read-only. | 3882 // to hit-test on touchstart, and it can be read-only. |
| 3862 if (point.state() == PlatformTouchPoint::TouchPressed) { | 3883 if (point.state() == PlatformTouchPoint::TouchPressed) { |
| 3863 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEv
ent | HitTestRequest::ReadOnly | HitTestRequest::Active; | 3884 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEv
ent | HitTestRequest::ReadOnly | HitTestRequest::Active; |
| 3864 LayoutPoint pagePoint = roundedLayoutPoint(m_frame->view()->rootFram
eToContents(point.pos())); | 3885 LayoutPoint pagePoint = roundedLayoutPoint(m_frame->view()->rootFram
eToContents(point.pos())); |
| 3865 HitTestResult result; | 3886 HitTestResult result; |
| 3866 if (!m_touchSequenceDocument) { | 3887 if (!m_touchSequenceDocument) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3881 node = ComposedTreeTraversal::parent(*node); | 3902 node = ComposedTreeTraversal::parent(*node); |
| 3882 | 3903 |
| 3883 if (!m_touchSequenceDocument) { | 3904 if (!m_touchSequenceDocument) { |
| 3884 // Keep track of which document should receive all touch events | 3905 // Keep track of which document should receive all touch events |
| 3885 // in the active sequence. This must be a single document to | 3906 // in the active sequence. This must be a single document to |
| 3886 // ensure we don't leak Nodes between documents. | 3907 // ensure we don't leak Nodes between documents. |
| 3887 m_touchSequenceDocument = &(result.innerNode()->document()); | 3908 m_touchSequenceDocument = &(result.innerNode()->document()); |
| 3888 ASSERT(m_touchSequenceDocument->frame()->view()); | 3909 ASSERT(m_touchSequenceDocument->frame()->view()); |
| 3889 } | 3910 } |
| 3890 | 3911 |
| 3912 // If it is the first TouchPressed we have seen so far, we will cons
ider it primary. |
| 3913 if (!m_primaryPointerId) |
| 3914 m_primaryPointerId = point.id(); |
| 3915 |
| 3891 // Ideally we'd ASSERT(!m_targetForTouchID.contains(point.id()) | 3916 // Ideally we'd ASSERT(!m_targetForTouchID.contains(point.id()) |
| 3892 // since we shouldn't get a touchstart for a touch that's already | 3917 // since we shouldn't get a touchstart for a touch that's already |
| 3893 // down. However EventSender allows this to be violated and there's | 3918 // down. However EventSender allows this to be violated and there's |
| 3894 // some tests that take advantage of it. There may also be edge | 3919 // some tests that take advantage of it. There may also be edge |
| 3895 // cases in the browser where this happens. | 3920 // cases in the browser where this happens. |
| 3896 // See http://crbug.com/345372. | 3921 // See http://crbug.com/345372. |
| 3897 m_targetForTouchID.set(point.id(), node); | 3922 m_targetForTouchID.set(point.id(), node); |
| 3898 | 3923 |
| 3899 TouchAction effectiveTouchAction = computeEffectiveTouchAction(*node
); | 3924 TouchAction effectiveTouchAction = computeEffectiveTouchAction(*node
); |
| 3900 if (effectiveTouchAction != TouchActionAuto) | 3925 if (effectiveTouchAction != TouchActionAuto) |
| 3901 m_frame->page()->chrome().client().setTouchAction(effectiveTouch
Action); | 3926 m_frame->page()->chrome().client().setTouchAction(effectiveTouch
Action); |
| 3902 } | 3927 } |
| 3903 } | 3928 } |
| 3904 | 3929 |
| 3905 m_touchPressed = !allTouchReleased; | 3930 m_touchPressed = !allTouchReleased; |
| 3906 | 3931 |
| 3932 unsigned lastPrimaryPointerId = m_primaryPointerId; |
| 3933 if (allTouchReleased) |
| 3934 m_primaryPointerId = 0; |
| 3935 |
| 3907 // If there's no document receiving touch events, or no handlers on the | 3936 // If there's no document receiving touch events, or no handlers on the |
| 3908 // document set to receive the events, then we can skip all the rest of | 3937 // document set to receive the events, then we can skip all the rest of |
| 3909 // this work. | 3938 // this work. |
| 3910 if (!m_touchSequenceDocument || !m_touchSequenceDocument->frameHost() || !m_
touchSequenceDocument->frameHost()->eventHandlerRegistry().hasEventHandlers(Even
tHandlerRegistry::TouchEvent) || !m_touchSequenceDocument->frame()) { | 3939 if (!m_touchSequenceDocument || !m_touchSequenceDocument->frameHost() || !m_
touchSequenceDocument->frameHost()->eventHandlerRegistry().hasEventHandlers(Even
tHandlerRegistry::TouchEvent) || !m_touchSequenceDocument->frame()) { |
| 3911 if (allTouchReleased) { | 3940 if (allTouchReleased) { |
| 3912 m_touchSequenceDocument.clear(); | 3941 m_touchSequenceDocument.clear(); |
| 3913 m_touchSequenceUserGestureToken.clear(); | 3942 m_touchSequenceUserGestureToken.clear(); |
| 3914 } | 3943 } |
| 3915 return false; | 3944 return false; |
| 3916 } | 3945 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3931 // Array of touches per state, used to assemble the 'changedTouches' list. | 3960 // Array of touches per state, used to assemble the 'changedTouches' list. |
| 3932 using EventTargetSet = WillBeHeapHashSet<RefPtrWillBeMember<EventTarget>>; | 3961 using EventTargetSet = WillBeHeapHashSet<RefPtrWillBeMember<EventTarget>>; |
| 3933 struct { | 3962 struct { |
| 3934 // The touches corresponding to the particular change state this struct | 3963 // The touches corresponding to the particular change state this struct |
| 3935 // instance represents. | 3964 // instance represents. |
| 3936 RefPtrWillBeMember<TouchList> m_touches; | 3965 RefPtrWillBeMember<TouchList> m_touches; |
| 3937 // Set of targets involved in m_touches. | 3966 // Set of targets involved in m_touches. |
| 3938 EventTargetSet m_targets; | 3967 EventTargetSet m_targets; |
| 3939 } changedTouches[PlatformTouchPoint::TouchStateEnd]; | 3968 } changedTouches[PlatformTouchPoint::TouchStateEnd]; |
| 3940 | 3969 |
| 3941 for (i = 0; i < points.size(); ++i) { | 3970 for (unsigned i = 0; i < points.size(); ++i) { |
| 3942 const PlatformTouchPoint& point = points[i]; | 3971 const PlatformTouchPoint& point = points[i]; |
| 3943 PlatformTouchPoint::State pointState = point.state(); | 3972 PlatformTouchPoint::State pointState = point.state(); |
| 3944 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr; | 3973 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr; |
| 3945 | 3974 |
| 3946 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla
tformTouchPoint::TouchCancelled) { | 3975 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla
tformTouchPoint::TouchCancelled) { |
| 3947 // The target should be the original target for this touch, so get | 3976 // The target should be the original target for this touch, so get |
| 3948 // it from the hashmap. As it's a release or cancel we also remove | 3977 // it from the hashmap. As it's a release or cancel we also remove |
| 3949 // it from the map. | 3978 // it from the map. |
| 3950 touchTarget = m_targetForTouchID.take(point.id()); | 3979 touchTarget = m_targetForTouchID.take(point.id()); |
| 3951 } else { | 3980 } else { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4024 changedTouches[pointState].m_touches = TouchList::create(); | 4053 changedTouches[pointState].m_touches = TouchList::create(); |
| 4025 changedTouches[pointState].m_touches->append(touch); | 4054 changedTouches[pointState].m_touches->append(touch); |
| 4026 changedTouches[pointState].m_targets.add(touchTarget); | 4055 changedTouches[pointState].m_targets.add(touchTarget); |
| 4027 } | 4056 } |
| 4028 } | 4057 } |
| 4029 if (allTouchReleased) { | 4058 if (allTouchReleased) { |
| 4030 m_touchSequenceDocument.clear(); | 4059 m_touchSequenceDocument.clear(); |
| 4031 m_touchSequenceUserGestureToken.clear(); | 4060 m_touchSequenceUserGestureToken.clear(); |
| 4032 } | 4061 } |
| 4033 | 4062 |
| 4063 bool swallowedEvent = false; |
| 4064 |
| 4065 if (RuntimeEnabledFeatures::pointerEventEnabled()) { |
| 4066 // Iterate the changedTouches list and m_targets within it, sending Poin
terEvents |
| 4067 // to the targets as required. |
| 4068 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++s
tate) { |
| 4069 if (!changedTouches[state].m_touches) |
| 4070 continue; |
| 4071 |
| 4072 const AtomicString& eventName(pointerEventNameForTouchPointState(sta
tic_cast<PlatformTouchPoint::State>(state))); |
| 4073 const EventTargetSet& targetsForState = changedTouches[state].m_targ
ets; |
| 4074 |
| 4075 for (const RefPtrWillBeMember<EventTarget>& eventTarget : targetsFor
State) { |
| 4076 EventTarget* pointerEventTarget = eventTarget.get(); |
| 4077 TouchList* touchesForTarget = touchesByTarget.get(pointerEventTa
rget); |
| 4078 for (unsigned i = 0; i < touchesForTarget->length(); i++) { |
| 4079 Touch* touch = touchesForTarget->item(i); |
| 4080 |
| 4081 PointerEventInit pointerEventInit; |
| 4082 pointerEventInit.setPointerId(touch->identifier()); |
| 4083 pointerEventInit.setWidth(touch->radiusX()); |
| 4084 pointerEventInit.setHeight(touch->radiusY()); |
| 4085 pointerEventInit.setPressure(touch->force()); |
| 4086 pointerEventInit.setTiltX(0.0); |
| 4087 pointerEventInit.setTiltY(0.0); |
| 4088 pointerEventInit.setPointerType(eventName); |
| 4089 pointerEventInit.setIsPrimary(lastPrimaryPointerId == touch-
>identifier()); |
| 4090 |
| 4091 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = PointerEvent
::create(eventName, pointerEventInit); |
| 4092 pointerEventTarget->toNode()->dispatchPointerEvent(pointerEv
ent.get()); |
| 4093 swallowedEvent = swallowedEvent || pointerEvent->defaultPrev
ented() || pointerEvent->defaultHandled(); |
| 4094 } |
| 4095 } |
| 4096 } |
| 4097 |
| 4098 // Skip firing TouchEvent's if any PointerEvent was consumed. |
| 4099 if (swallowedEvent) |
| 4100 return true; |
| 4101 } |
| 4102 |
| 4034 // Now iterate the changedTouches list and m_targets within it, sending | 4103 // Now iterate the changedTouches list and m_targets within it, sending |
| 4035 // events to the targets as required. | 4104 // TouchEvents to the targets as required. |
| 4036 bool swallowedEvent = false; | |
| 4037 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state
) { | 4105 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state
) { |
| 4038 if (!changedTouches[state].m_touches) | 4106 if (!changedTouches[state].m_touches) |
| 4039 continue; | 4107 continue; |
| 4040 | 4108 |
| 4041 const AtomicString& stateName(eventNameForTouchPointState(static_cast<Pl
atformTouchPoint::State>(state))); | 4109 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca
st<PlatformTouchPoint::State>(state))); |
| 4042 const EventTargetSet& targetsForState = changedTouches[state].m_targets; | 4110 const EventTargetSet& targetsForState = changedTouches[state].m_targets; |
| 4043 for (const RefPtrWillBeMember<EventTarget>& eventTarget : targetsForStat
e) { | 4111 for (const RefPtrWillBeMember<EventTarget>& eventTarget : targetsForStat
e) { |
| 4044 EventTarget* touchEventTarget = eventTarget.get(); | 4112 EventTarget* touchEventTarget = eventTarget.get(); |
| 4045 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create( | 4113 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create( |
| 4046 touches.get(), touchesByTarget.get(touchEventTarget), changedTou
ches[state].m_touches.get(), | 4114 touches.get(), touchesByTarget.get(touchEventTarget), changedTou
ches[state].m_touches.get(), |
| 4047 stateName, touchEventTarget->toNode()->document().domWindow(), | 4115 eventName, touchEventTarget->toNode()->document().domWindow(), |
| 4048 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey
(), event.cancelable(), event.causesScrollingIfUncanceled(), event.timestamp()); | 4116 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey
(), event.cancelable(), event.causesScrollingIfUncanceled(), event.timestamp()); |
| 4049 touchEventTarget->toNode()->dispatchTouchEvent(touchEvent.get()); | 4117 touchEventTarget->toNode()->dispatchTouchEvent(touchEvent.get()); |
| 4050 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() ||
touchEvent->defaultHandled(); | 4118 swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() ||
touchEvent->defaultHandled(); |
| 4051 } | 4119 } |
| 4052 } | 4120 } |
| 4053 | 4121 |
| 4054 return swallowedEvent; | 4122 return swallowedEvent; |
| 4055 } | 4123 } |
| 4056 | 4124 |
| 4057 TouchAction EventHandler::intersectTouchAction(TouchAction action1, TouchAction
action2) | 4125 TouchAction EventHandler::intersectTouchAction(TouchAction action1, TouchAction
action2) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4169 unsigned EventHandler::accessKeyModifiers() | 4237 unsigned EventHandler::accessKeyModifiers() |
| 4170 { | 4238 { |
| 4171 #if OS(MACOSX) | 4239 #if OS(MACOSX) |
| 4172 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4240 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 4173 #else | 4241 #else |
| 4174 return PlatformEvent::AltKey; | 4242 return PlatformEvent::AltKey; |
| 4175 #endif | 4243 #endif |
| 4176 } | 4244 } |
| 4177 | 4245 |
| 4178 } // namespace blink | 4246 } // namespace blink |
| OLD | NEW |