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.
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 HTMLFormControlElement_h
25 #define HTMLFormControlElement_h
27 #include "FormControlElement.h"
28 #include "FormControlElementWithState.h"
29 #include "HTMLElement.h"
34 class HTMLFormElement
;
36 class HTMLFormControlElement
: public HTMLElement
, public FormControlElement
{
38 HTMLFormControlElement(const QualifiedName
& tagName
, Document
*, HTMLFormElement
*);
39 virtual ~HTMLFormControlElement();
41 virtual HTMLTagStatus
endTagRequirement() const { return TagStatusRequired
; }
42 virtual int tagPriority() const { return 1; }
44 HTMLFormElement
* form() const { return m_form
; }
46 virtual const AtomicString
& type() const = 0;
48 virtual bool isControl() const { return true; }
49 virtual bool isEnabled() const { return !disabled(); }
51 virtual void parseMappedAttribute(MappedAttribute
*);
52 virtual void attach();
53 virtual void insertedIntoTree(bool deep
);
54 virtual void removedFromTree(bool deep
);
56 virtual void reset() {}
58 virtual bool valueMatchesRenderer() const { return m_valueMatchesRenderer
; }
59 virtual void setValueMatchesRenderer(bool b
= true) { m_valueMatchesRenderer
= b
; }
63 bool disabled() const;
64 void setDisabled(bool);
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; }
72 virtual bool isReadOnlyControl() const { return m_readOnly
; }
73 void setReadOnly(bool);
75 // Determines whether or not a control will be automatically focused
76 virtual bool autofocus() const;
77 void setAutofocus(bool);
79 virtual void recalcStyle(StyleChange
);
81 virtual const AtomicString
& name() const;
82 void setName(const AtomicString
& name
);
84 virtual bool isFormControlElement() const { return true; }
85 virtual bool isRadioButton() const { return false; }
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).
90 virtual bool appendFormData(FormDataList
&, bool) { return false; }
92 virtual bool isSuccessfulSubmitButton() const { return false; }
93 virtual bool isActivatedSubmit() const { return false; }
94 virtual void setActivatedSubmit(bool) { }
96 virtual short tabIndex() const;
98 virtual void dispatchFocusEvent();
99 virtual void dispatchBlurEvent();
101 bool autocorrect() const;
102 void setAutocorrect(bool);
104 bool autocapitalize() const;
105 void setAutocapitalize(bool);
107 virtual bool willValidate() const;
109 void formDestroyed() { m_form
= 0; }
112 void removeFromForm();
115 virtual HTMLFormElement
* virtualForm() const;
117 HTMLFormElement
* m_form
;
120 bool m_valueMatchesRenderer
;
123 class HTMLFormControlElementWithState
: public HTMLFormControlElement
, public FormControlElementWithState
{
125 HTMLFormControlElementWithState(const QualifiedName
& tagName
, Document
*, HTMLFormElement
*);
126 virtual ~HTMLFormControlElementWithState();
128 virtual bool isFormControlElementWithState() const { return true; }
130 virtual FormControlElement
* toFormControlElement() { return this; }
131 virtual void finishParsingChildren();
134 virtual void willMoveToNewOwnerDocument();
135 virtual void didMoveToNewOwnerDocument();