summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/core/inspector/InspectorNodeIds.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/inspector/InspectorNodeIds.cpp')
-rw-r--r--chromium/third_party/WebKit/Source/core/inspector/InspectorNodeIds.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/chromium/third_party/WebKit/Source/core/inspector/InspectorNodeIds.cpp b/chromium/third_party/WebKit/Source/core/inspector/InspectorNodeIds.cpp
new file mode 100644
index 00000000000..81bb9e76fc6
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/core/inspector/InspectorNodeIds.cpp
@@ -0,0 +1,35 @@
+// Copyright 2014 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/inspector/InspectorNodeIds.h"
+
+#include "core/dom/WeakNodeMap.h"
+
+namespace WebCore {
+
+static WeakNodeMap& nodeIds()
+{
+ DEFINE_STATIC_LOCAL(WeakNodeMap, self, ());
+ return self;
+}
+
+int InspectorNodeIds::idForNode(Node* node)
+{
+ static int s_nextNodeId = 1;
+ WeakNodeMap& ids = nodeIds();
+ int result = ids.value(node);
+ if (!result) {
+ result = s_nextNodeId++;
+ ids.put(node, result);
+ }
+ return result;
+}
+
+Node* InspectorNodeIds::nodeForId(int id)
+{
+ return nodeIds().node(id);
+}
+
+}