Index: third_party/WebKit/Source/core/input/PointerEventManager.h |
diff --git a/third_party/WebKit/Source/core/input/PointerEventManager.h b/third_party/WebKit/Source/core/input/PointerEventManager.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..24cd630f8f5b8bc1638c4370f2f4ad1263cc629d |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/input/PointerEventManager.h |
@@ -0,0 +1,88 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef PointerEventManager_h |
+#define PointerEventManager_h |
+ |
+#include "core/CoreExport.h" |
+#include "core/events/PointerEvent.h" |
+#include "core/events/PointerEventFactory.h" |
+#include "public/platform/WebInputEventResult.h" |
+#include "public/platform/WebPointerProperties.h" |
+#include "wtf/Allocator.h" |
+#include "wtf/HashMap.h" |
+ |
+namespace blink { |
+ |
+/** |
+ Helper class for tracking the pointer ids for each type of PointerEvents. |
+ Using id re-mapping at this layer, this class makes sure that regardless of the |
+ domain of the id (i.e. in touch or pen) the corresponding pointer event will have |
+ a unique id amongst all pointer events as per pointer events' specification. |
+ This class intended to behave the same as existing browsers as much as possible |
+ for compatibility reasons. Particularly it behaves very similar to MS Edge to have |
+ pointer event ids generated by mouse always equal 1 and those that are generated |
+ by touch and pen will have increasing ids from 2. |
+*/ |
+class CORE_EXPORT PointerEventManager { |
+ DISALLOW_NEW(); |
+public: |
+ PointerEventManager(); |
+ ~PointerEventManager(); |
+ DECLARE_TRACE(); |
+ |
+ WebInputEventResult sendMousePointerEvent( |
+ PassRefPtrWillBeRawPtr<Node>, const AtomicString& type, |
+ int clickCount, const PlatformMouseEvent&, |
+ PassRefPtrWillBeRawPtr<Node> relatedTarget, |
+ PassRefPtrWillBeRawPtr<AbstractView>); |
+ |
+ // Returns whether the event is consumed or not |
+ WebInputEventResult sendTouchPointerEvent( |
+ PassRefPtrWillBeRawPtr<EventTarget>, |
+ const PlatformTouchPoint&, PlatformEvent::Modifiers, |
+ const double width, const double height, |
+ const double clientX, const double clientY); |
+ |
+ void sendTouchCancelPointerEvent(PassRefPtrWillBeRawPtr<EventTarget>, |
+ const PlatformTouchPoint&); |
+ |
+ // Sends node transition events (pointer|mouse)(out|leave|over|enter) to the corresponding targets |
+ void sendNodeTransitionEvents(PassRefPtrWillBeRawPtr<Node> exitedNode, |
+ PassRefPtrWillBeRawPtr<Node> enteredNode, |
+ const PlatformMouseEvent&, |
+ PassRefPtrWillBeRawPtr<AbstractView>); |
+ |
+ // Clear all the existing ids. |
+ void clear(); |
+ |
+ // Clear PREVENT MOUSE EVENT flag as per pointer event spec: |
+ // https://w3c.github.io/pointerevents/#compatibility-mapping-with-mouse-events |
+ void clearPreventMouseEventForPointerTypeMouse(); |
+ |
+private: |
+ PassRefPtrWillBeRawPtr<Node> getEffectiveTargetForPointerEvent( |
+ PassRefPtrWillBeRawPtr<Node>, |
+ PassRefPtrWillBeRawPtr<PointerEvent>); |
+ void sendNodeTransitionEvents( |
+ PassRefPtrWillBeRawPtr<EventTarget> exitedTarget, |
+ PassRefPtrWillBeRawPtr<EventTarget> enteredTarget, |
+ PassRefPtrWillBeRawPtr<PointerEvent>, |
+ const PlatformMouseEvent& = PlatformMouseEvent(), |
+ bool sendMouseEvent = false); |
+ void setNodeUnderPointer(PassRefPtrWillBeRawPtr<PointerEvent>, |
+ PassRefPtrWillBeRawPtr<EventTarget>); |
+ |
+ // Prevents firing mousedown, mousemove & mouseup in-between a canceled pointerdown and next pointerup/pointercancel. |
+ // See "PREVENT MOUSE EVENT flag" in the spec: |
+ // https://w3c.github.io/pointerevents/#compatibility-mapping-with-mouse-events |
+ bool m_preventMouseEventForPointerTypeMouse; |
+ |
+ 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
|
+ PointerEventFactory m_pointerEventFactory; |
+}; |
+ |
+} // namespace blink |
+ |
+#endif // PointerEventManager_h |