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

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

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

Powered by Google App Engine
This is Rietveld 408576698