• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
endTagRequirement()41     virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
tagPriority()42     virtual int tagPriority() const { return 1; }
43 
form()44     HTMLFormElement* form() const { return m_form; }
45 
46     virtual const AtomicString& type() const = 0;
47 
isControl()48     virtual bool isControl() const { return true; }
isEnabled()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 
reset()56     virtual void reset() {}
57 
valueMatchesRenderer()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;
isEnumeratable()70     virtual bool isEnumeratable() const { return false; }
71 
isReadOnlyControl()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 
isFormControlElement()84     virtual bool isFormControlElement() const { return true; }
isRadioButton()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      */
appendFormData(FormDataList &,bool)90     virtual bool appendFormData(FormDataList&, bool) { return false; }
91 
isSuccessfulSubmitButton()92     virtual bool isSuccessfulSubmitButton() const { return false; }
isActivatedSubmit()93     virtual bool isActivatedSubmit() const { return false; }
setActivatedSubmit(bool)94     virtual void setActivatedSubmit(bool) { }
95 
96     virtual short tabIndex() const;
97 
98     virtual bool willValidate() const;
99 
formDestroyed()100     void formDestroyed() { m_form = 0; }
101 
102 protected:
103     void removeFromForm();
104 
105 private:
106     virtual HTMLFormElement* virtualForm() const;
107 
108     HTMLFormElement* m_form;
109     bool m_disabled;
110     bool m_readOnly;
111     bool m_valueMatchesRenderer;
112 };
113 
114 class HTMLFormControlElementWithState : public HTMLFormControlElement, public FormControlElementWithState  {
115 public:
116     HTMLFormControlElementWithState(const QualifiedName& tagName, Document*, HTMLFormElement*);
117     virtual ~HTMLFormControlElementWithState();
118 
isFormControlElementWithState()119     virtual bool isFormControlElementWithState() const { return true; }
120 
toFormControlElement()121     virtual FormControlElement* toFormControlElement() { return this; }
122     virtual void finishParsingChildren();
123 
124 protected:
125     virtual void willMoveToNewOwnerDocument();
126     virtual void didMoveToNewOwnerDocument();
127 };
128 
129 } //namespace
130 
131 #endif
132