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

Side by Side Diff: Source/core/dom/DOMNodeIds.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/dom/DOMNodeIds.h ('k') | Source/core/inspector/InspectorAnimationAgent.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/inspector/InspectorNodeIds.h" 6 #include "core/dom/DOMNodeIds.h"
7 7
8 #if ENABLE(OILPAN) 8 #if ENABLE(OILPAN)
9 #include "core/dom/Node.h" 9 #include "core/dom/Node.h"
10 #else 10 #else
11 #include "core/dom/WeakNodeMap.h" 11 #include "core/dom/WeakNodeMap.h"
12 #endif 12 #endif
13 #include "platform/heap/Handle.h" 13 #include "platform/heap/Handle.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 #if ENABLE(OILPAN) 17 #if ENABLE(OILPAN)
18 typedef HeapHashMap<WeakMember<Node>, int> NodeToIdMap; 18 typedef HeapHashMap<WeakMember<Node>, int> NodeToIdMap;
19 typedef HeapHashMap<int, WeakMember<Node> > IdToNodeMap; 19 typedef HeapHashMap<int, WeakMember<Node>> IdToNodeMap;
20 20
21 static NodeToIdMap& nodeToIdMap() 21 static NodeToIdMap& nodeToIdMap()
22 { 22 {
23 DEFINE_STATIC_LOCAL(Persistent<NodeToIdMap>, nodeToIdMap, (new NodeToIdMap() )); 23 DEFINE_STATIC_LOCAL(Persistent<NodeToIdMap>, nodeToIdMap, (new NodeToIdMap() ));
24 return *nodeToIdMap; 24 return *nodeToIdMap;
25 } 25 }
26 26
27 static IdToNodeMap& idToNodeMap() 27 static IdToNodeMap& idToNodeMap()
28 { 28 {
29 DEFINE_STATIC_LOCAL(Persistent<IdToNodeMap>, idToNodeMap, (new IdToNodeMap() )); 29 DEFINE_STATIC_LOCAL(Persistent<IdToNodeMap>, idToNodeMap, (new IdToNodeMap() ));
30 return *idToNodeMap; 30 return *idToNodeMap;
31 } 31 }
32 32
33 int InspectorNodeIds::idForNode(Node* node) 33 int DOMNodeIds::idForNode(Node* node)
34 { 34 {
35 static int s_nextNodeId = 1; 35 static int s_nextNodeId = 1;
36 NodeToIdMap::iterator it = nodeToIdMap().find(node); 36 NodeToIdMap::iterator it = nodeToIdMap().find(node);
37 if (it != nodeToIdMap().end()) 37 if (it != nodeToIdMap().end())
38 return it->value; 38 return it->value;
39 int id = s_nextNodeId++; 39 int id = s_nextNodeId++;
40 nodeToIdMap().set(node, id); 40 nodeToIdMap().set(node, id);
41 ASSERT(idToNodeMap().find(id) == idToNodeMap().end()); 41 ASSERT(idToNodeMap().find(id) == idToNodeMap().end());
42 idToNodeMap().set(id, node); 42 idToNodeMap().set(id, node);
43 return id; 43 return id;
44 } 44 }
45 45
46 Node* InspectorNodeIds::nodeForId(int id) 46 Node* DOMNodeIds::nodeForId(int id)
47 { 47 {
48 return idToNodeMap().get(id); 48 return idToNodeMap().get(id);
49 } 49 }
50 #else 50 #else
51 static WeakNodeMap& nodeIds() 51 static WeakNodeMap& nodeIds()
52 { 52 {
53 DEFINE_STATIC_LOCAL(WeakNodeMap, self, ()); 53 DEFINE_STATIC_LOCAL(WeakNodeMap, self, ());
54 return self; 54 return self;
55 } 55 }
56 56
57 int InspectorNodeIds::idForNode(Node* node) 57 int DOMNodeIds::idForNode(Node* node)
58 { 58 {
59 static int s_nextNodeId = 1; 59 static int s_nextNodeId = 1;
60 WeakNodeMap& ids = nodeIds(); 60 WeakNodeMap& ids = nodeIds();
61 int result = ids.value(node); 61 int result = ids.value(node);
62 if (!result) { 62 if (!result) {
63 result = s_nextNodeId++; 63 result = s_nextNodeId++;
64 ids.put(node, result); 64 ids.put(node, result);
65 } 65 }
66 return result; 66 return result;
67 } 67 }
68 68
69 Node* InspectorNodeIds::nodeForId(int id) 69 Node* DOMNodeIds::nodeForId(int id)
70 { 70 {
71 return nodeIds().node(id); 71 return nodeIds().node(id);
72 } 72 }
73 #endif 73 #endif
74 74
75 } 75 }
OLDNEW
« no previous file with comments | « Source/core/dom/DOMNodeIds.h ('k') | Source/core/inspector/InspectorAnimationAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698