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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « Source/core/html/FormAssociatedElement.cpp ('k') | Source/core/html/HTMLLabelElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/html/FormAssociatedElement.h"
27 #include "core/html/HTMLElement.h" 28 #include "core/html/HTMLElement.h"
28 #include "core/html/LabelableElement.h" 29 #include "core/html/LabelableElement.h"
29 30
30 namespace blink { 31 namespace blink {
31 32
32 class HTMLLabelElement FINAL : public HTMLElement { 33 class HTMLLabelElement FINAL : public HTMLElement, public FormAssociatedElement {
33 DEFINE_WRAPPERTYPEINFO(); 34 DEFINE_WRAPPERTYPEINFO();
35 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLLabelElement);
34 public: 36 public:
35 DECLARE_NODE_FACTORY(HTMLLabelElement); 37 static PassRefPtrWillBeRawPtr<HTMLLabelElement> create(Document&, HTMLFormEl ement*);
36
37 LabelableElement* control() const; 38 LabelableElement* control() const;
38 39
39 virtual bool willRespondToMouseClickEvents() OVERRIDE; 40 virtual bool willRespondToMouseClickEvents() OVERRIDE;
40 41
42 virtual void trace(Visitor*) OVERRIDE;
43
41 virtual HTMLFormElement* formOwner() const OVERRIDE; 44 virtual HTMLFormElement* formOwner() const OVERRIDE;
42 45
46
47 #if !ENABLE(OILPAN)
48 using Node::ref;
49 using Node::deref;
50 #endif
51
43 private: 52 private:
44 explicit HTMLLabelElement(Document&); 53 explicit HTMLLabelElement(Document&, HTMLFormElement*);
45 bool isInInteractiveContent(Node*) const; 54 bool isInInteractiveContent(Node*) const;
46 55
47 virtual bool rendererIsFocusable() const OVERRIDE; 56 virtual bool rendererIsFocusable() const OVERRIDE;
48 virtual bool isInteractiveContent() const OVERRIDE; 57 virtual bool isInteractiveContent() const OVERRIDE;
49 virtual void accessKeyAction(bool sendMouseEvents) OVERRIDE; 58 virtual void accessKeyAction(bool sendMouseEvents) OVERRIDE;
50 59
51 virtual void attributeWillChange(const QualifiedName&, const AtomicString& o ldValue, const AtomicString& newValue) OVERRIDE; 60 virtual void attributeWillChange(const QualifiedName&, const AtomicString& o ldValue, const AtomicString& newValue) OVERRIDE;
52 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; 61 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
53 virtual void removedFrom(ContainerNode*) OVERRIDE; 62 virtual void removedFrom(ContainerNode*) OVERRIDE;
54 63
55 // Overridden to update the hover/active state of the corresponding control. 64 // Overridden to update the hover/active state of the corresponding control.
56 virtual void setActive(bool = true) OVERRIDE; 65 virtual void setActive(bool = true) OVERRIDE;
57 virtual void setHovered(bool = true) OVERRIDE; 66 virtual void setHovered(bool = true) OVERRIDE;
58 67
59 // Overridden to either click() or focus() the corresponding control. 68 // Overridden to either click() or focus() the corresponding control.
60 virtual void defaultEventHandler(Event*) OVERRIDE; 69 virtual void defaultEventHandler(Event*) OVERRIDE;
61 70
62 virtual void focus(bool restorePreviousSelection, FocusType) OVERRIDE; 71 virtual void focus(bool restorePreviousSelection, FocusType) OVERRIDE;
63 72
73 // FormAssociatedElement methods
74 virtual bool isFormControlElement() const OVERRIDE { return false; }
75 virtual bool isEnumeratable() const OVERRIDE { return false; }
76 virtual bool isLabelElement() const OVERRIDE { return true; }
77 #if !ENABLE(OILPAN)
78 virtual void refFormAssociatedElement() OVERRIDE { ref(); }
79 virtual void derefFormAssociatedElement() OVERRIDE { deref(); }
80 #endif
81
82 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE;
83
64 void updateLabel(TreeScope&, const AtomicString& oldForAttributeValue, const AtomicString& newForAttributeValue); 84 void updateLabel(TreeScope&, const AtomicString& oldForAttributeValue, const AtomicString& newForAttributeValue);
65 }; 85 };
66 86
87
88 template<typename T> inline const T& toElement(const FormAssociatedElement&);
89 template<typename T> inline const T* toElement(const FormAssociatedElement*);
90 // Make toHTMLLabelElement() accept a FormAssociatedElement as input instead of a Node.
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 || labelElement->hasTagName(H TMLNames::labelTag));
96 return labelElement;
97 }
98
99 template<> inline const HTMLLabelElement& toElement<HTMLLabelElement>(const Form AssociatedElement& element)
100 {
101 const HTMLLabelElement& labelElement = static_cast<const HTMLLabelElement&>( element);
102 // FormAssociatedElement doesn't have hasTagName, hence check for assert.
103 ASSERT_WITH_SECURITY_IMPLICATION(labelElement.hasTagName(HTMLNames::labelTag ));
104 return labelElement;
105 }
106
67 } // namespace blink 107 } // namespace blink
68 108
69 #endif // HTMLLabelElement_h 109 #endif // HTMLLabelElement_h
OLDNEW
« 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