Chromium Code Reviews| 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 Helper class for tracking the pointer ids for each type of PointerEvents. | |
| 20 Using id re-mapping at this layer, this class makes sure that regardless of th e | |
| 21 domain of the id (i.e. in touch or pen) the corresponding pointer event will h ave | |
| 22 a unique id amongst all pointer events as per pointer events' specification. | |
| 23 This class intended to behave the same as existing browsers as much as possibl e | |
| 24 for compatibility reasons. Particularly it behaves very similar to MS Edge to have | |
| 25 pointer event ids generated by mouse always equal 1 and those that are generat ed | |
| 26 by touch and pen will have increasing ids from 2. | |
| 27 */ | |
| 28 class CORE_EXPORT PointerEventManager { | |
| 29 DISALLOW_NEW(); | |
| 30 public: | |
| 31 PointerEventManager(); | |
| 32 ~PointerEventManager(); | |
| 33 DECLARE_TRACE(); | |
| 34 | |
| 35 WebInputEventResult sendMousePointerEvent( | |
| 36 PassRefPtrWillBeRawPtr<Node>, const AtomicString& type, | |
| 37 int clickCount, const PlatformMouseEvent&, | |
| 38 PassRefPtrWillBeRawPtr<Node> relatedTarget, | |
| 39 PassRefPtrWillBeRawPtr<AbstractView>); | |
| 40 | |
| 41 // Returns whether the event is consumed or not | |
| 42 WebInputEventResult sendTouchPointerEvent( | |
| 43 PassRefPtrWillBeRawPtr<EventTarget>, | |
| 44 const PlatformTouchPoint&, PlatformEvent::Modifiers, | |
| 45 const double width, const double height, | |
| 46 const double clientX, const double clientY); | |
| 47 | |
| 48 void sendTouchCancelPointerEvent(PassRefPtrWillBeRawPtr<EventTarget>, | |
| 49 const PlatformTouchPoint&); | |
| 50 | |
| 51 // Sends node transition events (pointer|mouse)(out|leave|over|enter) to the corresponding targets | |
| 52 void sendNodeTransitionEvents(PassRefPtrWillBeRawPtr<Node> exitedNode, | |
| 53 PassRefPtrWillBeRawPtr<Node> enteredNode, | |
| 54 const PlatformMouseEvent&, | |
| 55 PassRefPtrWillBeRawPtr<AbstractView>); | |
| 56 | |
| 57 // Clear all the existing ids. | |
| 58 void clear(); | |
| 59 | |
| 60 // Clear PREVENT MOUSE EVENT flag as per pointer event spec: | |
| 61 // https://w3c.github.io/pointerevents/#compatibility-mapping-with-mouse-eve nts | |
| 62 void clearPreventMouseEventForPointerTypeMouse(); | |
| 63 | |
| 64 private: | |
| 65 PassRefPtrWillBeRawPtr<Node> getEffectiveTargetForPointerEvent( | |
| 66 PassRefPtrWillBeRawPtr<Node>, | |
| 67 PassRefPtrWillBeRawPtr<PointerEvent>); | |
| 68 void sendNodeTransitionEvents( | |
| 69 PassRefPtrWillBeRawPtr<EventTarget> exitedTarget, | |
| 70 PassRefPtrWillBeRawPtr<EventTarget> enteredTarget, | |
| 71 PassRefPtrWillBeRawPtr<PointerEvent>, | |
| 72 const PlatformMouseEvent& = PlatformMouseEvent(), | |
| 73 bool sendMouseEvent = false); | |
| 74 void setNodeUnderPointer(PassRefPtrWillBeRawPtr<PointerEvent>, | |
| 75 PassRefPtrWillBeRawPtr<EventTarget>); | |
| 76 | |
| 77 // Prevents firing mousedown, mousemove & mouseup in-between a canceled poin terdown and next pointerup/pointercancel. | |
| 78 // See "PREVENT MOUSE EVENT flag" in the spec: | |
| 79 // https://w3c.github.io/pointerevents/#compatibility-mapping-with-mouse-e vents | |
| 80 bool m_preventMouseEventForPointerTypeMouse; | |
| 81 | |
| 82 WillBeHeapHashMap<int, RefPtrWillBeMember<EventTarget>> m_nodeUnderPointer; | |
|
mustaq
2016/02/11 16:15:16
This surely needs some attention. We can easily ha
Navid Zolghadr
2016/02/11 16:34:52
I had that problem in mind. The catch is that this
mustaq
2016/02/11 16:51:12
Sorry didn't get it: for touch, we are currently s
Navid Zolghadr
2016/02/11 17:47:49
Not through PointerEventManager class. EventHandle
| |
| 83 PointerEventFactory m_pointerEventFactory; | |
| 84 }; | |
| 85 | |
| 86 } // namespace blink | |
| 87 | |
| 88 #endif // PointerEventManager_h | |
| OLD | NEW |