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

Unified Diff: Source/core/events/PointerIdManager.cpp

Issue 1144313003: Added PointerEvent firing on touch events. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased. TODO fixes. Created 5 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/events/PointerIdManager.h ('k') | Source/core/events/ThreadLocalEventNames.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/events/PointerIdManager.cpp
diff --git a/Source/core/events/PointerIdManager.cpp b/Source/core/events/PointerIdManager.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..09bf74d2410cc9865afd76255e9185e4445ec330
--- /dev/null
+++ b/Source/core/events/PointerIdManager.cpp
@@ -0,0 +1,52 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/events/PointerIdManager.h"
+
+namespace blink {
+
+PointerIdManager::PointerIdManager()
+{
+ clear();
+}
+
+PointerIdManager::~PointerIdManager()
+{
+ clear();
+}
+
+void PointerIdManager::clear()
+{
+ for (int type = 0; type < static_cast<int>(PointerTypeLastEntry); type++) {
+ m_ids[type].clear();
+ m_hasPrimaryId[type] = false;
+ }
+}
+
+void PointerIdManager::add(PointerType type, unsigned id)
+{
+ if (m_ids[type].isEmpty())
+ m_hasPrimaryId[type] = true;
+ m_ids[type].add(id);
+}
+
+void PointerIdManager::remove(PointerType type, unsigned id)
+{
+ if (isPrimary(type, id)) {
+ m_ids[type].removeFirst();
+ m_hasPrimaryId[type] = false;
+ } else {
+ // Note that simply counting the number of ids instead of storing all of them is not enough.
+ // When id is absent, remove() should be a no-op.
+ m_ids[type].remove(id);
+ }
+}
+
+bool PointerIdManager::isPrimary(PointerType type, unsigned id)
+{
+ return m_hasPrimaryId[type] && m_ids[type].first() == id;
+}
+
+} // namespace blink
« no previous file with comments | « Source/core/events/PointerIdManager.h ('k') | Source/core/events/ThreadLocalEventNames.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698