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

Unified Diff: Source/core/inspector/InspectorDOMAgent.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/inspector/DOMPatchSupport.cpp ('k') | Source/core/page/PageSerializer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorDOMAgent.cpp
diff --git a/Source/core/inspector/InspectorDOMAgent.cpp b/Source/core/inspector/InspectorDOMAgent.cpp
index 9d1319887369679e13b0733e06892aa90063fc1b..376ad6b3f13ac57ca389cad4c81741adce9a799f 100644
--- a/Source/core/inspector/InspectorDOMAgent.cpp
+++ b/Source/core/inspector/InspectorDOMAgent.cpp
@@ -721,15 +721,15 @@ void InspectorDOMAgent::setAttributesAsText(ErrorString* errorString, int elemen
}
bool foundOriginalAttribute = false;
- unsigned numAttrs = parsedElement->attributeCount();
- for (unsigned i = 0; i < numAttrs; ++i) {
+ AttributeIteratorAccessor attributes = parsedElement->attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
// Add attribute pair
- const Attribute& attribute = parsedElement->attributeItem(i);
- String attributeName = attribute.name().toString();
+ String attributeName = it->name().toString();
if (shouldIgnoreCase)
attributeName = attributeName.lower();
foundOriginalAttribute |= name && attributeName == caseAdjustedName;
- if (!m_domEditor->setAttribute(element, attributeName, attribute.value(), errorString))
+ if (!m_domEditor->setAttribute(element, attributeName, it->value(), errorString))
return;
}
@@ -981,17 +981,17 @@ void InspectorDOMAgent::performSearch(ErrorString*, const String& whitespaceTrim
if (!element->hasAttributes())
break;
- unsigned numAttrs = element->attributeCount();
- for (unsigned i = 0; i < numAttrs; ++i) {
+ AttributeIteratorAccessor attributes = element->attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
// Add attribute pair
- const Attribute& attribute = element->attributeItem(i);
- if (attribute.localName().find(whitespaceTrimmedQuery, 0, false) != kNotFound) {
+ if (it->localName().find(whitespaceTrimmedQuery, 0, false) != kNotFound) {
resultCollector.add(node);
break;
}
- size_t foundPosition = attribute.value().find(attributeQuery, 0, false);
+ size_t foundPosition = it->value().find(attributeQuery, 0, false);
if (foundPosition != kNotFound) {
- if (!exactAttributeMatch || (!foundPosition && attribute.value().length() == attributeQuery.length())) {
+ if (!exactAttributeMatch || (!foundPosition && it->value().length() == attributeQuery.length())) {
resultCollector.add(node);
break;
}
@@ -1597,12 +1597,12 @@ PassRefPtr<TypeBuilder::Array<String> > InspectorDOMAgent::buildArrayForElementA
// Go through all attributes and serialize them.
if (!element->hasAttributes())
return attributesValue.release();
- unsigned numAttrs = element->attributeCount();
- for (unsigned i = 0; i < numAttrs; ++i) {
+ AttributeIteratorAccessor attributes = element->attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
// Add attribute pair
- const Attribute& attribute = element->attributeItem(i);
- attributesValue->addItem(attribute.name().toString());
- attributesValue->addItem(attribute.value());
+ attributesValue->addItem(it->name().toString());
+ attributesValue->addItem(it->value());
}
return attributesValue.release();
}
« no previous file with comments | « Source/core/inspector/DOMPatchSupport.cpp ('k') | Source/core/page/PageSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698