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

Unified Diff: Source/core/dom/Node.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/NamedNodeMap.cpp ('k') | Source/core/dom/PresentationAttributeStyle.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Node.cpp
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp
index abac3f9ed3f73664fa5a77eebe52eebd8309d9c8..03d6285314aa16d6dfbae508bfe14f4ef8509451 100644
--- a/Source/core/dom/Node.cpp
+++ b/Source/core/dom/Node.cpp
@@ -1270,13 +1270,11 @@ bool Node::isDefaultNamespace(const AtomicString& namespaceURIMaybeEmpty) const
if (element.prefix().isNull())
return element.namespaceURI() == namespaceURI;
- if (element.hasAttributes()) {
- AttributeCollection attributes = element.attributes();
- AttributeCollection::const_iterator end = attributes.end();
- for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
- if (it->localName() == xmlnsAtom)
- return it->value() == namespaceURI;
- }
+ AttributeCollection attributes = element.attributes();
+ AttributeCollection::const_iterator end = attributes.end();
+ for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
+ if (it->localName() == xmlnsAtom)
+ return it->value() == namespaceURI;
}
if (Element* parent = parentElement())
@@ -1355,22 +1353,21 @@ const AtomicString& Node::lookupNamespaceURI(const String& prefix) const
if (!element.namespaceURI().isNull() && element.prefix() == prefix)
return element.namespaceURI();
- if (element.hasAttributes()) {
- AttributeCollection attributes = element.attributes();
- AttributeCollection::const_iterator end = attributes.end();
- for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
- if (it->prefix() == xmlnsAtom && it->localName() == prefix) {
- if (!it->value().isEmpty())
- return it->value();
- return nullAtom;
- }
- if (it->localName() == xmlnsAtom && prefix.isNull()) {
- if (!it->value().isEmpty())
- return it->value();
- return nullAtom;
- }
+ AttributeCollection attributes = element.attributes();
+ AttributeCollection::const_iterator end = attributes.end();
+ for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
+ if (it->prefix() == xmlnsAtom && it->localName() == prefix) {
+ if (!it->value().isEmpty())
+ return it->value();
+ return nullAtom;
+ }
+ if (it->localName() == xmlnsAtom && prefix.isNull()) {
+ if (!it->value().isEmpty())
+ return it->value();
+ return nullAtom;
}
}
+
if (Element* parent = parentElement())
return parent->lookupNamespaceURI(prefix);
return nullAtom;
@@ -1517,7 +1514,6 @@ unsigned short Node::compareDocumentPosition(const Node* otherNode, ShadowTreesT
if (attr1 && attr2 && start1 == start2 && start1) {
// We are comparing two attributes on the same node. Crawl our attribute map and see which one we hit first.
const Element* owner1 = attr1->ownerElement();
- owner1->synchronizeAllAttributes();
AttributeCollection attributes = owner1->attributes();
AttributeCollection::const_iterator end = attributes.end();
for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
« no previous file with comments | « Source/core/dom/NamedNodeMap.cpp ('k') | Source/core/dom/PresentationAttributeStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698