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

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

Issue 2914673002: Refactor TouchEventManager::TouchInfo class (Closed)
Patch Set: Rebase 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 // The entries in touch point array of WebTouchEvent (i.e. first parameter)
52 // capturing frame for touch events. Returns true if touch events could be 36 // correspond to the entries of the PointerEventTargets (i.e. last parameter).
53 // dispatched and otherwise returns false. 37 WebInputEventResult HandleTouchEvent(
54 bool ReHitTestTouchPointsIfNeeded(const WebTouchEvent&, 38 const WebTouchEvent&,
55 HeapVector<TouchInfo>&); 39 const Vector<WebTouchEvent>&,
56 40 const HeapVector<EventHandlingUtil::PointerEventTarget>&);
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 41
64 // Resets the internal state of this object. 42 // Resets the internal state of this object.
65 void Clear(); 43 void Clear();
66 44
67 // Returns whether there is any touch on the screen. 45 // Returns whether there is any touch on the screen.
68 bool IsAnyTouchActive() const; 46 bool IsAnyTouchActive() const;
69 47
70 private: 48 private:
71 void UpdateTargetAndRegionMapsForTouchStarts(HeapVector<TouchInfo>&); 49 Touch* CreateDomTouch(const WebTouchPoint&, bool* known_target);
72 void SetAllPropertiesOfTouchInfos(HeapVector<TouchInfo>&); 50
51 void UpdateTargetAndRegionMapsForTouchStart(
52 const WebTouchPoint&,
53 const EventHandlingUtil::PointerEventTarget&);
54
55 // Does the hit-testing if the original hit test result was not inside
56 // capturing frame for touch events. Returns true if touch events could be
57 // dispatched and otherwise returns false.
58 bool HitTestTouchPointsIfNeeded(
59 const WebTouchEvent&,
60 const HeapVector<EventHandlingUtil::PointerEventTarget>&);
73 61
74 WebInputEventResult DispatchTouchEvents(const WebTouchEvent&, 62 WebInputEventResult DispatchTouchEvents(const WebTouchEvent&,
75 const Vector<WebTouchEvent>&, 63 const Vector<WebTouchEvent>&,
76 const HeapVector<TouchInfo>&,
77 bool all_touches_released); 64 bool all_touches_released);
78 65
79 // NOTE: If adding a new field to this class please ensure that it is 66 // NOTE: If adding a new field to this class please ensure that it is
80 // cleared in |TouchEventManager::clear()|. 67 // cleared in |TouchEventManager::clear()|.
81 68
82 const Member<LocalFrame> frame_; 69 const Member<LocalFrame> frame_;
83 70
84 // The target of each active touch point indexed by the touch ID. 71 // The target of each active touch point indexed by the touch ID.
85 using TouchTargetMap = 72 using TouchTargetMap =
86 HeapHashMap<unsigned, 73 HeapHashMap<unsigned,
(...skipping 14 matching lines...) Expand all
101 bool touch_pressed_; 88 bool touch_pressed_;
102 bool suppressing_touchmoves_within_slop_; 89 bool suppressing_touchmoves_within_slop_;
103 90
104 // The current touch action, computed on each touch start and is 91 // The current touch action, computed on each touch start and is
105 // a union of all touches. Reset when all touches are released. 92 // a union of all touches. Reset when all touches are released.
106 TouchAction current_touch_action_; 93 TouchAction current_touch_action_;
107 }; 94 };
108 95
109 } // namespace blink 96 } // namespace blink
110 97
111 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::TouchEventManager::TouchInfo);
112
113 #endif // TouchEventManager_h 98 #endif // TouchEventManager_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698