Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: third_party/WebKit/Source/core/events/PointerEventManager.h

Issue 1670073004: Send node transition events for touch events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "public/platform/WebPointerProperties.h" 10 #include "public/platform/WebPointerProperties.h"
11 #include "wtf/Allocator.h" 11 #include "wtf/Allocator.h"
12 #include "wtf/HashMap.h" 12 #include "wtf/HashMap.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 /** 16 /**
17 Helper class for tracking the pointer ids for each type of PointerEvents. 17 Helper class for tracking the pointer ids for each type of PointerEvents.
18 Using id re-mapping at this layer, this class makes sure that regardless of th e 18 Using id re-mapping at this layer, this class makes sure that regardless of th e
19 domain of the id (i.e. in touch or pen) the corresponding pointer event will h ave 19 domain of the id (i.e. in touch or pen) the corresponding pointer event will h ave
20 a unique id amongst all pointer events as per pointer events' specification. 20 a unique id amongst all pointer events as per pointer events' specification.
21 This class intended to behave the same as existing browsers as much as possibl e 21 This class intended to behave the same as existing browsers as much as possibl e
22 for compatibility reasons. Particularly it behaves very similar to MS Edge to have 22 for compatibility reasons. Particularly it behaves very similar to MS Edge to have
23 pointer event ids generated by mouse always equal 1 and those that are generat ed 23 pointer event ids generated by mouse always equal 1 and those that are generat ed
24 by touch and pen will have increasing ids from 2. 24 by touch and pen will have increasing ids from 2.
25 */ 25 */
26 class CORE_EXPORT PointerEventManager { 26 class CORE_EXPORT PointerEventManager {
27 DISALLOW_NEW(); 27 DISALLOW_NEW();
28 public: 28 public:
29 PointerEventManager();
30 ~PointerEventManager();
31 DECLARE_TRACE();
29 32
30 PassRefPtrWillBeRawPtr<PointerEvent> create(const AtomicString& type, 33 PassRefPtrWillBeRawPtr<PointerEvent> create(const AtomicString& type,
31 const PlatformMouseEvent&, PassRefPtrWillBeRawPtr<Node> relatedTarget, 34 const PlatformMouseEvent&, PassRefPtrWillBeRawPtr<Node> relatedTarget,
32 PassRefPtrWillBeRawPtr<AbstractView>); 35 PassRefPtrWillBeRawPtr<AbstractView>);
33 36
34 PassRefPtrWillBeRawPtr<PointerEvent> create(const AtomicString& type, 37 // Returns whether the event is consumed or not
38 bool sendTouchPointerEvent(PassRefPtrWillBeRawPtr<EventTarget>,
35 const PlatformTouchPoint&, PlatformEvent::Modifiers, 39 const PlatformTouchPoint&, PlatformEvent::Modifiers,
36 const double width, const double height, 40 const double width, const double height,
37 const double clientX, const double clientY); 41 const double clientX, const double clientY);
38 42
39 PassRefPtrWillBeRawPtr<PointerEvent> createPointerCancel(const PlatformTouch Point&); 43 void sendTouchCancelPointerEvent(PassRefPtrWillBeRawPtr<EventTarget>,
40 44 const PlatformTouchPoint&);
41 PointerEventManager();
42 ~PointerEventManager();
43 45
44 // Clear all the existing ids. 46 // Clear all the existing ids.
45 void clear(); 47 void clear();
46 /* 48 /*
47 * When a pointerEvent with a particular id is removed that id is considered 49 * When a pointerEvent with a particular id is removed that id is considered
48 * free even though there might have been other PointerEvents that were 50 * free even though there might have been other PointerEvents that were
49 * generated with the same id before. 51 * generated with the same id before.
50 */ 52 */
51 void remove(const PassRefPtrWillBeRawPtr<PointerEvent>); 53 void remove(const PassRefPtrWillBeRawPtr<PointerEvent>);
mustaq 2016/02/08 17:01:34 We can make it private now since the manager class
Navid Zolghadr 2016/02/10 16:25:29 Yup.
52 54
53 // Returns the node capturing this pointer id, and null if no node is captur ing it. 55 // Returns the node capturing this pointer id, and null if no node is captur ing it.
54 EventTarget* getCapturingNode(PassRefPtrWillBeRawPtr<PointerEvent>); 56 EventTarget* getCapturingNode(PassRefPtrWillBeRawPtr<PointerEvent>);
55 57
56 private: 58 private:
57 typedef long MappedId; 59 typedef long MappedId;
58 typedef std::pair<int, int> IncomingId; 60 typedef std::pair<int, int> IncomingId;
59 61
60 MappedId add(const IncomingId); 62 MappedId add(const IncomingId);
61 bool isPrimary(const MappedId) const; 63 bool isPrimary(const MappedId) const;
62 void setIdAndType(PointerEventInit &, const WebPointerProperties &); 64 void setIdAndType(PointerEventInit &, const WebPointerProperties &);
65 void sendNodeTransitionEvents(EventTarget* exitedTarget,
66 EventTarget* enteredTarget,
67 PassRefPtrWillBeRawPtr<PointerEvent>);
68
69 PassRefPtrWillBeRawPtr<PointerEvent> create(const AtomicString& type,
70 const PlatformTouchPoint&, PlatformEvent::Modifiers,
71 const double width, const double height,
72 const double clientX, const double clientY);
73 PassRefPtrWillBeRawPtr<PointerEvent> create(
74 PassRefPtrWillBeRawPtr<PointerEvent>,
75 const AtomicString& type,
76 PassRefPtrWillBeRawPtr<EventTarget>);
77 PassRefPtrWillBeRawPtr<PointerEvent> createPointerCancel(
78 const PlatformTouchPoint&);
79 void setNodeUnderPointer(PassRefPtrWillBeRawPtr<PointerEvent>,
80 EventTarget*);
63 81
64 static const MappedId s_invalidId; 82 static const MappedId s_invalidId;
65 static const MappedId s_mouseId; 83 static const MappedId s_mouseId;
66 84
67 PointerEventManager::MappedId m_currentId; 85 PointerEventManager::MappedId m_currentId;
68 HashMap<IncomingId, MappedId, WTF::PairHash<int, int>, WTF::PairHashTraits<W TF::UnsignedWithZeroKeyHashTraits<int>, WTF::UnsignedWithZeroKeyHashTraits<int>> > m_idMapping; 86 HashMap<IncomingId, MappedId, WTF::PairHash<int, int>, WTF::PairHashTraits<W TF::UnsignedWithZeroKeyHashTraits<int>, WTF::UnsignedWithZeroKeyHashTraits<int>> > m_idMapping;
69 HashMap<MappedId, IncomingId, WTF::IntHash<MappedId>, WTF::UnsignedWithZeroK eyHashTraits<MappedId>> m_idReverseMapping; 87 HashMap<MappedId, IncomingId, WTF::IntHash<MappedId>, WTF::UnsignedWithZeroK eyHashTraits<MappedId>> m_idReverseMapping;
70 MappedId m_primaryId[static_cast<int>(WebPointerProperties::PointerType::Las tEntry) + 1]; 88 MappedId m_primaryId[static_cast<int>(WebPointerProperties::PointerType::Las tEntry) + 1];
71 MappedId m_idCount[static_cast<int>(WebPointerProperties::PointerType::LastE ntry) + 1]; 89 MappedId m_idCount[static_cast<int>(WebPointerProperties::PointerType::LastE ntry) + 1];
90 WillBeHeapHashMap<int, RefPtrWillBeMember<EventTarget>> m_nodeUnderPointer;
72 }; 91 };
73 92
74 } // namespace blink 93 } // namespace blink
75 94
76 #endif // PointerEventManager_h 95 #endif // PointerEventManager_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698