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

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

Issue 298253009: Add iterator object to iterate efficiently over an Element's attributes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLObjectElement.cpp ('k') | Source/core/inspector/InspectorDOMAgent.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 d4a7251744941d80f49aa75a02a4197a9a0c4bb9..c2cfcec443a5b4cf039de8ea5f3349ac4472de23 100644
--- a/Source/core/inspector/DOMPatchSupport.cpp
+++ b/Source/core/inspector/DOMPatchSupport.cpp
@@ -199,10 +199,10 @@ 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.
if (newElement->hasAttributesWithoutUpdate()) {
- size_t numAttrs = newElement->attributeCount();
- for (size_t i = 0; i < numAttrs; ++i) {
- const Attribute& attribute = newElement->attributeItem(i);
- if (!m_domEditor->setAttribute(oldElement, attribute.name().localName(), attribute.value(), exceptionState))
+ AttributeIteratorAccessor attributes = newElement->attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
+ if (!m_domEditor->setAttribute(oldElement, it->name().localName(), it->value(), exceptionState))
return false;
}
}
@@ -431,12 +431,12 @@ PassOwnPtr<DOMPatchSupport::Digest> DOMPatchSupport::createDigest(Node* node, Un
}
if (element.hasAttributesWithoutUpdate()) {
- size_t numAttrs = element.attributeCount();
OwnPtr<blink::WebCryptoDigestor> attrsDigestor = createDigestor(HashAlgorithmSha1);
- for (size_t i = 0; i < numAttrs; ++i) {
- const Attribute& attribute = element.attributeItem(i);
- addStringToDigestor(attrsDigestor.get(), attribute.name().toString());
- addStringToDigestor(attrsDigestor.get(), attribute.value().string());
+ AttributeIteratorAccessor attributes = element.attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
+ addStringToDigestor(attrsDigestor.get(), it->name().toString());
+ addStringToDigestor(attrsDigestor.get(), it->value().string());
}
finishDigestor(attrsDigestor.get(), digestResult);
digest->m_attrsSHA1 = base64Encode(reinterpret_cast<const char*>(digestResult.data()), 10);
« no previous file with comments | « Source/core/html/HTMLObjectElement.cpp ('k') | Source/core/inspector/InspectorDOMAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698