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