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

Unified Diff: Source/core/dom/Element.cpp

Issue 436603003: Make Element::attributes() less error-prone and simplify call sites (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Take feedback into consideration Created 6 years, 4 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/Element.h ('k') | Source/core/dom/NamedNodeMap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 899045fefa31be39fa3c4a11fc497c45e52c5153..7393c42c6fddd3cead47a14e6c20d3be9dd498af 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -431,7 +431,7 @@ const AtomicString& Element::getAttribute(const QualifiedName& name) const
if (!elementData())
return nullAtom;
synchronizeAttribute(name);
- if (const Attribute* attribute = attributes().find(name))
+ if (const Attribute* attribute = elementData()->attributes().find(name))
return attribute->value();
return nullAtom;
}
@@ -910,7 +910,7 @@ ALWAYS_INLINE void Element::setAttributeInternal(size_t index, const QualifiedNa
return;
}
- const Attribute& existingAttribute = attributes().at(index);
+ const Attribute& existingAttribute = elementData()->attributes().at(index);
QualifiedName existingAttributeName = existingAttribute.name();
if (!inSynchronizationOfLazyAttribute)
@@ -1135,12 +1135,6 @@ void Element::parserSetAttributes(const Vector<Attribute>& attributeVector)
attributeChangedFromParserOrByCloning(attributeVector[i].name(), attributeVector[i].value(), ModifiedDirectly);
}
-bool Element::hasAttributes() const
-{
- synchronizeAllAttributes();
- return elementData() && !elementData()->attributes().isEmpty();
-}
-
bool Element::hasEquivalentAttributes(const Element* other) const
{
synchronizeAllAttributes();
@@ -1192,13 +1186,11 @@ const AtomicString& Element::locateNamespacePrefix(const AtomicString& namespace
if (!prefix().isNull() && namespaceURI() == namespaceToLocate)
return prefix();
- if (hasAttributes()) {
- AttributeCollection attributes = this->attributes();
- AttributeCollection::const_iterator end = attributes.end();
- for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
- if (it->prefix() == xmlnsAtom && it->value() == namespaceToLocate)
- return it->localName();
- }
+ AttributeCollection attributes = this->attributes();
+ AttributeCollection::const_iterator end = attributes.end();
+ for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
+ if (it->prefix() == xmlnsAtom && it->value() == namespaceToLocate)
+ return it->localName();
}
if (Element* parent = parentElement())
@@ -2969,7 +2961,7 @@ void Element::detachAllAttrNodesFromElement()
AttrNodeList* list = this->attrNodeList();
ASSERT(list);
- AttributeCollection attributes = this->attributes();
+ AttributeCollection attributes = elementData()->attributes();
AttributeCollection::const_iterator end = attributes.end();
for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
if (RefPtrWillBeRawPtr<Attr> attrNode = findAttrNodeInList(*list, it->name()))
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/NamedNodeMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698