OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 * | 21 * |
22 */ | 22 */ |
23 | 23 |
24 #ifndef HTMLLabelElement_h | 24 #ifndef HTMLLabelElement_h |
25 #define HTMLLabelElement_h | 25 #define HTMLLabelElement_h |
26 | 26 |
27 #include "core/CoreExport.h" | 27 #include "core/CoreExport.h" |
28 #include "core/html/FormAssociatedElement.h" | |
29 #include "core/html/HTMLElement.h" | 28 #include "core/html/HTMLElement.h" |
30 #include "core/html/LabelableElement.h" | |
31 | 29 |
32 namespace blink { | 30 namespace blink { |
33 | 31 |
34 class CORE_EXPORT HTMLLabelElement final : public HTMLElement, public FormAssoci
atedElement { | 32 class LabelableElement; |
| 33 |
| 34 class CORE_EXPORT HTMLLabelElement final : public HTMLElement { |
35 DEFINE_WRAPPERTYPEINFO(); | 35 DEFINE_WRAPPERTYPEINFO(); |
36 USING_GARBAGE_COLLECTED_MIXIN(HTMLLabelElement); | |
37 public: | 36 public: |
38 static HTMLLabelElement* create(Document&, HTMLFormElement*); | 37 static HTMLLabelElement* create(Document&); |
39 LabelableElement* control() const; | 38 LabelableElement* control() const; |
| 39 HTMLFormElement* form() const; |
40 | 40 |
41 bool willRespondToMouseClickEvents() override; | 41 bool willRespondToMouseClickEvents() override; |
42 | 42 |
43 DECLARE_VIRTUAL_TRACE(); | |
44 | |
45 HTMLFormElement* formOwner() const override; | |
46 HTMLFormElement* formForBinding() const; | |
47 | |
48 private: | 43 private: |
49 explicit HTMLLabelElement(Document&, HTMLFormElement*); | 44 explicit HTMLLabelElement(Document&); |
50 bool isInInteractiveContent(Node*) const; | 45 bool isInInteractiveContent(Node*) const; |
51 | 46 |
52 bool isInteractiveContent() const override; | 47 bool isInteractiveContent() const override; |
53 void accessKeyAction(bool sendMouseEvents) override; | 48 void accessKeyAction(bool sendMouseEvents) override; |
54 | 49 |
55 InsertionNotificationRequest insertedInto(ContainerNode*) override; | 50 InsertionNotificationRequest insertedInto(ContainerNode*) override; |
56 void removedFrom(ContainerNode*) override; | 51 void removedFrom(ContainerNode*) override; |
57 | 52 |
58 // Overridden to update the hover/active state of the corresponding control. | 53 // Overridden to update the hover/active state of the corresponding control. |
59 void setActive(bool = true) override; | 54 void setActive(bool = true) override; |
60 void setHovered(bool = true) override; | 55 void setHovered(bool = true) override; |
61 | 56 |
62 // Overridden to either click() or focus() the corresponding control. | 57 // Overridden to either click() or focus() the corresponding control. |
63 void defaultEventHandler(Event*) override; | 58 void defaultEventHandler(Event*) override; |
64 | 59 |
65 void focus(const FocusParams&) override; | 60 void focus(const FocusParams&) override; |
66 | 61 |
67 // FormAssociatedElement methods | |
68 bool isFormControlElement() const override { return false; } | |
69 bool isEnumeratable() const override { return false; } | |
70 bool isLabelElement() const override { return true; } | |
71 | |
72 void parseAttribute(const QualifiedName&, const AtomicString&, const AtomicS
tring&) override; | 62 void parseAttribute(const QualifiedName&, const AtomicString&, const AtomicS
tring&) override; |
73 | 63 |
74 void updateLabel(TreeScope&, const AtomicString& oldForAttributeValue, const
AtomicString& newForAttributeValue); | 64 void updateLabel(TreeScope&, const AtomicString& oldForAttributeValue, const
AtomicString& newForAttributeValue); |
75 | 65 |
76 bool m_processingClick; | 66 bool m_processingClick; |
77 }; | 67 }; |
78 | 68 |
79 | |
80 template<typename T> inline const T& toElement(const FormAssociatedElement&); | |
81 template<typename T> inline const T* toElement(const FormAssociatedElement*); | |
82 // Make toHTMLLabelElement() accept a FormAssociatedElement as input instead of
a Node. | |
83 template<> inline const HTMLLabelElement* toElement<HTMLLabelElement>(const Form
AssociatedElement* element) | |
84 { | |
85 const HTMLLabelElement* labelElement = static_cast<const HTMLLabelElement*>(
element); | |
86 // FormAssociatedElement doesn't have hasTagName, hence check for assert. | |
87 ASSERT_WITH_SECURITY_IMPLICATION(!labelElement || labelElement->hasTagName(H
TMLNames::labelTag)); | |
88 return labelElement; | |
89 } | |
90 | |
91 template<> inline const HTMLLabelElement& toElement<HTMLLabelElement>(const Form
AssociatedElement& element) | |
92 { | |
93 const HTMLLabelElement& labelElement = static_cast<const HTMLLabelElement&>(
element); | |
94 // FormAssociatedElement doesn't have hasTagName, hence check for assert. | |
95 ASSERT_WITH_SECURITY_IMPLICATION(labelElement.hasTagName(HTMLNames::labelTag
)); | |
96 return labelElement; | |
97 } | |
98 | |
99 } // namespace blink | 69 } // namespace blink |
100 | 70 |
101 #endif // HTMLLabelElement_h | 71 #endif // HTMLLabelElement_h |
OLD | NEW |