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

Side by Side Diff: Source/core/inspector/InspectorNodeIds.cpp

Issue 997073004: Move inspector/InspectorNodeIds to dom/DOMNodeIds. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/InspectorNodeIds.h ('k') | Source/core/inspector/InspectorStyleSheet.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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/inspector/InspectorNodeIds.h"
7
8 #if ENABLE(OILPAN)
9 #include "core/dom/Node.h"
10 #else
11 #include "core/dom/WeakNodeMap.h"
12 #endif
13 #include "platform/heap/Handle.h"
14
15 namespace blink {
16
17 #if ENABLE(OILPAN)
18 typedef HeapHashMap<WeakMember<Node>, int> NodeToIdMap;
19 typedef HeapHashMap<int, WeakMember<Node> > IdToNodeMap;
20
21 static NodeToIdMap& nodeToIdMap()
22 {
23 DEFINE_STATIC_LOCAL(Persistent<NodeToIdMap>, nodeToIdMap, (new NodeToIdMap() ));
24 return *nodeToIdMap;
25 }
26
27 static IdToNodeMap& idToNodeMap()
28 {
29 DEFINE_STATIC_LOCAL(Persistent<IdToNodeMap>, idToNodeMap, (new IdToNodeMap() ));
30 return *idToNodeMap;
31 }
32
33 int InspectorNodeIds::idForNode(Node* node)
34 {
35 static int s_nextNodeId = 1;
36 NodeToIdMap::iterator it = nodeToIdMap().find(node);
37 if (it != nodeToIdMap().end())
38 return it->value;
39 int id = s_nextNodeId++;
40 nodeToIdMap().set(node, id);
41 ASSERT(idToNodeMap().find(id) == idToNodeMap().end());
42 idToNodeMap().set(id, node);
43 return id;
44 }
45
46 Node* InspectorNodeIds::nodeForId(int id)
47 {
48 return idToNodeMap().get(id);
49 }
50 #else
51 static WeakNodeMap& nodeIds()
52 {
53 DEFINE_STATIC_LOCAL(WeakNodeMap, self, ());
54 return self;
55 }
56
57 int InspectorNodeIds::idForNode(Node* node)
58 {
59 static int s_nextNodeId = 1;
60 WeakNodeMap& ids = nodeIds();
61 int result = ids.value(node);
62 if (!result) {
63 result = s_nextNodeId++;
64 ids.put(node, result);
65 }
66 return result;
67 }
68
69 Node* InspectorNodeIds::nodeForId(int id)
70 {
71 return nodeIds().node(id);
72 }
73 #endif
74
75 }
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorNodeIds.h ('k') | Source/core/inspector/InspectorStyleSheet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698