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

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 1800143002: Notify Blink about start of gesture scroll through a queued event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a few checks. Created 4 years, 8 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
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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d) 263 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d)
264 , m_svgPan(false) 264 , m_svgPan(false)
265 , m_resizeScrollableArea(nullptr) 265 , m_resizeScrollableArea(nullptr)
266 , m_eventHandlerWillResetCapturingMouseEventsNode(0) 266 , m_eventHandlerWillResetCapturingMouseEventsNode(0)
267 , m_clickCount(0) 267 , m_clickCount(0)
268 , m_shouldOnlyFireDragOverEvent(false) 268 , m_shouldOnlyFireDragOverEvent(false)
269 , m_accumulatedRootOverscroll(FloatSize()) 269 , m_accumulatedRootOverscroll(FloatSize())
270 , m_mousePositionIsUnknown(true) 270 , m_mousePositionIsUnknown(true)
271 , m_mouseDownTimestamp(0) 271 , m_mouseDownTimestamp(0)
272 , m_touchPressed(false) 272 , m_touchPressed(false)
273 , m_inPointerCanceledState(false)
274 , m_scrollGestureHandlingNode(nullptr) 273 , m_scrollGestureHandlingNode(nullptr)
275 , m_lastGestureScrollOverWidget(false) 274 , m_lastGestureScrollOverWidget(false)
276 , m_longTapShouldInvokeContextMenu(false) 275 , m_longTapShouldInvokeContextMenu(false)
277 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) 276 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired)
278 , m_lastShowPressTimestamp(0) 277 , m_lastShowPressTimestamp(0)
279 , m_deltaConsumedForScrollSequence(false) 278 , m_deltaConsumedForScrollSequence(false)
280 { 279 {
281 } 280 }
282 281
283 EventHandler::~EventHandler() 282 EventHandler::~EventHandler()
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 m_capturesDragging = false; 337 m_capturesDragging = false;
339 m_capturingMouseEventsNode = nullptr; 338 m_capturingMouseEventsNode = nullptr;
340 m_targetForTouchID.clear(); 339 m_targetForTouchID.clear();
341 m_touchSequenceDocument.clear(); 340 m_touchSequenceDocument.clear();
342 m_touchSequenceUserGestureToken.clear(); 341 m_touchSequenceUserGestureToken.clear();
343 clearGestureScrollState(); 342 clearGestureScrollState();
344 m_lastGestureScrollOverWidget = false; 343 m_lastGestureScrollOverWidget = false;
345 m_scrollbarHandlingScrollGesture = nullptr; 344 m_scrollbarHandlingScrollGesture = nullptr;
346 m_touchPressed = false; 345 m_touchPressed = false;
347 m_pointerEventManager.clear(); 346 m_pointerEventManager.clear();
348 m_inPointerCanceledState = false;
349 m_mouseDownMayStartDrag = false; 347 m_mouseDownMayStartDrag = false;
350 m_lastShowPressTimestamp = 0; 348 m_lastShowPressTimestamp = 0;
351 m_lastDeferredTapElement = nullptr; 349 m_lastDeferredTapElement = nullptr;
352 m_eventHandlerWillResetCapturingMouseEventsNode = false; 350 m_eventHandlerWillResetCapturingMouseEventsNode = false;
353 m_mouseDownMayStartAutoscroll = false; 351 m_mouseDownMayStartAutoscroll = false;
354 m_svgPan = false; 352 m_svgPan = false;
355 m_mouseDownPos = IntPoint(); 353 m_mouseDownPos = IntPoint();
356 m_mouseDownTimestamp = 0; 354 m_mouseDownTimestamp = 0;
357 m_longTapShouldInvokeContextMenu = false; 355 m_longTapShouldInvokeContextMenu = false;
358 m_dragStartPos = LayoutPoint(); 356 m_dragStartPos = LayoutPoint();
(...skipping 3230 matching lines...) Expand 10 before | Expand all | Expand 10 after
3589 3587
3590 WebInputEventResult result = 3588 WebInputEventResult result =
3591 m_pointerEventManager.sendTouchPointerEvent( 3589 m_pointerEventManager.sendTouchPointerEvent(
3592 touchInfo.touchTarget, touchPoint, event.getModifiers(), 3590 touchInfo.touchTarget, touchPoint, event.getModifiers(),
3593 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(), 3591 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(),
3594 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y()); 3592 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y());
3595 touchInfo.consumed = result != WebInputEventResult::NotHandled; 3593 touchInfo.consumed = result != WebInputEventResult::NotHandled;
3596 } 3594 }
3597 } 3595 }
3598 3596
3599 void EventHandler::sendPointerCancels(HeapVector<TouchInfo>& touchInfos)
3600 {
3601 if (!RuntimeEnabledFeatures::pointerEventEnabled())
3602 return;
3603
3604 for (unsigned i = 0; i < touchInfos.size(); ++i) {
3605 TouchInfo& touchInfo = touchInfos[i];
3606 const PlatformTouchPoint& point = touchInfo.point;
3607 const PlatformTouchPoint::TouchState pointState = point.state();
3608
3609 if (pointState == PlatformTouchPoint::TouchReleased
3610 || pointState == PlatformTouchPoint::TouchCancelled)
3611 continue;
3612
3613 m_pointerEventManager.sendTouchCancelPointerEvent(
3614 touchInfo.touchTarget,
3615 point);
3616 }
3617 }
3618
3619 namespace { 3597 namespace {
3620 3598
3621 // Defining this class type local to dispatchTouchEvents() and annotating 3599 // Defining this class type local to dispatchTouchEvents() and annotating
3622 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning 3600 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning
3623 // that the local class doesn't provide a local definition for 'operator new'. 3601 // that the local class doesn't provide a local definition for 'operator new'.
3624 // Which it intentionally doesn't and shouldn't. 3602 // Which it intentionally doesn't and shouldn't.
3625 // 3603 //
3626 // Work around such toolchain bugginess by lifting out the type, thereby 3604 // Work around such toolchain bugginess by lifting out the type, thereby
3627 // taking it out of C4822's reach. 3605 // taking it out of C4822's reach.
3628 class ChangedTouches final { 3606 class ChangedTouches final {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3728 eventName, touchEventTarget->toNode()->document().domWindow(), 3706 eventName, touchEventTarget->toNode()->document().domWindow(),
3729 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), event.timestamp()); 3707 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), event.timestamp());
3730 3708
3731 eventResult = mergeEventResult(eventResult, toWebInputEventResult(to uchEventTarget->dispatchEvent(touchEvent))); 3709 eventResult = mergeEventResult(eventResult, toWebInputEventResult(to uchEventTarget->dispatchEvent(touchEvent)));
3732 } 3710 }
3733 } 3711 }
3734 3712
3735 return eventResult; 3713 return eventResult;
3736 } 3714 }
3737 3715
3738 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt) 3716 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt)
bokan 2016/04/12 22:42:46 This method is way too big. Not in this CL, but I'
mustaq 2016/04/13 14:56:27 Agree, too big is too unhealthy/unreadable. Navid
bokan 2016/04/13 22:59:48 Awesome, thanks!
3739 { 3717 {
3740 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); 3718 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent");
3741 3719
3720 if (event.type() == PlatformEvent::TouchScrollStarted) {
3721 m_pointerEventManager.blockTouchPointers();
3722 return WebInputEventResult::HandledSystem;
3723 }
3724
3742 const Vector<PlatformTouchPoint>& points = event.touchPoints(); 3725 const Vector<PlatformTouchPoint>& points = event.touchPoints();
3743 3726
3744 bool freshTouchEvents = true; 3727 bool newTouchSequence = true;
bokan 2016/04/12 22:42:46 Please also update the param name in dispatchTouch
Navid Zolghadr 2016/04/13 14:33:06 I couldn't find any use for this variable in that
mustaq 2016/04/13 14:56:27 Removed.
3745 bool allTouchReleased = true; 3728 bool allTouchReleased = true;
3746 for (unsigned i = 0; i < points.size(); ++i) { 3729 for (unsigned i = 0; i < points.size(); ++i) {
3747 const PlatformTouchPoint& point = points[i]; 3730 const PlatformTouchPoint& point = points[i];
3748 3731
3749 if (point.state() != PlatformTouchPoint::TouchPressed) 3732 if (point.state() != PlatformTouchPoint::TouchPressed)
3750 freshTouchEvents = false; 3733 newTouchSequence = false;
3751 if (point.state() != PlatformTouchPoint::TouchReleased && point.state() != PlatformTouchPoint::TouchCancelled) 3734 if (point.state() != PlatformTouchPoint::TouchReleased && point.state() != PlatformTouchPoint::TouchCancelled)
3752 allTouchReleased = false; 3735 allTouchReleased = false;
3753 } 3736 }
3754 if (freshTouchEvents) { 3737 if (newTouchSequence) {
3755 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should 3738 // Ideally we'd ASSERT !m_touchSequenceDocument here since we should
3756 // have cleared the active document when we saw the last release. But we 3739 // have cleared the active document when we saw the last release. But we
3757 // have some tests that violate this, ClusterFuzz could trigger it, and 3740 // have some tests that violate this, ClusterFuzz could trigger it, and
3758 // there may be cases where the browser doesn't reliably release all 3741 // there may be cases where the browser doesn't reliably release all
3759 // touches. http://crbug.com/345372 tracks this. 3742 // touches. http://crbug.com/345372 tracks this.
3760 m_touchSequenceDocument.clear(); 3743 m_touchSequenceDocument.clear();
3761 m_touchSequenceUserGestureToken.clear(); 3744 m_touchSequenceUserGestureToken.clear();
3762 } 3745 }
3763 3746
3764 ASSERT(m_frame->view()); 3747 ASSERT(m_frame->view());
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
3919 touchInfo.point = point; 3902 touchInfo.point = point;
3920 touchInfo.touchTarget = touchTarget; 3903 touchInfo.touchTarget = touchTarget;
3921 touchInfo.targetFrame = targetFrame; 3904 touchInfo.targetFrame = targetFrame;
3922 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor); 3905 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor);
3923 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor); 3906 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor);
3924 touchInfo.knownTarget = knownTarget; 3907 touchInfo.knownTarget = knownTarget;
3925 touchInfo.consumed = false; 3908 touchInfo.consumed = false;
3926 touchInfo.region = regionID; 3909 touchInfo.region = regionID;
3927 } 3910 }
3928 3911
3929 if (!m_inPointerCanceledState) { 3912 if (newTouchSequence)
3930 dispatchPointerEvents(event, touchInfos); 3913 m_pointerEventManager.unblockTouchPointers();
bokan 2016/04/12 22:42:46 Does this have to be way down here or can it be mo
mustaq 2016/04/13 14:56:27 I kept it here because the code above is fairly un
3931 // Note that the disposition of any pointer events affects only the gene ration of touch 3914 dispatchPointerEvents(event, touchInfos);
3932 // events. If all pointer events were handled (and hence no touch events were fired), that 3915 // Note that the disposition of any pointer events affects only the generati on of touch
3933 // is still equivalent to the touch events going unhandled because point er event handler 3916 // events. If all pointer events were handled (and hence no touch events wer e fired), that
3934 // don't block scroll gesture generation. 3917 // is still equivalent to the touch events going unhandled because pointer e vent handler
3935 } 3918 // don't block scroll gesture generation.
3936 3919
3937 // TODO(crbug.com/507408): If PE handlers always call preventDefault, we won 't see TEs until after 3920 // TODO(crbug.com/507408): If PE handlers always call preventDefault, we won 't see TEs until after
3938 // scrolling starts because the scrolling would suppress upcoming PEs. This sudden "break" in TE 3921 // scrolling starts because the scrolling would suppress upcoming PEs. This sudden "break" in TE
3939 // suppression can make the visible TEs inconsistent (e.g. touchmove without a touchstart). 3922 // suppression can make the visible TEs inconsistent (e.g. touchmove without a touchstart).
3940 3923
3941 WebInputEventResult eventResult = dispatchTouchEvents(event, touchInfos, fre shTouchEvents, 3924 return dispatchTouchEvents(event, touchInfos, newTouchSequence, allTouchRele ased);
bokan 2016/04/12 22:42:46 Question: How are touch events canceled and blocke
mustaq 2016/04/13 14:56:27 Any PE that was canceled above effectively "hides"
bokan 2016/04/13 22:59:48 Got it, thanks.
3942 allTouchReleased);
3943
3944 if (!m_inPointerCanceledState) {
3945 // Check if we need to stop firing pointer events because of a touch act ion.
3946 // See: www.w3.org/TR/pointerevents/#declaring-candidate-regions-for-def ault-touch-behaviors
3947 if (event.causesScrollingIfUncanceled() && eventResult == WebInputEventR esult::NotHandled) {
3948 m_inPointerCanceledState = true;
3949 sendPointerCancels(touchInfos);
3950 }
3951 } else if (allTouchReleased) {
3952 m_inPointerCanceledState = false;
3953 }
3954
3955 return eventResult;
3956 } 3925 }
3957 3926
3958 void EventHandler::userGestureUtilized() 3927 void EventHandler::userGestureUtilized()
3959 { 3928 {
3960 // This is invoked for UserGestureIndicators created in handleTouchEvent whi ch perhaps represent 3929 // This is invoked for UserGestureIndicators created in handleTouchEvent whi ch perhaps represent
3961 // touch actions which shouldn't be considered a user-gesture. 3930 // touch actions which shouldn't be considered a user-gesture.
3962 UseCounter::count(m_frame, UseCounter::TouchDragUserGestureUsed); 3931 UseCounter::count(m_frame, UseCounter::TouchDragUserGestureUsed);
3963 Deprecation::countDeprecationCrossOriginIframe(m_frame, UseCounter::TouchDra gUserGestureUsedCrossOrigin); 3932 Deprecation::countDeprecationCrossOriginIframe(m_frame, UseCounter::TouchDra gUserGestureUsedCrossOrigin);
3964 } 3933 }
3965 3934
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4013 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 3982 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
4014 { 3983 {
4015 #if OS(MACOSX) 3984 #if OS(MACOSX)
4016 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 3985 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
4017 #else 3986 #else
4018 return PlatformEvent::AltKey; 3987 return PlatformEvent::AltKey;
4019 #endif 3988 #endif
4020 } 3989 }
4021 3990
4022 } // namespace blink 3991 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698