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

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

Issue 569993002: <label> should support form association by parser (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated Created 6 years, 3 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/FormAssociatedElement.cpp ('k') | Source/core/html/HTMLLabelElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « Source/core/html/FormAssociatedElement.cpp ('k') | Source/core/html/HTMLLabelElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698