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

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

Issue 2669663002: Move touch slop suppression 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/input/TouchEventManager.h" 5 #include "core/input/TouchEventManager.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/events/TouchEvent.h" 8 #include "core/events/TouchEvent.h"
9 #include "core/frame/Deprecation.h" 9 #include "core/frame/Deprecation.h"
10 #include "core/frame/EventHandlerRegistry.h" 10 #include "core/frame/EventHandlerRegistry.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 TouchEventManager::TouchEventManager(LocalFrame& frame) : m_frame(frame) { 89 TouchEventManager::TouchEventManager(LocalFrame& frame) : m_frame(frame) {
90 clear(); 90 clear();
91 } 91 }
92 92
93 void TouchEventManager::clear() { 93 void TouchEventManager::clear() {
94 m_touchSequenceDocument.clear(); 94 m_touchSequenceDocument.clear();
95 m_targetForTouchID.clear(); 95 m_targetForTouchID.clear();
96 m_regionForTouchID.clear(); 96 m_regionForTouchID.clear();
97 m_touchPressed = false; 97 m_touchPressed = false;
98 m_suppressingTouchmoves = false;
98 m_currentTouchAction = TouchActionAuto; 99 m_currentTouchAction = TouchActionAuto;
99 } 100 }
100 101
101 DEFINE_TRACE(TouchEventManager) { 102 DEFINE_TRACE(TouchEventManager) {
102 visitor->trace(m_frame); 103 visitor->trace(m_frame);
103 visitor->trace(m_touchSequenceDocument); 104 visitor->trace(m_touchSequenceDocument);
104 visitor->trace(m_targetForTouchID); 105 visitor->trace(m_targetForTouchID);
105 } 106 }
106 107
107 WebInputEventResult TouchEventManager::dispatchTouchEvents( 108 WebInputEventResult TouchEventManager::dispatchTouchEvents(
108 const WebTouchEvent& event, 109 const WebTouchEvent& event,
109 const HeapVector<TouchInfo>& touchInfos, 110 const HeapVector<TouchInfo>& touchInfos,
110 bool allTouchesReleased) { 111 bool allTouchesReleased) {
111 // Build up the lists to use for the |touches|, |targetTouches| and 112 // Build up the lists to use for the |touches|, |targetTouches| and
112 // |changedTouches| attributes in the JS event. See 113 // |changedTouches| attributes in the JS event. See
113 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these 114 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these
114 // lists fit together. 115 // lists fit together.
115 116
117 // Suppress all the touch moves in the slop region.
118 if (event.type() == WebInputEvent::TouchStart)
dtapuska 2017/02/01 15:42:06 I don't think this matches the consistent state we
lanwei 2017/02/02 19:49:36 Done.
119 m_suppressingTouchmoves = true;
120
121 if (m_suppressingTouchmoves && event.type() == WebInputEvent::TouchMove &&
122 touchInfos.size() == 1) {
123 if (!event.movedBeyondSlopRegion)
124 return WebInputEventResult::HandledSuppressed;
125 m_suppressingTouchmoves = false;
126 }
127
116 // Holds the complete set of touches on the screen. 128 // Holds the complete set of touches on the screen.
117 TouchList* touches = TouchList::create(); 129 TouchList* touches = TouchList::create();
118 130
119 // A different view on the 'touches' list above, filtered and grouped by 131 // A different view on the 'touches' list above, filtered and grouped by
120 // event target. Used for the |targetTouches| list in the JS event. 132 // event target. Used for the |targetTouches| list in the JS event.
121 using TargetTouchesHeapMap = HeapHashMap<EventTarget*, Member<TouchList>>; 133 using TargetTouchesHeapMap = HeapHashMap<EventTarget*, Member<TouchList>>;
122 TargetTouchesHeapMap touchesByTarget; 134 TargetTouchesHeapMap touchesByTarget;
123 135
124 // Array of touches per state, used to assemble the |changedTouches| list. 136 // Array of touches per state, used to assemble the |changedTouches| list.
125 ChangedTouches changedTouches[WebTouchPoint::StateMax + 1]; 137 ChangedTouches changedTouches[WebTouchPoint::StateMax + 1];
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 } 495 }
484 496
485 return dispatchTouchEvents(event, touchInfos, allTouchesReleased); 497 return dispatchTouchEvents(event, touchInfos, allTouchesReleased);
486 } 498 }
487 499
488 bool TouchEventManager::isAnyTouchActive() const { 500 bool TouchEventManager::isAnyTouchActive() const {
489 return m_touchPressed; 501 return m_touchPressed;
490 } 502 }
491 503
492 } // namespace blink 504 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698