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 HTMLGenericFormElement_h
25 #define HTMLGenericFormElement_h
27 #include "HTMLElement.h"
32 class HTMLFormElement;
34 // FIXME: Rename this class to HTMLFormControlElement.
35 class HTMLGenericFormElement : public HTMLElement {
37 HTMLGenericFormElement(const QualifiedName& tagName, Document*, HTMLFormElement*);
38 virtual ~HTMLGenericFormElement();
40 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
41 virtual int tagPriority() const { return 1; }
43 HTMLFormElement* form() const { return m_form; }
45 virtual const AtomicString& type() const = 0;
47 virtual bool isControl() const { return true; }
48 virtual bool isEnabled() const { return !disabled(); }
50 virtual void parseMappedAttribute(MappedAttribute*);
51 virtual void attach();
52 virtual void insertedIntoTree(bool deep);
53 virtual void removedFromTree(bool deep);
55 virtual void reset() {}
57 bool valueMatchesRenderer() const { return m_valueMatchesRenderer; }
58 void setValueMatchesRenderer(bool b = true) const { m_valueMatchesRenderer = b; }
62 bool disabled() const;
63 void setDisabled(bool);
65 virtual bool supportsFocus() const;
66 virtual bool isFocusable() const;
67 virtual bool isKeyboardFocusable(KeyboardEvent*) const;
68 virtual bool isMouseFocusable() const;
69 virtual bool isEnumeratable() const { return false; }
71 virtual bool isReadOnlyControl() const { return m_readOnly; }
72 void setReadOnly(bool);
74 virtual void recalcStyle(StyleChange);
76 virtual const AtomicString& name() const;
77 void setName(const AtomicString& name);
79 virtual bool isGenericFormElement() const { return true; }
80 virtual bool isRadioButton() const { return false; }
82 /* Override in derived classes to get the encoded name=value pair for submitting.
83 * Return true for a successful control (see HTML4-17.13.2).
85 virtual bool appendFormData(FormDataList&, bool) { return false; }
87 virtual bool isSuccessfulSubmitButton() const { return false; }
88 virtual bool isActivatedSubmit() const { return false; }
89 virtual void setActivatedSubmit(bool flag) { }
91 void setTabIndex(int);
93 void formDestroyed() { m_form = 0; }
96 void removeFromForm();
99 virtual HTMLFormElement* virtualForm() const;
101 HTMLFormElement* m_form;
104 mutable bool m_valueMatchesRenderer;
107 class HTMLFormControlElementWithState : public HTMLGenericFormElement {
109 HTMLFormControlElementWithState(const QualifiedName& tagName, Document*, HTMLFormElement*);
110 virtual ~HTMLFormControlElementWithState();
112 virtual void finishedParsing();
114 virtual bool saveState(String& value) const = 0;
117 virtual void willMoveToNewOwnerDocument();
118 virtual void didMoveToNewOwnerDocument();
121 virtual void restoreState(const String& value) = 0;