| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef TouchEventManager_h |
| 6 #define TouchEventManager_h |
| 7 |
| 8 #include "core/CoreExport.h" |
| 9 #include "core/events/PointerEventFactory.h" |
| 10 #include "platform/UserGestureIndicator.h" |
| 11 #include "public/platform/WebInputEventResult.h" |
| 12 #include "wtf/Allocator.h" |
| 13 #include "wtf/HashMap.h" |
| 14 |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 class LocalFrame; |
| 19 class Document; |
| 20 class PlatformTouchEvent; |
| 21 class PointerEventWithTarget; |
| 22 |
| 23 // This class takes care of dispatching all touch events and |
| 24 // maintaining related states. |
| 25 class CORE_EXPORT TouchEventManager { |
| 26 DISALLOW_NEW(); |
| 27 public: |
| 28 class TouchInfo { |
| 29 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 30 public: |
| 31 DEFINE_INLINE_TRACE() |
| 32 { |
| 33 visitor->trace(touchNode); |
| 34 visitor->trace(targetFrame); |
| 35 } |
| 36 |
| 37 PlatformTouchPoint point; |
| 38 Member<Node> touchNode; |
| 39 Member<LocalFrame> targetFrame; |
| 40 FloatPoint adjustedPagePoint; |
| 41 FloatSize adjustedRadius; |
| 42 bool knownTarget; |
| 43 bool consumed; |
| 44 String region; |
| 45 }; |
| 46 |
| 47 explicit TouchEventManager(LocalFrame*); |
| 48 ~TouchEventManager(); |
| 49 DECLARE_TRACE(); |
| 50 |
| 51 // Returns true if it succesfully generates touchInfos. |
| 52 bool generateTouchInfosAfterHittest( |
| 53 const PlatformTouchEvent&, |
| 54 HeapVector<TouchInfo>&); |
| 55 |
| 56 WebInputEventResult handleTouchEvent( |
| 57 const PlatformTouchEvent&, |
| 58 const HeapVector<TouchInfo>&); |
| 59 |
| 60 // Resets the internal state of this object. |
| 61 void clear(); |
| 62 |
| 63 // Returns whether there is any touch on the screen. |
| 64 bool isAnyTouchActive() const; |
| 65 |
| 66 private: |
| 67 |
| 68 void updateTargetAndRegionMapsForTouchStarts(HeapVector<TouchInfo>&); |
| 69 void setAllPropertiesOfTouchInfos(HeapVector<TouchInfo>&); |
| 70 |
| 71 WebInputEventResult dispatchTouchEvents( |
| 72 const PlatformTouchEvent&, |
| 73 const HeapVector<TouchInfo>&, |
| 74 bool allTouchesReleased); |
| 75 |
| 76 |
| 77 // NOTE: If adding a new field to this class please ensure that it is |
| 78 // cleared in |TouchEventManager::clear()|. |
| 79 |
| 80 const Member<LocalFrame> m_frame; |
| 81 |
| 82 // The target of each active touch point indexed by the touch ID. |
| 83 using TouchTargetMap = HeapHashMap<unsigned, Member<Node>, DefaultHash<unsig
ned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; |
| 84 TouchTargetMap m_targetForTouchID; |
| 85 using TouchRegionMap = HashMap<unsigned, String, DefaultHash<unsigned>::Hash
, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; |
| 86 TouchRegionMap m_regionForTouchID; |
| 87 |
| 88 // If set, the document of the active touch sequence. Unset if no touch sequ
ence active. |
| 89 Member<Document> m_touchSequenceDocument; |
| 90 |
| 91 RefPtr<UserGestureToken> m_touchSequenceUserGestureToken; |
| 92 bool m_touchPressed; |
| 93 // True if waiting on first touch move after a touch start. |
| 94 bool m_waitingForFirstTouchMove; |
| 95 |
| 96 }; |
| 97 |
| 98 } // namespace blink |
| 99 |
| 100 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::TouchEventManager::TouchInfo); |
| 101 |
| 102 #endif // TouchEventManager_h |
| OLD | NEW |