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