Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: third_party/WebKit/Source/core/events/PointerIdManager.cpp

Issue 1426643008: Cleaning up PointerIdManager and add id re-mapping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix EXPECT_EQ compilation error on Android Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/PointerIdManager.h"
7
8 namespace blink {
9
10 namespace {
11
12 inline int toInt(WebPointerProperties::PointerType t) { return static_cast<int>( t); }
13
14 } // namespace
15
16 PointerIdManager::PointerIdManager()
17 {
18 clear();
19 }
20
21 PointerIdManager::~PointerIdManager()
22 {
23 clear();
24 }
25
26 void PointerIdManager::clear()
27 {
28 for (int type = 0; type <= toInt(WebPointerProperties::PointerType::LastEntr y); type++) {
29 m_ids[type].clear();
30 m_hasPrimaryId[type] = false;
31 }
32 }
33
34 void PointerIdManager::add(WebPointerProperties::PointerType type, unsigned id)
35 {
36 if (m_ids[toInt(type)].isEmpty())
37 m_hasPrimaryId[toInt(type)] = true;
38 m_ids[toInt(type)].add(id);
39 }
40
41 void PointerIdManager::remove(WebPointerProperties::PointerType type, unsigned i d)
42 {
43 if (isPrimary(type, id)) {
44 m_ids[toInt(type)].removeFirst();
45 m_hasPrimaryId[toInt(type)] = false;
46 } else {
47 // Note that simply counting the number of ids instead of storing all of them is not enough.
48 // When id is absent, remove() should be a no-op.
49 m_ids[toInt(type)].remove(id);
50 }
51 }
52
53 bool PointerIdManager::isPrimary(WebPointerProperties::PointerType type, unsigne d id)
54 {
55 return m_hasPrimaryId[toInt(type)] && m_ids[toInt(type)].first() == id;
56 }
57
58 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/PointerIdManager.h ('k') | third_party/WebKit/Source/core/input/EventHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698