| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire
d) | 251 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire
d) |
| 252 , m_svgPan(false) | 252 , m_svgPan(false) |
| 253 , m_resizeScrollableArea(nullptr) | 253 , m_resizeScrollableArea(nullptr) |
| 254 , m_eventHandlerWillResetCapturingMouseEventsNode(0) | 254 , m_eventHandlerWillResetCapturingMouseEventsNode(0) |
| 255 , m_clickCount(0) | 255 , m_clickCount(0) |
| 256 , m_shouldOnlyFireDragOverEvent(false) | 256 , m_shouldOnlyFireDragOverEvent(false) |
| 257 , m_accumulatedRootOverscroll(FloatSize()) | 257 , m_accumulatedRootOverscroll(FloatSize()) |
| 258 , m_mousePositionIsUnknown(true) | 258 , m_mousePositionIsUnknown(true) |
| 259 , m_mouseDownTimestamp(0) | 259 , m_mouseDownTimestamp(0) |
| 260 , m_touchPressed(false) | 260 , m_touchPressed(false) |
| 261 , m_inPointerCanceledState(false) | |
| 262 , m_scrollGestureHandlingNode(nullptr) | 261 , m_scrollGestureHandlingNode(nullptr) |
| 263 , m_lastGestureScrollOverWidget(false) | 262 , m_lastGestureScrollOverWidget(false) |
| 264 , m_longTapShouldInvokeContextMenu(false) | 263 , m_longTapShouldInvokeContextMenu(false) |
| 265 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 264 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
| 266 , m_lastShowPressTimestamp(0) | 265 , m_lastShowPressTimestamp(0) |
| 267 , m_deltaConsumedForScrollSequence(false) | 266 , m_deltaConsumedForScrollSequence(false) |
| 268 { | 267 { |
| 269 } | 268 } |
| 270 | 269 |
| 271 EventHandler::~EventHandler() | 270 EventHandler::~EventHandler() |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 m_capturesDragging = false; | 326 m_capturesDragging = false; |
| 328 m_capturingMouseEventsNode = nullptr; | 327 m_capturingMouseEventsNode = nullptr; |
| 329 m_targetForTouchID.clear(); | 328 m_targetForTouchID.clear(); |
| 330 m_touchSequenceDocument.clear(); | 329 m_touchSequenceDocument.clear(); |
| 331 m_touchSequenceUserGestureToken.clear(); | 330 m_touchSequenceUserGestureToken.clear(); |
| 332 clearGestureScrollState(); | 331 clearGestureScrollState(); |
| 333 m_lastGestureScrollOverWidget = false; | 332 m_lastGestureScrollOverWidget = false; |
| 334 m_scrollbarHandlingScrollGesture = nullptr; | 333 m_scrollbarHandlingScrollGesture = nullptr; |
| 335 m_touchPressed = false; | 334 m_touchPressed = false; |
| 336 m_pointerEventManager.clear(); | 335 m_pointerEventManager.clear(); |
| 337 m_inPointerCanceledState = false; | |
| 338 m_mouseDownMayStartDrag = false; | 336 m_mouseDownMayStartDrag = false; |
| 339 m_lastShowPressTimestamp = 0; | 337 m_lastShowPressTimestamp = 0; |
| 340 m_lastDeferredTapElement = nullptr; | 338 m_lastDeferredTapElement = nullptr; |
| 341 m_eventHandlerWillResetCapturingMouseEventsNode = false; | 339 m_eventHandlerWillResetCapturingMouseEventsNode = false; |
| 342 m_mouseDownMayStartAutoscroll = false; | 340 m_mouseDownMayStartAutoscroll = false; |
| 343 m_svgPan = false; | 341 m_svgPan = false; |
| 344 m_mouseDownPos = IntPoint(); | 342 m_mouseDownPos = IntPoint(); |
| 345 m_mouseDownTimestamp = 0; | 343 m_mouseDownTimestamp = 0; |
| 346 m_longTapShouldInvokeContextMenu = false; | 344 m_longTapShouldInvokeContextMenu = false; |
| 347 m_dragStartPos = LayoutPoint(); | 345 m_dragStartPos = LayoutPoint(); |
| (...skipping 3274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3622 | 3620 |
| 3623 WebInputEventResult result = | 3621 WebInputEventResult result = |
| 3624 m_pointerEventManager.sendTouchPointerEvent( | 3622 m_pointerEventManager.sendTouchPointerEvent( |
| 3625 touchInfo.touchTarget, touchPoint, event.getModifiers(), | 3623 touchInfo.touchTarget, touchPoint, event.getModifiers(), |
| 3626 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(), | 3624 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(), |
| 3627 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y()); | 3625 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y()); |
| 3628 touchInfo.consumed = result != WebInputEventResult::NotHandled; | 3626 touchInfo.consumed = result != WebInputEventResult::NotHandled; |
| 3629 } | 3627 } |
| 3630 } | 3628 } |
| 3631 | 3629 |
| 3632 void EventHandler::sendPointerCancels(WillBeHeapVector<TouchInfo>& touchInfos) | |
| 3633 { | |
| 3634 if (!RuntimeEnabledFeatures::pointerEventEnabled()) | |
| 3635 return; | |
| 3636 | |
| 3637 for (unsigned i = 0; i < touchInfos.size(); ++i) { | |
| 3638 TouchInfo& touchInfo = touchInfos[i]; | |
| 3639 const PlatformTouchPoint& point = touchInfo.point; | |
| 3640 const PlatformTouchPoint::TouchState pointState = point.state(); | |
| 3641 | |
| 3642 if (pointState == PlatformTouchPoint::TouchReleased | |
| 3643 || pointState == PlatformTouchPoint::TouchCancelled) | |
| 3644 continue; | |
| 3645 | |
| 3646 m_pointerEventManager.sendTouchCancelPointerEvent( | |
| 3647 touchInfo.touchTarget, | |
| 3648 point); | |
| 3649 } | |
| 3650 } | |
| 3651 | |
| 3652 namespace { | 3630 namespace { |
| 3653 | 3631 |
| 3654 // Defining this class type local to dispatchTouchEvents() and annotating | 3632 // Defining this class type local to dispatchTouchEvents() and annotating |
| 3655 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning | 3633 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning |
| 3656 // that the local class doesn't provide a local definition for 'operator new'. | 3634 // that the local class doesn't provide a local definition for 'operator new'. |
| 3657 // Which it intentionally doesn't and shouldn't. | 3635 // Which it intentionally doesn't and shouldn't. |
| 3658 // | 3636 // |
| 3659 // Work around such toolchain bugginess by lifting out the type, thereby | 3637 // Work around such toolchain bugginess by lifting out the type, thereby |
| 3660 // taking it out of C4822's reach. | 3638 // taking it out of C4822's reach. |
| 3661 class ChangedTouches final { | 3639 class ChangedTouches final { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3764 } | 3742 } |
| 3765 } | 3743 } |
| 3766 | 3744 |
| 3767 return eventResult; | 3745 return eventResult; |
| 3768 } | 3746 } |
| 3769 | 3747 |
| 3770 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
nt) | 3748 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
nt) |
| 3771 { | 3749 { |
| 3772 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); | 3750 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); |
| 3773 | 3751 |
| 3752 fprintf(stderr, "======= mDebug %s received %d\n", __FUNCTION__, event.type(
) - PlatformEvent::TouchStart); |
| 3753 |
| 3754 if (event.type() == PlatformEvent::TouchScrollStarted) { |
| 3755 m_pointerEventManager.blockTouchPointers(); |
| 3756 return WebInputEventResult::HandledSystem; |
| 3757 } |
| 3758 |
| 3774 const Vector<PlatformTouchPoint>& points = event.touchPoints(); | 3759 const Vector<PlatformTouchPoint>& points = event.touchPoints(); |
| 3775 | 3760 |
| 3776 bool freshTouchEvents = true; | 3761 bool freshTouchEvents = true; |
| 3777 bool allTouchReleased = true; | 3762 bool allTouchReleased = true; |
| 3778 for (unsigned i = 0; i < points.size(); ++i) { | 3763 for (unsigned i = 0; i < points.size(); ++i) { |
| 3779 const PlatformTouchPoint& point = points[i]; | 3764 const PlatformTouchPoint& point = points[i]; |
| 3780 | 3765 |
| 3781 if (point.state() != PlatformTouchPoint::TouchPressed) | 3766 if (point.state() != PlatformTouchPoint::TouchPressed) |
| 3782 freshTouchEvents = false; | 3767 freshTouchEvents = false; |
| 3783 if (point.state() != PlatformTouchPoint::TouchReleased && point.state()
!= PlatformTouchPoint::TouchCancelled) | 3768 if (point.state() != PlatformTouchPoint::TouchReleased && point.state()
!= PlatformTouchPoint::TouchCancelled) |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3929 TouchInfo& touchInfo = touchInfos[i]; | 3914 TouchInfo& touchInfo = touchInfos[i]; |
| 3930 touchInfo.point = point; | 3915 touchInfo.point = point; |
| 3931 touchInfo.touchTarget = touchTarget; | 3916 touchInfo.touchTarget = touchTarget; |
| 3932 touchInfo.targetFrame = targetFrame; | 3917 touchInfo.targetFrame = targetFrame; |
| 3933 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor); | 3918 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor); |
| 3934 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor); | 3919 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor); |
| 3935 touchInfo.knownTarget = knownTarget; | 3920 touchInfo.knownTarget = knownTarget; |
| 3936 touchInfo.consumed = false; | 3921 touchInfo.consumed = false; |
| 3937 } | 3922 } |
| 3938 | 3923 |
| 3939 if (!m_inPointerCanceledState) { | 3924 if (freshTouchEvents) |
| 3940 dispatchPointerEvents(event, touchInfos); | 3925 m_pointerEventManager.unblockTouchPointers(); |
| 3941 // Note that the disposition of any pointer events affects only the gene
ration of touch | 3926 dispatchPointerEvents(event, touchInfos); |
| 3942 // events. If all pointer events were handled (and hence no touch events
were fired), that | 3927 // Note that the disposition of any pointer events affects only the generati
on of touch |
| 3943 // is still equivalent to the touch events going unhandled because point
er event handler | 3928 // events. If all pointer events were handled (and hence no touch events wer
e fired), that |
| 3944 // don't block scroll gesture generation. | 3929 // is still equivalent to the touch events going unhandled because pointer e
vent handler |
| 3945 } | 3930 // don't block scroll gesture generation. |
| 3946 | 3931 |
| 3947 // TODO(crbug.com/507408): If PE handlers always call preventDefault, we won
't see TEs until after | 3932 // TODO(crbug.com/507408): If PE handlers always call preventDefault, we won
't see TEs until after |
| 3948 // scrolling starts because the scrolling would suppress upcoming PEs. This
sudden "break" in TE | 3933 // scrolling starts because the scrolling would suppress upcoming PEs. This
sudden "break" in TE |
| 3949 // suppression can make the visible TEs inconsistent (e.g. touchmove without
a touchstart). | 3934 // suppression can make the visible TEs inconsistent (e.g. touchmove without
a touchstart). |
| 3950 | 3935 |
| 3951 WebInputEventResult eventResult = dispatchTouchEvents(event, touchInfos, fre
shTouchEvents, | 3936 return dispatchTouchEvents(event, touchInfos, freshTouchEvents, allTouchRele
ased); |
| 3952 allTouchReleased); | |
| 3953 | |
| 3954 if (!m_inPointerCanceledState) { | |
| 3955 // Check if we need to stop firing pointer events because of a touch act
ion. | |
| 3956 // See: www.w3.org/TR/pointerevents/#declaring-candidate-regions-for-def
ault-touch-behaviors | |
| 3957 if (event.causesScrollingIfUncanceled() && eventResult == WebInputEventR
esult::NotHandled) { | |
| 3958 m_inPointerCanceledState = true; | |
| 3959 sendPointerCancels(touchInfos); | |
| 3960 } | |
| 3961 } else if (allTouchReleased) { | |
| 3962 m_inPointerCanceledState = false; | |
| 3963 } | |
| 3964 | |
| 3965 return eventResult; | |
| 3966 } | 3937 } |
| 3967 | 3938 |
| 3968 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) | 3939 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) |
| 3969 { | 3940 { |
| 3970 m_mousePositionIsUnknown = false; | 3941 m_mousePositionIsUnknown = false; |
| 3971 m_lastKnownMousePosition = event.position(); | 3942 m_lastKnownMousePosition = event.position(); |
| 3972 m_lastKnownMouseGlobalPosition = event.globalPosition(); | 3943 m_lastKnownMouseGlobalPosition = event.globalPosition(); |
| 3973 } | 3944 } |
| 3974 | 3945 |
| 3975 WebInputEventResult EventHandler::passMousePressEventToSubframe(MouseEventWithHi
tTestResults& mev, LocalFrame* subframe) | 3946 WebInputEventResult EventHandler::passMousePressEventToSubframe(MouseEventWithHi
tTestResults& mev, LocalFrame* subframe) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4015 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() | 3986 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() |
| 4016 { | 3987 { |
| 4017 #if OS(MACOSX) | 3988 #if OS(MACOSX) |
| 4018 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); | 3989 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); |
| 4019 #else | 3990 #else |
| 4020 return PlatformEvent::AltKey; | 3991 return PlatformEvent::AltKey; |
| 4021 #endif | 3992 #endif |
| 4022 } | 3993 } |
| 4023 | 3994 |
| 4024 } // namespace blink | 3995 } // namespace blink |
| OLD | NEW |