1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is Mozilla Communicator client code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : /**
39 : * Declaration of HTML <label> elements.
40 : */
41 : #ifndef nsHTMLLabelElement_h
42 : #define nsHTMLLabelElement_h
43 :
44 : #include "nsGenericHTMLElement.h"
45 : #include "nsIDOMHTMLLabelElement.h"
46 :
47 : class nsHTMLLabelElement : public nsGenericHTMLFormElement,
48 : public nsIDOMHTMLLabelElement
49 : {
50 : public:
51 : nsHTMLLabelElement(already_AddRefed<nsINodeInfo> aNodeInfo);
52 : virtual ~nsHTMLLabelElement();
53 :
54 0 : static nsHTMLLabelElement* FromContent(nsIContent* aPossibleLabel)
55 : {
56 0 : if (aPossibleLabel->IsHTML(nsGkAtoms::label)) {
57 0 : return static_cast<nsHTMLLabelElement*>(aPossibleLabel);
58 : }
59 :
60 0 : return nsnull;
61 : }
62 :
63 : // nsISupports
64 : NS_DECL_ISUPPORTS_INHERITED
65 :
66 : // nsIDOMNode
67 0 : NS_FORWARD_NSIDOMNODE(nsGenericHTMLFormElement::)
68 :
69 : // nsIDOMElement
70 0 : NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFormElement::)
71 :
72 : // nsIDOMHTMLLabelElement
73 : NS_DECL_NSIDOMHTMLLABELELEMENT
74 :
75 : // nsIDOMHTMLElement
76 0 : NS_FORWARD_NSIDOMHTMLELEMENT_BASIC(nsGenericHTMLFormElement::)
77 0 : NS_SCRIPTABLE NS_IMETHOD Click() {
78 0 : return nsGenericHTMLFormElement::Click();
79 : }
80 0 : NS_SCRIPTABLE NS_IMETHOD GetTabIndex(PRInt32* aTabIndex) {
81 0 : return nsGenericHTMLFormElement::GetTabIndex(aTabIndex);
82 : }
83 0 : NS_SCRIPTABLE NS_IMETHOD SetTabIndex(PRInt32 aTabIndex) {
84 0 : return nsGenericHTMLFormElement::SetTabIndex(aTabIndex);
85 : }
86 : NS_SCRIPTABLE NS_IMETHOD Focus();
87 0 : NS_SCRIPTABLE NS_IMETHOD GetDraggable(bool* aDraggable) {
88 0 : return nsGenericHTMLFormElement::GetDraggable(aDraggable);
89 : }
90 0 : NS_SCRIPTABLE NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML) {
91 0 : return nsGenericHTMLFormElement::GetInnerHTML(aInnerHTML);
92 : }
93 0 : NS_SCRIPTABLE NS_IMETHOD SetInnerHTML(const nsAString& aInnerHTML) {
94 0 : return nsGenericHTMLFormElement::SetInnerHTML(aInnerHTML);
95 : }
96 :
97 : // nsIFormControl
98 0 : NS_IMETHOD_(PRUint32) GetType() const { return NS_FORM_LABEL; }
99 : NS_IMETHOD Reset();
100 : NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission);
101 :
102 0 : virtual bool IsDisabled() const { return false; }
103 :
104 : // nsIContent
105 : virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
106 : nsIContent* aBindingParent,
107 : bool aCompileEventHandlers);
108 : virtual void UnbindFromTree(bool aDeep = true,
109 : bool aNullParent = true);
110 :
111 : virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
112 :
113 : nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
114 : const nsAString& aValue, bool aNotify)
115 : {
116 : return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
117 : }
118 : virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
119 : nsIAtom* aPrefix, const nsAString& aValue,
120 : bool aNotify);
121 : virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
122 : bool aNotify);
123 : virtual void PerformAccesskey(bool aKeyCausesActivation,
124 : bool aIsTrustedEvent);
125 : virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
126 :
127 : virtual nsXPCClassInfo* GetClassInfo();
128 :
129 : mozilla::dom::Element* GetLabeledElement();
130 : protected:
131 : mozilla::dom::Element* GetFirstDescendantFormControl();
132 :
133 : // XXX It would be nice if we could use an event flag instead.
134 : bool mHandlingEvent;
135 : };
136 :
137 : #endif /* nsHTMLLabelElement_h */
|