]> git.saurik.com Git - iphone-api.git/blob - WebCore/HTMLFormControlElement.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / HTMLFormControlElement.h
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 Apple Inc. All rights reserved.
6 *
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.
11 *
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.
16 *
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.
21 *
22 */
23
24 #ifndef HTMLFormControlElement_h
25 #define HTMLFormControlElement_h
26
27 #include "FormControlElement.h"
28 #include "FormControlElementWithState.h"
29 #include "HTMLElement.h"
30
31 namespace WebCore {
32
33 class FormDataList;
34 class HTMLFormElement;
35
36 class HTMLFormControlElement : public HTMLElement, public FormControlElement {
37 public:
38 HTMLFormControlElement(const QualifiedName& tagName, Document*, HTMLFormElement*);
39 virtual ~HTMLFormControlElement();
40
41 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
42 virtual int tagPriority() const { return 1; }
43
44 HTMLFormElement* form() const { return m_form; }
45
46 virtual const AtomicString& type() const = 0;
47
48 virtual bool isControl() const { return true; }
49 virtual bool isEnabled() const { return !disabled(); }
50
51 virtual void parseMappedAttribute(MappedAttribute*);
52 virtual void attach();
53 virtual void insertedIntoTree(bool deep);
54 virtual void removedFromTree(bool deep);
55
56 virtual void reset() {}
57
58 virtual bool valueMatchesRenderer() const { return m_valueMatchesRenderer; }
59 virtual void setValueMatchesRenderer(bool b = true) { m_valueMatchesRenderer = b; }
60
61 void onChange();
62
63 bool disabled() const;
64 void setDisabled(bool);
65
66 virtual bool supportsFocus() const;
67 virtual bool isFocusable() const;
68 virtual bool isKeyboardFocusable(KeyboardEvent*) const;
69 virtual bool isMouseFocusable() const;
70 virtual bool isEnumeratable() const { return false; }
71
72 virtual bool isReadOnlyControl() const { return m_readOnly; }
73 void setReadOnly(bool);
74
75 // Determines whether or not a control will be automatically focused
76 virtual bool autofocus() const;
77 void setAutofocus(bool);
78
79 virtual void recalcStyle(StyleChange);
80
81 virtual const AtomicString& name() const;
82 void setName(const AtomicString& name);
83
84 virtual bool isFormControlElement() const { return true; }
85 virtual bool isRadioButton() const { return false; }
86
87 /* Override in derived classes to get the encoded name=value pair for submitting.
88 * Return true for a successful control (see HTML4-17.13.2).
89 */
90 virtual bool appendFormData(FormDataList&, bool) { return false; }
91
92 virtual bool isSuccessfulSubmitButton() const { return false; }
93 virtual bool isActivatedSubmit() const { return false; }
94 virtual void setActivatedSubmit(bool) { }
95
96 virtual short tabIndex() const;
97
98 virtual void dispatchFocusEvent();
99 virtual void dispatchBlurEvent();
100
101 bool autocorrect() const;
102 void setAutocorrect(bool);
103
104 bool autocapitalize() const;
105 void setAutocapitalize(bool);
106
107 virtual bool willValidate() const;
108
109 void formDestroyed() { m_form = 0; }
110
111 protected:
112 void removeFromForm();
113
114 private:
115 virtual HTMLFormElement* virtualForm() const;
116
117 HTMLFormElement* m_form;
118 bool m_disabled;
119 bool m_readOnly;
120 bool m_valueMatchesRenderer;
121 };
122
123 class HTMLFormControlElementWithState : public HTMLFormControlElement, public FormControlElementWithState {
124 public:
125 HTMLFormControlElementWithState(const QualifiedName& tagName, Document*, HTMLFormElement*);
126 virtual ~HTMLFormControlElementWithState();
127
128 virtual bool isFormControlElementWithState() const { return true; }
129
130 virtual FormControlElement* toFormControlElement() { return this; }
131 virtual void finishParsingChildren();
132
133 protected:
134 virtual void willMoveToNewOwnerDocument();
135 virtual void didMoveToNewOwnerDocument();
136 };
137
138 } //namespace
139
140 #endif