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

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: 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..46550a503644e9685f260796b25baaee7029dcd7 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())
Inactive 2014/01/17 21:10:43 Got rid of a useless null check.
+ 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,16 @@ 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;
+ Element* element = const_cast<HTMLLabelElement*>(this);
adamk 2014/01/21 21:43:55 I'd prefer restructuring the logic and removing th
Inactive 2014/01/21 23:14:04 Sure, I will refactor to a for loop and thus avoid
Inactive 2014/01/21 23:40:20 Done.
while ((element = ElementTraversal::next(*element, this))) {
- if (!supportsLabels(element))
+ if (!supportsLabels(*element))
continue;
return toLabelableElement(element);
}
@@ -78,7 +78,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