<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[162394] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/162394">162394</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2014-01-20 17:31:37 -0800 (Mon, 20 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add a nicer way to iterate over all the attributes of an element
https://bugs.webkit.org/show_bug.cgi?id=127266
Reviewed by Geoffrey Garen.
When using Element::attributeAt() in a loop, the compiler had to generate two kinds of
accessor:
-If the element data is unique, the length and data comes from the attribute Vector.
-If the element data is shared, the data comes from the tail of elementData itself.
The choice was done for every access, which caused the assembly to be a little
hard to follow.
This patch unify the data access by doing everything as a array pointer with offset (getting
that data from Vector when necessary).
To make it easier to do the right thing, a new iterator was added so that range-based loops
can replace all the faulty cases.
* css/SelectorChecker.cpp:
(WebCore::anyAttributeMatches):
* css/SelectorChecker.h:
(WebCore::SelectorChecker::checkExactAttribute):
* dom/DatasetDOMStringMap.cpp:
(WebCore::DatasetDOMStringMap::getNames):
(WebCore::DatasetDOMStringMap::item):
(WebCore::DatasetDOMStringMap::contains):
* dom/Element.cpp:
(WebCore::Element::normalizeAttributes):
(WebCore::Element::detachAllAttrNodesFromElement):
(WebCore::Element::cloneAttributesFromElement):
* dom/Element.h:
(WebCore::Element::attributesIterator):
* dom/ElementData.cpp:
(WebCore::ElementData::isEquivalent):
(WebCore::ElementData::findAttributeIndexByNameSlowCase):
* dom/ElementData.h:
(WebCore::AttributeConstIterator::AttributeConstIterator):
(WebCore::AttributeConstIterator::operator*):
(WebCore::AttributeConstIterator::operator->):
(WebCore::AttributeConstIterator::operator++):
(WebCore::AttributeConstIterator::operator==):
(WebCore::AttributeConstIterator::operator!=):
(WebCore::AttributeIteratorAccessor::AttributeIteratorAccessor):
(WebCore::AttributeIteratorAccessor::begin):
(WebCore::AttributeIteratorAccessor::end):
(WebCore::ElementData::attributesIterator):
* dom/Node.cpp:
(WebCore::Node::isDefaultNamespace):
(WebCore::Node::lookupNamespaceURI):
(WebCore::Node::lookupNamespacePrefix):
(WebCore::Node::compareDocumentPosition):
* dom/StyledElement.cpp:
(WebCore::StyledElement::makePresentationAttributeCacheKey):
(WebCore::StyledElement::rebuildPresentationAttributeStyle):
* editing/MarkupAccumulator.cpp:
(WebCore::MarkupAccumulator::appendElement):
* editing/markup.cpp:
(WebCore::completeURLs):
(WebCore::StyledMarkupAccumulator::appendElement):
* html/HTMLEmbedElement.cpp:
(WebCore::HTMLEmbedElement::parametersForPlugin):
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::parametersForPlugin):
* inspector/DOMPatchSupport.cpp:
(WebCore::DOMPatchSupport::innerPatchNode):
(WebCore::DOMPatchSupport::createDigest):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::setAttributesAsText):
(WebCore::InspectorDOMAgent::buildArrayForElementAttributes):
* inspector/InspectorNodeFinder.cpp:
(WebCore::InspectorNodeFinder::matchesElement):
* page/PageSerializer.cpp:
(WebCore::isCharsetSpecifyingNode):
* xml/XPathNodeSet.cpp:
(WebCore::XPath::NodeSet::traversalSort):
* xml/XPathStep.cpp:
(WebCore::XPath::Step::nodesInAxis):
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::XMLDocumentParser):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssSelectorCheckercpp">trunk/Source/WebCore/css/SelectorChecker.cpp</a></li>
<li><a href="#trunkSourceWebCorecssSelectorCheckerh">trunk/Source/WebCore/css/SelectorChecker.h</a></li>
<li><a href="#trunkSourceWebCoredomDatasetDOMStringMapcpp">trunk/Source/WebCore/dom/DatasetDOMStringMap.cpp</a></li>
<li><a href="#trunkSourceWebCoredomElementcpp">trunk/Source/WebCore/dom/Element.cpp</a></li>
<li><a href="#trunkSourceWebCoredomElementh">trunk/Source/WebCore/dom/Element.h</a></li>
<li><a href="#trunkSourceWebCoredomElementDatacpp">trunk/Source/WebCore/dom/ElementData.cpp</a></li>
<li><a href="#trunkSourceWebCoredomElementDatah">trunk/Source/WebCore/dom/ElementData.h</a></li>
<li><a href="#trunkSourceWebCoredomNodecpp">trunk/Source/WebCore/dom/Node.cpp</a></li>
<li><a href="#trunkSourceWebCoredomStyledElementcpp">trunk/Source/WebCore/dom/StyledElement.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingMarkupAccumulatorcpp">trunk/Source/WebCore/editing/MarkupAccumulator.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingmarkupcpp">trunk/Source/WebCore/editing/markup.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLEmbedElementcpp">trunk/Source/WebCore/html/HTMLEmbedElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLObjectElementcpp">trunk/Source/WebCore/html/HTMLObjectElement.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorDOMPatchSupportcpp">trunk/Source/WebCore/inspector/DOMPatchSupport.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorDOMAgentcpp">trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorNodeFindercpp">trunk/Source/WebCore/inspector/InspectorNodeFinder.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageSerializercpp">trunk/Source/WebCore/page/PageSerializer.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlXPathNodeSetcpp">trunk/Source/WebCore/xml/XPathNodeSet.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlXPathStepcpp">trunk/Source/WebCore/xml/XPathStep.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlparserXMLDocumentParserLibxml2cpp">trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/ChangeLog        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -1,3 +1,85 @@
</span><ins>+2014-01-20 Benjamin Poulain <benjamin@webkit.org>
+
+ Add a nicer way to iterate over all the attributes of an element
+ https://bugs.webkit.org/show_bug.cgi?id=127266
+
+ Reviewed by Geoffrey Garen.
+
+ When using Element::attributeAt() in a loop, the compiler had to generate two kinds of
+ accessor:
+ -If the element data is unique, the length and data comes from the attribute Vector.
+ -If the element data is shared, the data comes from the tail of elementData itself.
+
+ The choice was done for every access, which caused the assembly to be a little
+ hard to follow.
+ This patch unify the data access by doing everything as a array pointer with offset (getting
+ that data from Vector when necessary).
+
+ To make it easier to do the right thing, a new iterator was added so that range-based loops
+ can replace all the faulty cases.
+
+ * css/SelectorChecker.cpp:
+ (WebCore::anyAttributeMatches):
+ * css/SelectorChecker.h:
+ (WebCore::SelectorChecker::checkExactAttribute):
+ * dom/DatasetDOMStringMap.cpp:
+ (WebCore::DatasetDOMStringMap::getNames):
+ (WebCore::DatasetDOMStringMap::item):
+ (WebCore::DatasetDOMStringMap::contains):
+ * dom/Element.cpp:
+ (WebCore::Element::normalizeAttributes):
+ (WebCore::Element::detachAllAttrNodesFromElement):
+ (WebCore::Element::cloneAttributesFromElement):
+ * dom/Element.h:
+ (WebCore::Element::attributesIterator):
+ * dom/ElementData.cpp:
+ (WebCore::ElementData::isEquivalent):
+ (WebCore::ElementData::findAttributeIndexByNameSlowCase):
+ * dom/ElementData.h:
+ (WebCore::AttributeConstIterator::AttributeConstIterator):
+ (WebCore::AttributeConstIterator::operator*):
+ (WebCore::AttributeConstIterator::operator->):
+ (WebCore::AttributeConstIterator::operator++):
+ (WebCore::AttributeConstIterator::operator==):
+ (WebCore::AttributeConstIterator::operator!=):
+ (WebCore::AttributeIteratorAccessor::AttributeIteratorAccessor):
+ (WebCore::AttributeIteratorAccessor::begin):
+ (WebCore::AttributeIteratorAccessor::end):
+ (WebCore::ElementData::attributesIterator):
+ * dom/Node.cpp:
+ (WebCore::Node::isDefaultNamespace):
+ (WebCore::Node::lookupNamespaceURI):
+ (WebCore::Node::lookupNamespacePrefix):
+ (WebCore::Node::compareDocumentPosition):
+ * dom/StyledElement.cpp:
+ (WebCore::StyledElement::makePresentationAttributeCacheKey):
+ (WebCore::StyledElement::rebuildPresentationAttributeStyle):
+ * editing/MarkupAccumulator.cpp:
+ (WebCore::MarkupAccumulator::appendElement):
+ * editing/markup.cpp:
+ (WebCore::completeURLs):
+ (WebCore::StyledMarkupAccumulator::appendElement):
+ * html/HTMLEmbedElement.cpp:
+ (WebCore::HTMLEmbedElement::parametersForPlugin):
+ * html/HTMLObjectElement.cpp:
+ (WebCore::HTMLObjectElement::parametersForPlugin):
+ * inspector/DOMPatchSupport.cpp:
+ (WebCore::DOMPatchSupport::innerPatchNode):
+ (WebCore::DOMPatchSupport::createDigest):
+ * inspector/InspectorDOMAgent.cpp:
+ (WebCore::InspectorDOMAgent::setAttributesAsText):
+ (WebCore::InspectorDOMAgent::buildArrayForElementAttributes):
+ * inspector/InspectorNodeFinder.cpp:
+ (WebCore::InspectorNodeFinder::matchesElement):
+ * page/PageSerializer.cpp:
+ (WebCore::isCharsetSpecifyingNode):
+ * xml/XPathNodeSet.cpp:
+ (WebCore::XPath::NodeSet::traversalSort):
+ * xml/XPathStep.cpp:
+ (WebCore::XPath::Step::nodesInAxis):
+ * xml/parser/XMLDocumentParserLibxml2.cpp:
+ (WebCore::XMLDocumentParser::XMLDocumentParser):
+
</ins><span class="cx"> 2014-01-20 Gyuyoung Kim <gyuyoung.kim@samsung.com>
</span><span class="cx">
</span><span class="cx"> Do refactor in collectGradientAttributes() and renderStyleForLengthResolve()
</span></span></pre></div>
<a id="trunkSourceWebCorecssSelectorCheckercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/SelectorChecker.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -342,9 +342,7 @@
</span><span class="cx"> static bool anyAttributeMatches(Element* element, const CSSSelector* selector, const QualifiedName& selectorAttr, bool caseSensitive)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(element->hasAttributesWithoutUpdate());
</span><del>- for (size_t i = 0, count = element->attributeCount(); i < count; ++i) {
- const Attribute& attribute = element->attributeAt(i);
-
</del><ins>+ for (const Attribute& attribute : element->attributesIterator()) {
</ins><span class="cx"> if (!attribute.matches(selectorAttr.prefix(), element->isHTMLElement() ? selector->attributeCanonicalLocalName() : selectorAttr.localName(), selectorAttr.namespaceURI()))
</span><span class="cx"> continue;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecssSelectorCheckerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/SelectorChecker.h (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/SelectorChecker.h        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/css/SelectorChecker.h        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -131,9 +131,7 @@
</span><span class="cx"> if (!element->hasAttributesWithoutUpdate())
</span><span class="cx"> return false;
</span><span class="cx"> const AtomicString& localName = element->isHTMLElement() ? selector->attributeCanonicalLocalName() : selectorAttributeName.localName();
</span><del>- unsigned size = element->attributeCount();
- for (unsigned i = 0; i < size; ++i) {
- const Attribute& attribute = element->attributeAt(i);
</del><ins>+ for (const Attribute& attribute : element->attributesIterator()) {
</ins><span class="cx"> if (attribute.matches(selectorAttributeName.prefix(), localName, selectorAttributeName.namespaceURI()) && (!value || attribute.value().impl() == value))
</span><span class="cx"> return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomDatasetDOMStringMapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DatasetDOMStringMap.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DatasetDOMStringMap.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/dom/DatasetDOMStringMap.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -138,9 +138,7 @@
</span><span class="cx"> if (!m_element.hasAttributes())
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- unsigned length = m_element.attributeCount();
- for (unsigned i = 0; i < length; i++) {
- const Attribute& attribute = m_element.attributeAt(i);
</del><ins>+ for (const Attribute& attribute : m_element.attributesIterator()) {
</ins><span class="cx"> if (isValidAttributeName(attribute.localName()))
</span><span class="cx"> names.append(convertAttributeNameToPropertyName(attribute.localName()));
</span><span class="cx"> }
</span><span class="lines">@@ -151,9 +149,7 @@
</span><span class="cx"> if (!m_element.hasAttributes())
</span><span class="cx"> return String();
</span><span class="cx">
</span><del>- unsigned length = m_element.attributeCount();
- for (unsigned i = 0; i < length; i++) {
- const Attribute& attribute = m_element.attributeAt(i);
</del><ins>+ for (const Attribute& attribute : m_element.attributesIterator()) {
</ins><span class="cx"> if (propertyNameMatchesAttributeName(name, attribute.localName()))
</span><span class="cx"> return attribute.value();
</span><span class="cx"> }
</span><span class="lines">@@ -166,9 +162,7 @@
</span><span class="cx"> if (!m_element.hasAttributes())
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- unsigned length = m_element.attributeCount();
- for (unsigned i = 0; i < length; i++) {
- const Attribute& attribute = m_element.attributeAt(i);
</del><ins>+ for (const Attribute& attribute : m_element.attributesIterator()) {
</ins><span class="cx"> if (propertyNameMatchesAttributeName(name, attribute.localName()))
</span><span class="cx"> return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/dom/Element.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -2314,8 +2314,8 @@
</span><span class="cx"> {
</span><span class="cx"> if (!hasAttributes())
</span><span class="cx"> return;
</span><del>- for (unsigned i = 0; i < attributeCount(); ++i) {
- if (RefPtr<Attr> attr = attrIfExists(attributeAt(i).name()))
</del><ins>+ for (const Attribute& attribute : attributesIterator()) {
+ if (RefPtr<Attr> attr = attrIfExists(attribute.name()))
</ins><span class="cx"> attr->normalize();
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -2916,8 +2916,7 @@
</span><span class="cx"> AttrNodeList* attrNodeList = attrNodeListForElement(this);
</span><span class="cx"> ASSERT(attrNodeList);
</span><span class="cx">
</span><del>- for (unsigned i = 0; i < attributeCount(); ++i) {
- const Attribute& attribute = attributeAt(i);
</del><ins>+ for (const Attribute& attribute : attributesIterator()) {
</ins><span class="cx"> if (RefPtr<Attr> attrNode = findAttrNodeInList(*attrNodeList, attribute.name()))
</span><span class="cx"> attrNode->detachFromElementWithValue(attribute.value());
</span><span class="cx"> }
</span><span class="lines">@@ -3038,9 +3037,7 @@
</span><span class="cx"> else
</span><span class="cx"> m_elementData = other.m_elementData->makeUniqueCopy();
</span><span class="cx">
</span><del>- unsigned length = m_elementData->length();
- for (unsigned i = 0; i < length; ++i) {
- const Attribute& attribute = const_cast<const ElementData*>(m_elementData.get())->attributeAt(i);
</del><ins>+ for (const Attribute& attribute : attributesIterator()) {
</ins><span class="cx"> attributeChanged(attribute.name(), attribute.value(), ModifiedByCloning);
</span><span class="cx"> }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.h (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.h        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/dom/Element.h        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -186,6 +186,7 @@
</span><span class="cx">
</span><span class="cx"> // Internal methods that assume the existence of attribute storage, one should use hasAttributes()
</span><span class="cx"> // before calling them.
</span><ins>+ AttributeIteratorAccessor attributesIterator() const { return elementData()->attributesIterator(); }
</ins><span class="cx"> unsigned attributeCount() const;
</span><span class="cx"> const Attribute& attributeAt(unsigned index) const;
</span><span class="cx"> const Attribute* findAttributeByName(const QualifiedName&) const;
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ElementData.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ElementData.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/dom/ElementData.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -163,12 +163,10 @@
</span><span class="cx"> if (!other)
</span><span class="cx"> return isEmpty();
</span><span class="cx">
</span><del>- unsigned len = length();
- if (len != other->length())
</del><ins>+ if (length() != other->length())
</ins><span class="cx"> return false;
</span><span class="cx">
</span><del>- for (unsigned i = 0; i < len; i++) {
- const Attribute& attribute = attributeAt(i);
</del><ins>+ for (const Attribute& attribute : attributesIterator()) {
</ins><span class="cx"> const Attribute* otherAttr = other->findAttributeByName(attribute.name());
</span><span class="cx"> if (!otherAttr || attribute.value() != otherAttr->value())
</span><span class="cx"> return false;
</span><span class="lines">@@ -180,8 +178,10 @@
</span><span class="cx"> unsigned ElementData::findAttributeIndexByNameSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const
</span><span class="cx"> {
</span><span class="cx"> // Continue to checking case-insensitively and/or full namespaced names if necessary:
</span><del>- for (unsigned i = 0; i < length(); ++i) {
- const Attribute& attribute = attributeAt(i);
</del><ins>+ const Attribute* attributes = attributeBase();
+ unsigned length = this->length();
+ for (unsigned i = 0; i < length; ++i) {
+ const Attribute& attribute = attributes[i];
</ins><span class="cx"> if (!attribute.name().hasPrefix()) {
</span><span class="cx"> if (shouldIgnoreAttributeCase && equalIgnoringCase(name, attribute.localName()))
</span><span class="cx"> return i;
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ElementData.h (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ElementData.h        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/dom/ElementData.h        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -37,6 +37,41 @@
</span><span class="cx"> class StyleProperties;
</span><span class="cx"> class UniqueElementData;
</span><span class="cx">
</span><ins>+class AttributeConstIterator {
+public:
+ AttributeConstIterator(const Attribute* array, unsigned offset)
+ : m_array(array)
+ , m_offset(offset)
+ {
+ }
+
+ const Attribute& operator*() const { return m_array[m_offset]; }
+ const Attribute* operator->() const { return &m_array[m_offset]; }
+ AttributeConstIterator& operator++() { ++m_offset; return *this; }
+
+ bool operator==(const AttributeConstIterator& other) const { return m_offset == other.m_offset; }
+ bool operator!=(const AttributeConstIterator& other) const { return !(*this == other); }
+
+private:
+ const Attribute* m_array;
+ unsigned m_offset;
+};
+
+class AttributeIteratorAccessor {
+public:
+ AttributeIteratorAccessor(const Attribute* array, unsigned size)
+ : m_array(array)
+ , m_size(size)
+ {
+ }
+
+ AttributeConstIterator begin() const { return AttributeConstIterator(m_array, 0); }
+ AttributeConstIterator end() const { return AttributeConstIterator(m_array, m_size); }
+private:
+ const Attribute* m_array;
+ unsigned m_size;
+};
+
</ins><span class="cx"> class ElementData : public RefCounted<ElementData> {
</span><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="lines">@@ -61,6 +96,7 @@
</span><span class="cx"> unsigned length() const;
</span><span class="cx"> bool isEmpty() const { return !length(); }
</span><span class="cx">
</span><ins>+ AttributeIteratorAccessor attributesIterator() const;
</ins><span class="cx"> const Attribute& attributeAt(unsigned index) const;
</span><span class="cx"> const Attribute* findAttributeByName(const QualifiedName&) const;
</span><span class="cx"> unsigned findAttributeIndexByName(const QualifiedName&) const;
</span><span class="lines">@@ -208,6 +244,15 @@
</span><span class="cx"> return static_cast<const UniqueElementData*>(this)->m_presentationAttributeStyle.get();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+inline AttributeIteratorAccessor ElementData::attributesIterator() const
+{
+ if (isUnique()) {
+ const Vector<Attribute, 4>& attributeVector = static_cast<const UniqueElementData*>(this)->m_attributeVector;
+ return AttributeIteratorAccessor(attributeVector.data(), attributeVector.size());
+ }
+ return AttributeIteratorAccessor(static_cast<const ShareableElementData*>(this)->m_attributeArray, arraySize());
+}
+
</ins><span class="cx"> inline const Attribute* ElementData::findAttributeByName(const AtomicString& name, bool shouldIgnoreAttributeCase) const
</span><span class="cx"> {
</span><span class="cx"> unsigned index = findAttributeIndexByName(name, shouldIgnoreAttributeCase);
</span></span></pre></div>
<a id="trunkSourceWebCoredomNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Node.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Node.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/dom/Node.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -1133,9 +1133,7 @@
</span><span class="cx"> return elem->namespaceURI() == namespaceURI;
</span><span class="cx">
</span><span class="cx"> if (elem->hasAttributes()) {
</span><del>- for (unsigned i = 0; i < elem->attributeCount(); i++) {
- const Attribute& attribute = elem->attributeAt(i);
-
</del><ins>+ for (const Attribute& attribute : elem->attributesIterator()) {
</ins><span class="cx"> if (attribute.localName() == xmlnsAtom)
</span><span class="cx"> return attribute.value() == namespaceURI;
</span><span class="cx"> }
</span><span class="lines">@@ -1217,8 +1215,7 @@
</span><span class="cx"> return elem->namespaceURI();
</span><span class="cx">
</span><span class="cx"> if (elem->hasAttributes()) {
</span><del>- for (unsigned i = 0; i < elem->attributeCount(); i++) {
- const Attribute& attribute = elem->attributeAt(i);
</del><ins>+ for (const Attribute& attribute : elem->attributesIterator()) {
</ins><span class="cx">
</span><span class="cx"> if (attribute.prefix() == xmlnsAtom && attribute.localName() == prefix) {
</span><span class="cx"> if (!attribute.value().isEmpty())
</span><span class="lines">@@ -1273,9 +1270,7 @@
</span><span class="cx"> ASSERT(isElementNode());
</span><span class="cx"> const Element* thisElement = toElement(this);
</span><span class="cx"> if (thisElement->hasAttributes()) {
</span><del>- for (unsigned i = 0; i < thisElement->attributeCount(); i++) {
- const Attribute& attribute = thisElement->attributeAt(i);
-
</del><ins>+ for (const Attribute& attribute : thisElement->attributesIterator()) {
</ins><span class="cx"> if (attribute.prefix() == xmlnsAtom && attribute.value() == _namespaceURI
</span><span class="cx"> && originalElement->lookupNamespaceURI(attribute.localName()) == _namespaceURI)
</span><span class="cx"> return attribute.localName();
</span><span class="lines">@@ -1426,14 +1421,12 @@
</span><span class="cx"> // We are comparing two attributes on the same node. Crawl our attribute map and see which one we hit first.
</span><span class="cx"> Element* owner1 = attr1->ownerElement();
</span><span class="cx"> owner1->synchronizeAllAttributes();
</span><del>- unsigned length = owner1->attributeCount();
- for (unsigned i = 0; i < length; ++i) {
- // If neither of the two determining nodes is a child node and nodeType is the same for both determining nodes, then an
</del><ins>+ for (const Attribute& attribute : owner1->attributesIterator()) {
+ // If neither of the two determining nodes is a child node and nodeType is the same for both determining nodes, then an
</ins><span class="cx"> // implementation-dependent order between the determining nodes is returned. This order is stable as long as no nodes of
</span><span class="cx"> // the same nodeType are inserted into or removed from the direct container. This would be the case, for example,
</span><span class="cx"> // when comparing two attributes of the same element, and inserting or removing additional attributes might change
</span><span class="cx"> // the order between existing attributes.
</span><del>- const Attribute& attribute = owner1->attributeAt(i);
</del><span class="cx"> if (attr1->qualifiedName() == attribute.name())
</span><span class="cx"> return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSITION_FOLLOWING;
</span><span class="cx"> if (attr2->qualifiedName() == attribute.name())
</span></span></pre></div>
<a id="trunkSourceWebCoredomStyledElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/StyledElement.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/StyledElement.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/dom/StyledElement.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -285,9 +285,7 @@
</span><span class="cx"> // Interpretation of the size attributes on <input> depends on the type attribute.
</span><span class="cx"> if (hasTagName(inputTag))
</span><span class="cx"> return;
</span><del>- unsigned size = attributeCount();
- for (unsigned i = 0; i < size; ++i) {
- const Attribute& attribute = attributeAt(i);
</del><ins>+ for (const Attribute& attribute : attributesIterator()) {
</ins><span class="cx"> if (!isPresentationAttribute(attribute.name()))
</span><span class="cx"> continue;
</span><span class="cx"> if (!attribute.namespaceURI().isNull())
</span><span class="lines">@@ -335,11 +333,8 @@
</span><span class="cx"> presentationAttributeCacheCleaner().didHitPresentationAttributeCache();
</span><span class="cx"> } else {
</span><span class="cx"> style = MutableStyleProperties::create(isSVGElement() ? SVGAttributeMode : CSSQuirksMode);
</span><del>- unsigned size = attributeCount();
- for (unsigned i = 0; i < size; ++i) {
- const Attribute& attribute = attributeAt(i);
</del><ins>+ for (const Attribute& attribute : attributesIterator())
</ins><span class="cx"> collectStyleForPresentationAttribute(attribute.name(), attribute.value(), static_cast<MutableStyleProperties&>(*style));
</span><del>- }
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ShareableElementData doesn't store presentation attribute style, so make sure we have a UniqueElementData.
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingMarkupAccumulatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/MarkupAccumulator.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/MarkupAccumulator.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/editing/MarkupAccumulator.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -426,9 +426,8 @@
</span><span class="cx"> appendOpenTag(result, element, namespaces);
</span><span class="cx">
</span><span class="cx"> if (element.hasAttributes()) {
</span><del>- unsigned length = element.attributeCount();
- for (unsigned int i = 0; i < length; i++)
- appendAttribute(result, element, element.attributeAt(i), namespaces);
</del><ins>+ for (const Attribute& attribute : element.attributesIterator())
+ appendAttribute(result, element, attribute, namespaces);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Give an opportunity to subclasses to add their own attributes.
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingmarkupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/markup.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/markup.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/editing/markup.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -102,9 +102,7 @@
</span><span class="cx"> for (auto& element : descendantsOfType<Element>(*fragment)) {
</span><span class="cx"> if (!element.hasAttributes())
</span><span class="cx"> continue;
</span><del>- unsigned length = element.attributeCount();
- for (unsigned i = 0; i < length; i++) {
- const Attribute& attribute = element.attributeAt(i);
</del><ins>+ for (const Attribute& attribute : element.attributesIterator()) {
</ins><span class="cx"> if (element.isURLAttribute(attribute) && !attribute.value().isEmpty())
</span><span class="cx"> changes.append(AttributeChange(&element, attribute.name(), URL(parsedBaseURL, attribute.value()).string()));
</span><span class="cx"> }
</span><span class="lines">@@ -290,15 +288,15 @@
</span><span class="cx"> const bool documentIsHTML = element.document().isHTMLDocument();
</span><span class="cx"> appendOpenTag(out, element, 0);
</span><span class="cx">
</span><del>- const unsigned length = element.hasAttributes() ? element.attributeCount() : 0;
</del><span class="cx"> const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldAnnotate() || addDisplayInline);
</span><span class="cx"> const bool shouldOverrideStyleAttr = shouldAnnotateOrForceInline || shouldApplyWrappingStyle(element);
</span><del>- for (unsigned i = 0; i < length; ++i) {
- const Attribute& attribute = element.attributeAt(i);
- // We'll handle the style attribute separately, below.
- if (attribute.name() == styleAttr && shouldOverrideStyleAttr)
- continue;
- appendAttribute(out, element, attribute, 0);
</del><ins>+ if (element.hasAttributes()) {
+ for (const Attribute& attribute : element.attributesIterator()) {
+ // We'll handle the style attribute separately, below.
+ if (attribute.name() == styleAttr && shouldOverrideStyleAttr)
+ continue;
+ appendAttribute(out, element, attribute, 0);
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (shouldOverrideStyleAttr) {
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLEmbedElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLEmbedElement.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLEmbedElement.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/html/HTMLEmbedElement.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -120,8 +120,7 @@
</span><span class="cx"> if (!hasAttributes())
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- for (unsigned i = 0; i < attributeCount(); ++i) {
- const Attribute& attribute = attributeAt(i);
</del><ins>+ for (const Attribute& attribute : attributesIterator()) {
</ins><span class="cx"> paramNames.append(attribute.localName().string());
</span><span class="cx"> paramValues.append(attribute.value().string());
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLObjectElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLObjectElement.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLObjectElement.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/html/HTMLObjectElement.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -202,8 +202,7 @@
</span><span class="cx">
</span><span class="cx"> // Turn the attributes of the <object> element into arrays, but don't override <param> values.
</span><span class="cx"> if (hasAttributes()) {
</span><del>- for (unsigned i = 0; i < attributeCount(); ++i) {
- const Attribute& attribute = attributeAt(i);
</del><ins>+ for (const Attribute& attribute : attributesIterator()) {
</ins><span class="cx"> const AtomicString& name = attribute.name().localName();
</span><span class="cx"> if (!uniqueParamNames.contains(name.impl())) {
</span><span class="cx"> paramNames.append(name.string());
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorDOMPatchSupportcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/DOMPatchSupport.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/DOMPatchSupport.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/inspector/DOMPatchSupport.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -197,9 +197,7 @@
</span><span class="cx">
</span><span class="cx"> // FIXME: Create a function in Element for copying properties. cloneDataFromElement() is close but not enough for this case.
</span><span class="cx"> if (newElement->hasAttributesWithoutUpdate()) {
</span><del>- size_t numAttrs = newElement->attributeCount();
- for (size_t i = 0; i < numAttrs; ++i) {
- const Attribute& attribute = newElement->attributeAt(i);
</del><ins>+ for (const Attribute& attribute : newElement->attributesIterator()) {
</ins><span class="cx"> if (!m_domEditor->setAttribute(oldElement, attribute.name().localName(), attribute.value(), ec))
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="lines">@@ -433,10 +431,8 @@
</span><span class="cx"> Element* element = toElement(node);
</span><span class="cx">
</span><span class="cx"> if (element->hasAttributesWithoutUpdate()) {
</span><del>- size_t numAttrs = element->attributeCount();
</del><span class="cx"> SHA1 attrsSHA1;
</span><del>- for (size_t i = 0; i < numAttrs; ++i) {
- const Attribute& attribute = element->attributeAt(i);
</del><ins>+ for (const Attribute& attribute : element->attributesIterator()) {
</ins><span class="cx"> addStringToSHA1(attrsSHA1, attribute.name().toString());
</span><span class="cx"> addStringToSHA1(attrsSHA1, attribute.value());
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorDOMAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -679,10 +679,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool foundOriginalAttribute = false;
</span><del>- unsigned numAttrs = childElement->attributeCount();
- for (unsigned i = 0; i < numAttrs; ++i) {
</del><ins>+ for (const Attribute& attribute : childElement->attributesIterator()) {
</ins><span class="cx"> // Add attribute pair
</span><del>- const Attribute& attribute = childElement->attributeAt(i);
</del><span class="cx"> foundOriginalAttribute = foundOriginalAttribute || (name && attribute.name().toString() == *name);
</span><span class="cx"> if (!m_domEditor->setAttribute(element, attribute.name().toString(), attribute.value(), errorString))
</span><span class="cx"> return;
</span><span class="lines">@@ -1322,10 +1320,8 @@
</span><span class="cx"> // Go through all attributes and serialize them.
</span><span class="cx"> if (!element->hasAttributes())
</span><span class="cx"> return attributesValue.release();
</span><del>- unsigned numAttrs = element->attributeCount();
- for (unsigned i = 0; i < numAttrs; ++i) {
</del><ins>+ for (const Attribute& attribute : element->attributesIterator()) {
</ins><span class="cx"> // Add attribute pair
</span><del>- const Attribute& attribute = element->attributeAt(i);
</del><span class="cx"> attributesValue->addItem(attribute.name().toString());
</span><span class="cx"> attributesValue->addItem(attribute.value());
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorNodeFindercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorNodeFinder.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorNodeFinder.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/inspector/InspectorNodeFinder.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -122,9 +122,8 @@
</span><span class="cx"> if (!element.hasAttributes())
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- unsigned numAttrs = element.attributeCount();
- for (unsigned i = 0; i < numAttrs; ++i) {
- if (matchesAttribute(element.attributeAt(i)))
</del><ins>+ for (const Attribute& attribute : element.attributesIterator()) {
+ if (matchesAttribute(attribute))
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageSerializercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PageSerializer.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PageSerializer.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/page/PageSerializer.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -74,8 +74,7 @@
</span><span class="cx"> return false;
</span><span class="cx"> HTMLMetaCharsetParser::AttributeList attributes;
</span><span class="cx"> if (element.hasAttributes()) {
</span><del>- for (unsigned i = 0; i < element.attributeCount(); ++i) {
- const Attribute& attribute = element.attributeAt(i);
</del><ins>+ for (const Attribute& attribute : element.attributesIterator()) {
</ins><span class="cx"> // FIXME: We should deal appropriately with the attribute if they have a namespace.
</span><span class="cx"> attributes.append(std::make_pair(attribute.name().toString(), attribute.value().string()));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXPathNodeSetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XPathNodeSet.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XPathNodeSet.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/xml/XPathNodeSet.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -218,9 +218,8 @@
</span><span class="cx"> if (!element->hasAttributes())
</span><span class="cx"> continue;
</span><span class="cx">
</span><del>- unsigned attributeCount = element->attributeCount();
- for (unsigned i = 0; i < attributeCount; ++i) {
- RefPtr<Attr> attr = element->attrIfExists(element->attributeAt(i).name());
</del><ins>+ for (const Attribute& attribute : element->attributesIterator()) {
+ RefPtr<Attr> attr = element->attrIfExists(attribute.name());
</ins><span class="cx"> if (attr && nodes.contains(attr.get()))
</span><span class="cx"> sortedNodes.append(attr);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXPathStepcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XPathStep.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XPathStep.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/xml/XPathStep.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -361,8 +361,8 @@
</span><span class="cx"> if (!contextElement.hasAttributes())
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- for (unsigned i = 0; i < contextElement.attributeCount(); ++i) {
- RefPtr<Attr> attr = contextElement.ensureAttr(contextElement.attributeAt(i).name());
</del><ins>+ for (const Attribute& attribute : contextElement.attributesIterator()) {
+ RefPtr<Attr> attr = contextElement.ensureAttr(attribute.name());
</ins><span class="cx"> if (nodeMatches(*attr, AttributeAxis, m_nodeTest))
</span><span class="cx"> nodes.append(attr.release());
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorexmlparserXMLDocumentParserLibxml2cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (162393 => 162394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp        2014-01-21 01:10:29 UTC (rev 162393)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp        2014-01-21 01:31:37 UTC (rev 162394)
</span><span class="lines">@@ -628,8 +628,7 @@
</span><span class="cx"> for (; !elemStack.isEmpty(); elemStack.removeLast()) {
</span><span class="cx"> Element* element = elemStack.last();
</span><span class="cx"> if (element->hasAttributes()) {
</span><del>- for (unsigned i = 0; i < element->attributeCount(); i++) {
- const Attribute& attribute = element->attributeAt(i);
</del><ins>+ for (const Attribute& attribute : element->attributesIterator()) {
</ins><span class="cx"> if (attribute.localName() == xmlnsAtom)
</span><span class="cx"> m_defaultNamespaceURI = attribute.value();
</span><span class="cx"> else if (attribute.prefix() == xmlnsAtom)
</span></span></pre>
</div>
</div>
</body>
</html>