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

Unified Diff: Source/web/WebPageSerializerImpl.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/xml/parser/XMLDocumentParser.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebPageSerializerImpl.cpp
diff --git a/Source/web/WebPageSerializerImpl.cpp b/Source/web/WebPageSerializerImpl.cpp
index 126b38feeb991c2f237563f4dbc836733e834124..28803d4b0731a407fe874bb9371f405b77140812 100644
--- a/Source/web/WebPageSerializerImpl.cpp
+++ b/Source/web/WebPageSerializerImpl.cpp
@@ -303,19 +303,19 @@ void WebPageSerializerImpl::openTagToString(Element* element,
result.append(element->nodeName().lower());
// Go through all attributes and serialize them.
if (element->hasAttributes()) {
- 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) {
result.append(' ');
// Add attribute pair
- const Attribute& attribute = element->attributeItem(i);
- result.append(attribute.name().toString());
+ result.append(it->name().toString());
result.appendLiteral("=\"");
- if (!attribute.value().isEmpty()) {
- const String& attrValue = attribute.value();
+ if (!it->value().isEmpty()) {
+ const String& attrValue = it->value();
// Check whether we need to replace some resource links
// with local resource paths.
- const QualifiedName& attrName = attribute.name();
+ const QualifiedName& attrName = it->name();
if (element->hasLegalLinkAttribute(attrName)) {
// For links start with "javascript:", we do not change it.
if (attrValue.startsWith("javascript:", false))
« no previous file with comments | « Source/core/xml/parser/XMLDocumentParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698