Index: Source/core/events/PointerEventUtils.cpp |
diff --git a/Source/core/events/PointerEventUtils.cpp b/Source/core/events/PointerEventUtils.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..11be154a6eb501754f1f01c5b868f948dbab7f67 |
--- /dev/null |
+++ b/Source/core/events/PointerEventUtils.cpp |
@@ -0,0 +1,45 @@ |
+// 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/PointerEventUtils.h" |
+ |
+namespace blink { |
+ |
+PointerIdManager::PointerIdManager() |
+{ |
+ clear(); |
+} |
+ |
+PointerIdManager::~PointerIdManager() |
+{ |
+ clear(); |
+} |
+ |
+void PointerIdManager::clear() |
+{ |
+ m_ids.clear(); |
+ m_hasPrimaryId = false; |
+} |
+ |
+void PointerIdManager::add(unsigned id) |
+{ |
+ if (m_ids.isEmpty()) |
+ m_hasPrimaryId = true; |
+ m_ids.add(id); |
+} |
+ |
+void PointerIdManager::remove(unsigned id) |
+{ |
+ if (isPrimary(id)) |
+ m_hasPrimaryId = false; |
+ m_ids.remove(id); |
+} |
+ |
+bool PointerIdManager::isPrimary(unsigned id) |
+{ |
+ return m_hasPrimaryId && m_ids.first() == id; |
+} |
+ |
+} // namespace blink |