Chromium Code Reviews| 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 PointerEventFactory_h | 5 #ifndef PointerEventFactory_h |
| 6 #define PointerEventFactory_h | 6 #define PointerEventFactory_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" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 const AtomicString& mouseEventName, const PlatformMouseEvent&, | 33 const AtomicString& mouseEventName, const PlatformMouseEvent&, |
| 34 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, | 34 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, |
| 35 PassRefPtrWillBeRawPtr<AbstractView>); | 35 PassRefPtrWillBeRawPtr<AbstractView>); |
| 36 | 36 |
| 37 PassRefPtrWillBeRawPtr<PointerEvent> create(const AtomicString& type, | 37 PassRefPtrWillBeRawPtr<PointerEvent> create(const AtomicString& type, |
| 38 const PlatformTouchPoint&, PlatformEvent::Modifiers, | 38 const PlatformTouchPoint&, PlatformEvent::Modifiers, |
| 39 const double width, const double height, | 39 const double width, const double height, |
| 40 const double clientX, const double clientY); | 40 const double clientX, const double clientY); |
| 41 | 41 |
| 42 PassRefPtrWillBeRawPtr<PointerEvent> createPointerCancelEvent( | 42 PassRefPtrWillBeRawPtr<PointerEvent> createPointerCancelEvent( |
| 43 const PlatformTouchPoint&); | 43 const int pointerId, const WebPointerProperties::PointerType); |
| 44 | 44 |
| 45 // For creating capture events (i.e got/lostpointercapture) | 45 // For creating capture events (i.e got/lostpointercapture) |
| 46 PassRefPtrWillBeRawPtr<PointerEvent> createPointerCaptureEvent( | 46 PassRefPtrWillBeRawPtr<PointerEvent> createPointerCaptureEvent( |
| 47 PassRefPtrWillBeRawPtr<PointerEvent>, | 47 PassRefPtrWillBeRawPtr<PointerEvent>, |
| 48 const AtomicString&); | 48 const AtomicString&); |
| 49 | 49 |
| 50 // For creating transition events (i.e pointerout/leave/over/enter) | 50 // For creating transition events (i.e pointerout/leave/over/enter) |
| 51 PassRefPtrWillBeRawPtr<PointerEvent> createPointerTransitionEvent( | 51 PassRefPtrWillBeRawPtr<PointerEvent> createPointerTransitionEvent( |
| 52 PassRefPtrWillBeRawPtr<PointerEvent>, | 52 PassRefPtrWillBeRawPtr<PointerEvent>, |
| 53 const AtomicString&, | 53 const AtomicString&, |
| 54 PassRefPtrWillBeRawPtr<EventTarget>); | 54 PassRefPtrWillBeRawPtr<EventTarget>); |
| 55 | 55 |
| 56 // Clear all the existing ids. | 56 // Clear all the existing ids. |
| 57 void clear(); | 57 void clear(); |
| 58 | 58 |
| 59 // Returns true if pointerEvent is removed. When a pointerEvent with a | 59 // When a particular pointerId is removed, the id is considered free even |
| 60 // particular id is removed that id is considered free even though there | 60 // though there might have been other PointerEvents that were generated with |
| 61 // might have been other PointerEvents that were generated with the same id | 61 // the same id before. |
| 62 // before. | 62 bool remove(const int); |
| 63 bool remove(const PassRefPtrWillBeRawPtr<PointerEvent>); | 63 |
| 64 // Returns all ids of the given pointerType. | |
| 65 WillBeHeapVector<int> getPointerIdsOfType(WebPointerProperties::PointerType) ; | |
|
tdresser
2016/04/01 14:50:24
We don't need WillBe types anymore, do we?
Might a
mustaq
2016/04/01 18:31:05
Yes, good catch. Let's save one search-replace fro
| |
| 64 | 66 |
| 65 // Returns whether a pointer id exists and active | 67 // Returns whether a pointer id exists and active |
| 66 bool isActive(const int); | 68 bool isActive(const int); |
| 67 | 69 |
| 68 // Returns whether a pointer id exists and has at least one pressed button | 70 // Returns whether a pointer id exists and has at least one pressed button |
| 69 bool isActiveButtonsState(const int); | 71 bool isActiveButtonsState(const int); |
| 70 | 72 |
| 71 private: | 73 private: |
| 72 typedef WTF::UnsignedWithZeroKeyHashTraits<int> UnsignedHash; | 74 typedef WTF::UnsignedWithZeroKeyHashTraits<int> UnsignedHash; |
| 73 typedef struct IncomingId : public std::pair<int, int> { | 75 typedef struct IncomingId : public std::pair<int, int> { |
| 74 IncomingId() {} | 76 IncomingId() {} |
| 75 IncomingId(WebPointerProperties::PointerType pointerType, | 77 IncomingId(WebPointerProperties::PointerType pointerType, |
| 76 int rawId) | 78 int rawId) |
| 77 : std::pair<int, int>(static_cast<int>(pointerType), rawId) {} | 79 : std::pair<int, int>(static_cast<int>(pointerType), rawId) {} |
| 78 int pointerType() const {return first;} | 80 int pointerType() const {return first;} |
| 79 int rawId() const {return second;} | 81 int rawId() const {return second;} |
| 80 } IncomingId; | 82 } IncomingId; |
| 81 typedef struct PointerAttributes { | 83 typedef struct PointerAttributes { |
| 82 IncomingId incomingId; | 84 IncomingId incomingId; |
| 83 bool isActiveButtons; | 85 bool isActiveButtons; |
| 84 PointerAttributes() {} | 86 PointerAttributes() {} |
| 85 PointerAttributes(IncomingId incomingId, unsigned isActiveButtons) | 87 PointerAttributes(IncomingId incomingId, unsigned isActiveButtons) |
| 86 : incomingId(incomingId) | 88 : incomingId(incomingId) |
| 87 , isActiveButtons(isActiveButtons) {} | 89 , isActiveButtons(isActiveButtons) {} |
| 88 } PointerAttributes; | 90 } PointerAttributes; |
| 89 | 91 |
| 90 int addIdAndActiveButtons(const IncomingId, bool isActiveButtons); | 92 int addIdAndActiveButtons(const IncomingId, bool isActiveButtons); |
| 91 bool isPrimary(const int) const; | 93 bool isPrimary(const int) const; |
| 92 void setIdTypeButtons(PointerEventInit &, const WebPointerProperties &, | 94 void setIdTypeButtons(PointerEventInit&, const WebPointerProperties&, |
| 93 unsigned buttons); | 95 unsigned buttons); |
| 96 void setBubblesAndCancelable(PointerEventInit&, const AtomicString& type); | |
| 94 | 97 |
| 95 static const int s_invalidId; | 98 static const int s_invalidId; |
| 96 static const int s_mouseId; | 99 static const int s_mouseId; |
| 97 | 100 |
| 98 int m_currentId; | 101 int m_currentId; |
| 99 HashMap<IncomingId, int, WTF::PairHash<int, int>, WTF::PairHashTraits<Unsign edHash, UnsignedHash>> m_pointerIncomingIdMapping; | 102 HashMap<IncomingId, int, WTF::PairHash<int, int>, WTF::PairHashTraits<Unsign edHash, UnsignedHash>> m_pointerIncomingIdMapping; |
| 100 HashMap<int, PointerAttributes, WTF::IntHash<int>, UnsignedHash> m_pointerId Mapping; | 103 HashMap<int, PointerAttributes, WTF::IntHash<int>, UnsignedHash> m_pointerId Mapping; |
| 101 int m_primaryId[static_cast<int>(WebPointerProperties::PointerType::LastEntr y) + 1]; | 104 int m_primaryId[static_cast<int>(WebPointerProperties::PointerType::LastEntr y) + 1]; |
| 102 int m_idCount[static_cast<int>(WebPointerProperties::PointerType::LastEntry) + 1]; | 105 int m_idCount[static_cast<int>(WebPointerProperties::PointerType::LastEntry) + 1]; |
| 103 }; | 106 }; |
| 104 | 107 |
| 105 } // namespace blink | 108 } // namespace blink |
| 106 | 109 |
| 107 #endif // PointerEventFactory_h | 110 #endif // PointerEventFactory_h |
| OLD | NEW |