Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / html / HTMLLabelElement.h
blobfca7c91550d95bcf63ea24e365b6b8ac97bf5447
1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
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
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #ifndef HTMLLabelElement_h
25 #define HTMLLabelElement_h
27 #include "core/CoreExport.h"
28 #include "core/html/FormAssociatedElement.h"
29 #include "core/html/HTMLElement.h"
30 #include "core/html/LabelableElement.h"
32 namespace blink {
34 class CORE_EXPORT HTMLLabelElement final : public HTMLElement, public FormAssociatedElement {
35 DEFINE_WRAPPERTYPEINFO();
36 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLLabelElement);
37 public:
38 static PassRefPtrWillBeRawPtr<HTMLLabelElement> create(Document&, HTMLFormElement*);
39 LabelableElement* control() const;
41 bool willRespondToMouseClickEvents() override;
43 DECLARE_VIRTUAL_TRACE();
45 HTMLFormElement* formOwner() const override;
48 #if !ENABLE(OILPAN)
49 using Node::ref;
50 using Node::deref;
51 #endif
53 private:
54 explicit HTMLLabelElement(Document&, HTMLFormElement*);
55 bool isInInteractiveContent(Node*) const;
57 bool layoutObjectIsFocusable() const override;
58 bool isInteractiveContent() const override;
59 void accessKeyAction(bool sendMouseEvents) override;
61 void attributeWillChange(const QualifiedName&, const AtomicString& oldValue, const AtomicString& newValue) override;
62 InsertionNotificationRequest insertedInto(ContainerNode*) override;
63 void removedFrom(ContainerNode*) override;
65 // Overridden to update the hover/active state of the corresponding control.
66 void setActive(bool = true) override;
67 void setHovered(bool = true) override;
69 // Overridden to either click() or focus() the corresponding control.
70 void defaultEventHandler(Event*) override;
72 void focus(bool restorePreviousSelection, WebFocusType, InputDeviceCapabilities* sourceCapabilities) override;
74 // FormAssociatedElement methods
75 bool isFormControlElement() const override { return false; }
76 bool isEnumeratable() const override { return false; }
77 bool isLabelElement() const override { return true; }
78 #if !ENABLE(OILPAN)
79 void refFormAssociatedElement() override { ref(); }
80 void derefFormAssociatedElement() override { deref(); }
81 #endif
83 void parseAttribute(const QualifiedName&, const AtomicString&) override;
85 void updateLabel(TreeScope&, const AtomicString& oldForAttributeValue, const AtomicString& newForAttributeValue);
87 bool m_processingClick;
91 template<typename T> inline const T& toElement(const FormAssociatedElement&);
92 template<typename T> inline const T* toElement(const FormAssociatedElement*);
93 // Make toHTMLLabelElement() accept a FormAssociatedElement as input instead of a Node.
94 template<> inline const HTMLLabelElement* toElement<HTMLLabelElement>(const FormAssociatedElement* element)
96 const HTMLLabelElement* labelElement = static_cast<const HTMLLabelElement*>(element);
97 // FormAssociatedElement doesn't have hasTagName, hence check for assert.
98 ASSERT_WITH_SECURITY_IMPLICATION(!labelElement || labelElement->hasTagName(HTMLNames::labelTag));
99 return labelElement;
102 template<> inline const HTMLLabelElement& toElement<HTMLLabelElement>(const FormAssociatedElement& element)
104 const HTMLLabelElement& labelElement = static_cast<const HTMLLabelElement&>(element);
105 // FormAssociatedElement doesn't have hasTagName, hence check for assert.
106 ASSERT_WITH_SECURITY_IMPLICATION(labelElement.hasTagName(HTMLNames::labelTag));
107 return labelElement;
110 } // namespace blink
112 #endif // HTMLLabelElement_h