Chromium Code Reviews| 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/BoundaryEventDispatcher.h" | |
| 11 #include "core/input/TouchEventManager.h" | 12 #include "core/input/TouchEventManager.h" |
| 12 #include "public/platform/WebInputEventResult.h" | 13 #include "public/platform/WebInputEventResult.h" |
| 13 #include "public/platform/WebPointerProperties.h" | 14 #include "public/platform/WebPointerProperties.h" |
| 14 #include "wtf/Allocator.h" | 15 #include "wtf/Allocator.h" |
| 15 #include "wtf/HashMap.h" | 16 #include "wtf/HashMap.h" |
| 16 | 17 |
| 17 namespace blink { | 18 namespace blink { |
| 18 | 19 |
| 19 class LocalFrame; | 20 class LocalFrame; |
| 21 class MouseEventManager; | |
| 20 | 22 |
| 21 // This class takes care of dispatching all pointer events and keeps track of | 23 // This class takes care of dispatching all pointer events and keeps track of |
| 22 // properties of active pointer events. | 24 // properties of active pointer events. |
| 23 class CORE_EXPORT PointerEventManager { | 25 class CORE_EXPORT PointerEventManager { |
| 24 WTF_MAKE_NONCOPYABLE(PointerEventManager); | 26 WTF_MAKE_NONCOPYABLE(PointerEventManager); |
| 25 DISALLOW_NEW(); | 27 DISALLOW_NEW(); |
| 26 public: | 28 public: |
| 27 explicit PointerEventManager(LocalFrame*); | 29 explicit PointerEventManager(LocalFrame*, MouseEventManager*); |
| 28 ~PointerEventManager(); | 30 ~PointerEventManager(); |
| 29 DECLARE_TRACE(); | 31 DECLARE_TRACE(); |
| 30 | 32 |
| 31 // Sends the mouse pointer events and the boundary events | 33 // Sends the mouse pointer events and the boundary events |
| 32 // that it may cause. It also sends the compat mouse events | 34 // that it may cause. It also sends the compat mouse events |
| 33 // and sets the newNodeUnderMouse if the capturing is set | 35 // and sets the newNodeUnderMouse if the capturing is set |
| 34 // in this function. | 36 // in this function. |
| 35 WebInputEventResult sendMousePointerEvent( | 37 WebInputEventResult sendMousePointerEvent( |
| 36 Node* target, const AtomicString& type, | 38 Node* target, const AtomicString& type, |
| 37 int clickCount, const PlatformMouseEvent&, | 39 int clickCount, const PlatformMouseEvent&, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 bool hasRecievedOverEvent; | 101 bool hasRecievedOverEvent; |
| 100 EventTargetAttributes() | 102 EventTargetAttributes() |
| 101 : target(nullptr) | 103 : target(nullptr) |
| 102 , hasRecievedOverEvent(false) {} | 104 , hasRecievedOverEvent(false) {} |
| 103 EventTargetAttributes(EventTarget* target, | 105 EventTargetAttributes(EventTarget* target, |
| 104 bool hasRecievedOverEvent) | 106 bool hasRecievedOverEvent) |
| 105 : target(target) | 107 : target(target) |
| 106 , hasRecievedOverEvent(hasRecievedOverEvent) {} | 108 , hasRecievedOverEvent(hasRecievedOverEvent) {} |
| 107 }; | 109 }; |
| 108 | 110 |
| 111 class PointerEventBoundaryEventDispatcher : public BoundaryEventDispatcher { | |
| 112 WTF_MAKE_NONCOPYABLE(PointerEventBoundaryEventDispatcher); | |
| 113 DISALLOW_NEW(); | |
| 114 | |
| 115 public: | |
| 116 DEFINE_INLINE_TRACE() | |
| 117 { | |
| 118 visitor->trace(m_pointerEvent); | |
| 119 BoundaryEventDispatcher::trace(visitor); | |
| 120 } | |
| 121 PointerEventBoundaryEventDispatcher(PointerEventManager*, PointerEvent*) ; | |
| 122 | |
| 123 protected: | |
| 124 virtual void dispatchOut(EventTarget*, EventTarget* relatedTarget); | |
| 125 virtual void dispatchOver(EventTarget*, EventTarget* relatedTarget); | |
| 126 virtual void dispatchLeave(EventTarget*, EventTarget* relatedTarget, boo l checkForListener); | |
|
bokan
2016/09/01 13:50:13
Use `override` instead if `virtual`
Navid Zolghadr
2016/09/01 17:07:27
Done.
| |
| 127 virtual void dispatchEnter(EventTarget*, EventTarget* relatedTarget, boo l checkForListener); | |
| 128 virtual AtomicString getLeaveEvent(); | |
| 129 virtual AtomicString getEnterEvent(); | |
| 130 | |
| 131 private: | |
| 132 void dispatch(EventTarget*, EventTarget* relatedTarget, const AtomicStri ng&, bool checkForListener); | |
| 133 PointerEventManager* m_pointerEventManager; | |
| 134 Member<PointerEvent> m_pointerEvent; | |
| 135 }; | |
| 136 | |
| 109 // Inhibits firing of touch-type PointerEvents until unblocked by unblockTou chPointers(). Also | 137 // Inhibits firing of touch-type PointerEvents until unblocked by unblockTou chPointers(). Also |
| 110 // sends pointercancels for existing touch-type PointerEvents. | 138 // sends pointercancels for existing touch-type PointerEvents. |
| 111 // See: www.w3.org/TR/pointerevents/#declaring-candidate-regions-for-default -touch-behaviors | 139 // See: www.w3.org/TR/pointerevents/#declaring-candidate-regions-for-default -touch-behaviors |
| 112 void blockTouchPointers(); | 140 void blockTouchPointers(); |
| 113 | 141 |
| 114 // Enables firing of touch-type PointerEvents after they were inhibited by b lockTouchPointers(). | 142 // Enables firing of touch-type PointerEvents after they were inhibited by b lockTouchPointers(). |
| 115 void unblockTouchPointers(); | 143 void unblockTouchPointers(); |
| 116 | 144 |
| 117 // Sends touch pointer events and sets consumed bits in TouchInfo array | 145 // Sends touch pointer events and sets consumed bits in TouchInfo array |
| 118 // based on the return value of pointer event handlers. | 146 // based on the return value of pointer event handlers. |
| 119 void dispatchTouchPointerEvents( | 147 void dispatchTouchPointerEvents( |
| 120 const PlatformTouchEvent&, | 148 const PlatformTouchEvent&, |
| 121 HeapVector<TouchEventManager::TouchInfo>&); | 149 HeapVector<TouchEventManager::TouchInfo>&); |
| 122 | 150 |
| 123 // Returns whether the event is consumed or not. | 151 // Returns whether the event is consumed or not. |
| 124 WebInputEventResult sendTouchPointerEvent(EventTarget*, PointerEvent*); | 152 WebInputEventResult sendTouchPointerEvent(EventTarget*, PointerEvent*); |
| 125 | 153 |
| 126 void sendBoundaryEvents( | 154 void sendBoundaryEvents( |
| 127 EventTarget* exitedTarget, | 155 EventTarget* exitedTarget, |
| 128 EventTarget* enteredTarget, | 156 EventTarget* enteredTarget, |
| 129 PointerEvent*, | 157 PointerEvent*); |
| 130 const PlatformMouseEvent& = PlatformMouseEvent(), | |
| 131 bool sendMouseEvent = false); | |
| 132 void setNodeUnderPointer(PointerEvent*, | 158 void setNodeUnderPointer(PointerEvent*, |
| 133 EventTarget*); | 159 EventTarget*); |
| 134 | 160 |
| 135 // Processes the assignment of |m_pointerCaptureTarget| from |m_pendingPoint erCaptureTarget| | 161 // Processes the assignment of |m_pointerCaptureTarget| from |m_pendingPoint erCaptureTarget| |
| 136 // and sends the got/lostpointercapture events, as per the spec: | 162 // and sends the got/lostpointercapture events, as per the spec: |
| 137 // https://w3c.github.io/pointerevents/#process-pending-pointer-capture | 163 // https://w3c.github.io/pointerevents/#process-pending-pointer-capture |
| 138 void processPendingPointerCapture(PointerEvent*); | 164 void processPendingPointerCapture(PointerEvent*); |
| 139 | 165 |
| 140 // Processes the capture state of a pointer, updates node under | 166 // Processes the capture state of a pointer, updates node under |
| 141 // pointer, and sends corresponding boundary events for pointer if | 167 // pointer, and sends corresponding boundary events for pointer if |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 // the pointer with id=1 is only taking care of true mouse related events. | 214 // the pointer with id=1 is only taking care of true mouse related events. |
| 189 using NodeUnderPointerMap = HeapHashMap<int, EventTargetAttributes, | 215 using NodeUnderPointerMap = HeapHashMap<int, EventTargetAttributes, |
| 190 WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int>>; | 216 WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int>>; |
| 191 NodeUnderPointerMap m_nodeUnderPointer; | 217 NodeUnderPointerMap m_nodeUnderPointer; |
| 192 | 218 |
| 193 PointerCapturingMap m_pointerCaptureTarget; | 219 PointerCapturingMap m_pointerCaptureTarget; |
| 194 PointerCapturingMap m_pendingPointerCaptureTarget; | 220 PointerCapturingMap m_pendingPointerCaptureTarget; |
| 195 | 221 |
| 196 PointerEventFactory m_pointerEventFactory; | 222 PointerEventFactory m_pointerEventFactory; |
| 197 TouchEventManager m_touchEventManager; | 223 TouchEventManager m_touchEventManager; |
| 224 MouseEventManager* m_mouseEventManager; | |
| 198 }; | 225 }; |
| 199 | 226 |
| 200 } // namespace blink | 227 } // namespace blink |
| 201 | 228 |
| 202 #endif // PointerEventManager_h | 229 #endif // PointerEventManager_h |
| OLD | NEW |