OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PointerEventManager_h |
| 6 #define PointerEventManager_h |
| 7 |
| 8 #include "core/CoreExport.h" |
| 9 #include "core/events/PointerEvent.h" |
| 10 #include "core/events/PointerEventFactory.h" |
| 11 #include "public/platform/WebInputEventResult.h" |
| 12 #include "public/platform/WebPointerProperties.h" |
| 13 #include "wtf/Allocator.h" |
| 14 #include "wtf/HashMap.h" |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 /** |
| 19 This class takes care of dispatching all pointer events and keeps track of |
| 20 properties of active pointer events. |
| 21 */ |
| 22 class CORE_EXPORT PointerEventManager { |
| 23 DISALLOW_NEW(); |
| 24 public: |
| 25 PointerEventManager(); |
| 26 ~PointerEventManager(); |
| 27 DECLARE_TRACE(); |
| 28 |
| 29 WebInputEventResult sendMousePointerEvent( |
| 30 PassRefPtrWillBeRawPtr<Node>, const AtomicString& type, |
| 31 int clickCount, const PlatformMouseEvent&, |
| 32 PassRefPtrWillBeRawPtr<Node> relatedTarget, |
| 33 PassRefPtrWillBeRawPtr<AbstractView>); |
| 34 |
| 35 // Returns whether the event is consumed or not |
| 36 WebInputEventResult sendTouchPointerEvent( |
| 37 PassRefPtrWillBeRawPtr<EventTarget>, |
| 38 const PlatformTouchPoint&, PlatformEvent::Modifiers, |
| 39 const double width, const double height, |
| 40 const double clientX, const double clientY); |
| 41 |
| 42 void sendTouchCancelPointerEvent(PassRefPtrWillBeRawPtr<EventTarget>, |
| 43 const PlatformTouchPoint&); |
| 44 |
| 45 // Sends node transition events (pointer|mouse)(out|leave|over|enter) to the
corresponding targets |
| 46 void sendNodeTransitionEvents(PassRefPtrWillBeRawPtr<Node> exitedNode, |
| 47 PassRefPtrWillBeRawPtr<Node> enteredNode, |
| 48 const PlatformMouseEvent&, |
| 49 PassRefPtrWillBeRawPtr<AbstractView>); |
| 50 |
| 51 // Clear all the existing ids. |
| 52 void clear(); |
| 53 |
| 54 // May clear PREVENT MOUSE EVENT flag as per pointer event spec: |
| 55 // https://w3c.github.io/pointerevents/#compatibility-mapping-with-mouse-eve
nts |
| 56 void conditionallyEnableMouseEventForPointerTypeMouse(unsigned); |
| 57 |
| 58 |
| 59 private: |
| 60 PassRefPtrWillBeRawPtr<Node> getEffectiveTargetForPointerEvent( |
| 61 PassRefPtrWillBeRawPtr<Node>, |
| 62 PassRefPtrWillBeRawPtr<PointerEvent>); |
| 63 void sendNodeTransitionEvents( |
| 64 PassRefPtrWillBeRawPtr<EventTarget> exitedTarget, |
| 65 PassRefPtrWillBeRawPtr<EventTarget> enteredTarget, |
| 66 PassRefPtrWillBeRawPtr<PointerEvent>, |
| 67 const PlatformMouseEvent& = PlatformMouseEvent(), |
| 68 bool sendMouseEvent = false); |
| 69 void setNodeUnderPointer(PassRefPtrWillBeRawPtr<PointerEvent>, |
| 70 PassRefPtrWillBeRawPtr<EventTarget>); |
| 71 |
| 72 // Prevents firing mousedown, mousemove & mouseup in-between a canceled poin
terdown and next pointerup/pointercancel. |
| 73 // See "PREVENT MOUSE EVENT flag" in the spec: |
| 74 // https://w3c.github.io/pointerevents/#compatibility-mapping-with-mouse-e
vents |
| 75 bool m_preventMouseEventForPointerTypeMouse; |
| 76 |
| 77 // Note that this map keeps track of node under pointer with id=1 as well |
| 78 // which might be different than m_nodeUnderMouse in EventHandler. That one |
| 79 // keeps track of any compatibility mouse event positions but this map for |
| 80 // the pointer with id=1 is only taking care of true mouse related events. |
| 81 WillBeHeapHashMap<int, RefPtrWillBeMember<EventTarget>> m_nodeUnderPointer; |
| 82 |
| 83 PointerEventFactory m_pointerEventFactory; |
| 84 }; |
| 85 |
| 86 } // namespace blink |
| 87 |
| 88 #endif // PointerEventManager_h |
OLD | NEW |