Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: third_party/WebKit/Source/core/input/TouchEventManager.h

Issue 2860663006: Remove WebTouchEvent from TouchEventManager APIs (Closed)
Patch Set: Add TODO for clarification of the fields Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "core/input/EventHandlingUtil.h"
11 #include "platform/graphics/TouchAction.h" 11 #include "platform/graphics/TouchAction.h"
12 #include "platform/wtf/Allocator.h" 12 #include "platform/wtf/Allocator.h"
13 #include "platform/wtf/HashMap.h" 13 #include "platform/wtf/HashMap.h"
14 #include "platform/wtf/Vector.h" 14 #include "platform/wtf/Vector.h"
15 #include "public/platform/WebCoalescedInputEvent.h"
15 #include "public/platform/WebInputEventResult.h" 16 #include "public/platform/WebInputEventResult.h"
16 #include "public/platform/WebTouchPoint.h" 17 #include "public/platform/WebPointerEvent.h"
18 #include "public/platform/WebTouchEvent.h"
17 19
18 namespace blink { 20 namespace blink {
19 21
20 class LocalFrame; 22 class LocalFrame;
21 class Document; 23 class Document;
22 class WebTouchEvent;
23 24
24 // This class takes care of dispatching all touch events and 25 // This class takes care of dispatching all touch events and
25 // maintaining related states. 26 // maintaining related states.
26 class CORE_EXPORT TouchEventManager 27 class CORE_EXPORT TouchEventManager
27 : public GarbageCollectedFinalized<TouchEventManager> { 28 : public GarbageCollectedFinalized<TouchEventManager> {
28 WTF_MAKE_NONCOPYABLE(TouchEventManager); 29 WTF_MAKE_NONCOPYABLE(TouchEventManager);
29 30
30 public: 31 public:
31 32
32 explicit TouchEventManager(LocalFrame&); 33 explicit TouchEventManager(LocalFrame&);
33 DECLARE_TRACE(); 34 DECLARE_TRACE();
34 35
35 // The entries in touch point array of WebTouchEvent (i.e. first parameter) 36 void HandleTouchPoint(const WebPointerEvent&,
36 // correspond to the entries of the PointerEventTargets (i.e. last parameter). 37 const Vector<WebPointerEvent>&,
37 WebInputEventResult HandleTouchEvent( 38 const EventHandlingUtil::PointerEventTarget&);
38 const WebTouchEvent&, 39
39 const Vector<WebTouchEvent>&, 40 WebInputEventResult FlushEvents();
40 const HeapVector<EventHandlingUtil::PointerEventTarget>&);
41 41
42 // Resets the internal state of this object. 42 // Resets the internal state of this object.
43 void Clear(); 43 void Clear();
44 44
45 // Returns whether there is any touch on the screen. 45 // Returns whether there is any touch on the screen.
46 bool IsAnyTouchActive() const; 46 bool IsAnyTouchActive() const;
47 47
48 private: 48 private:
49 Touch* CreateDomTouch(const WebTouchPoint&, bool* known_target); 49 // Class represending one touch point event with its coalesced events and
50 // related attributes.
51 class TouchPointAttributes
52 : public GarbageCollectedFinalized<TouchPointAttributes> {
53 public:
54 DEFINE_INLINE_TRACE() { visitor->Trace(target_); }
50 55
51 void UpdateTargetAndRegionMapsForTouchStart( 56 TouchPointAttributes() {}
52 const WebTouchPoint&, 57 explicit TouchPointAttributes(WebPointerEvent event)
58 : event_(event), stale_(false) {}
59
60 // Last state of the touch point.
61 WebPointerEvent event_;
62 // The list of coalesced events of the touch point represented by this class
63 // if there is any. Note that at the end of each frame this list gets
64 // cleared and the touch point |stale_| flag will be true for the next frame
65 // unless more new events arrives for this touch point.
66 Vector<WebPointerEvent> coalesced_events_;
67 Member<Node> target_; // The target of each active touch point.
68 String region_; // // The region of each active touch point.
69 bool stale_;
70 };
71
72 WebCoalescedInputEvent GenerateWebCoalescedInputEvent();
73 Touch* CreateDomTouch(const TouchPointAttributes*, bool* known_target);
74 void AllTouchesReleasedCleanup();
75
76 // Keeps track of attributes of the touch point in the
77 // |touch_points_attributes_| map and does the hit-testing if the original hit
78 // test result was not inside capturing frame |touch_sequence_document_| for
79 // touch events.
80 void UpdateTouchAttributeMapsForPointerDown(
81 const WebPointerEvent&,
53 const EventHandlingUtil::PointerEventTarget&); 82 const EventHandlingUtil::PointerEventTarget&);
54 83
55 // Does the hit-testing if the original hit test result was not inside 84 // This is triggered either by VSync signal to send one touch event per frame
56 // capturing frame for touch events. Returns true if touch events could be 85 // accumulating all move events or by discrete events pointerdown/up/cancel.
57 // dispatched and otherwise returns false. 86 WebInputEventResult DispatchTouchEventFromAccumulatdTouchPoints();
58 bool HitTestTouchPointsIfNeeded(
59 const WebTouchEvent&,
60 const HeapVector<EventHandlingUtil::PointerEventTarget>&);
61
62 WebInputEventResult DispatchTouchEvents(const WebTouchEvent&,
63 const Vector<WebTouchEvent>&,
64 bool all_touches_released);
65 87
66 // NOTE: If adding a new field to this class please ensure that it is 88 // NOTE: If adding a new field to this class please ensure that it is
67 // cleared in |TouchEventManager::clear()|. 89 // cleared in |TouchEventManager::clear()|.
68 90
69 const Member<LocalFrame> frame_; 91 const Member<LocalFrame> frame_;
70 92
71 // The target of each active touch point indexed by the touch ID. 93 // The attributes of each active touch point indexed by the touch ID.
72 using TouchTargetMap = 94 using TouchAttributeMap =
73 HeapHashMap<unsigned, 95 HeapHashMap<int,
74 Member<Node>, 96 Member<TouchPointAttributes>,
75 DefaultHash<unsigned>::Hash, 97 WTF::IntHash<int>,
76 WTF::UnsignedWithZeroKeyHashTraits<unsigned>>; 98 WTF::UnsignedWithZeroKeyHashTraits<int>>;
77 TouchTargetMap target_for_touch_id_; 99 TouchAttributeMap touch_attribute_map_;
78 using TouchRegionMap = HashMap<unsigned,
79 String,
80 DefaultHash<unsigned>::Hash,
81 WTF::UnsignedWithZeroKeyHashTraits<unsigned>>;
82 TouchRegionMap region_for_touch_id_;
83 100
84 // If set, the document of the active touch sequence. Unset if no touch 101 // If set, the document of the active touch sequence. Unset if no touch
85 // sequence active. 102 // sequence active.
86 Member<Document> touch_sequence_document_; 103 Member<Document> touch_sequence_document_;
87 104
88 bool touch_pressed_;
89 bool suppressing_touchmoves_within_slop_; 105 bool suppressing_touchmoves_within_slop_;
90 106
107 // This is used to created a consistent sequence of coalesced events compared
108 // to the last frame.
109 WebTouchEvent last_coalesced_touch_event_;
110
91 // The current touch action, computed on each touch start and is 111 // The current touch action, computed on each touch start and is
92 // a union of all touches. Reset when all touches are released. 112 // a union of all touches. Reset when all touches are released.
93 TouchAction current_touch_action_; 113 TouchAction current_touch_action_;
94 }; 114 };
95 115
96 } // namespace blink 116 } // namespace blink
97 117
98 #endif // TouchEventManager_h 118 #endif // TouchEventManager_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698