| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // Returns whether a pointer id exists and active. | 68 // Returns whether a pointer id exists and active. |
| 69 bool isActive(const int) const; | 69 bool isActive(const int) const; |
| 70 | 70 |
| 71 // Returns whether a pointer id exists and has at least one pressed button. | 71 // Returns whether a pointer id exists and has at least one pressed button. |
| 72 bool isActiveButtonsState(const int) const; | 72 bool isActiveButtonsState(const int) const; |
| 73 | 73 |
| 74 // Returns the id of the pointer event corresponding to the given pointer | 74 // Returns the id of the pointer event corresponding to the given pointer |
| 75 // properties if exists otherwise s_invalidId. | 75 // properties if exists otherwise s_invalidId. |
| 76 int getPointerEventId(const WebPointerProperties&) const; | 76 int getPointerEventId(const WebPointerProperties&) const; |
| 77 | 77 |
| 78 static const int s_mouseId; |
| 79 |
| 78 private: | 80 private: |
| 79 typedef WTF::UnsignedWithZeroKeyHashTraits<int> UnsignedHash; | 81 typedef WTF::UnsignedWithZeroKeyHashTraits<int> UnsignedHash; |
| 80 typedef struct IncomingId : public std::pair<int, int> { | 82 typedef struct IncomingId : public std::pair<int, int> { |
| 81 IncomingId() {} | 83 IncomingId() {} |
| 82 IncomingId(WebPointerProperties::PointerType pointerType, | 84 IncomingId(WebPointerProperties::PointerType pointerType, |
| 83 int rawId) | 85 int rawId) |
| 84 : std::pair<int, int>(static_cast<int>(pointerType), rawId) {} | 86 : std::pair<int, int>(static_cast<int>(pointerType), rawId) {} |
| 85 WebPointerProperties::PointerType pointerType() const { return static_ca
st<WebPointerProperties::PointerType>(first); } | 87 WebPointerProperties::PointerType pointerType() const { return static_ca
st<WebPointerProperties::PointerType>(first); } |
| 86 int pointerTypeInt() const { return first; } | 88 int pointerTypeInt() const { return first; } |
| 87 int rawId() const { return second; } | 89 int rawId() const { return second; } |
| 88 } IncomingId; | 90 } IncomingId; |
| 89 typedef struct PointerAttributes { | 91 typedef struct PointerAttributes { |
| 90 IncomingId incomingId; | 92 IncomingId incomingId; |
| 91 bool isActiveButtons; | 93 bool isActiveButtons; |
| 92 PointerAttributes() {} | 94 PointerAttributes() {} |
| 93 PointerAttributes(IncomingId incomingId, unsigned isActiveButtons) | 95 PointerAttributes(IncomingId incomingId, unsigned isActiveButtons) |
| 94 : incomingId(incomingId) | 96 : incomingId(incomingId) |
| 95 , isActiveButtons(isActiveButtons) {} | 97 , isActiveButtons(isActiveButtons) {} |
| 96 } PointerAttributes; | 98 } PointerAttributes; |
| 97 | 99 |
| 98 int addIdAndActiveButtons(const IncomingId, bool isActiveButtons); | 100 int addIdAndActiveButtons(const IncomingId, bool isActiveButtons); |
| 99 bool isPrimary(const int) const; | 101 bool isPrimary(const int) const; |
| 100 void setIdTypeButtons(PointerEventInit&, const WebPointerProperties&, | 102 void setIdTypeButtons(PointerEventInit&, const WebPointerProperties&, |
| 101 unsigned buttons); | 103 unsigned buttons); |
| 102 void setBubblesAndCancelable(PointerEventInit&, const AtomicString& type); | 104 void setBubblesAndCancelable(PointerEventInit&, const AtomicString& type); |
| 103 | 105 |
| 104 static const int s_invalidId; | 106 static const int s_invalidId; |
| 105 static const int s_mouseId; | |
| 106 | 107 |
| 107 int m_currentId; | 108 int m_currentId; |
| 108 HashMap<IncomingId, int, WTF::PairHash<int, int>, WTF::PairHashTraits<Unsign
edHash, UnsignedHash>> m_pointerIncomingIdMapping; | 109 HashMap<IncomingId, int, WTF::PairHash<int, int>, WTF::PairHashTraits<Unsign
edHash, UnsignedHash>> m_pointerIncomingIdMapping; |
| 109 HashMap<int, PointerAttributes, WTF::IntHash<int>, UnsignedHash> m_pointerId
Mapping; | 110 HashMap<int, PointerAttributes, WTF::IntHash<int>, UnsignedHash> m_pointerId
Mapping; |
| 110 int m_primaryId[static_cast<int>(WebPointerProperties::PointerType::LastEntr
y) + 1]; | 111 int m_primaryId[static_cast<int>(WebPointerProperties::PointerType::LastEntr
y) + 1]; |
| 111 int m_idCount[static_cast<int>(WebPointerProperties::PointerType::LastEntry)
+ 1]; | 112 int m_idCount[static_cast<int>(WebPointerProperties::PointerType::LastEntry)
+ 1]; |
| 112 }; | 113 }; |
| 113 | 114 |
| 114 } // namespace blink | 115 } // namespace blink |
| 115 | 116 |
| 116 #endif // PointerEventFactory_h | 117 #endif // PointerEventFactory_h |
| OLD | NEW |