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

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

Issue 141683004: Use more const references in HTMLCollection / LiveNodeList (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Get rid of const_cast Created 6 years, 11 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/HTMLLabelElement.h ('k') | Source/core/html/HTMLOptionElement.h » ('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 6e8fa3d5ea0fea8eb36051383935992e1039df51..c7239b53b73afabb1fecc516a25becdaea9dedb9 100644
--- a/Source/core/html/HTMLLabelElement.cpp
+++ b/Source/core/html/HTMLLabelElement.cpp
@@ -35,13 +35,13 @@ namespace WebCore {
using namespace HTMLNames;
-static bool supportsLabels(Element* element)
+static bool supportsLabels(const Element& element)
{
- if (!element || !element->isHTMLElement())
+ if (!element.isHTMLElement())
return false;
- if (!toHTMLElement(element)->isLabelable())
+ if (!toHTMLElement(element).isLabelable())
return false;
- return toLabelableElement(element)->supportLabels();
+ return toLabelableElement(element).supportLabels();
}
inline HTMLLabelElement::HTMLLabelElement(Document& document)
@@ -61,16 +61,15 @@ bool HTMLLabelElement::rendererIsFocusable() const
return that->isContentEditable();
}
-LabelableElement* HTMLLabelElement::control()
+LabelableElement* HTMLLabelElement::control() const
{
const AtomicString& controlId = getAttribute(forAttr);
if (controlId.isNull()) {
// 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".
- Element* element = this;
- while ((element = ElementTraversal::next(*element, this))) {
- if (!supportsLabels(element))
+ for (Element* element = ElementTraversal::next(*this, this); element; element = ElementTraversal::next(*element, this)) {
+ if (!supportsLabels(*element))
continue;
return toLabelableElement(element);
}
@@ -78,7 +77,7 @@ LabelableElement* HTMLLabelElement::control()
}
if (Element* element = treeScope().getElementById(controlId)) {
- if (supportsLabels(element))
+ if (supportsLabels(*element))
return toLabelableElement(element);
}
« no previous file with comments | « Source/core/html/HTMLLabelElement.h ('k') | Source/core/html/HTMLOptionElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698