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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // Set of targets involved in m_touches. | 81 // Set of targets involved in m_touches. |
82 EventTargetSet m_targets; | 82 EventTargetSet m_targets; |
83 }; | 83 }; |
84 | 84 |
85 } // namespace | 85 } // namespace |
86 | 86 |
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() { |
| 92 m_touchSequenceDocument.clear(); |
| 93 m_touchSequenceUserGestureToken.clear(); |
| 94 m_targetForTouchID.clear(); |
| 95 m_regionForTouchID.clear(); |
| 96 m_touchPressed = false; |
| 97 m_touchScrollStarted = false; |
| 98 m_currentEvent = PlatformEvent::NoType; |
| 99 } |
| 100 |
| 101 DEFINE_TRACE(TouchEventManager) { |
| 102 visitor->trace(m_frame); |
| 103 visitor->trace(m_touchSequenceDocument); |
| 104 visitor->trace(m_targetForTouchID); |
| 105 } |
| 106 |
91 WebInputEventResult TouchEventManager::dispatchTouchEvents( | 107 WebInputEventResult TouchEventManager::dispatchTouchEvents( |
92 const PlatformTouchEvent& event, | 108 const PlatformTouchEvent& event, |
93 const HeapVector<TouchInfo>& touchInfos, | 109 const HeapVector<TouchInfo>& touchInfos, |
94 bool allTouchesReleased) { | 110 bool allTouchesReleased) { |
95 // Build up the lists to use for the |touches|, |targetTouches| and | 111 // Build up the lists to use for the |touches|, |targetTouches| and |
96 // |changedTouches| attributes in the JS event. See | 112 // |changedTouches| attributes in the JS event. See |
97 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these | 113 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these |
98 // lists fit together. | 114 // lists fit together. |
99 | 115 |
100 // Holds the complete set of touches on the screen. | 116 // Holds the complete set of touches on the screen. |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 m_touchSequenceUserGestureToken.release(), callback)); | 535 m_touchSequenceUserGestureToken.release(), callback)); |
520 else | 536 else |
521 gestureIndicator = wrapUnique( | 537 gestureIndicator = wrapUnique( |
522 new UserGestureIndicator(DefinitelyProcessingUserGesture, callback)); | 538 new UserGestureIndicator(DefinitelyProcessingUserGesture, callback)); |
523 m_touchSequenceUserGestureToken = UserGestureIndicator::currentToken(); | 539 m_touchSequenceUserGestureToken = UserGestureIndicator::currentToken(); |
524 } | 540 } |
525 | 541 |
526 return dispatchTouchEvents(event, touchInfos, allTouchesReleased); | 542 return dispatchTouchEvents(event, touchInfos, allTouchesReleased); |
527 } | 543 } |
528 | 544 |
529 void TouchEventManager::clear() { | |
530 m_touchSequenceDocument.clear(); | |
531 m_touchSequenceUserGestureToken.clear(); | |
532 m_targetForTouchID.clear(); | |
533 m_regionForTouchID.clear(); | |
534 m_touchPressed = false; | |
535 m_touchScrollStarted = false; | |
536 m_currentEvent = PlatformEvent::NoType; | |
537 } | |
538 | |
539 bool TouchEventManager::isAnyTouchActive() const { | 545 bool TouchEventManager::isAnyTouchActive() const { |
540 return m_touchPressed; | 546 return m_touchPressed; |
541 } | 547 } |
542 | 548 |
543 DEFINE_TRACE(TouchEventManager) { | |
544 visitor->trace(m_frame); | |
545 visitor->trace(m_touchSequenceDocument); | |
546 visitor->trace(m_targetForTouchID); | |
547 } | |
548 | 549 |
549 void TouchEventManager::userGestureUtilized() { | 550 void TouchEventManager::userGestureUtilized() { |
550 // This is invoked for UserGestureIndicators created in TouchEventManger::hand
leTouchEvent which perhaps | 551 // This is invoked for UserGestureIndicators created in TouchEventManger::hand
leTouchEvent which perhaps |
551 // represent touch actions which shouldn't be considered a user-gesture. Trig
ger a UseCounter based | 552 // represent touch actions which shouldn't be considered a user-gesture. Trig
ger a UseCounter based |
552 // on the touch event that's currently being dispatched. | 553 // on the touch event that's currently being dispatched. |
553 UseCounter::Feature feature; | 554 UseCounter::Feature feature; |
554 | 555 |
555 switch (m_currentEvent) { | 556 switch (m_currentEvent) { |
556 case PlatformEvent::TouchStart: | 557 case PlatformEvent::TouchStart: |
557 feature = UseCounter::TouchStartUserGestureUtilized; | 558 feature = UseCounter::TouchStartUserGestureUtilized; |
558 break; | 559 break; |
559 case PlatformEvent::TouchMove: | 560 case PlatformEvent::TouchMove: |
560 feature = UseCounter::TouchMoveUserGestureUtilized; | 561 feature = UseCounter::TouchMoveUserGestureUtilized; |
561 break; | 562 break; |
562 case PlatformEvent::TouchEnd: | 563 case PlatformEvent::TouchEnd: |
563 feature = UseCounter::TouchEndDuringScrollUserGestureUtilized; | 564 feature = UseCounter::TouchEndDuringScrollUserGestureUtilized; |
564 break; | 565 break; |
565 default: | 566 default: |
566 NOTREACHED(); | 567 NOTREACHED(); |
567 return; | 568 return; |
568 } | 569 } |
569 Deprecation::countDeprecation(m_frame, feature); | 570 Deprecation::countDeprecation(m_frame, feature); |
570 } | 571 } |
571 | 572 |
572 } // namespace blink | 573 } // namespace blink |
OLD | NEW |