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 PointerEventManager_h | 5 #ifndef PointerEventManager_h |
6 #define PointerEventManager_h | 6 #define PointerEventManager_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/events/PointerEvent.h" | 9 #include "core/events/PointerEvent.h" |
10 #include "core/events/PointerEventFactory.h" | 10 #include "core/events/PointerEventFactory.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 bool hasPointerCapture(int, const EventTarget*) const; | 61 bool hasPointerCapture(int, const EventTarget*) const; |
62 | 62 |
63 // See Element::hasProcessedPointerCapture(int). | 63 // See Element::hasProcessedPointerCapture(int). |
64 bool hasProcessedPointerCapture(int, const EventTarget*) const; | 64 bool hasProcessedPointerCapture(int, const EventTarget*) const; |
65 | 65 |
66 bool isActive(const int) const; | 66 bool isActive(const int) const; |
67 | 67 |
68 // Returns whether there is any touch on the screen. | 68 // Returns whether there is any touch on the screen. |
69 bool isAnyTouchActive() const; | 69 bool isAnyTouchActive() const; |
70 | 70 |
71 // TODO(crbug.com/625843): This can be hidden when mouse refactoring in EventH
andler is done. | 71 // TODO(crbug.com/625843): This can be hidden when mouse refactoring in |
| 72 // EventHandler is done. |
72 EventTarget* getMouseCapturingNode(); | 73 EventTarget* getMouseCapturingNode(); |
73 | 74 |
74 // Returns true if the primary pointerdown corresponding to the given | 75 // Returns true if the primary pointerdown corresponding to the given |
75 // |uniqueTouchEventId| was canceled. Also drops stale ids from | 76 // |uniqueTouchEventId| was canceled. Also drops stale ids from |
76 // |m_touchIdsForCanceledPointerdowns|. | 77 // |m_touchIdsForCanceledPointerdowns|. |
77 bool primaryPointerdownCanceled(uint32_t uniqueTouchEventId); | 78 bool primaryPointerdownCanceled(uint32_t uniqueTouchEventId); |
78 | 79 |
79 private: | 80 private: |
80 typedef HeapHashMap<int, | 81 typedef HeapHashMap<int, |
81 Member<EventTarget>, | 82 Member<EventTarget>, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 115 |
115 private: | 116 private: |
116 void dispatch(EventTarget*, | 117 void dispatch(EventTarget*, |
117 EventTarget* relatedTarget, | 118 EventTarget* relatedTarget, |
118 const AtomicString&, | 119 const AtomicString&, |
119 bool checkForListener); | 120 bool checkForListener); |
120 Member<PointerEventManager> m_pointerEventManager; | 121 Member<PointerEventManager> m_pointerEventManager; |
121 Member<PointerEvent> m_pointerEvent; | 122 Member<PointerEvent> m_pointerEvent; |
122 }; | 123 }; |
123 | 124 |
124 // Inhibits firing of touch-type PointerEvents until unblocked by unblockTouch
Pointers(). Also | 125 // Inhibits firing of touch-type PointerEvents until unblocked by |
125 // sends pointercancels for existing touch-type PointerEvents. | 126 // unblockTouchPointers(). Also sends pointercancels for existing touch-type |
126 // See: www.w3.org/TR/pointerevents/#declaring-candidate-regions-for-default-t
ouch-behaviors | 127 // PointerEvents. See: |
| 128 // www.w3.org/TR/pointerevents/#declaring-candidate-regions-for-default-touch-
behaviors |
127 void blockTouchPointers(); | 129 void blockTouchPointers(); |
128 | 130 |
129 // Enables firing of touch-type PointerEvents after they were inhibited by blo
ckTouchPointers(). | 131 // Enables firing of touch-type PointerEvents after they were inhibited by |
| 132 // blockTouchPointers(). |
130 void unblockTouchPointers(); | 133 void unblockTouchPointers(); |
131 | 134 |
132 // Sends touch pointer events and sets consumed bits in TouchInfo array | 135 // Sends touch pointer events and sets consumed bits in TouchInfo array |
133 // based on the return value of pointer event handlers. | 136 // based on the return value of pointer event handlers. |
134 void dispatchTouchPointerEvents(const PlatformTouchEvent&, | 137 void dispatchTouchPointerEvents(const PlatformTouchEvent&, |
135 HeapVector<TouchEventManager::TouchInfo>&); | 138 HeapVector<TouchEventManager::TouchInfo>&); |
136 | 139 |
137 // Returns whether the event is consumed or not. | 140 // Returns whether the event is consumed or not. |
138 WebInputEventResult sendTouchPointerEvent(EventTarget*, PointerEvent*); | 141 WebInputEventResult sendTouchPointerEvent(EventTarget*, PointerEvent*); |
139 | 142 |
140 void sendBoundaryEvents(EventTarget* exitedTarget, | 143 void sendBoundaryEvents(EventTarget* exitedTarget, |
141 EventTarget* enteredTarget, | 144 EventTarget* enteredTarget, |
142 PointerEvent*); | 145 PointerEvent*); |
143 void setNodeUnderPointer(PointerEvent*, EventTarget*); | 146 void setNodeUnderPointer(PointerEvent*, EventTarget*); |
144 | 147 |
145 // Processes the assignment of |m_pointerCaptureTarget| from |m_pendingPointer
CaptureTarget| | 148 // Processes the assignment of |m_pointerCaptureTarget| from |
146 // and sends the got/lostpointercapture events, as per the spec: | 149 // |m_pendingPointerCaptureTarget| and sends the got/lostpointercapture |
| 150 // events, as per the spec: |
147 // https://w3c.github.io/pointerevents/#process-pending-pointer-capture | 151 // https://w3c.github.io/pointerevents/#process-pending-pointer-capture |
148 void processPendingPointerCapture(PointerEvent*); | 152 void processPendingPointerCapture(PointerEvent*); |
149 | 153 |
150 // Processes the capture state of a pointer, updates node under | 154 // Processes the capture state of a pointer, updates node under |
151 // pointer, and sends corresponding boundary events for pointer if | 155 // pointer, and sends corresponding boundary events for pointer if |
152 // setPointerPosition is true. It also sends corresponding boundary events | 156 // setPointerPosition is true. It also sends corresponding boundary events |
153 // for mouse if sendMouseEvent is true. | 157 // for mouse if sendMouseEvent is true. |
154 // Returns the target that the pointer event is supposed to be fired at. | 158 // Returns the target that the pointer event is supposed to be fired at. |
155 EventTarget* processCaptureAndPositionOfPointerEvent( | 159 EventTarget* processCaptureAndPositionOfPointerEvent( |
156 PointerEvent*, | 160 PointerEvent*, |
(...skipping 13 matching lines...) Expand all Loading... |
170 // Returns true if capture target and pending capture target were different. | 174 // Returns true if capture target and pending capture target were different. |
171 bool getPointerCaptureState(int pointerId, | 175 bool getPointerCaptureState(int pointerId, |
172 EventTarget** pointerCaptureTarget, | 176 EventTarget** pointerCaptureTarget, |
173 EventTarget** pendingPointerCaptureTarget); | 177 EventTarget** pendingPointerCaptureTarget); |
174 | 178 |
175 // NOTE: If adding a new field to this class please ensure that it is | 179 // NOTE: If adding a new field to this class please ensure that it is |
176 // cleared in |PointerEventManager::clear()|. | 180 // cleared in |PointerEventManager::clear()|. |
177 | 181 |
178 const Member<LocalFrame> m_frame; | 182 const Member<LocalFrame> m_frame; |
179 | 183 |
180 // Prevents firing mousedown, mousemove & mouseup in-between a canceled pointe
rdown and next pointerup/pointercancel. | 184 // Prevents firing mousedown, mousemove & mouseup in-between a canceled |
| 185 // pointerdown and next pointerup/pointercancel. |
181 // See "PREVENT MOUSE EVENT flag" in the spec: | 186 // See "PREVENT MOUSE EVENT flag" in the spec: |
182 // https://w3c.github.io/pointerevents/#compatibility-mapping-with-mouse-eve
nts | 187 // https://w3c.github.io/pointerevents/#compatibility-mapping-with-mouse-eve
nts |
183 bool m_preventMouseEventForPointerType | 188 bool m_preventMouseEventForPointerType |
184 [static_cast<size_t>(WebPointerProperties::PointerType::LastEntry) + 1]; | 189 [static_cast<size_t>(WebPointerProperties::PointerType::LastEntry) + 1]; |
185 | 190 |
186 // Set upon sending a pointercancel for touch, prevents PE dispatches for touc
hes until | 191 // Set upon sending a pointercancel for touch, prevents PE dispatches for |
187 // all touch-points become inactive. | 192 // touches until all touch-points become inactive. |
188 bool m_inCanceledStateForPointerTypeTouch; | 193 bool m_inCanceledStateForPointerTypeTouch; |
189 | 194 |
190 Deque<uint32_t> m_touchIdsForCanceledPointerdowns; | 195 Deque<uint32_t> m_touchIdsForCanceledPointerdowns; |
191 | 196 |
192 // Note that this map keeps track of node under pointer with id=1 as well | 197 // Note that this map keeps track of node under pointer with id=1 as well |
193 // which might be different than m_nodeUnderMouse in EventHandler. That one | 198 // which might be different than m_nodeUnderMouse in EventHandler. That one |
194 // keeps track of any compatibility mouse event positions but this map for | 199 // keeps track of any compatibility mouse event positions but this map for |
195 // the pointer with id=1 is only taking care of true mouse related events. | 200 // the pointer with id=1 is only taking care of true mouse related events. |
196 using NodeUnderPointerMap = | 201 using NodeUnderPointerMap = |
197 HeapHashMap<int, | 202 HeapHashMap<int, |
198 EventTargetAttributes, | 203 EventTargetAttributes, |
199 WTF::IntHash<int>, | 204 WTF::IntHash<int>, |
200 WTF::UnsignedWithZeroKeyHashTraits<int>>; | 205 WTF::UnsignedWithZeroKeyHashTraits<int>>; |
201 NodeUnderPointerMap m_nodeUnderPointer; | 206 NodeUnderPointerMap m_nodeUnderPointer; |
202 | 207 |
203 PointerCapturingMap m_pointerCaptureTarget; | 208 PointerCapturingMap m_pointerCaptureTarget; |
204 PointerCapturingMap m_pendingPointerCaptureTarget; | 209 PointerCapturingMap m_pendingPointerCaptureTarget; |
205 | 210 |
206 PointerEventFactory m_pointerEventFactory; | 211 PointerEventFactory m_pointerEventFactory; |
207 Member<TouchEventManager> m_touchEventManager; | 212 Member<TouchEventManager> m_touchEventManager; |
208 Member<MouseEventManager> m_mouseEventManager; | 213 Member<MouseEventManager> m_mouseEventManager; |
209 }; | 214 }; |
210 | 215 |
211 } // namespace blink | 216 } // namespace blink |
212 | 217 |
213 #endif // PointerEventManager_h | 218 #endif // PointerEventManager_h |
OLD | NEW |