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

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: Created 6 years, 7 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
Index: Source/core/inspector/DOMPatchSupport.cpp
diff --git a/Source/core/inspector/DOMPatchSupport.cpp b/Source/core/inspector/DOMPatchSupport.cpp
index 8afcb0dbce2770433d52c5ab64d16a8787576fd7..5a046fd6e2fcb348a64416daf203f621dea2f998 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
Element* element = toElement(node);
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);

Powered by Google App Engine
This is Rietveld 408576698