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

Unified Diff: Source/core/dom/PresentationAttributeStyle.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/Node.cpp ('k') | Source/core/editing/MarkupAccumulator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/PresentationAttributeStyle.cpp
diff --git a/Source/core/dom/PresentationAttributeStyle.cpp b/Source/core/dom/PresentationAttributeStyle.cpp
index 3d9a3e35496002585144b1fc427368e391cafac9..38cca3f2bd2171f3b99cf31f86b910d74362fd7d 100644
--- a/Source/core/dom/PresentationAttributeStyle.cpp
+++ b/Source/core/dom/PresentationAttributeStyle.cpp
@@ -123,17 +123,17 @@ static void makePresentationAttributeCacheKey(Element& element, PresentationAttr
// Interpretation of the size attributes on <input> depends on the type attribute.
if (isHTMLInputElement(element))
return;
- unsigned size = element.attributeCount();
- for (unsigned i = 0; i < size; ++i) {
- const Attribute& attribute = element.attributeItem(i);
- if (!element.isPresentationAttribute(attribute.name()))
+ AttributeIteratorAccessor attributes = element.attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
+ if (!element.isPresentationAttribute(it->name()))
continue;
- if (!attribute.namespaceURI().isNull())
+ if (!it->namespaceURI().isNull())
return;
// FIXME: Background URL may depend on the base URL and can't be shared. Disallow caching.
- if (attribute.name() == backgroundAttr)
+ if (it->name() == backgroundAttr)
return;
- result.attributesAndValues.append(std::make_pair(attribute.localName().impl(), attribute.value()));
+ result.attributesAndValues.append(std::make_pair(it->localName().impl(), it->value()));
}
if (result.attributesAndValues.isEmpty())
return;
@@ -178,11 +178,10 @@ PassRefPtr<StylePropertySet> computePresentationAttributeStyle(Element& element)
cacheCleaner.didHitPresentationAttributeCache();
} else {
style = MutableStylePropertySet::create(element.isSVGElement() ? SVGAttributeMode : HTMLAttributeMode);
- unsigned size = element.attributeCount();
- for (unsigned i = 0; i < size; ++i) {
- const Attribute& attribute = element.attributeItem(i);
- element.collectStyleForPresentationAttribute(attribute.name(), attribute.value(), toMutableStylePropertySet(style));
- }
+ AttributeIteratorAccessor attributes = element.attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it)
+ element.collectStyleForPresentationAttribute(it->name(), it->value(), toMutableStylePropertySet(style));
}
if (!cacheHash || cacheValue->value)
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/core/editing/MarkupAccumulator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698