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

Unified Diff: Source/core/editing/markup.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/editing/MarkupAccumulator.cpp ('k') | Source/core/html/HTMLEmbedElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/markup.cpp
diff --git a/Source/core/editing/markup.cpp b/Source/core/editing/markup.cpp
index c256e91188405d72f9ab8d464a74648fae00aa19..53b195c1762bcf667a4a872059bf23b31a3e4504 100644
--- a/Source/core/editing/markup.cpp
+++ b/Source/core/editing/markup.cpp
@@ -112,11 +112,11 @@ static void completeURLs(DocumentFragment& fragment, const String& baseURL)
for (Element* element = ElementTraversal::firstWithin(fragment); element; element = ElementTraversal::next(*element, &fragment)) {
if (!element->hasAttributes())
continue;
- unsigned length = element->attributeCount();
- for (unsigned i = 0; i < length; i++) {
- const Attribute& attribute = element->attributeItem(i);
- if (element->isURLAttribute(attribute) && !attribute.value().isEmpty())
- changes.append(AttributeChange(element, attribute.name(), KURL(parsedBaseURL, attribute.value()).string()));
+ AttributeIteratorAccessor attributes = element->attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
+ if (element->isURLAttribute(**it) && !it->value().isEmpty())
+ changes.append(AttributeChange(element, it->name(), KURL(parsedBaseURL, it->value()).string()));
}
}
@@ -288,15 +288,18 @@ void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element
const bool documentIsHTML = element.document().isHTMLDocument();
appendOpenTag(out, element, 0);
- const unsigned length = element.hasAttributes() ? element.attributeCount() : 0;
const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldAnnotate() || addDisplayInline);
const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldApplyWrappingStyle(element);
- for (unsigned i = 0; i < length; ++i) {
- const Attribute& attribute = element.attributeItem(i);
- // We'll handle the style attribute separately, below.
- if (attribute.name() == styleAttr && shouldOverrideStyleAttr)
- continue;
- appendAttribute(out, element, attribute, 0);
+
+ if (element.hasAttributes()) {
+ AttributeIteratorAccessor attributes = element.attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
+ // We'll handle the style attribute separately, below.
+ if (it->name() == styleAttr && shouldOverrideStyleAttr)
+ continue;
+ appendAttribute(out, element, **it, 0);
+ }
}
if (shouldOverrideStyleAttr) {
« no previous file with comments | « Source/core/editing/MarkupAccumulator.cpp ('k') | Source/core/html/HTMLEmbedElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698