Index: Source/core/html/HTMLLabelElement.h |
diff --git a/Source/core/html/HTMLLabelElement.h b/Source/core/html/HTMLLabelElement.h |
index 7415dcb5a64a1ea08cb6be9e82f641b2c2f2307a..ce49dd2d68c6d870097c5bd527adeb6817b4e036 100644 |
--- a/Source/core/html/HTMLLabelElement.h |
+++ b/Source/core/html/HTMLLabelElement.h |
@@ -24,24 +24,33 @@ |
#ifndef HTMLLabelElement_h |
#define HTMLLabelElement_h |
+#include "core/html/FormAssociatedElement.h" |
#include "core/html/HTMLElement.h" |
#include "core/html/LabelableElement.h" |
namespace blink { |
-class HTMLLabelElement FINAL : public HTMLElement { |
+class HTMLLabelElement FINAL : public HTMLElement, public FormAssociatedElement { |
DEFINE_WRAPPERTYPEINFO(); |
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLLabelElement); |
public: |
- DECLARE_NODE_FACTORY(HTMLLabelElement); |
- |
+ static PassRefPtrWillBeRawPtr<HTMLLabelElement> create(Document&, HTMLFormElement*); |
LabelableElement* control() const; |
virtual bool willRespondToMouseClickEvents() OVERRIDE; |
+ virtual void trace(Visitor*) OVERRIDE; |
+ |
virtual HTMLFormElement* formOwner() const OVERRIDE; |
+ |
+#if !ENABLE(OILPAN) |
+ using Node::ref; |
+ using Node::deref; |
+#endif |
+ |
private: |
- explicit HTMLLabelElement(Document&); |
+ explicit HTMLLabelElement(Document&, HTMLFormElement*); |
bool isInInteractiveContent(Node*) const; |
virtual bool rendererIsFocusable() const OVERRIDE; |
@@ -61,9 +70,40 @@ private: |
virtual void focus(bool restorePreviousSelection, FocusType) OVERRIDE; |
+ // FormAssociatedElement methods |
+ virtual bool isFormControlElement() const OVERRIDE { return false; } |
+ virtual bool isEnumeratable() const OVERRIDE { return false; } |
+ virtual bool isLabelElement() const OVERRIDE { return true; } |
+#if !ENABLE(OILPAN) |
+ virtual void refFormAssociatedElement() OVERRIDE { ref(); } |
+ virtual void derefFormAssociatedElement() OVERRIDE { deref(); } |
+#endif |
+ |
+ virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; |
+ |
void updateLabel(TreeScope&, const AtomicString& oldForAttributeValue, const AtomicString& newForAttributeValue); |
}; |
+ |
+template<typename T> inline const T& toElement(const FormAssociatedElement&); |
+template<typename T> inline const T* toElement(const FormAssociatedElement*); |
+// Make toHTMLLabelElement() accept a FormAssociatedElement as input instead of a Node. |
+template<> inline const HTMLLabelElement* toElement<HTMLLabelElement>(const FormAssociatedElement* element) |
+{ |
+ const HTMLLabelElement* labelElement = static_cast<const HTMLLabelElement*>(element); |
+ // FormAssociatedElement doesn't have hasTagName, hence check for assert. |
+ ASSERT_WITH_SECURITY_IMPLICATION(!labelElement || labelElement->hasTagName(HTMLNames::labelTag)); |
+ return labelElement; |
+} |
+ |
+template<> inline const HTMLLabelElement& toElement<HTMLLabelElement>(const FormAssociatedElement& element) |
+{ |
+ const HTMLLabelElement& labelElement = static_cast<const HTMLLabelElement&>(element); |
+ // FormAssociatedElement doesn't have hasTagName, hence check for assert. |
+ ASSERT_WITH_SECURITY_IMPLICATION(labelElement.hasTagName(HTMLNames::labelTag)); |
+ return labelElement; |
+} |
+ |
} // namespace blink |
#endif // HTMLLabelElement_h |