| 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 #ifndef TouchEventManager_h | 5 #ifndef TouchEventManager_h |
| 6 #define TouchEventManager_h | 6 #define TouchEventManager_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/events/PointerEventFactory.h" | 9 #include "core/events/PointerEventFactory.h" |
| 10 #include "platform/UserGestureIndicator.h" | 10 #include "platform/UserGestureIndicator.h" |
| 11 #include "public/platform/WebInputEventResult.h" | 11 #include "public/platform/WebInputEventResult.h" |
| 12 #include "wtf/Allocator.h" | 12 #include "wtf/Allocator.h" |
| 13 #include "wtf/HashMap.h" | 13 #include "wtf/HashMap.h" |
| 14 | 14 |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 class LocalFrame; | 18 class LocalFrame; |
| 19 class Document; | 19 class Document; |
| 20 class PlatformTouchEvent; | 20 class PlatformTouchEvent; |
| 21 class PointerEventWithTarget; | 21 class PointerEventWithTarget; |
| 22 | 22 |
| 23 // This class takes care of dispatching all touch events and | 23 // This class takes care of dispatching all touch events and |
| 24 // maintaining related states. | 24 // maintaining related states. |
| 25 class CORE_EXPORT TouchEventManager { | 25 class CORE_EXPORT TouchEventManager: public UserGestureUtilizedCallback { |
| 26 DISALLOW_NEW(); | 26 DISALLOW_NEW(); |
| 27 public: | 27 public: |
| 28 class TouchInfo { | 28 class TouchInfo { |
| 29 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 29 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 30 public: | 30 public: |
| 31 DEFINE_INLINE_TRACE() | 31 DEFINE_INLINE_TRACE() |
| 32 { | 32 { |
| 33 visitor->trace(touchNode); | 33 visitor->trace(touchNode); |
| 34 visitor->trace(targetFrame); | 34 visitor->trace(targetFrame); |
| 35 } | 35 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 60 WebInputEventResult handleTouchEvent( | 60 WebInputEventResult handleTouchEvent( |
| 61 const PlatformTouchEvent&, | 61 const PlatformTouchEvent&, |
| 62 HeapVector<TouchInfo>&); | 62 HeapVector<TouchInfo>&); |
| 63 | 63 |
| 64 // Resets the internal state of this object. | 64 // Resets the internal state of this object. |
| 65 void clear(); | 65 void clear(); |
| 66 | 66 |
| 67 // Returns whether there is any touch on the screen. | 67 // Returns whether there is any touch on the screen. |
| 68 bool isAnyTouchActive() const; | 68 bool isAnyTouchActive() const; |
| 69 | 69 |
| 70 // Indicate that a touch scroll has started. |
| 71 void setTouchScrollStarted() { m_touchScrollStarted = true; } |
| 72 |
| 73 // Invoked when a UserGestureIndicator corresponding to a touch event is uti
lized. |
| 74 void userGestureUtilized() override; |
| 75 |
| 70 private: | 76 private: |
| 71 | |
| 72 void updateTargetAndRegionMapsForTouchStarts(HeapVector<TouchInfo>&); | 77 void updateTargetAndRegionMapsForTouchStarts(HeapVector<TouchInfo>&); |
| 73 void setAllPropertiesOfTouchInfos(HeapVector<TouchInfo>&); | 78 void setAllPropertiesOfTouchInfos(HeapVector<TouchInfo>&); |
| 74 | 79 |
| 75 WebInputEventResult dispatchTouchEvents( | 80 WebInputEventResult dispatchTouchEvents( |
| 76 const PlatformTouchEvent&, | 81 const PlatformTouchEvent&, |
| 77 const HeapVector<TouchInfo>&, | 82 const HeapVector<TouchInfo>&, |
| 78 bool allTouchesReleased); | 83 bool allTouchesReleased); |
| 79 | 84 |
| 80 | 85 |
| 81 // NOTE: If adding a new field to this class please ensure that it is | 86 // NOTE: If adding a new field to this class please ensure that it is |
| 82 // cleared in |TouchEventManager::clear()|. | 87 // cleared in |TouchEventManager::clear()|. |
| 83 | 88 |
| 84 const Member<LocalFrame> m_frame; | 89 const Member<LocalFrame> m_frame; |
| 85 | 90 |
| 86 // The target of each active touch point indexed by the touch ID. | 91 // The target of each active touch point indexed by the touch ID. |
| 87 using TouchTargetMap = HeapHashMap<unsigned, Member<Node>, DefaultHash<unsig
ned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; | 92 using TouchTargetMap = HeapHashMap<unsigned, Member<Node>, DefaultHash<unsig
ned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; |
| 88 TouchTargetMap m_targetForTouchID; | 93 TouchTargetMap m_targetForTouchID; |
| 89 using TouchRegionMap = HashMap<unsigned, String, DefaultHash<unsigned>::Hash
, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; | 94 using TouchRegionMap = HashMap<unsigned, String, DefaultHash<unsigned>::Hash
, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; |
| 90 TouchRegionMap m_regionForTouchID; | 95 TouchRegionMap m_regionForTouchID; |
| 91 | 96 |
| 92 // If set, the document of the active touch sequence. Unset if no touch sequ
ence active. | 97 // If set, the document of the active touch sequence. Unset if no touch sequ
ence active. |
| 93 Member<Document> m_touchSequenceDocument; | 98 Member<Document> m_touchSequenceDocument; |
| 94 | 99 |
| 95 RefPtr<UserGestureToken> m_touchSequenceUserGestureToken; | 100 RefPtr<UserGestureToken> m_touchSequenceUserGestureToken; |
| 96 bool m_touchPressed; | 101 bool m_touchPressed; |
| 97 // True if waiting on first touch move after a touch start. | 102 // True if waiting on first touch move after a touch start. |
| 98 bool m_waitingForFirstTouchMove; | 103 bool m_waitingForFirstTouchMove; |
| 99 | 104 // True if a touch is active but scrolling/zooming has started. |
| 105 bool m_touchScrollStarted; |
| 106 // The touch event currently being handled or NoType if none. |
| 107 PlatformEvent::EventType m_currentEvent; |
| 100 }; | 108 }; |
| 101 | 109 |
| 102 } // namespace blink | 110 } // namespace blink |
| 103 | 111 |
| 104 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::TouchEventManager::TouchInfo); | 112 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::TouchEventManager::TouchInfo); |
| 105 | 113 |
| 106 #endif // TouchEventManager_h | 114 #endif // TouchEventManager_h |
| OLD | NEW |