| 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 "core/input/EventHandlingUtil.h" |
| 10 #include "platform/wtf/Allocator.h" | 11 #include "platform/wtf/Allocator.h" |
| 11 #include "platform/wtf/HashMap.h" | 12 #include "platform/wtf/HashMap.h" |
| 12 #include "public/platform/WebInputEventResult.h" | 13 #include "public/platform/WebInputEventResult.h" |
| 14 #include "public/platform/WebPointerEvent.h" |
| 13 #include "public/platform/WebTouchPoint.h" | 15 #include "public/platform/WebTouchPoint.h" |
| 14 | 16 |
| 15 namespace blink { | 17 namespace blink { |
| 16 | 18 |
| 17 class LocalFrame; | 19 class LocalFrame; |
| 18 class Document; | 20 class Document; |
| 19 class WebTouchEvent; | |
| 20 | 21 |
| 21 // This class takes care of dispatching all touch events and | 22 // This class takes care of dispatching all touch events and |
| 22 // maintaining related states. | 23 // maintaining related states. |
| 23 class CORE_EXPORT TouchEventManager | 24 class CORE_EXPORT TouchEventManager |
| 24 : public GarbageCollectedFinalized<TouchEventManager> { | 25 : public GarbageCollectedFinalized<TouchEventManager> { |
| 25 WTF_MAKE_NONCOPYABLE(TouchEventManager); | 26 WTF_MAKE_NONCOPYABLE(TouchEventManager); |
| 26 | 27 |
| 27 public: | 28 public: |
| 28 class TouchInfo { | 29 class TouchInfo { |
| 29 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 30 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 30 | 31 |
| 31 public: | 32 public: |
| 32 DEFINE_INLINE_TRACE() { | 33 DEFINE_INLINE_TRACE() { |
| 33 visitor->Trace(touch_node); | 34 visitor->Trace(touch_node); |
| 34 visitor->Trace(target_frame); | 35 visitor->Trace(target_frame); |
| 35 } | 36 } |
| 36 | 37 |
| 37 WebTouchPoint point; | 38 WebTouchPoint point; |
| 38 Member<Node> touch_node; | 39 Member<Node> touch_node; |
| 39 Member<LocalFrame> target_frame; | 40 Member<LocalFrame> target_frame; |
| 40 FloatPoint content_point; | 41 FloatPoint content_point; |
| 41 FloatSize adjusted_radius; | 42 FloatSize adjusted_radius; |
| 42 bool known_target; | 43 bool known_target; |
| 43 String region; | 44 String region; |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 explicit TouchEventManager(LocalFrame&); | 47 explicit TouchEventManager(LocalFrame&); |
| 47 DECLARE_TRACE(); | 48 DECLARE_TRACE(); |
| 48 | 49 |
| 49 // Does the hit-testing again if the original hit test result was not inside | |
| 50 // capturing frame for touch events. Returns true if touch events could be | |
| 51 // dispatched and otherwise returns false. | |
| 52 bool ReHitTestTouchPointsIfNeeded(const WebTouchEvent&, | |
| 53 HeapVector<TouchInfo>&); | |
| 54 | |
| 55 // The TouchInfo array is reference just to prevent the copy. However, it | 50 // The TouchInfo array is reference just to prevent the copy. However, it |
| 56 // cannot be const as this function might change some of the properties in | 51 // cannot be const as this function might change some of the properties in |
| 57 // TouchInfo objects. | 52 // TouchInfo objects. |
| 58 WebInputEventResult HandleTouchEvent(const WebTouchEvent&, | 53 WebInputEventResult HandleTouchEvent(const Vector<WebCoalescedPointerEvent>&, |
| 59 HeapVector<TouchInfo>&); | 54 HeapVector<TouchInfo>&); |
| 60 | 55 |
| 61 // Resets the internal state of this object. | 56 // Resets the internal state of this object. |
| 62 void Clear(); | 57 void Clear(); |
| 63 | 58 |
| 64 // Returns whether there is any touch on the screen. | 59 // Returns whether there is any touch on the screen. |
| 65 bool IsAnyTouchActive() const; | 60 bool IsAnyTouchActive() const; |
| 66 | 61 |
| 67 private: | 62 private: |
| 68 void UpdateTargetAndRegionMapsForTouchStarts(HeapVector<TouchInfo>&); | 63 void UpdateTargetAndRegionMapsForTouchStarts(HeapVector<TouchInfo>&); |
| 69 void SetAllPropertiesOfTouchInfos(HeapVector<TouchInfo>&); | 64 void SetAllPropertiesOfTouchInfos(HeapVector<TouchInfo>&); |
| 70 | 65 |
| 71 WebInputEventResult DispatchTouchEvents(const WebTouchEvent&, | 66 WebInputEventResult DispatchTouchEvents( |
| 72 const HeapVector<TouchInfo>&, | 67 const Vector<WebCoalescedPointerEvent>&, |
| 73 bool all_touches_released); | 68 const HeapVector<TouchInfo>&, |
| 69 bool all_touches_released); |
| 70 |
| 71 // Does the hit-testing again if the original hit test result was not inside |
| 72 // capturing frame for touch events. Returns true if touch events could be |
| 73 // dispatched and otherwise returns false. |
| 74 bool ReHitTestTouchPointsIfNeeded(const Vector<WebCoalescedPointerEvent>&, |
| 75 HeapVector<TouchInfo>&); |
| 74 | 76 |
| 75 // NOTE: If adding a new field to this class please ensure that it is | 77 // NOTE: If adding a new field to this class please ensure that it is |
| 76 // cleared in |TouchEventManager::clear()|. | 78 // cleared in |TouchEventManager::clear()|. |
| 77 | 79 |
| 78 const Member<LocalFrame> frame_; | 80 const Member<LocalFrame> frame_; |
| 79 | 81 |
| 80 // The target of each active touch point indexed by the touch ID. | 82 // The target of each active touch point indexed by the touch ID. |
| 81 using TouchTargetMap = | 83 using TouchTargetMap = |
| 82 HeapHashMap<unsigned, | 84 HeapHashMap<unsigned, |
| 83 Member<Node>, | 85 Member<Node>, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 100 // The current touch action, computed on each touch start and is | 102 // The current touch action, computed on each touch start and is |
| 101 // a union of all touches. Reset when all touches are released. | 103 // a union of all touches. Reset when all touches are released. |
| 102 TouchAction current_touch_action_; | 104 TouchAction current_touch_action_; |
| 103 }; | 105 }; |
| 104 | 106 |
| 105 } // namespace blink | 107 } // namespace blink |
| 106 | 108 |
| 107 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::TouchEventManager::TouchInfo); | 109 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::TouchEventManager::TouchInfo); |
| 108 | 110 |
| 109 #endif // TouchEventManager_h | 111 #endif // TouchEventManager_h |
| OLD | NEW |