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

Unified Diff: Source/core/html/HTMLLabelElement.cpp

Issue 420193007: Use new Traversal<> API more in the code base (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Take feedback into consideration Created 6 years, 5 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/html/HTMLFieldSetElement.cpp ('k') | Source/core/html/track/vtt/VTTRegion.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLLabelElement.cpp
diff --git a/Source/core/html/HTMLLabelElement.cpp b/Source/core/html/HTMLLabelElement.cpp
index 643fbf32bff33194cdf9f77583903c9f8a85951b..b8576d1e99c5191108cf75caed4a31b305e31fdb 100644
--- a/Source/core/html/HTMLLabelElement.cpp
+++ b/Source/core/html/HTMLLabelElement.cpp
@@ -37,15 +37,6 @@ namespace blink {
using namespace HTMLNames;
-static bool supportsLabels(const Element& element)
-{
- if (!element.isHTMLElement())
- return false;
- if (!toHTMLElement(element).isLabelable())
- return false;
- return toLabelableElement(element).supportLabels();
-}
-
inline HTMLLabelElement::HTMLLabelElement(Document& document)
: HTMLElement(labelTag, document)
{
@@ -67,16 +58,15 @@ LabelableElement* HTMLLabelElement::control() const
// Search the children and descendants of the label element for a form element.
// per http://dev.w3.org/html5/spec/Overview.html#the-label-element
// the form element must be "labelable form-associated element".
- for (Element* element = ElementTraversal::next(*this, this); element; element = ElementTraversal::next(*element, this)) {
- if (!supportsLabels(*element))
- continue;
- return toLabelableElement(element);
+ for (LabelableElement* element = Traversal<LabelableElement>::next(*this, this); element; element = Traversal<LabelableElement>::next(*element, this)) {
+ if (element->supportLabels())
+ return element;
}
return 0;
}
if (Element* element = treeScope().getElementById(controlId)) {
- if (supportsLabels(*element))
+ if (isLabelableElement(*element) && toLabelableElement(*element).supportLabels())
return toLabelableElement(element);
}
« no previous file with comments | « Source/core/html/HTMLFieldSetElement.cpp ('k') | Source/core/html/track/vtt/VTTRegion.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698