| 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 10 matching lines...) Expand all Loading... |
| 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 { |
| 24 WTF_MAKE_NONCOPYABLE(PointerEventManager); | 24 WTF_MAKE_NONCOPYABLE(PointerEventManager); |
| 25 DISALLOW_NEW(); | 25 DISALLOW_NEW(); |
| 26 public: | 26 public: |
| 27 explicit PointerEventManager(LocalFrame*); | 27 explicit PointerEventManager(LocalFrame*); |
| 28 ~PointerEventManager(); | 28 ~PointerEventManager(); |
| 29 DECLARE_TRACE(); | 29 DECLARE_TRACE(); |
| 30 | 30 |
| 31 // Sends the mouse pointer events and the boundary events |
| 32 // that it may cause. It also sends the compat mouse events |
| 33 // and sets the newNodeUnderMouse if the capturing is set |
| 34 // in this function. |
| 31 WebInputEventResult sendMousePointerEvent( | 35 WebInputEventResult sendMousePointerEvent( |
| 32 Node*, const AtomicString& type, | 36 Node* target, const AtomicString& type, |
| 33 int clickCount, const PlatformMouseEvent&, | 37 int clickCount, const PlatformMouseEvent&, |
| 34 Node* relatedTarget, | 38 Node* relatedTarget, |
| 35 Node* lastNodeUnderMouse); | 39 Node* lastNodeUnderMouse, |
| 40 Node** newNodeUnderMouse); |
| 36 | 41 |
| 37 WebInputEventResult handleTouchEvents( | 42 WebInputEventResult handleTouchEvents( |
| 38 const PlatformTouchEvent&); | 43 const PlatformTouchEvent&); |
| 39 | 44 |
| 40 // Sends boundary events mouseout/leave/over/enter to the | 45 // Sends boundary events mouseout/leave/over/enter to the |
| 41 // corresponding targets. This function sends pointerout/leave/over/enter | 46 // corresponding targets. This function sends pointerout/leave/over/enter |
| 42 // only when isFrameBoundaryTransition is true which indicates the | 47 // only when isFrameBoundaryTransition is true which indicates the |
| 43 // transition is over the document boundary and not only the elements border | 48 // transition is over the document boundary and not only the elements border |
| 44 // inside the document. If isFrameBoundaryTransition is false, | 49 // inside the document. If isFrameBoundaryTransition is false, |
| 45 // then the event is a compatibility event like those created by touch | 50 // then the event is a compatibility event like those created by touch |
| (...skipping 12 matching lines...) Expand all Loading... |
| 58 void clear(); | 63 void clear(); |
| 59 | 64 |
| 60 void elementRemoved(EventTarget*); | 65 void elementRemoved(EventTarget*); |
| 61 void setPointerCapture(int, EventTarget*); | 66 void setPointerCapture(int, EventTarget*); |
| 62 void releasePointerCapture(int, EventTarget*); | 67 void releasePointerCapture(int, EventTarget*); |
| 63 bool isActive(const int) const; | 68 bool isActive(const int) const; |
| 64 | 69 |
| 65 // Returns whether there is any touch on the screen. | 70 // Returns whether there is any touch on the screen. |
| 66 bool isAnyTouchActive() const; | 71 bool isAnyTouchActive() const; |
| 67 | 72 |
| 73 // TODO(crbug.com/625843): This can be hidden when mouse refactoring in Even
tHandler is done. |
| 74 EventTarget* getMouseCapturingNode(); |
| 75 |
| 68 // Returns true if the primary pointerdown corresponding to the given | 76 // Returns true if the primary pointerdown corresponding to the given |
| 69 // |uniqueTouchEventId| was canceled. Also drops stale ids from | 77 // |uniqueTouchEventId| was canceled. Also drops stale ids from |
| 70 // |m_touchIdsForCanceledPointerdowns|. | 78 // |m_touchIdsForCanceledPointerdowns|. |
| 71 bool primaryPointerdownCanceled(uint32_t uniqueTouchEventId); | 79 bool primaryPointerdownCanceled(uint32_t uniqueTouchEventId); |
| 72 | 80 |
| 73 // Try to immediately send the got/lostpointercapture without boundary | 81 // Processes the assignment of |m_pointerCaptureTarget| from |m_pendingPoint
erCaptureTarget| |
| 74 // events. | 82 // and sends the got/lostpointercapture events, as per the spec: |
| 83 // https://w3c.github.io/pointerevents/#process-pending-pointer-capture |
| 75 // TODO(crbug.com/629935): This function should be private as soon as Pointe
rEventManager | 84 // TODO(crbug.com/629935): This function should be private as soon as Pointe
rEventManager |
| 76 // a GC managed object and postTask can be done internally in this class. | 85 // a GC managed object and postTask can be done internally in this class. |
| 77 void immediatelyProcessPendingPointerCapture(int pointerId); | 86 void processPendingPointerCapture(int pointerId); |
| 78 | 87 |
| 79 private: | 88 private: |
| 80 typedef HeapHashMap<int, Member<EventTarget>, WTF::IntHash<int>, | 89 typedef HeapHashMap<int, Member<EventTarget>, WTF::IntHash<int>, |
| 81 WTF::UnsignedWithZeroKeyHashTraits<int>> PointerCapturingMap; | 90 WTF::UnsignedWithZeroKeyHashTraits<int>> PointerCapturingMap; |
| 82 class EventTargetAttributes { | 91 class EventTargetAttributes { |
| 83 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 92 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 84 public: | 93 public: |
| 85 DEFINE_INLINE_TRACE() | 94 DEFINE_INLINE_TRACE() |
| 86 { | 95 { |
| 87 visitor->trace(target); | 96 visitor->trace(target); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 114 // Returns whether the event is consumed or not. | 123 // Returns whether the event is consumed or not. |
| 115 WebInputEventResult sendTouchPointerEvent(EventTarget*, PointerEvent*); | 124 WebInputEventResult sendTouchPointerEvent(EventTarget*, PointerEvent*); |
| 116 | 125 |
| 117 void sendBoundaryEvents( | 126 void sendBoundaryEvents( |
| 118 EventTarget* exitedTarget, | 127 EventTarget* exitedTarget, |
| 119 EventTarget* enteredTarget, | 128 EventTarget* enteredTarget, |
| 120 PointerEvent*, | 129 PointerEvent*, |
| 121 const PlatformMouseEvent& = PlatformMouseEvent(), | 130 const PlatformMouseEvent& = PlatformMouseEvent(), |
| 122 bool sendMouseEvent = false); | 131 bool sendMouseEvent = false); |
| 123 void setNodeUnderPointer(PointerEvent*, | 132 void setNodeUnderPointer(PointerEvent*, |
| 124 EventTarget*, bool sendEvent = true); | 133 EventTarget*); |
| 125 | |
| 126 // Processes the assignment of |m_pointerCaptureTarget| from |m_pendingPoint
erCaptureTarget| | |
| 127 // and sends the got/lostpointercapture events, as per the spec: | |
| 128 // https://w3c.github.io/pointerevents/#process-pending-pointer-capture | |
| 129 // Returns whether the pointer capture is changed. When pointer capture is c
hanged, | |
| 130 // this function will take care of boundary events. | |
| 131 bool processPendingPointerCapture( | |
| 132 PointerEvent*, | |
| 133 EventTarget*, | |
| 134 const PlatformMouseEvent& = PlatformMouseEvent(), | |
| 135 bool sendMouseEvent = false); | |
| 136 | 134 |
| 137 // Processes the capture state of a pointer, updates node under | 135 // Processes the capture state of a pointer, updates node under |
| 138 // pointer, and sends corresponding boundary events for pointer if | 136 // pointer, and sends corresponding boundary events for pointer if |
| 139 // setPointerPosition is true. It also sends corresponding boundary events | 137 // setPointerPosition is true. It also sends corresponding boundary events |
| 140 // for mouse if sendMouseEvent is true. | 138 // for mouse if sendMouseEvent is true. |
| 141 void processCaptureAndPositionOfPointerEvent( | 139 // Returns the target that the pointer event is supposed to be fired at. |
| 140 EventTarget* processCaptureAndPositionOfPointerEvent( |
| 142 PointerEvent*, | 141 PointerEvent*, |
| 143 EventTarget* hitTestTarget, | 142 EventTarget* hitTestTarget, |
| 144 EventTarget* lastNodeUnderMouse = nullptr, | 143 EventTarget* lastNodeUnderMouse = nullptr, |
| 145 const PlatformMouseEvent& = PlatformMouseEvent(), | 144 const PlatformMouseEvent& = PlatformMouseEvent(), |
| 146 bool sendMouseEvent = false, | 145 bool sendMouseEvent = false, |
| 147 bool setPointerPosition = true); | 146 bool setPointerPosition = true); |
| 148 | 147 |
| 149 void removeTargetFromPointerCapturingMapping( | 148 void removeTargetFromPointerCapturingMapping( |
| 150 PointerCapturingMap&, const EventTarget*); | 149 PointerCapturingMap&, const EventTarget*); |
| 151 EventTarget* getEffectiveTargetForPointerEvent( | 150 EventTarget* getEffectiveTargetForPointerEvent( |
| 152 EventTarget*, int); | 151 EventTarget*, int); |
| 153 EventTarget* getCapturingNode(int); | 152 EventTarget* getCapturingNode(int); |
| 154 void removePointer(PointerEvent*); | 153 void removePointer(PointerEvent*); |
| 155 WebInputEventResult dispatchPointerEvent( | 154 WebInputEventResult dispatchPointerEvent( |
| 156 EventTarget*, | 155 EventTarget*, |
| 157 PointerEvent*, | 156 PointerEvent*, |
| 158 bool checkForListener = false); | 157 bool checkForListener = false); |
| 159 void modifyPendingPointerCapture(int pointerId, EventTarget*); | 158 // Set |m_pendingPointerCaptureTarget| for the given pointerId to the given |
| 159 // target. It calls |processPendingPointerCapture| immediately if immediate |
| 160 // is set. Otherwise it schedules it based on the heuristic to prevent |
| 161 // the infinite look between lost/gotpointercapture handlers. |
| 162 void modifyPendingPointerCapture(int pointerId, EventTarget*, |
| 163 bool immediate = false); |
| 160 // Returns true if capture target and pending capture target were different. | 164 // Returns true if capture target and pending capture target were different. |
| 161 bool getPointerCaptureState(int pointerId, | 165 bool getPointerCaptureState(int pointerId, |
| 162 EventTarget** pointerCaptureTarget, | 166 EventTarget** pointerCaptureTarget, |
| 163 EventTarget** pendingPointerCaptureTarget); | 167 EventTarget** pendingPointerCaptureTarget); |
| 164 | 168 |
| 165 // NOTE: If adding a new field to this class please ensure that it is | 169 // NOTE: If adding a new field to this class please ensure that it is |
| 166 // cleared in |PointerEventManager::clear()|. | 170 // cleared in |PointerEventManager::clear()|. |
| 167 | 171 |
| 168 const Member<LocalFrame> m_frame; | 172 const Member<LocalFrame> m_frame; |
| 169 | 173 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 189 PointerCapturingMap m_pointerCaptureTarget; | 193 PointerCapturingMap m_pointerCaptureTarget; |
| 190 PointerCapturingMap m_pendingPointerCaptureTarget; | 194 PointerCapturingMap m_pendingPointerCaptureTarget; |
| 191 | 195 |
| 192 PointerEventFactory m_pointerEventFactory; | 196 PointerEventFactory m_pointerEventFactory; |
| 193 TouchEventManager m_touchEventManager; | 197 TouchEventManager m_touchEventManager; |
| 194 }; | 198 }; |
| 195 | 199 |
| 196 } // namespace blink | 200 } // namespace blink |
| 197 | 201 |
| 198 #endif // PointerEventManager_h | 202 #endif // PointerEventManager_h |
| OLD | NEW |