Chromium Code Reviews| Index: third_party/WebKit/Source/core/events/PointerIdManager.h |
| diff --git a/third_party/WebKit/Source/core/events/PointerIdManager.h b/third_party/WebKit/Source/core/events/PointerIdManager.h |
| index b3e01343bf4fefc6cbcc68ac76172fe634b890a1..a4b14b46b4df3fe38fcca29eea790c7a25eb1eaf 100644 |
| --- a/third_party/WebKit/Source/core/events/PointerIdManager.h |
| +++ b/third_party/WebKit/Source/core/events/PointerIdManager.h |
| @@ -5,29 +5,44 @@ |
| #ifndef PointerIdManager_h |
| #define PointerIdManager_h |
| +#include "core/CoreExport.h" |
| #include "public/platform/WebPointerProperties.h" |
| #include "wtf/Allocator.h" |
| -#include "wtf/ListHashSet.h" |
| +#include "wtf/HashMap.h" |
| namespace blink { |
| /** |
| - Helper class for tracking the primary pointer id for each type of PointerEvents. |
| + 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 PointerIdManager { |
| +class CORE_EXPORT PointerIdManager { |
| DISALLOW_NEW(); |
| public: |
| + typedef unsigned MappedId; |
| + typedef std::pair<WebPointerProperties::PointerType, unsigned> GeneratedPointer; |
| + static const MappedId s_invalidId; |
| PointerIdManager(); |
| ~PointerIdManager(); |
| void clear(); |
| - void add(WebPointerProperties::PointerType, unsigned); |
| - void remove(WebPointerProperties::PointerType, unsigned); |
| - bool isPrimary(WebPointerProperties::PointerType, unsigned); |
| + MappedId add(const GeneratedPointer); |
| + void remove(const GeneratedPointer); |
|
mustaq
2015/11/20 20:13:53
Two remove()s is confusing. just pass a ref to Poi
|
| + void remove(const MappedId); |
| + bool isPrimary(const MappedId) const; |
| + MappedId getPrimaryId(const WebPointerProperties::PointerType) const; |
| + WebPointerProperties::PointerType getType(const MappedId) const; |
| private: |
| - // TODO(crbug.com/537319): Switch to /one/ set of ids to guarantee uniqueness. |
| - ListHashSet<unsigned> m_ids[static_cast<int>(WebPointerProperties::PointerType::LastEntry) + 1]; |
| - bool m_hasPrimaryId[static_cast<int>(WebPointerProperties::PointerType::LastEntry) + 1]; |
| + PointerIdManager::MappedId m_currentId; |
| + HashMap<unsigned, MappedId, WTF::IntHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned>> m_ids[static_cast<int>(WebPointerProperties::PointerType::LastEntry) + 1]; |
| + HashMap<MappedId, GeneratedPointer, WTF::IntHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned>> m_reverseMapping; |
| + MappedId m_primaryId[static_cast<int>(WebPointerProperties::PointerType::LastEntry) + 1]; |
| }; |
| } // namespace blink |