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

Unified Diff: Source/core/dom/Element.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/dom/Element.h ('k') | Source/core/dom/ElementData.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 1f8d3da2f814b5c2e18f7c427c578c2cb2245b90..3290e65505cf0a289497f82811bb6025a72ca061 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -1241,12 +1241,11 @@ const AtomicString& Element::locateNamespacePrefix(const AtomicString& namespace
return prefix();
if (hasAttributes()) {
- unsigned attributeCount = this->attributeCount();
- for (unsigned i = 0; i < attributeCount; ++i) {
- const Attribute& attr = attributeItem(i);
-
- if (attr.prefix() == xmlnsAtom && attr.value() == namespaceToLocate)
- return attr.localName();
+ AttributeIteratorAccessor attributes = attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
+ if (it->prefix() == xmlnsAtom && it->value() == namespaceToLocate)
+ return it->localName();
}
}
@@ -3013,11 +3012,11 @@ void Element::detachAllAttrNodesFromElement()
AttrNodeList* attrNodeList = attrNodeListForElement(this);
ASSERT(attrNodeList);
- unsigned attributeCount = this->attributeCount();
- for (unsigned i = 0; i < attributeCount; ++i) {
- const Attribute& attribute = attributeItem(i);
- if (RefPtrWillBeRawPtr<Attr> attrNode = findAttrNodeInList(*attrNodeList, attribute.name()))
- attrNode->detachFromElementWithValue(attribute.value());
+ AttributeIteratorAccessor attributes = attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
+ if (RefPtrWillBeRawPtr<Attr> attrNode = findAttrNodeInList(*attrNodeList, it->name()))
+ attrNode->detachFromElementWithValue(it->value());
}
removeAttrNodeListForElement(this);
@@ -3081,11 +3080,10 @@ void Element::cloneAttributesFromElement(const Element& other)
else
m_elementData = other.m_elementData->makeUniqueCopy();
- unsigned length = m_elementData->length();
- for (unsigned i = 0; i < length; ++i) {
- const Attribute& attribute = m_elementData->attributeItem(i);
- attributeChangedFromParserOrByCloning(attribute.name(), attribute.value(), ModifiedByCloning);
- }
+ AttributeIteratorAccessor attributes = m_elementData->attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it)
+ attributeChangedFromParserOrByCloning(it->name(), it->value(), ModifiedByCloning);
}
void Element::cloneDataFromElement(const Element& other)
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/ElementData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698