| 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 their properties. |
| 24 class CORE_EXPORT TouchEventManager { |
| 25 DISALLOW_NEW(); |
| 26 public: |
| 27 class TouchInfo { |
| 28 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 29 public: |
| 30 DEFINE_INLINE_TRACE() |
| 31 { |
| 32 visitor->trace(touchNode); |
| 33 visitor->trace(targetFrame); |
| 34 } |
| 35 |
| 36 PlatformTouchPoint point; |
| 37 Member<Node> touchNode; |
| 38 Member<LocalFrame> targetFrame; |
| 39 FloatPoint adjustedPagePoint; |
| 40 FloatSize adjustedRadius; |
| 41 bool knownTarget; |
| 42 String region; |
| 43 }; |
| 44 |
| 45 explicit TouchEventManager(LocalFrame*); |
| 46 ~TouchEventManager(); |
| 47 DECLARE_TRACE(); |
| 48 |
| 49 WebInputEventResult handleTouchEvent( |
| 50 const PlatformTouchEvent&, |
| 51 HeapVector<TouchInfo>&); |
| 52 |
| 53 // Resets the internal state of this object. |
| 54 void clear(); |
| 55 |
| 56 // Returns whether there is any touch on the screen. |
| 57 bool isAnyTouchActive(); |
| 58 |
| 59 private: |
| 60 |
| 61 void updateTargetAndRegionMapsForTouchStarts(HeapVector<TouchInfo>&); |
| 62 void setAllPropertiesOfTouchInfos(HeapVector<TouchInfo>&); |
| 63 |
| 64 WebInputEventResult dispatchTouchEvents( |
| 65 const PlatformTouchEvent&, |
| 66 HeapVector<TouchInfo>&, |
| 67 bool allTouchReleased); |
| 68 |
| 69 |
| 70 // NOTE: If adding a new field to this class please ensure that it is |
| 71 // cleared in |PointerEventManager::clear()|. |
| 72 |
| 73 const Member<LocalFrame> m_frame; |
| 74 |
| 75 // The target of each active touch point indexed by the touch ID. |
| 76 using TouchTargetMap = HeapHashMap<unsigned, Member<Node>, DefaultHash<unsig
ned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; |
| 77 TouchTargetMap m_targetForTouchID; |
| 78 using TouchRegionMap = HashMap<unsigned, String, DefaultHash<unsigned>::Hash
, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; |
| 79 TouchRegionMap m_regionForTouchID; |
| 80 |
| 81 bool m_touchPressed; |
| 82 |
| 83 // If set, the document of the active touch sequence. Unset if no touch sequ
ence active. |
| 84 Member<Document> m_touchSequenceDocument; |
| 85 RefPtr<UserGestureToken> m_touchSequenceUserGestureToken; |
| 86 |
| 87 // True if waiting on first touch move after a touch start. |
| 88 bool m_waitingForFirstTouchMove; |
| 89 |
| 90 }; |
| 91 |
| 92 } // namespace blink |
| 93 |
| 94 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::TouchEventManager::TouchInfo); |
| 95 |
| 96 #endif // TouchEventManager_h |
| OLD | NEW |