| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire
d) | 278 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire
d) |
| 279 , m_svgPan(false) | 279 , m_svgPan(false) |
| 280 , m_resizeScrollableArea(nullptr) | 280 , m_resizeScrollableArea(nullptr) |
| 281 , m_eventHandlerWillResetCapturingMouseEventsNode(0) | 281 , m_eventHandlerWillResetCapturingMouseEventsNode(0) |
| 282 , m_clickCount(0) | 282 , m_clickCount(0) |
| 283 , m_shouldOnlyFireDragOverEvent(false) | 283 , m_shouldOnlyFireDragOverEvent(false) |
| 284 , m_accumulatedRootOverscroll(FloatSize()) | 284 , m_accumulatedRootOverscroll(FloatSize()) |
| 285 , m_mousePositionIsUnknown(true) | 285 , m_mousePositionIsUnknown(true) |
| 286 , m_mouseDownTimestamp(0) | 286 , m_mouseDownTimestamp(0) |
| 287 , m_touchPressed(false) | 287 , m_touchPressed(false) |
| 288 , m_inPointerCanceledState(false) | |
| 289 , m_scrollGestureHandlingNode(nullptr) | 288 , m_scrollGestureHandlingNode(nullptr) |
| 290 , m_lastGestureScrollOverWidget(false) | 289 , m_lastGestureScrollOverWidget(false) |
| 291 , m_longTapShouldInvokeContextMenu(false) | 290 , m_longTapShouldInvokeContextMenu(false) |
| 292 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 291 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
| 293 , m_lastShowPressTimestamp(0) | 292 , m_lastShowPressTimestamp(0) |
| 294 , m_deltaConsumedForScrollSequence(false) | 293 , m_deltaConsumedForScrollSequence(false) |
| 295 { | 294 { |
| 296 } | 295 } |
| 297 | 296 |
| 298 EventHandler::~EventHandler() | 297 EventHandler::~EventHandler() |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 m_capturesDragging = false; | 352 m_capturesDragging = false; |
| 354 m_capturingMouseEventsNode = nullptr; | 353 m_capturingMouseEventsNode = nullptr; |
| 355 m_targetForTouchID.clear(); | 354 m_targetForTouchID.clear(); |
| 356 m_touchSequenceDocument.clear(); | 355 m_touchSequenceDocument.clear(); |
| 357 m_touchSequenceUserGestureToken.clear(); | 356 m_touchSequenceUserGestureToken.clear(); |
| 358 clearGestureScrollState(); | 357 clearGestureScrollState(); |
| 359 m_lastGestureScrollOverWidget = false; | 358 m_lastGestureScrollOverWidget = false; |
| 360 m_scrollbarHandlingScrollGesture = nullptr; | 359 m_scrollbarHandlingScrollGesture = nullptr; |
| 361 m_touchPressed = false; | 360 m_touchPressed = false; |
| 362 m_pointerEventManager.clear(); | 361 m_pointerEventManager.clear(); |
| 363 m_inPointerCanceledState = false; | |
| 364 m_mouseDownMayStartDrag = false; | 362 m_mouseDownMayStartDrag = false; |
| 365 m_lastShowPressTimestamp = 0; | 363 m_lastShowPressTimestamp = 0; |
| 366 m_lastDeferredTapElement = nullptr; | 364 m_lastDeferredTapElement = nullptr; |
| 367 m_eventHandlerWillResetCapturingMouseEventsNode = false; | 365 m_eventHandlerWillResetCapturingMouseEventsNode = false; |
| 368 m_mouseDownMayStartAutoscroll = false; | 366 m_mouseDownMayStartAutoscroll = false; |
| 369 m_svgPan = false; | 367 m_svgPan = false; |
| 370 m_mouseDownPos = IntPoint(); | 368 m_mouseDownPos = IntPoint(); |
| 371 m_mouseDownTimestamp = 0; | 369 m_mouseDownTimestamp = 0; |
| 372 m_longTapShouldInvokeContextMenu = false; | 370 m_longTapShouldInvokeContextMenu = false; |
| 373 m_dragStartPos = LayoutPoint(); | 371 m_dragStartPos = LayoutPoint(); |
| (...skipping 3354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3728 | 3726 |
| 3729 WebInputEventResult result = | 3727 WebInputEventResult result = |
| 3730 m_pointerEventManager.sendTouchPointerEvent( | 3728 m_pointerEventManager.sendTouchPointerEvent( |
| 3731 touchInfo.touchTarget, touchPoint, event.getModifiers(), | 3729 touchInfo.touchTarget, touchPoint, event.getModifiers(), |
| 3732 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(), | 3730 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(), |
| 3733 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y()); | 3731 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y()); |
| 3734 touchInfo.consumed = result != WebInputEventResult::NotHandled; | 3732 touchInfo.consumed = result != WebInputEventResult::NotHandled; |
| 3735 } | 3733 } |
| 3736 } | 3734 } |
| 3737 | 3735 |
| 3738 void EventHandler::sendPointerCancels(HeapVector<TouchInfo>& touchInfos) | |
| 3739 { | |
| 3740 if (!RuntimeEnabledFeatures::pointerEventEnabled()) | |
| 3741 return; | |
| 3742 | |
| 3743 for (unsigned i = 0; i < touchInfos.size(); ++i) { | |
| 3744 TouchInfo& touchInfo = touchInfos[i]; | |
| 3745 const PlatformTouchPoint& point = touchInfo.point; | |
| 3746 const PlatformTouchPoint::TouchState pointState = point.state(); | |
| 3747 | |
| 3748 if (pointState == PlatformTouchPoint::TouchReleased | |
| 3749 || pointState == PlatformTouchPoint::TouchCancelled) | |
| 3750 continue; | |
| 3751 | |
| 3752 m_pointerEventManager.sendTouchCancelPointerEvent( | |
| 3753 touchInfo.touchTarget, | |
| 3754 point); | |
| 3755 } | |
| 3756 } | |
| 3757 | |
| 3758 namespace { | 3736 namespace { |
| 3759 | 3737 |
| 3760 // Defining this class type local to dispatchTouchEvents() and annotating | 3738 // Defining this class type local to dispatchTouchEvents() and annotating |
| 3761 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning | 3739 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning |
| 3762 // that the local class doesn't provide a local definition for 'operator new'. | 3740 // that the local class doesn't provide a local definition for 'operator new'. |
| 3763 // Which it intentionally doesn't and shouldn't. | 3741 // Which it intentionally doesn't and shouldn't. |
| 3764 // | 3742 // |
| 3765 // Work around such toolchain bugginess by lifting out the type, thereby | 3743 // Work around such toolchain bugginess by lifting out the type, thereby |
| 3766 // taking it out of C4822's reach. | 3744 // taking it out of C4822's reach. |
| 3767 class ChangedTouches final { | 3745 class ChangedTouches final { |
| 3768 STACK_ALLOCATED(); | 3746 STACK_ALLOCATED(); |
| 3769 public: | 3747 public: |
| 3770 // The touches corresponding to the particular change state this struct | 3748 // The touches corresponding to the particular change state this struct |
| 3771 // instance represents. | 3749 // instance represents. |
| 3772 Member<TouchList> m_touches; | 3750 Member<TouchList> m_touches; |
| 3773 | 3751 |
| 3774 using EventTargetSet = HeapHashSet<Member<EventTarget>>; | 3752 using EventTargetSet = HeapHashSet<Member<EventTarget>>; |
| 3775 // Set of targets involved in m_touches. | 3753 // Set of targets involved in m_touches. |
| 3776 EventTargetSet m_targets; | 3754 EventTargetSet m_targets; |
| 3777 }; | 3755 }; |
| 3778 | 3756 |
| 3779 } // namespace | 3757 } // namespace |
| 3780 | 3758 |
| 3781 WebInputEventResult EventHandler::dispatchTouchEvents(const PlatformTouchEvent&
event, | 3759 WebInputEventResult EventHandler::dispatchTouchEvents(const PlatformTouchEvent&
event, |
| 3782 HeapVector<TouchInfo>& touchInfos, bool freshTouchEvents, bool allTouchRelea
sed) | 3760 HeapVector<TouchInfo>& touchInfos, bool allTouchReleased) |
| 3783 { | 3761 { |
| 3784 // Build up the lists to use for the 'touches', 'targetTouches' and | 3762 // Build up the lists to use for the 'touches', 'targetTouches' and |
| 3785 // 'changedTouches' attributes in the JS event. See | 3763 // 'changedTouches' attributes in the JS event. See |
| 3786 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these | 3764 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these |
| 3787 // lists fit together. | 3765 // lists fit together. |
| 3788 | 3766 |
| 3789 // Holds the complete set of touches on the screen. | 3767 // Holds the complete set of touches on the screen. |
| 3790 TouchList* touches = TouchList::create(); | 3768 TouchList* touches = TouchList::create(); |
| 3791 | 3769 |
| 3792 // A different view on the 'touches' list above, filtered and grouped by | 3770 // A different view on the 'touches' list above, filtered and grouped by |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3871 } | 3849 } |
| 3872 } | 3850 } |
| 3873 | 3851 |
| 3874 return eventResult; | 3852 return eventResult; |
| 3875 } | 3853 } |
| 3876 | 3854 |
| 3877 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
nt) | 3855 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
nt) |
| 3878 { | 3856 { |
| 3879 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); | 3857 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); |
| 3880 | 3858 |
| 3859 if (event.type() == PlatformEvent::TouchScrollStarted) { |
| 3860 m_pointerEventManager.blockTouchPointers(); |
| 3861 return WebInputEventResult::HandledSystem; |
| 3862 } |
| 3863 |
| 3881 const Vector<PlatformTouchPoint>& points = event.touchPoints(); | 3864 const Vector<PlatformTouchPoint>& points = event.touchPoints(); |
| 3882 | 3865 |
| 3883 bool freshTouchEvents = true; | 3866 bool newTouchSequence = true; |
| 3884 bool allTouchReleased = true; | 3867 bool allTouchReleased = true; |
| 3885 for (unsigned i = 0; i < points.size(); ++i) { | 3868 for (unsigned i = 0; i < points.size(); ++i) { |
| 3886 const PlatformTouchPoint& point = points[i]; | 3869 const PlatformTouchPoint& point = points[i]; |
| 3887 | 3870 |
| 3888 if (point.state() != PlatformTouchPoint::TouchPressed) | 3871 if (point.state() != PlatformTouchPoint::TouchPressed) |
| 3889 freshTouchEvents = false; | 3872 newTouchSequence = false; |
| 3890 if (point.state() != PlatformTouchPoint::TouchReleased && point.state()
!= PlatformTouchPoint::TouchCancelled) | 3873 if (point.state() != PlatformTouchPoint::TouchReleased && point.state()
!= PlatformTouchPoint::TouchCancelled) |
| 3891 allTouchReleased = false; | 3874 allTouchReleased = false; |
| 3892 } | 3875 } |
| 3893 if (freshTouchEvents) { | 3876 |
| 3877 if (newTouchSequence) { |
| 3894 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should | 3878 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should |
| 3895 // have cleared the active document when we saw the last release. But we | 3879 // have cleared the active document when we saw the last release. But we |
| 3896 // have some tests that violate this, ClusterFuzz could trigger it, and | 3880 // have some tests that violate this, ClusterFuzz could trigger it, and |
| 3897 // there may be cases where the browser doesn't reliably release all | 3881 // there may be cases where the browser doesn't reliably release all |
| 3898 // touches. http://crbug.com/345372 tracks this. | 3882 // touches. http://crbug.com/345372 tracks this. |
| 3899 m_touchSequenceDocument.clear(); | 3883 m_touchSequenceDocument.clear(); |
| 3900 m_touchSequenceUserGestureToken.clear(); | 3884 m_touchSequenceUserGestureToken.clear(); |
| 3885 m_pointerEventManager.unblockTouchPointers(); |
| 3901 } | 3886 } |
| 3902 | 3887 |
| 3903 ASSERT(m_frame->view()); | 3888 ASSERT(m_frame->view()); |
| 3904 if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touc
hSequenceDocument->frame()->view())) { | 3889 if (m_touchSequenceDocument && (!m_touchSequenceDocument->frame() || !m_touc
hSequenceDocument->frame()->view())) { |
| 3905 // If the active touch document has no frame or view, it's probably bein
g destroyed | 3890 // If the active touch document has no frame or view, it's probably bein
g destroyed |
| 3906 // so we can't dispatch events. | 3891 // so we can't dispatch events. |
| 3907 return WebInputEventResult::NotHandled; | 3892 return WebInputEventResult::NotHandled; |
| 3908 } | 3893 } |
| 3909 | 3894 |
| 3910 // First do hit tests for any new touch points. | 3895 // First do hit tests for any new touch points. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4058 touchInfo.point = point; | 4043 touchInfo.point = point; |
| 4059 touchInfo.touchTarget = touchTarget; | 4044 touchInfo.touchTarget = touchTarget; |
| 4060 touchInfo.targetFrame = targetFrame; | 4045 touchInfo.targetFrame = targetFrame; |
| 4061 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor); | 4046 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor); |
| 4062 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor); | 4047 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor); |
| 4063 touchInfo.knownTarget = knownTarget; | 4048 touchInfo.knownTarget = knownTarget; |
| 4064 touchInfo.consumed = false; | 4049 touchInfo.consumed = false; |
| 4065 touchInfo.region = regionID; | 4050 touchInfo.region = regionID; |
| 4066 } | 4051 } |
| 4067 | 4052 |
| 4068 if (!m_inPointerCanceledState) { | 4053 dispatchPointerEvents(event, touchInfos); |
| 4069 dispatchPointerEvents(event, touchInfos); | 4054 // Note that the disposition of any pointer events affects only the generati
on of touch |
| 4070 // Note that the disposition of any pointer events affects only the gene
ration of touch | 4055 // events. If all pointer events were handled (and hence no touch events wer
e fired), that |
| 4071 // events. If all pointer events were handled (and hence no touch events
were fired), that | 4056 // is still equivalent to the touch events going unhandled because pointer e
vent handler |
| 4072 // is still equivalent to the touch events going unhandled because point
er event handler | 4057 // don't block scroll gesture generation. |
| 4073 // don't block scroll gesture generation. | |
| 4074 } | |
| 4075 | 4058 |
| 4076 // TODO(crbug.com/507408): If PE handlers always call preventDefault, we won
't see TEs until after | 4059 // TODO(crbug.com/507408): If PE handlers always call preventDefault, we won
't see TEs until after |
| 4077 // scrolling starts because the scrolling would suppress upcoming PEs. This
sudden "break" in TE | 4060 // scrolling starts because the scrolling would suppress upcoming PEs. This
sudden "break" in TE |
| 4078 // suppression can make the visible TEs inconsistent (e.g. touchmove without
a touchstart). | 4061 // suppression can make the visible TEs inconsistent (e.g. touchmove without
a touchstart). |
| 4079 | 4062 |
| 4080 WebInputEventResult eventResult = dispatchTouchEvents(event, touchInfos, fre
shTouchEvents, | 4063 return dispatchTouchEvents(event, touchInfos, allTouchReleased); |
| 4081 allTouchReleased); | |
| 4082 | |
| 4083 if (!m_inPointerCanceledState) { | |
| 4084 // Check if we need to stop firing pointer events because of a touch act
ion. | |
| 4085 // See: www.w3.org/TR/pointerevents/#declaring-candidate-regions-for-def
ault-touch-behaviors | |
| 4086 if (event.causesScrollingIfUncanceled() && eventResult == WebInputEventR
esult::NotHandled) { | |
| 4087 m_inPointerCanceledState = true; | |
| 4088 sendPointerCancels(touchInfos); | |
| 4089 } | |
| 4090 } else if (allTouchReleased) { | |
| 4091 m_inPointerCanceledState = false; | |
| 4092 } | |
| 4093 | |
| 4094 return eventResult; | |
| 4095 } | 4064 } |
| 4096 | 4065 |
| 4097 void EventHandler::userGestureUtilized() | 4066 void EventHandler::userGestureUtilized() |
| 4098 { | 4067 { |
| 4099 // This is invoked for UserGestureIndicators created in handleTouchEvent whi
ch perhaps represent | 4068 // This is invoked for UserGestureIndicators created in handleTouchEvent whi
ch perhaps represent |
| 4100 // touch actions which shouldn't be considered a user-gesture. | 4069 // touch actions which shouldn't be considered a user-gesture. |
| 4101 UseCounter::count(m_frame, UseCounter::TouchDragUserGestureUsed); | 4070 UseCounter::count(m_frame, UseCounter::TouchDragUserGestureUsed); |
| 4102 Deprecation::countDeprecationCrossOriginIframe(m_frame, UseCounter::TouchDra
gUserGestureUsedCrossOrigin); | 4071 Deprecation::countDeprecationCrossOriginIframe(m_frame, UseCounter::TouchDra
gUserGestureUsedCrossOrigin); |
| 4103 } | 4072 } |
| 4104 | 4073 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4152 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() | 4121 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() |
| 4153 { | 4122 { |
| 4154 #if OS(MACOSX) | 4123 #if OS(MACOSX) |
| 4155 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); | 4124 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); |
| 4156 #else | 4125 #else |
| 4157 return PlatformEvent::AltKey; | 4126 return PlatformEvent::AltKey; |
| 4158 #endif | 4127 #endif |
| 4159 } | 4128 } |
| 4160 | 4129 |
| 4161 } // namespace blink | 4130 } // namespace blink |
| OLD | NEW |