| 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" |
| 11 #include "core/input/TouchEventManager.h" | 11 #include "core/input/TouchEventManager.h" |
| 12 #include "public/platform/WebInputEventResult.h" | 12 #include "public/platform/WebInputEventResult.h" |
| 13 #include "public/platform/WebPointerProperties.h" | 13 #include "public/platform/WebPointerProperties.h" |
| 14 #include "wtf/Allocator.h" | 14 #include "wtf/Allocator.h" |
| 15 #include "wtf/HashMap.h" | 15 #include "wtf/HashMap.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class LocalFrame; | 19 class LocalFrame; |
| 20 | 20 |
| 21 // This class takes care of dispatching all pointer events and keeps track of | 21 // This class takes care of dispatching all pointer events and keeps track of |
| 22 // properties of active pointer events. | 22 // properties of active pointer events. |
| 23 class CORE_EXPORT PointerEventManager { | 23 class CORE_EXPORT PointerEventManager : public GarbageCollectedFinalized<EventHa
ndler> { |
| 24 WTF_MAKE_NONCOPYABLE(PointerEventManager); | 24 WTF_MAKE_NONCOPYABLE(PointerEventManager); |
| 25 DISALLOW_NEW(); | |
| 26 public: | 25 public: |
| 27 explicit PointerEventManager(LocalFrame*); | 26 explicit PointerEventManager(LocalFrame*); |
| 28 ~PointerEventManager(); | 27 ~PointerEventManager(); |
| 29 DECLARE_TRACE(); | 28 DECLARE_TRACE(); |
| 30 | 29 |
| 31 WebInputEventResult sendMousePointerEvent( | 30 WebInputEventResult sendMousePointerEvent( |
| 32 Node*, const AtomicString& type, | 31 Node*, const AtomicString& type, |
| 33 int clickCount, const PlatformMouseEvent&, | 32 int clickCount, const PlatformMouseEvent&, |
| 34 Node* relatedTarget, | 33 Node* relatedTarget, |
| 35 Node* lastNodeUnderMouse); | 34 Node* lastNodeUnderMouse); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // and sends the got/lostpointercapture events, as per the spec: | 120 // and sends the got/lostpointercapture events, as per the spec: |
| 122 // https://w3c.github.io/pointerevents/#process-pending-pointer-capture | 121 // https://w3c.github.io/pointerevents/#process-pending-pointer-capture |
| 123 // Returns whether the pointer capture is changed. When pointer capture is c
hanged, | 122 // Returns whether the pointer capture is changed. When pointer capture is c
hanged, |
| 124 // this function will take care of boundary events. | 123 // this function will take care of boundary events. |
| 125 bool processPendingPointerCapture( | 124 bool processPendingPointerCapture( |
| 126 PointerEvent*, | 125 PointerEvent*, |
| 127 EventTarget*, | 126 EventTarget*, |
| 128 const PlatformMouseEvent& = PlatformMouseEvent(), | 127 const PlatformMouseEvent& = PlatformMouseEvent(), |
| 129 bool sendMouseEvent = false); | 128 bool sendMouseEvent = false); |
| 130 | 129 |
| 130 // Try to immediately send the got/lostpointercapture without boundary |
| 131 // events. |
| 132 void immediatelyProcessPendingPointerCapture(int pointerId); |
| 133 |
| 131 // Processes the capture state of a pointer, updates node under | 134 // Processes the capture state of a pointer, updates node under |
| 132 // pointer, and sends corresponding boundary events for pointer if | 135 // pointer, and sends corresponding boundary events for pointer if |
| 133 // setPointerPosition is true. It also sends corresponding boundary events | 136 // setPointerPosition is true. It also sends corresponding boundary events |
| 134 // for mouse if sendMouseEvent is true. | 137 // for mouse if sendMouseEvent is true. |
| 135 void processCaptureAndPositionOfPointerEvent( | 138 void processCaptureAndPositionOfPointerEvent( |
| 136 PointerEvent*, | 139 PointerEvent*, |
| 137 EventTarget* hitTestTarget, | 140 EventTarget* hitTestTarget, |
| 138 EventTarget* lastNodeUnderMouse = nullptr, | 141 EventTarget* lastNodeUnderMouse = nullptr, |
| 139 const PlatformMouseEvent& = PlatformMouseEvent(), | 142 const PlatformMouseEvent& = PlatformMouseEvent(), |
| 140 bool sendMouseEvent = false, | 143 bool sendMouseEvent = false, |
| 141 bool setPointerPosition = true); | 144 bool setPointerPosition = true); |
| 142 | 145 |
| 143 void removeTargetFromPointerCapturingMapping( | 146 void removeTargetFromPointerCapturingMapping( |
| 144 PointerCapturingMap&, const EventTarget*); | 147 PointerCapturingMap&, const EventTarget*); |
| 145 EventTarget* getEffectiveTargetForPointerEvent( | 148 EventTarget* getEffectiveTargetForPointerEvent( |
| 146 EventTarget*, int); | 149 EventTarget*, int); |
| 147 EventTarget* getCapturingNode(int); | 150 EventTarget* getCapturingNode(int); |
| 148 void removePointer(PointerEvent*); | 151 void removePointer(PointerEvent*); |
| 149 WebInputEventResult dispatchPointerEvent( | 152 WebInputEventResult dispatchPointerEvent( |
| 150 EventTarget*, | 153 EventTarget*, |
| 151 PointerEvent*, | 154 PointerEvent*, |
| 152 bool checkForListener = false); | 155 bool checkForListener = false); |
| 153 void releasePointerCapture(int); | 156 void modifyPendingPointerCapture(int pointerId, EventTarget*); |
| 157 // Returns true if capture target and pending capture target were different. |
| 158 bool getPointerCaptureState(int pointerId, |
| 159 EventTarget** pointerCaptureTarget, |
| 160 EventTarget** pendingPointerCaptureTarget); |
| 154 | 161 |
| 155 // NOTE: If adding a new field to this class please ensure that it is | 162 // NOTE: If adding a new field to this class please ensure that it is |
| 156 // cleared in |PointerEventManager::clear()|. | 163 // cleared in |PointerEventManager::clear()|. |
| 157 | 164 |
| 158 const Member<LocalFrame> m_frame; | 165 const Member<LocalFrame> m_frame; |
| 159 | 166 |
| 160 // Prevents firing mousedown, mousemove & mouseup in-between a canceled poin
terdown and next pointerup/pointercancel. | 167 // Prevents firing mousedown, mousemove & mouseup in-between a canceled poin
terdown and next pointerup/pointercancel. |
| 161 // See "PREVENT MOUSE EVENT flag" in the spec: | 168 // See "PREVENT MOUSE EVENT flag" in the spec: |
| 162 // https://w3c.github.io/pointerevents/#compatibility-mapping-with-mouse-e
vents | 169 // https://w3c.github.io/pointerevents/#compatibility-mapping-with-mouse-e
vents |
| 163 bool m_preventMouseEventForPointerType[static_cast<size_t>(WebPointerPropert
ies::PointerType::LastEntry) + 1]; | 170 bool m_preventMouseEventForPointerType[static_cast<size_t>(WebPointerPropert
ies::PointerType::LastEntry) + 1]; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 179 PointerCapturingMap m_pointerCaptureTarget; | 186 PointerCapturingMap m_pointerCaptureTarget; |
| 180 PointerCapturingMap m_pendingPointerCaptureTarget; | 187 PointerCapturingMap m_pendingPointerCaptureTarget; |
| 181 | 188 |
| 182 PointerEventFactory m_pointerEventFactory; | 189 PointerEventFactory m_pointerEventFactory; |
| 183 TouchEventManager m_touchEventManager; | 190 TouchEventManager m_touchEventManager; |
| 184 }; | 191 }; |
| 185 | 192 |
| 186 } // namespace blink | 193 } // namespace blink |
| 187 | 194 |
| 188 #endif // PointerEventManager_h | 195 #endif // PointerEventManager_h |
| OLD | NEW |