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

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

Issue 2669663002: Move touch slop suppression to TouchEventManager (Closed)
Patch Set: slop regesion 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 6561639c92306c184a507ffda0ca0ebbd7347306..149cff36bc908842d65b6dc63fe73d9b538f3a66 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 WebTouchEvent& event) {
+ if (!event.touchesLength)
+ return false;
+ if (event.type() != WebInputEvent::TouchStart)
+ return false;
+ for (size_t i = 0; i < event.touchesLength; ++i) {
+ if (event.touches[i].state != blink::WebTouchPoint::StatePressed)
+ 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'.
@@ -95,6 +107,7 @@ void TouchEventManager::clear() {
m_targetForTouchID.clear();
m_regionForTouchID.clear();
m_touchPressed = false;
+ m_suppressingTouchmovesWithinSlop = false;
m_currentTouchAction = TouchActionAuto;
}
@@ -113,6 +126,22 @@ 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() == WebInputEvent::TouchEnd ||
+ event.type() == WebInputEvent::TouchCancel || event.touchesLength > 1) {
+ m_suppressingTouchmovesWithinSlop = false;
+ }
+
+ if (m_suppressingTouchmovesWithinSlop &&
+ event.type() == WebInputEvent::TouchMove) {
+ if (!event.movedBeyondSlopRegion)
+ 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