OLD | NEW |
---|---|
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/dom/DocumentUserGestureToken.h" | 8 #include "core/dom/DocumentUserGestureToken.h" |
9 #include "core/events/TouchEvent.h" | 9 #include "core/events/TouchEvent.h" |
10 #include "core/frame/Deprecation.h" | 10 #include "core/frame/Deprecation.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 } | 90 } |
91 | 91 |
92 void TouchEventManager::clear() { | 92 void TouchEventManager::clear() { |
93 m_touchSequenceDocument.clear(); | 93 m_touchSequenceDocument.clear(); |
94 m_touchSequenceUserGestureToken.clear(); | 94 m_touchSequenceUserGestureToken.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_touchScrollStarted = false; | 98 m_touchScrollStarted = false; |
99 m_currentEvent = PlatformEvent::NoType; | 99 m_currentEvent = PlatformEvent::NoType; |
100 m_currentTouchAction = TouchActionAuto; | |
100 } | 101 } |
101 | 102 |
102 DEFINE_TRACE(TouchEventManager) { | 103 DEFINE_TRACE(TouchEventManager) { |
103 visitor->trace(m_frame); | 104 visitor->trace(m_frame); |
104 visitor->trace(m_touchSequenceDocument); | 105 visitor->trace(m_touchSequenceDocument); |
105 visitor->trace(m_targetForTouchID); | 106 visitor->trace(m_targetForTouchID); |
106 } | 107 } |
107 | 108 |
108 WebInputEventResult TouchEventManager::dispatchTouchEvents( | 109 WebInputEventResult TouchEventManager::dispatchTouchEvents( |
109 const PlatformTouchEvent& event, | 110 const PlatformTouchEvent& event, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 if (!changedTouches[pointState].m_touches) | 166 if (!changedTouches[pointState].m_touches) |
166 changedTouches[pointState].m_touches = TouchList::create(); | 167 changedTouches[pointState].m_touches = TouchList::create(); |
167 changedTouches[pointState].m_touches->append(touch); | 168 changedTouches[pointState].m_touches->append(touch); |
168 changedTouches[pointState].m_targets.add(touchInfo.touchNode); | 169 changedTouches[pointState].m_targets.add(touchInfo.touchNode); |
169 } | 170 } |
170 } | 171 } |
171 | 172 |
172 if (allTouchesReleased) { | 173 if (allTouchesReleased) { |
173 m_touchSequenceDocument.clear(); | 174 m_touchSequenceDocument.clear(); |
174 m_touchSequenceUserGestureToken.clear(); | 175 m_touchSequenceUserGestureToken.clear(); |
176 m_currentTouchAction = TouchActionAuto; | |
175 } | 177 } |
176 | 178 |
177 WebInputEventResult eventResult = WebInputEventResult::NotHandled; | 179 WebInputEventResult eventResult = WebInputEventResult::NotHandled; |
178 | 180 |
179 // Now iterate through the |changedTouches| list and |m_targets| within it, | 181 // Now iterate through the |changedTouches| list and |m_targets| within it, |
180 // sending TouchEvents to the targets as required. | 182 // sending TouchEvents to the targets as required. |
181 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; | 183 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; |
182 ++state) { | 184 ++state) { |
183 if (!changedTouches[state].m_touches) | 185 if (!changedTouches[state].m_touches) |
184 continue; | 186 continue; |
185 | 187 |
186 const AtomicString& eventName(touchEventNameForTouchPointState( | 188 const AtomicString& eventName(touchEventNameForTouchPointState( |
187 static_cast<PlatformTouchPoint::TouchState>(state))); | 189 static_cast<PlatformTouchPoint::TouchState>(state))); |
188 for (const auto& eventTarget : changedTouches[state].m_targets) { | 190 for (const auto& eventTarget : changedTouches[state].m_targets) { |
189 EventTarget* touchEventTarget = eventTarget; | 191 EventTarget* touchEventTarget = eventTarget; |
190 TouchEvent* touchEvent = TouchEvent::create( | 192 TouchEvent* touchEvent = |
191 touches, touchesByTarget.get(touchEventTarget), | 193 TouchEvent::create(touches, touchesByTarget.get(touchEventTarget), |
192 changedTouches[state].m_touches.get(), eventName, | 194 changedTouches[state].m_touches.get(), eventName, |
193 touchEventTarget->toNode()->document().domWindow(), | 195 touchEventTarget->toNode()->document().domWindow(), |
194 event.getModifiers(), event.cancelable(), | 196 event.getModifiers(), event.cancelable(), |
195 event.causesScrollingIfUncanceled(), | 197 event.causesScrollingIfUncanceled(), |
196 event.touchStartOrFirstTouchMove(), event.timestamp()); | 198 event.touchStartOrFirstTouchMove(), |
199 event.timestamp(), m_currentTouchAction); | |
197 | 200 |
198 DispatchEventResult domDispatchResult = | 201 DispatchEventResult domDispatchResult = |
199 touchEventTarget->dispatchEvent(touchEvent); | 202 touchEventTarget->dispatchEvent(touchEvent); |
200 | 203 |
201 // Only report for top level documents with a single touch on | 204 // Only report for top level documents with a single touch on |
202 // touch-start or the first touch-move. | 205 // touch-start or the first touch-move. |
203 if (event.touchStartOrFirstTouchMove() && touchInfos.size() == 1 && | 206 if (event.touchStartOrFirstTouchMove() && touchInfos.size() == 1 && |
204 m_frame->isMainFrame()) { | 207 m_frame->isMainFrame()) { |
205 // Record the disposition and latency of touch starts and first touch | 208 // Record the disposition and latency of touch starts and first touch |
206 // moves before and after the page is fully loaded respectively. | 209 // moves before and after the page is fully loaded respectively. |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 // cases in the browser where this happens. | 339 // cases in the browser where this happens. |
337 // See http://crbug.com/345372. | 340 // See http://crbug.com/345372. |
338 m_targetForTouchID.set(touchInfo.point.id(), touchInfo.touchNode); | 341 m_targetForTouchID.set(touchInfo.point.id(), touchInfo.touchNode); |
339 | 342 |
340 m_regionForTouchID.set(touchInfo.point.id(), touchInfo.region); | 343 m_regionForTouchID.set(touchInfo.point.id(), touchInfo.region); |
341 | 344 |
342 TouchAction effectiveTouchAction = | 345 TouchAction effectiveTouchAction = |
343 TouchActionUtil::computeEffectiveTouchAction(*touchInfo.touchNode); | 346 TouchActionUtil::computeEffectiveTouchAction(*touchInfo.touchNode); |
344 if (effectiveTouchAction != TouchActionAuto) | 347 if (effectiveTouchAction != TouchActionAuto) |
345 m_frame->page()->chromeClient().setTouchAction(effectiveTouchAction); | 348 m_frame->page()->chromeClient().setTouchAction(effectiveTouchAction); |
349 m_currentTouchAction = effectiveTouchAction; | |
Rick Byers
2016/11/07 17:01:09
This isn't sufficient for multi-finger gestures.
dtapuska
2016/11/07 18:51:40
Done.
| |
346 } | 350 } |
347 } | 351 } |
348 } | 352 } |
349 | 353 |
350 void TouchEventManager::setAllPropertiesOfTouchInfos( | 354 void TouchEventManager::setAllPropertiesOfTouchInfos( |
351 HeapVector<TouchInfo>& touchInfos) { | 355 HeapVector<TouchInfo>& touchInfos) { |
352 for (auto& touchInfo : touchInfos) { | 356 for (auto& touchInfo : touchInfos) { |
353 PlatformTouchPoint::TouchState pointState = touchInfo.point.state(); | 357 PlatformTouchPoint::TouchState pointState = touchInfo.point.state(); |
354 Node* touchNode = nullptr; | 358 Node* touchNode = nullptr; |
355 String regionID; | 359 String regionID; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
565 feature = UseCounter::TouchEndDuringScrollUserGestureUtilized; | 569 feature = UseCounter::TouchEndDuringScrollUserGestureUtilized; |
566 break; | 570 break; |
567 default: | 571 default: |
568 NOTREACHED(); | 572 NOTREACHED(); |
569 return; | 573 return; |
570 } | 574 } |
571 Deprecation::countDeprecation(m_frame, feature); | 575 Deprecation::countDeprecation(m_frame, feature); |
572 } | 576 } |
573 | 577 |
574 } // namespace blink | 578 } // namespace blink |
OLD | NEW |