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

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

Issue 189523003: Update DOM code to use the new Traversal<HTML*Element> API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/TreeScope.cpp
diff --git a/Source/core/dom/TreeScope.cpp b/Source/core/dom/TreeScope.cpp
index 45dd8a0e991870a8dad6293ec9cfefea410871ee..ed11d7efbffaedf6e3d1bff1253bc5ca4be2eac0 100644
--- a/Source/core/dom/TreeScope.cpp
+++ b/Source/core/dom/TreeScope.cpp
@@ -272,13 +272,10 @@ HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeV
if (!m_labelsByForAttribute) {
// Populate the map on first access.
m_labelsByForAttribute = adoptPtr(new DocumentOrderedMap);
- for (Element* element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::next(*element)) {
- if (element->hasTagName(labelTag)) {
- HTMLLabelElement* label = toHTMLLabelElement(element);
- const AtomicString& forValue = label->fastGetAttribute(forAttr);
- if (!forValue.isEmpty())
- addLabel(forValue, label);
- }
+ for (HTMLLabelElement* label = Traversal<HTMLLabelElement>::firstWithin(rootNode()); label; label = Traversal<HTMLLabelElement>::next(*label)) {
+ const AtomicString& forValue = label->fastGetAttribute(forAttr);
+ if (!forValue.isEmpty())
+ addLabel(forValue, label);
}
}
@@ -306,18 +303,15 @@ Element* TreeScope::findAnchor(const String& name)
return 0;
if (Element* element = getElementById(AtomicString(name)))
return element;
- for (Element* element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::next(*element)) {
- if (element->hasTagName(aTag)) {
- HTMLAnchorElement* anchor = toHTMLAnchorElement(element);
- if (rootNode().document().inQuirksMode()) {
- // Quirks mode, case insensitive comparison of names.
- if (equalIgnoringCase(anchor->name(), name))
- return anchor;
- } else {
- // Strict mode, names need to match exactly.
- if (anchor->name() == name)
- return anchor;
- }
+ for (HTMLAnchorElement* anchor = Traversal<HTMLAnchorElement>::firstWithin(rootNode()); anchor; anchor = Traversal<HTMLAnchorElement>::next(*anchor)) {
+ if (rootNode().document().inQuirksMode()) {
+ // Quirks mode, case insensitive comparison of names.
+ if (equalIgnoringCase(anchor->name(), name))
+ return anchor;
+ } else {
+ // Strict mode, names need to match exactly.
+ if (anchor->name() == name)
+ return anchor;
}
}
return 0;
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698