]> git.saurik.com Git - iphone-api.git/blob - WebCore/HTMLFormElement.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / HTMLFormElement.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, 2008 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 HTMLFormElement_h
25 #define HTMLFormElement_h
26
27 #include "FormDataBuilder.h"
28 #include "HTMLCollection.h"
29 #include "HTMLElement.h"
30
31 #include <wtf/OwnPtr.h>
32
33 namespace WebCore {
34
35 class Event;
36 class FormData;
37 class HTMLFormControlElement;
38 class HTMLImageElement;
39 class HTMLInputElement;
40 class HTMLFormCollection;
41 class TextEncoding;
42
43 class HTMLFormElement : public HTMLElement {
44 public:
45 HTMLFormElement(const QualifiedName&, Document*);
46 virtual ~HTMLFormElement();
47
48 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
49 virtual int tagPriority() const { return 3; }
50
51 virtual void attach();
52 virtual void insertedIntoDocument();
53 virtual void removedFromDocument();
54
55 virtual void handleLocalEvents(Event*, bool useCapture);
56
57 PassRefPtr<HTMLCollection> elements();
58 void getNamedElements(const AtomicString&, Vector<RefPtr<Node> >&);
59
60 unsigned length() const;
61 Node* item(unsigned index);
62
63 String enctype() const { return m_formDataBuilder.encodingType(); }
64 void setEnctype(const String&);
65
66 String encoding() const { return m_formDataBuilder.encodingType(); }
67 void setEncoding(const String& value) { setEnctype(value); }
68
69 bool autoComplete() const { return m_autocomplete; }
70
71 bool autocorrect() const;
72 void setAutocorrect(bool);
73
74 bool autocapitalize() const;
75 void setAutocapitalize(bool);
76
77 virtual void parseMappedAttribute(MappedAttribute*);
78
79 void registerFormElement(HTMLFormControlElement*);
80 void removeFormElement(HTMLFormControlElement*);
81 void registerImgElement(HTMLImageElement*);
82 void removeImgElement(HTMLImageElement*);
83
84 bool prepareSubmit(Event*);
85 void submit(Event* = 0, bool activateSubmitButton = false, bool lockHistory = false, bool lockBackForwardList = false);
86 void reset();
87
88 // Used to indicate a malformed state to keep from applying the bottom margin of the form.
89 void setMalformed(bool malformed) { m_malformed = malformed; }
90 bool isMalformed() const { return m_malformed; }
91
92 virtual bool isURLAttribute(Attribute*) const;
93
94 void submitClick(Event*);
95 bool formWouldHaveSecureSubmission(const String& url);
96
97 String name() const;
98 void setName(const String&);
99
100 String acceptCharset() const { return m_formDataBuilder.acceptCharset(); }
101 void setAcceptCharset(const String&);
102
103 String action() const;
104 void setAction(const String&);
105
106 String method() const;
107 void setMethod(const String&);
108
109 virtual String target() const;
110 void setTarget(const String&);
111
112 PassRefPtr<HTMLFormControlElement> elementForAlias(const AtomicString&);
113 void addElementAlias(HTMLFormControlElement*, const AtomicString& alias);
114
115 // FIXME: Change this to be private after getting rid of all the clients.
116 Vector<HTMLFormControlElement*> formElements;
117
118 class CheckedRadioButtons {
119 public:
120 void addButton(HTMLFormControlElement*);
121 void removeButton(HTMLFormControlElement*);
122 HTMLInputElement* checkedButtonForGroup(const AtomicString& name) const;
123
124 private:
125 typedef HashMap<AtomicStringImpl*, HTMLInputElement*> NameToInputMap;
126 OwnPtr<NameToInputMap> m_nameToCheckedRadioButtonMap;
127 };
128
129 CheckedRadioButtons& checkedRadioButtons() { return m_checkedRadioButtons; }
130
131 virtual void documentDidBecomeActive();
132
133 protected:
134 virtual void willMoveToNewOwnerDocument();
135 virtual void didMoveToNewOwnerDocument();
136
137 private:
138 bool isMailtoForm() const;
139 TextEncoding dataEncoding() const;
140 PassRefPtr<FormData> createFormData(const CString& boundary);
141 unsigned formElementIndex(HTMLFormControlElement*);
142
143 friend class HTMLFormCollection;
144
145 typedef HashMap<RefPtr<AtomicStringImpl>, RefPtr<HTMLFormControlElement> > AliasMap;
146
147 FormDataBuilder m_formDataBuilder;
148 AliasMap* m_elementAliases;
149 HTMLCollection::CollectionInfo* collectionInfo;
150
151 CheckedRadioButtons m_checkedRadioButtons;
152
153 Vector<HTMLImageElement*> imgElements;
154 String m_url;
155 String m_target;
156 bool m_autocomplete : 1;
157 bool m_insubmit : 1;
158 bool m_doingsubmit : 1;
159 bool m_inreset : 1;
160 bool m_malformed : 1;
161 AtomicString m_name;
162 };
163
164 } // namespace WebCore
165
166 #endif // HTMLFormElement_h