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

Unified Diff: Source/core/inspector/DOMPatchSupport.cpp

Issue 800113002: Use C++11 range-based for loop in Source/core/inspector (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase again and again! Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/inspector/ContentSearchUtils.cpp ('k') | Source/core/inspector/InjectedScriptManager.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/DOMPatchSupport.cpp
diff --git a/Source/core/inspector/DOMPatchSupport.cpp b/Source/core/inspector/DOMPatchSupport.cpp
index 60e49c7d5a897ef47d8607d1a42a0209fc00f8c5..ecb2d8635ea1d8a206523fdb710c073b9eb8e698 100644
--- a/Source/core/inspector/DOMPatchSupport.cpp
+++ b/Source/core/inspector/DOMPatchSupport.cpp
@@ -199,10 +199,8 @@ bool DOMPatchSupport::innerPatchNode(Digest* oldDigest, Digest* newDigest, Excep
}
// FIXME: Create a function in Element for copying properties. cloneDataFromElement() is close but not enough for this case.
- AttributeCollection attributes = newElement->attributesWithoutUpdate();
- AttributeCollection::iterator end = attributes.end();
- for (AttributeCollection::iterator it = attributes.begin(); it != end; ++it) {
- if (!m_domEditor->setAttribute(oldElement, it->name().localName(), it->value(), exceptionState))
+ for (auto& attribute : newElement->attributesWithoutUpdate()) {
+ if (!m_domEditor->setAttribute(oldElement, attribute.name().localName(), attribute.value(), exceptionState))
return false;
}
}
@@ -256,16 +254,16 @@ DOMPatchSupport::diff(const Vector<OwnPtr<Digest> >& oldList, const Vector<OwnPt
oldTable.add(oldList[i]->m_sha1, Vector<size_t>()).storedValue->value.append(i);
}
- for (DiffTable::iterator newIt = newTable.begin(); newIt != newTable.end(); ++newIt) {
- if (newIt->value.size() != 1)
+ for (auto& newIt : newTable) {
+ if (newIt.value.size() != 1)
continue;
- DiffTable::iterator oldIt = oldTable.find(newIt->key);
+ DiffTable::iterator oldIt = oldTable.find(newIt.key);
if (oldIt == oldTable.end() || oldIt->value.size() != 1)
continue;
- newMap[newIt->value[0]] = std::make_pair(newList[newIt->value[0]].get(), oldIt->value[0]);
- oldMap[oldIt->value[0]] = std::make_pair(oldList[oldIt->value[0]].get(), newIt->value[0]);
+ newMap[newIt.value[0]] = std::make_pair(newList[newIt.value[0]].get(), oldIt->value[0]);
+ oldMap[oldIt->value[0]] = std::make_pair(oldList[oldIt->value[0]].get(), newIt.value[0]);
}
for (size_t i = 0; newList.size() > 0 && i < newList.size() - 1; ++i) {
@@ -372,8 +370,8 @@ bool DOMPatchSupport::innerPatchChildren(ContainerNode* parentNode, const Vector
}
// 2. Patch nodes marked for merge.
- for (HashMap<Digest*, Digest*>::iterator it = merges.begin(); it != merges.end(); ++it) {
- if (!innerPatchNode(it->value, it->key, exceptionState))
+ for (auto& merge: merges) {
+ if (!innerPatchNode(merge.value, merge.key, exceptionState))
return false;
}
@@ -432,10 +430,9 @@ PassOwnPtr<DOMPatchSupport::Digest> DOMPatchSupport::createDigest(Node* node, Un
AttributeCollection attributes = element.attributesWithoutUpdate();
if (!attributes.isEmpty()) {
OwnPtr<blink::WebCryptoDigestor> attrsDigestor = createDigestor(HashAlgorithmSha1);
- AttributeCollection::iterator end = attributes.end();
- for (AttributeCollection::iterator it = attributes.begin(); it != end; ++it) {
- addStringToDigestor(attrsDigestor.get(), it->name().toString());
- addStringToDigestor(attrsDigestor.get(), it->value().string());
+ for (auto& attribute : attributes) {
+ addStringToDigestor(attrsDigestor.get(), attribute.name().toString());
+ addStringToDigestor(attrsDigestor.get(), attribute.value().string());
}
finishDigestor(attrsDigestor.get(), digestResult);
digest->m_attrsSHA1 = base64Encode(reinterpret_cast<const char*>(digestResult.data()), 10);
« no previous file with comments | « Source/core/inspector/ContentSearchUtils.cpp ('k') | Source/core/inspector/InjectedScriptManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698