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/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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 TouchEventManager::TouchEventManager(LocalFrame* frame) : m_frame(frame) { | 87 TouchEventManager::TouchEventManager(LocalFrame* frame) : m_frame(frame) { |
88 clear(); | 88 clear(); |
89 } | 89 } |
90 | 90 |
91 void TouchEventManager::clear() { | 91 void TouchEventManager::clear() { |
92 m_touchSequenceDocument.clear(); | 92 m_touchSequenceDocument.clear(); |
93 m_targetForTouchID.clear(); | 93 m_targetForTouchID.clear(); |
94 m_regionForTouchID.clear(); | 94 m_regionForTouchID.clear(); |
95 m_touchPressed = false; | 95 m_touchPressed = false; |
96 m_currentEvent = PlatformEvent::NoType; | 96 m_currentEvent = PlatformEvent::NoType; |
| 97 m_currentTouchAction = TouchActionAuto; |
97 } | 98 } |
98 | 99 |
99 DEFINE_TRACE(TouchEventManager) { | 100 DEFINE_TRACE(TouchEventManager) { |
100 visitor->trace(m_frame); | 101 visitor->trace(m_frame); |
101 visitor->trace(m_touchSequenceDocument); | 102 visitor->trace(m_touchSequenceDocument); |
102 visitor->trace(m_targetForTouchID); | 103 visitor->trace(m_targetForTouchID); |
103 } | 104 } |
104 | 105 |
105 WebInputEventResult TouchEventManager::dispatchTouchEvents( | 106 WebInputEventResult TouchEventManager::dispatchTouchEvents( |
106 const PlatformTouchEvent& event, | 107 const PlatformTouchEvent& event, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 ASSERT(pointState < PlatformTouchPoint::TouchStateEnd); | 161 ASSERT(pointState < PlatformTouchPoint::TouchStateEnd); |
161 if (!changedTouches[pointState].m_touches) | 162 if (!changedTouches[pointState].m_touches) |
162 changedTouches[pointState].m_touches = TouchList::create(); | 163 changedTouches[pointState].m_touches = TouchList::create(); |
163 changedTouches[pointState].m_touches->append(touch); | 164 changedTouches[pointState].m_touches->append(touch); |
164 changedTouches[pointState].m_targets.add(touchInfo.touchNode); | 165 changedTouches[pointState].m_targets.add(touchInfo.touchNode); |
165 } | 166 } |
166 } | 167 } |
167 | 168 |
168 if (allTouchesReleased) { | 169 if (allTouchesReleased) { |
169 m_touchSequenceDocument.clear(); | 170 m_touchSequenceDocument.clear(); |
| 171 m_currentTouchAction = TouchActionAuto; |
170 } | 172 } |
171 | 173 |
172 WebInputEventResult eventResult = WebInputEventResult::NotHandled; | 174 WebInputEventResult eventResult = WebInputEventResult::NotHandled; |
173 | 175 |
174 // Now iterate through the |changedTouches| list and |m_targets| within it, | 176 // Now iterate through the |changedTouches| list and |m_targets| within it, |
175 // sending TouchEvents to the targets as required. | 177 // sending TouchEvents to the targets as required. |
176 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; | 178 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; |
177 ++state) { | 179 ++state) { |
178 if (!changedTouches[state].m_touches) | 180 if (!changedTouches[state].m_touches) |
179 continue; | 181 continue; |
180 | 182 |
181 const AtomicString& eventName(touchEventNameForTouchPointState( | 183 const AtomicString& eventName(touchEventNameForTouchPointState( |
182 static_cast<PlatformTouchPoint::TouchState>(state))); | 184 static_cast<PlatformTouchPoint::TouchState>(state))); |
183 for (const auto& eventTarget : changedTouches[state].m_targets) { | 185 for (const auto& eventTarget : changedTouches[state].m_targets) { |
184 EventTarget* touchEventTarget = eventTarget; | 186 EventTarget* touchEventTarget = eventTarget; |
185 TouchEvent* touchEvent = TouchEvent::create( | 187 TouchEvent* touchEvent = |
186 touches, touchesByTarget.get(touchEventTarget), | 188 TouchEvent::create(touches, touchesByTarget.get(touchEventTarget), |
187 changedTouches[state].m_touches.get(), eventName, | 189 changedTouches[state].m_touches.get(), eventName, |
188 touchEventTarget->toNode()->document().domWindow(), | 190 touchEventTarget->toNode()->document().domWindow(), |
189 event.getModifiers(), event.cancelable(), | 191 event.getModifiers(), event.cancelable(), |
190 event.causesScrollingIfUncanceled(), | 192 event.causesScrollingIfUncanceled(), |
191 event.touchStartOrFirstTouchMove(), event.timestamp()); | 193 event.touchStartOrFirstTouchMove(), |
| 194 event.timestamp(), m_currentTouchAction); |
192 | 195 |
193 DispatchEventResult domDispatchResult = | 196 DispatchEventResult domDispatchResult = |
194 touchEventTarget->dispatchEvent(touchEvent); | 197 touchEventTarget->dispatchEvent(touchEvent); |
195 | 198 |
196 // Only report for top level documents with a single touch on | 199 // Only report for top level documents with a single touch on |
197 // touch-start or the first touch-move. | 200 // touch-start or the first touch-move. |
198 if (event.touchStartOrFirstTouchMove() && touchInfos.size() == 1 && | 201 if (event.touchStartOrFirstTouchMove() && touchInfos.size() == 1 && |
199 m_frame->isMainFrame()) { | 202 m_frame->isMainFrame()) { |
200 // Record the disposition and latency of touch starts and first touch | 203 // Record the disposition and latency of touch starts and first touch |
201 // moves before and after the page is fully loaded respectively. | 204 // moves before and after the page is fully loaded respectively. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 // down. However EventSender allows this to be violated and there's | 329 // down. However EventSender allows this to be violated and there's |
327 // some tests that take advantage of it. There may also be edge | 330 // some tests that take advantage of it. There may also be edge |
328 // cases in the browser where this happens. | 331 // cases in the browser where this happens. |
329 // See http://crbug.com/345372. | 332 // See http://crbug.com/345372. |
330 m_targetForTouchID.set(touchInfo.point.id(), touchInfo.touchNode); | 333 m_targetForTouchID.set(touchInfo.point.id(), touchInfo.touchNode); |
331 | 334 |
332 m_regionForTouchID.set(touchInfo.point.id(), touchInfo.region); | 335 m_regionForTouchID.set(touchInfo.point.id(), touchInfo.region); |
333 | 336 |
334 TouchAction effectiveTouchAction = | 337 TouchAction effectiveTouchAction = |
335 TouchActionUtil::computeEffectiveTouchAction(*touchInfo.touchNode); | 338 TouchActionUtil::computeEffectiveTouchAction(*touchInfo.touchNode); |
336 if (effectiveTouchAction != TouchActionAuto) | 339 if (effectiveTouchAction != TouchActionAuto) { |
337 m_frame->page()->chromeClient().setTouchAction(effectiveTouchAction); | 340 m_frame->page()->chromeClient().setTouchAction(effectiveTouchAction); |
| 341 |
| 342 // Combine the current touch action sequence with the touch action |
| 343 // for the current finger press. |
| 344 m_currentTouchAction &= effectiveTouchAction; |
| 345 } |
338 } | 346 } |
339 } | 347 } |
340 } | 348 } |
341 | 349 |
342 void TouchEventManager::setAllPropertiesOfTouchInfos( | 350 void TouchEventManager::setAllPropertiesOfTouchInfos( |
343 HeapVector<TouchInfo>& touchInfos) { | 351 HeapVector<TouchInfo>& touchInfos) { |
344 for (auto& touchInfo : touchInfos) { | 352 for (auto& touchInfo : touchInfos) { |
345 PlatformTouchPoint::TouchState pointState = touchInfo.point.state(); | 353 PlatformTouchPoint::TouchState pointState = touchInfo.point.state(); |
346 Node* touchNode = nullptr; | 354 Node* touchNode = nullptr; |
347 String regionID; | 355 String regionID; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 } | 499 } |
492 | 500 |
493 return dispatchTouchEvents(event, touchInfos, allTouchesReleased); | 501 return dispatchTouchEvents(event, touchInfos, allTouchesReleased); |
494 } | 502 } |
495 | 503 |
496 bool TouchEventManager::isAnyTouchActive() const { | 504 bool TouchEventManager::isAnyTouchActive() const { |
497 return m_touchPressed; | 505 return m_touchPressed; |
498 } | 506 } |
499 | 507 |
500 } // namespace blink | 508 } // namespace blink |
OLD | NEW |