OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "core/events/PointerEventUtils.h" | |
7 | |
8 namespace blink { | |
9 | |
10 PointerIdManager::PointerIdManager() | |
11 { | |
12 clear(); | |
13 } | |
14 | |
15 PointerIdManager::~PointerIdManager() | |
16 { | |
17 clear(); | |
18 } | |
19 | |
20 void PointerIdManager::clear() | |
21 { | |
22 for (int type = 0; type < static_cast<int>(PointerTypeLastEntry); type++) { | |
23 m_ids[type].clear(); | |
24 m_hasPrimaryId[type] = false; | |
25 } | |
26 } | |
27 | |
28 void PointerIdManager::add(PointerType type, unsigned id) | |
29 { | |
30 if (m_ids[type].isEmpty()) | |
31 m_hasPrimaryId[type] = true; | |
Rick Byers
2015/06/16 17:25:39
ASSERT(!m_hasPrimaryId[type]) ?
mustaq
2015/06/16 20:18:42
I relied on deduping-through-set here instead of a
Rick Byers
2015/06/18 17:40:07
Oh right, clusterfuzz can definitely trigger this
mustaq
2015/06/18 18:20:53
Acknowledged.
| |
32 m_ids[type].add(id); | |
33 } | |
34 | |
35 void PointerIdManager::remove(PointerType type, unsigned id) | |
36 { | |
37 if (isPrimary(type, id)) { | |
38 m_ids[type].removeFirst(); | |
39 m_hasPrimaryId[type] = false; | |
Rick Byers
2015/06/16 17:25:39
ASSERT(m_hasPrimaryId[type]) ?
mustaq
2015/06/16 20:18:42
Ditto.
| |
40 } else { | |
41 // Note that simply counting the number of ids instead of storing all of them is not enough. | |
42 // When id is absent, remove() should be a no-op. | |
43 m_ids[type].remove(id); | |
44 } | |
45 } | |
46 | |
47 bool PointerIdManager::isPrimary(PointerType type, unsigned id) | |
48 { | |
49 return m_hasPrimaryId[type] && m_ids[type].first() == id; | |
50 } | |
51 | |
52 } // namespace blink | |
OLD | NEW |