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; |