| OLD | NEW |
| 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 "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/core/inspector/InspectorNodeIds.h" | 6 #include "sky/engine/core/inspector/InspectorNodeIds.h" |
| 7 | 7 |
| 8 #if ENABLE(OILPAN) | |
| 9 #include "sky/engine/core/dom/Node.h" | |
| 10 #else | |
| 11 #include "sky/engine/core/dom/WeakNodeMap.h" | 8 #include "sky/engine/core/dom/WeakNodeMap.h" |
| 12 #endif | |
| 13 #include "sky/engine/platform/heap/Handle.h" | 9 #include "sky/engine/platform/heap/Handle.h" |
| 14 | 10 |
| 15 namespace blink { | 11 namespace blink { |
| 16 | 12 |
| 17 static WeakNodeMap& nodeIds() | 13 static WeakNodeMap& nodeIds() |
| 18 { | 14 { |
| 19 DEFINE_STATIC_LOCAL(WeakNodeMap, self, ()); | 15 DEFINE_STATIC_LOCAL(WeakNodeMap, self, ()); |
| 20 return self; | 16 return self; |
| 21 } | 17 } |
| 22 | 18 |
| 23 int InspectorNodeIds::idForNode(Node* node) | 19 int InspectorNodeIds::idForNode(Node* node) |
| 24 { | 20 { |
| 25 static int s_nextNodeId = 1; | 21 static int s_nextNodeId = 1; |
| 26 WeakNodeMap& ids = nodeIds(); | 22 WeakNodeMap& ids = nodeIds(); |
| 27 int result = ids.value(node); | 23 int result = ids.value(node); |
| 28 if (!result) { | 24 if (!result) { |
| 29 result = s_nextNodeId++; | 25 result = s_nextNodeId++; |
| 30 ids.put(node, result); | 26 ids.put(node, result); |
| 31 } | 27 } |
| 32 return result; | 28 return result; |
| 33 } | 29 } |
| 34 | 30 |
| 35 Node* InspectorNodeIds::nodeForId(int id) | 31 Node* InspectorNodeIds::nodeForId(int id) |
| 36 { | 32 { |
| 37 return nodeIds().node(id); | 33 return nodeIds().node(id); |
| 38 } | 34 } |
| 39 | 35 |
| 40 } | 36 } |
| OLD | NEW |