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

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

Issue 2680013009: Move touch slop suppression from LegacyTouchEventQueue to TouchEventManager (Closed)
Patch Set: slop region Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/input/TouchEventManager.cpp
diff --git a/third_party/WebKit/Source/core/input/TouchEventManager.cpp b/third_party/WebKit/Source/core/input/TouchEventManager.cpp
index 8d161e1ef2727d4b4eb29e42defb9eefbf560174..165b255623a1b97501e1d09320796dbd6511b5c0 100644
--- a/third_party/WebKit/Source/core/input/TouchEventManager.cpp
+++ b/third_party/WebKit/Source/core/input/TouchEventManager.cpp
@@ -62,6 +62,18 @@ enum TouchEventDispatchResultType {
TouchEventDispatchResultTypeMax,
};
+bool IsTouchSequenceStart(const PlatformTouchEvent& event) {
+ if (!event.touchPoints().size())
+ return false;
+ if (event.type() != PlatformEvent::TouchStart)
+ return false;
+ for (const auto& point : event.touchPoints()) {
+ if (point.state() != PlatformTouchPoint::TouchPressed)
+ return false;
+ }
+ return true;
+}
+
// Defining this class type local to dispatchTouchEvents() and annotating
// it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning
// that the local class doesn't provide a local definition for 'operator new'.
@@ -96,6 +108,7 @@ void TouchEventManager::clear() {
m_regionForTouchID.clear();
m_touchPressed = false;
m_currentEvent = PlatformEvent::NoType;
+ m_suppressingTouchmovesWithinSlop = false;
m_currentTouchAction = TouchActionAuto;
}
@@ -114,6 +127,23 @@ WebInputEventResult TouchEventManager::dispatchTouchEvents(
// http://www.w3.org/TR/touch-events/#touchevent-interface for how these
// lists fit together.
+ // Suppress all the touch moves in the slop region.
+ if (IsTouchSequenceStart(event))
+ m_suppressingTouchmovesWithinSlop = true;
+
+ if (event.type() == PlatformEvent::TouchEnd ||
+ event.type() == PlatformEvent::TouchCancel ||
+ event.touchPoints().size() > 1) {
+ m_suppressingTouchmovesWithinSlop = false;
+ }
+
+ if (m_suppressingTouchmovesWithinSlop &&
+ event.type() == PlatformEvent::TouchMove) {
+ if (!event.causesScrollingIfUncanceled())
+ return WebInputEventResult::HandledSuppressed;
+ m_suppressingTouchmovesWithinSlop = false;
+ }
+
// Holds the complete set of touches on the screen.
TouchList* touches = TouchList::create();

Powered by Google App Engine
This is Rietveld 408576698