Chromium Code Reviews| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d) | 252 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d) |
| 253 , m_svgPan(false) | 253 , m_svgPan(false) |
| 254 , m_resizeScrollableArea(nullptr) | 254 , m_resizeScrollableArea(nullptr) |
| 255 , m_eventHandlerWillResetCapturingMouseEventsNode(0) | 255 , m_eventHandlerWillResetCapturingMouseEventsNode(0) |
| 256 , m_clickCount(0) | 256 , m_clickCount(0) |
| 257 , m_shouldOnlyFireDragOverEvent(false) | 257 , m_shouldOnlyFireDragOverEvent(false) |
| 258 , m_accumulatedRootOverscroll(FloatSize()) | 258 , m_accumulatedRootOverscroll(FloatSize()) |
| 259 , m_mousePositionIsUnknown(true) | 259 , m_mousePositionIsUnknown(true) |
| 260 , m_mouseDownTimestamp(0) | 260 , m_mouseDownTimestamp(0) |
| 261 , m_touchPressed(false) | 261 , m_touchPressed(false) |
| 262 , m_inPointerCanceledState(false) | |
| 263 , m_scrollGestureHandlingNode(nullptr) | 262 , m_scrollGestureHandlingNode(nullptr) |
| 264 , m_lastGestureScrollOverWidget(false) | 263 , m_lastGestureScrollOverWidget(false) |
| 265 , m_longTapShouldInvokeContextMenu(false) | 264 , m_longTapShouldInvokeContextMenu(false) |
| 266 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 265 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
| 267 , m_lastShowPressTimestamp(0) | 266 , m_lastShowPressTimestamp(0) |
| 268 , m_deltaConsumedForScrollSequence(false) | 267 , m_deltaConsumedForScrollSequence(false) |
| 269 { | 268 { |
| 270 } | 269 } |
| 271 | 270 |
| 272 EventHandler::~EventHandler() | 271 EventHandler::~EventHandler() |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 m_capturesDragging = false; | 328 m_capturesDragging = false; |
| 330 m_capturingMouseEventsNode = nullptr; | 329 m_capturingMouseEventsNode = nullptr; |
| 331 m_targetForTouchID.clear(); | 330 m_targetForTouchID.clear(); |
| 332 m_touchSequenceDocument.clear(); | 331 m_touchSequenceDocument.clear(); |
| 333 m_touchSequenceUserGestureToken.clear(); | 332 m_touchSequenceUserGestureToken.clear(); |
| 334 clearGestureScrollState(); | 333 clearGestureScrollState(); |
| 335 m_lastGestureScrollOverWidget = false; | 334 m_lastGestureScrollOverWidget = false; |
| 336 m_scrollbarHandlingScrollGesture = nullptr; | 335 m_scrollbarHandlingScrollGesture = nullptr; |
| 337 m_touchPressed = false; | 336 m_touchPressed = false; |
| 338 m_pointerEventManager.clear(); | 337 m_pointerEventManager.clear(); |
| 339 m_inPointerCanceledState = false; | |
| 340 m_mouseDownMayStartDrag = false; | 338 m_mouseDownMayStartDrag = false; |
| 341 m_lastShowPressTimestamp = 0; | 339 m_lastShowPressTimestamp = 0; |
| 342 m_lastDeferredTapElement = nullptr; | 340 m_lastDeferredTapElement = nullptr; |
| 343 m_eventHandlerWillResetCapturingMouseEventsNode = false; | 341 m_eventHandlerWillResetCapturingMouseEventsNode = false; |
| 344 m_mouseDownMayStartAutoscroll = false; | 342 m_mouseDownMayStartAutoscroll = false; |
| 345 m_svgPan = false; | 343 m_svgPan = false; |
| 346 m_mouseDownPos = IntPoint(); | 344 m_mouseDownPos = IntPoint(); |
| 347 m_mouseDownTimestamp = 0; | 345 m_mouseDownTimestamp = 0; |
| 348 m_longTapShouldInvokeContextMenu = false; | 346 m_longTapShouldInvokeContextMenu = false; |
| 349 m_dragStartPos = LayoutPoint(); | 347 m_dragStartPos = LayoutPoint(); |
| (...skipping 3233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3583 | 3581 |
| 3584 WebInputEventResult result = | 3582 WebInputEventResult result = |
| 3585 m_pointerEventManager.sendTouchPointerEvent( | 3583 m_pointerEventManager.sendTouchPointerEvent( |
| 3586 touchInfo.touchTarget, touchPoint, event.getModifiers(), | 3584 touchInfo.touchTarget, touchPoint, event.getModifiers(), |
| 3587 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(), | 3585 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(), |
| 3588 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y()); | 3586 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y()); |
| 3589 touchInfo.consumed = result != WebInputEventResult::NotHandled; | 3587 touchInfo.consumed = result != WebInputEventResult::NotHandled; |
| 3590 } | 3588 } |
| 3591 } | 3589 } |
| 3592 | 3590 |
| 3593 void EventHandler::sendPointerCancels(WillBeHeapVector<TouchInfo>& touchInfos) | |
| 3594 { | |
| 3595 if (!RuntimeEnabledFeatures::pointerEventEnabled()) | |
| 3596 return; | |
| 3597 | |
| 3598 for (unsigned i = 0; i < touchInfos.size(); ++i) { | |
| 3599 TouchInfo& touchInfo = touchInfos[i]; | |
| 3600 const PlatformTouchPoint& point = touchInfo.point; | |
| 3601 const PlatformTouchPoint::TouchState pointState = point.state(); | |
| 3602 | |
| 3603 if (pointState == PlatformTouchPoint::TouchReleased | |
| 3604 || pointState == PlatformTouchPoint::TouchCancelled) | |
| 3605 continue; | |
| 3606 | |
| 3607 m_pointerEventManager.sendTouchCancelPointerEvent( | |
| 3608 touchInfo.touchTarget, | |
| 3609 point); | |
| 3610 } | |
| 3611 } | |
| 3612 | |
| 3613 namespace { | 3591 namespace { |
| 3614 | 3592 |
| 3615 // Defining this class type local to dispatchTouchEvents() and annotating | 3593 // Defining this class type local to dispatchTouchEvents() and annotating |
| 3616 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning | 3594 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning |
| 3617 // that the local class doesn't provide a local definition for 'operator new'. | 3595 // that the local class doesn't provide a local definition for 'operator new'. |
| 3618 // Which it intentionally doesn't and shouldn't. | 3596 // Which it intentionally doesn't and shouldn't. |
| 3619 // | 3597 // |
| 3620 // Work around such toolchain bugginess by lifting out the type, thereby | 3598 // Work around such toolchain bugginess by lifting out the type, thereby |
| 3621 // taking it out of C4822's reach. | 3599 // taking it out of C4822's reach. |
| 3622 class ChangedTouches final { | 3600 class ChangedTouches final { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3726 } | 3704 } |
| 3727 } | 3705 } |
| 3728 | 3706 |
| 3729 return eventResult; | 3707 return eventResult; |
| 3730 } | 3708 } |
| 3731 | 3709 |
| 3732 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt) | 3710 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt) |
| 3733 { | 3711 { |
| 3734 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); | 3712 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); |
| 3735 | 3713 |
| 3714 if (event.type() == PlatformEvent::TouchScrollStarted) { | |
| 3715 m_pointerEventManager.blockTouchPointers(); | |
| 3716 return WebInputEventResult::HandledSystem; | |
| 3717 } | |
| 3718 | |
| 3736 const Vector<PlatformTouchPoint>& points = event.touchPoints(); | 3719 const Vector<PlatformTouchPoint>& points = event.touchPoints(); |
| 3737 | 3720 |
| 3738 bool freshTouchEvents = true; | 3721 bool freshTouchEvents = true; |
|
tdresser
2016/04/01 14:50:24
I'm not a big fan of the name of this variable. Co
mustaq
2016/04/01 18:31:05
Done.
| |
| 3739 bool allTouchReleased = true; | 3722 bool allTouchReleased = true; |
| 3740 for (unsigned i = 0; i < points.size(); ++i) { | 3723 for (unsigned i = 0; i < points.size(); ++i) { |
| 3741 const PlatformTouchPoint& point = points[i]; | 3724 const PlatformTouchPoint& point = points[i]; |
| 3742 | 3725 |
| 3743 if (point.state() != PlatformTouchPoint::TouchPressed) | 3726 if (point.state() != PlatformTouchPoint::TouchPressed) |
| 3744 freshTouchEvents = false; | 3727 freshTouchEvents = false; |
| 3745 if (point.state() != PlatformTouchPoint::TouchReleased && point.state() != PlatformTouchPoint::TouchCancelled) | 3728 if (point.state() != PlatformTouchPoint::TouchReleased && point.state() != PlatformTouchPoint::TouchCancelled) |
| 3746 allTouchReleased = false; | 3729 allTouchReleased = false; |
| 3747 } | 3730 } |
| 3748 if (freshTouchEvents) { | 3731 if (freshTouchEvents) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3902 touchInfo.point = point; | 3885 touchInfo.point = point; |
| 3903 touchInfo.touchTarget = touchTarget; | 3886 touchInfo.touchTarget = touchTarget; |
| 3904 touchInfo.targetFrame = targetFrame; | 3887 touchInfo.targetFrame = targetFrame; |
| 3905 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor); | 3888 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor); |
| 3906 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor); | 3889 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor); |
| 3907 touchInfo.knownTarget = knownTarget; | 3890 touchInfo.knownTarget = knownTarget; |
| 3908 touchInfo.consumed = false; | 3891 touchInfo.consumed = false; |
| 3909 touchInfo.region = regionID; | 3892 touchInfo.region = regionID; |
| 3910 } | 3893 } |
| 3911 | 3894 |
| 3912 if (!m_inPointerCanceledState) { | 3895 if (freshTouchEvents) |
| 3913 dispatchPointerEvents(event, touchInfos); | 3896 m_pointerEventManager.unblockTouchPointers(); |
| 3914 // Note that the disposition of any pointer events affects only the gene ration of touch | 3897 dispatchPointerEvents(event, touchInfos); |
| 3915 // events. If all pointer events were handled (and hence no touch events were fired), that | 3898 // Note that the disposition of any pointer events affects only the generati on of touch |
| 3916 // is still equivalent to the touch events going unhandled because point er event handler | 3899 // events. If all pointer events were handled (and hence no touch events wer e fired), that |
| 3917 // don't block scroll gesture generation. | 3900 // is still equivalent to the touch events going unhandled because pointer e vent handler |
| 3918 } | 3901 // don't block scroll gesture generation. |
| 3919 | 3902 |
| 3920 // TODO(crbug.com/507408): If PE handlers always call preventDefault, we won 't see TEs until after | 3903 // TODO(crbug.com/507408): If PE handlers always call preventDefault, we won 't see TEs until after |
| 3921 // scrolling starts because the scrolling would suppress upcoming PEs. This sudden "break" in TE | 3904 // scrolling starts because the scrolling would suppress upcoming PEs. This sudden "break" in TE |
| 3922 // suppression can make the visible TEs inconsistent (e.g. touchmove without a touchstart). | 3905 // suppression can make the visible TEs inconsistent (e.g. touchmove without a touchstart). |
| 3923 | 3906 |
| 3924 WebInputEventResult eventResult = dispatchTouchEvents(event, touchInfos, fre shTouchEvents, | 3907 return dispatchTouchEvents(event, touchInfos, freshTouchEvents, allTouchRele ased); |
| 3925 allTouchReleased); | |
| 3926 | |
| 3927 if (!m_inPointerCanceledState) { | |
| 3928 // Check if we need to stop firing pointer events because of a touch act ion. | |
| 3929 // See: www.w3.org/TR/pointerevents/#declaring-candidate-regions-for-def ault-touch-behaviors | |
| 3930 if (event.causesScrollingIfUncanceled() && eventResult == WebInputEventR esult::NotHandled) { | |
| 3931 m_inPointerCanceledState = true; | |
| 3932 sendPointerCancels(touchInfos); | |
| 3933 } | |
| 3934 } else if (allTouchReleased) { | |
| 3935 m_inPointerCanceledState = false; | |
| 3936 } | |
| 3937 | |
| 3938 return eventResult; | |
| 3939 } | 3908 } |
| 3940 | 3909 |
| 3941 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) | 3910 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) |
| 3942 { | 3911 { |
| 3943 m_mousePositionIsUnknown = false; | 3912 m_mousePositionIsUnknown = false; |
| 3944 m_lastKnownMousePosition = event.position(); | 3913 m_lastKnownMousePosition = event.position(); |
| 3945 m_lastKnownMouseGlobalPosition = event.globalPosition(); | 3914 m_lastKnownMouseGlobalPosition = event.globalPosition(); |
| 3946 } | 3915 } |
| 3947 | 3916 |
| 3948 WebInputEventResult EventHandler::passMousePressEventToSubframe(MouseEventWithHi tTestResults& mev, LocalFrame* subframe) | 3917 WebInputEventResult EventHandler::passMousePressEventToSubframe(MouseEventWithHi tTestResults& mev, LocalFrame* subframe) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3988 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() | 3957 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() |
| 3989 { | 3958 { |
| 3990 #if OS(MACOSX) | 3959 #if OS(MACOSX) |
| 3991 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); | 3960 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); |
| 3992 #else | 3961 #else |
| 3993 return PlatformEvent::AltKey; | 3962 return PlatformEvent::AltKey; |
| 3994 #endif | 3963 #endif |
| 3995 } | 3964 } |
| 3996 | 3965 |
| 3997 } // namespace blink | 3966 } // namespace blink |
| OLD | NEW |