2 * This file is part of the DOM implementation for KDE.
4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
5 * (C) 1999 Antti Koivisto (koivisto@kde.org)
6 * (C) 2000 Dirk Mueller (mueller@kde.org)
7 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public License
20 * along with this library; see the file COPYING.LIB. If not, write to
21 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
26 #ifndef HTML_HTMLGenericFormElementImpl_h
27 #define HTML_HTMLGenericFormElementImpl_h
30 #include "HTMLElement.h"
35 class HTMLFormElement;
36 class RenderFormElement;
38 class HTMLGenericFormElement : public HTMLElement
40 friend class HTMLFormElement;
41 friend class RenderFormElement;
44 HTMLGenericFormElement(const QualifiedName& tagName, Document*, HTMLFormElement* = 0);
45 virtual ~HTMLGenericFormElement();
47 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
48 virtual int tagPriority() const { return 1; }
50 HTMLFormElement* form() const { return m_form; }
52 virtual const AtomicString& type() const = 0;
54 virtual bool isControl() const { return true; }
55 virtual bool isEnabled() const { return !disabled(); }
57 virtual void parseMappedAttribute(MappedAttribute*);
58 virtual void attach();
59 virtual void insertedIntoTree(bool deep);
60 virtual void removedFromTree(bool deep);
61 virtual void closeRenderer();
63 virtual void reset() {}
65 bool valueMatchesRenderer() const { return m_valueMatchesRenderer; }
66 void setValueMatchesRenderer(bool b = true) const { m_valueMatchesRenderer = b; }
71 bool disabled() const;
72 void setDisabled(bool);
74 virtual bool supportsFocus() const { return isFocusable() || (!disabled() && document() && !document()->haveStylesheetsLoaded()); }
75 virtual bool isFocusable() const;
76 virtual bool isKeyboardFocusable(KeyboardEvent*) const;
77 virtual bool isMouseFocusable() const;
78 virtual bool isEnumeratable() const { return false; }
80 virtual bool isReadOnlyControl() const { return m_readOnly; }
81 void setReadOnly(bool);
83 virtual void recalcStyle(StyleChange);
85 virtual const AtomicString& name() const;
86 void setName(const AtomicString& name);
88 virtual bool isGenericFormElement() const { return true; }
89 virtual bool isRadioButton() const { return false; }
91 /* Override in derived classes to get the encoded name=value pair for submitting.
92 * Return true for a successful control (see HTML4-17.13.2).
94 virtual bool appendFormData(FormDataList&, bool) { return false; }
96 virtual String stateValue() const;
97 virtual void restoreState(const String& value);
99 virtual bool isSuccessfulSubmitButton() const { return false; }
100 virtual bool isActivatedSubmit() const { return false; }
101 virtual void setActivatedSubmit(bool flag) { }
103 int tabIndex() const;
104 void setTabIndex(int);
107 HTMLFormElement* getForm() const;
110 HTMLFormElement* m_form;
113 mutable bool m_valueMatchesRenderer;