OLD | NEW |
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 PointerIdManager_h | 5 #ifndef PointerIdManager_h |
6 #define PointerIdManager_h | 6 #define PointerIdManager_h |
7 | 7 |
8 #include "public/platform/WebPointerProperties.h" | 8 #include "public/platform/WebPointerProperties.h" |
9 #include "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
10 #include "wtf/ListHashSet.h" | 10 #include "wtf/HashMap.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 /** | 14 /** |
15 Helper class for tracking the primary pointer id for each type of PointerEvent
s. | 15 Helper class for tracking the primary pointer id for each type of PointerEvent
s. |
16 */ | 16 */ |
17 class PointerIdManager { | 17 class PointerIdManager { |
18 DISALLOW_NEW(); | 18 DISALLOW_NEW(); |
19 public: | 19 public: |
| 20 typedef unsigned MappedId; |
| 21 typedef std::pair<WebPointerProperties::PointerType, unsigned> GeneratedPoin
ter; |
| 22 static const MappedId s_invalidId; |
20 PointerIdManager(); | 23 PointerIdManager(); |
21 ~PointerIdManager(); | 24 ~PointerIdManager(); |
22 void clear(); | 25 void clear(); |
23 void add(WebPointerProperties::PointerType, unsigned); | 26 MappedId add(const GeneratedPointer); |
24 void remove(WebPointerProperties::PointerType, unsigned); | 27 void remove(const GeneratedPointer); |
25 bool isPrimary(WebPointerProperties::PointerType, unsigned); | 28 void remove(const MappedId); |
| 29 bool isPrimary(const MappedId) const; |
| 30 MappedId getPrimaryId(const WebPointerProperties::PointerType) const; |
| 31 WebPointerProperties::PointerType getType(const MappedId) const; |
26 | 32 |
27 private: | 33 private: |
28 // TODO(crbug.com/537319): Switch to /one/ set of ids to guarantee uniquenes
s. | 34 HashMap<unsigned, MappedId> m_ids[static_cast<int>(WebPointerProperties::Poi
nterType::LastEntry) + 1]; |
29 ListHashSet<unsigned> m_ids[static_cast<int>(WebPointerProperties::PointerTy
pe::LastEntry) + 1]; | 35 HashMap<MappedId, GeneratedPointer> m_reverseMapping; |
30 bool m_hasPrimaryId[static_cast<int>(WebPointerProperties::PointerType::Last
Entry) + 1]; | 36 MappedId m_primaryId[static_cast<int>(WebPointerProperties::PointerType::Las
tEntry) + 1]; |
31 }; | 37 }; |
32 | 38 |
33 } // namespace blink | 39 } // namespace blink |
34 | 40 |
35 #endif // PointerIdManager_h | 41 #endif // PointerIdManager_h |
OLD | NEW |