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

Unified Diff: third_party/WebKit/Source/core/input/PointerEventManager.cpp

Issue 2414273003: Remove UserGesture on touch scrolls (Closed)
Patch Set: Improve comments Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/input/PointerEventManager.cpp
diff --git a/third_party/WebKit/Source/core/input/PointerEventManager.cpp b/third_party/WebKit/Source/core/input/PointerEventManager.cpp
index f3b1dd0d0c524ebcbd722ae74953040dbedbd00b..aa42f46837b4e09bc0c4b25bce46f0f942d3b23f 100644
--- a/third_party/WebKit/Source/core/input/PointerEventManager.cpp
+++ b/third_party/WebKit/Source/core/input/PointerEventManager.cpp
@@ -169,14 +169,6 @@ WebInputEventResult PointerEventManager::dispatchPointerEvent(
UseCounter::count(m_frame->document(),
UseCounter::PointerEventDispatchPointerDown);
- std::unique_ptr<UserGestureIndicator> gestureIndicator;
- if (eventType == EventTypeNames::pointerup &&
- pointerEvent->pointerType() == "touch") {
- gestureIndicator =
- wrapUnique(new UserGestureIndicator(DocumentUserGestureToken::create(
- target->toNode() ? &target->toNode()->document() : nullptr)));
- }
-
DispatchEventResult dispatchResult = target->dispatchEvent(pointerEvent);
return EventHandlingUtil::toWebInputEventResult(dispatchResult);
}
@@ -298,7 +290,6 @@ WebInputEventResult PointerEventManager::handleTouchEvents(
const PlatformTouchEvent& event) {
if (event.type() == PlatformEvent::TouchScrollStarted) {
blockTouchPointers();
- m_touchEventManager->setTouchScrollStarted();
return WebInputEventResult::HandledSystem;
}
@@ -311,18 +302,36 @@ WebInputEventResult PointerEventManager::handleTouchEvents(
}
if (newTouchSequence)
unblockTouchPointers();
+
+ // Do any necessary hit-tests and compute the event targets for all pointers
+ // in the event.
HeapVector<TouchEventManager::TouchInfo> touchInfos;
+ computeTouchTargets(event, touchInfos);
+
+ // Any finger lifting is a user gesture only when it wasn't associated with a
+ // scroll.
+ // https://docs.google.com/document/d/1oF1T3O7_E4t1PYHV6gyCwHxOi3ystm0eSL5xZu7nvOg/edit#
+ // Re-use the same UserGesture for touchend and pointerup (but not for the
+ // mouse events generated by GestureTap).
+ // For the rare case of multi-finger scenarios spanning documents, it
+ // seems extremely unlikely to matter which document the gesture is
+ // associated with so just pick the first finger.
+ RefPtr<UserGestureToken> possibleGestureToken;
+ if (event.type() == PlatformEvent::TouchEnd &&
+ !m_inCanceledStateForPointerTypeTouch) {
+ possibleGestureToken =
+ DocumentUserGestureToken::create(touchInfos[0].targetFrame->document());
+ }
+ UserGestureIndicator holder(possibleGestureToken);
dispatchTouchPointerEvents(event, touchInfos);
return m_touchEventManager->handleTouchEvent(event, touchInfos);
}
-void PointerEventManager::dispatchTouchPointerEvents(
+void PointerEventManager::computeTouchTargets(
const PlatformTouchEvent& event,
HeapVector<TouchEventManager::TouchInfo>& touchInfos) {
- // Iterate through the touch points, sending PointerEvents to the targets as
- // required.
for (const auto& touchPoint : event.touchPoints()) {
TouchEventManager::TouchInfo touchInfo;
touchInfo.point = touchPoint;
@@ -373,6 +382,17 @@ void PointerEventManager::dispatchTouchPointerEvents(
touchInfo.targetFrame = touchInfo.touchNode->document().frame();
}
+ touchInfos.append(touchInfo);
+ }
+}
+
+void PointerEventManager::dispatchTouchPointerEvents(
+ const PlatformTouchEvent& event,
+ HeapVector<TouchEventManager::TouchInfo>& touchInfos) {
+ // Iterate through the touch points, sending PointerEvents to the targets as
+ // required.
+ for (auto touchInfo : touchInfos) {
+ const PlatformTouchPoint& touchPoint = touchInfo.point;
// Do not send pointer events for stationary touches or null targetFrame
if (touchInfo.touchNode && touchInfo.targetFrame &&
touchPoint.state() != PlatformTouchPoint::TouchStationary &&
@@ -405,8 +425,6 @@ void PointerEventManager::dispatchTouchPointerEvents(
m_touchIdsForCanceledPointerdowns.append(event.uniqueTouchEventId());
}
}
-
- touchInfos.append(touchInfo);
}
}
« no previous file with comments | « third_party/WebKit/Source/core/input/PointerEventManager.h ('k') | third_party/WebKit/Source/core/input/TouchEventManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698