Chromium Code Reviews| Index: Source/core/html/HTMLLabelElement.h |
| diff --git a/Source/core/html/HTMLLabelElement.h b/Source/core/html/HTMLLabelElement.h |
| index 7415dcb5a64a1ea08cb6be9e82f641b2c2f2307a..0808d1924ef61ce3a3d5dcf68a67926cd25a0484 100644 |
| --- a/Source/core/html/HTMLLabelElement.h |
| +++ b/Source/core/html/HTMLLabelElement.h |
| @@ -24,24 +24,32 @@ |
| #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(); |
|
keishi
2014/09/16 01:59:19
FormAssociatedElement is GarbageCollectedMixin so
spartha
2014/09/17 11:02:18
Done.
|
| 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 +69,37 @@ 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 |
| 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 |