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

Side by Side Diff: Source/core/dom/WeakNodeMap.cpp

Issue 796913002: Use C++11 range-based loop for core/clipboard, core/dom and core/testing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 11 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
« no previous file with comments | « Source/core/dom/ScriptedAnimationController.cpp ('k') | Source/core/testing/Internals.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/dom/WeakNodeMap.h" 6 #include "core/dom/WeakNodeMap.h"
7 7
8 #include "core/dom/Node.h" 8 #include "core/dom/Node.h"
9 9
10 namespace blink { 10 namespace blink {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 if (mapList->size() == 0) { 48 if (mapList->size() == 0) {
49 m_nodeToMapList.remove(it); 49 m_nodeToMapList.remove(it);
50 return true; 50 return true;
51 } 51 }
52 return false; 52 return false;
53 } 53 }
54 54
55 void NodeToWeakNodeMaps::nodeDestroyed(Node* node) 55 void NodeToWeakNodeMaps::nodeDestroyed(Node* node)
56 { 56 {
57 OwnPtr<NodeToWeakNodeMaps::MapList> maps = m_nodeToMapList.take(node); 57 OwnPtr<NodeToWeakNodeMaps::MapList> maps = m_nodeToMapList.take(node);
58 for (size_t i = 0; i < maps->size(); i++) 58 for (auto& map : *maps)
59 (*maps)[i]->nodeDestroyed(node); 59 map->nodeDestroyed(node);
60 } 60 }
61 61
62 WeakNodeMap::~WeakNodeMap() 62 WeakNodeMap::~WeakNodeMap()
63 { 63 {
64 NodeToWeakNodeMaps& allMaps = NodeToWeakNodeMaps::instance(); 64 NodeToWeakNodeMaps& allMaps = NodeToWeakNodeMaps::instance();
65 for (NodeToValue::iterator it = m_nodeToValue.begin(); it != m_nodeToValue.e nd(); ++it) { 65 for (auto& map : m_nodeToValue) {
66 Node* node = it->key; 66 Node* node = map.key;
67 if (allMaps.removedFromMap(node, this)) 67 if (allMaps.removedFromMap(node, this))
68 node->clearFlag(Node::HasWeakReferencesFlag); 68 node->clearFlag(Node::HasWeakReferencesFlag);
69 } 69 }
70 } 70 }
71 71
72 void WeakNodeMap::put(Node* node, int value) 72 void WeakNodeMap::put(Node* node, int value)
73 { 73 {
74 ASSERT(node && !m_nodeToValue.contains(node)); 74 ASSERT(node && !m_nodeToValue.contains(node));
75 m_nodeToValue.set(node, value); 75 m_nodeToValue.set(node, value);
76 m_valueToNode.set(value, node); 76 m_valueToNode.set(value, node);
(...skipping 20 matching lines...) Expand all
97 m_valueToNode.remove(value); 97 m_valueToNode.remove(value);
98 } 98 }
99 99
100 void WeakNodeMap::notifyNodeDestroyed(Node* node) 100 void WeakNodeMap::notifyNodeDestroyed(Node* node)
101 { 101 {
102 NodeToWeakNodeMaps::instance().nodeDestroyed(node); 102 NodeToWeakNodeMaps::instance().nodeDestroyed(node);
103 } 103 }
104 #endif 104 #endif
105 105
106 } 106 }
OLDNEW
« no previous file with comments | « Source/core/dom/ScriptedAnimationController.cpp ('k') | Source/core/testing/Internals.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698