~ubuntu-branches/ubuntu/maverick/webkit/maverick

« back to all changes in this revision

Viewing changes to WebCore/html/HTMLSelectElement.h

  • Committer: Bazaar Package Importer
  • Author(s): Mike Hommey
  • Date: 2007-08-19 15:54:12 UTC
  • Revision ID: james.westby@ubuntu.com-20070819155412-uxxg1h9plpghmtbi
Tags: upstream-0~svn25144
ImportĀ upstreamĀ versionĀ 0~svn25144

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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., 59 Temple Place - Suite 330,
 
20
 * Boston, MA 02111-1307, USA.
 
21
 *
 
22
 */
 
23
 
 
24
#ifndef HTMLSelectElement_h
 
25
#define HTMLSelectElement_h
 
26
 
 
27
#include "Event.h"
 
28
#include "HTMLCollection.h"
 
29
#include "HTMLGenericFormElement.h"
 
30
#include <wtf/Vector.h>
 
31
 
 
32
namespace WebCore {
 
33
 
 
34
class HTMLOptionElement;
 
35
class HTMLOptionsCollection;
 
36
class KeyboardEvent;
 
37
 
 
38
class HTMLSelectElement : public HTMLFormControlElementWithState {
 
39
public:
 
40
    HTMLSelectElement(Document*, HTMLFormElement* = 0);
 
41
    HTMLSelectElement(const QualifiedName& tagName, Document*, HTMLFormElement* = 0);
 
42
 
 
43
    virtual int tagPriority() const { return 6; }
 
44
    virtual bool checkDTD(const Node* newChild);
 
45
 
 
46
    virtual const AtomicString& type() const;
 
47
    
 
48
    virtual bool isKeyboardFocusable(KeyboardEvent*) const;
 
49
    virtual bool isMouseFocusable() const;
 
50
    virtual bool canSelectAll() const;
 
51
    virtual void selectAll();
 
52
 
 
53
    virtual void recalcStyle(StyleChange);
 
54
 
 
55
    virtual void dispatchFocusEvent();
 
56
    virtual void dispatchBlurEvent();
 
57
 
 
58
    int selectedIndex() const;
 
59
    void setSelectedIndex(int index, bool deselect = true, bool fireOnChange = false);
 
60
    int lastSelectedListIndex() const;
 
61
 
 
62
    virtual bool isEnumeratable() const { return true; }
 
63
 
 
64
    unsigned length() const;
 
65
 
 
66
    int minWidth() const { return m_minwidth; }
 
67
 
 
68
    int size() const { return m_size; }
 
69
 
 
70
    bool multiple() const { return m_multiple; }
 
71
 
 
72
    void add(HTMLElement* element, HTMLElement* before, ExceptionCode&);
 
73
    void remove(int index);
 
74
 
 
75
    String value();
 
76
    void setValue(const String&);
 
77
    
 
78
    PassRefPtr<HTMLOptionsCollection> options();
 
79
 
 
80
    virtual bool saveState(String& value) const;
 
81
    virtual void restoreState(const String&);
 
82
 
 
83
    virtual bool insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode&);
 
84
    virtual bool replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode&);
 
85
    virtual bool removeChild(Node* child, ExceptionCode&);
 
86
    virtual bool appendChild(PassRefPtr<Node> newChild, ExceptionCode&);
 
87
    virtual ContainerNode* addChild(PassRefPtr<Node>);
 
88
 
 
89
    virtual void childrenChanged();
 
90
 
 
91
    virtual void parseMappedAttribute(MappedAttribute*);
 
92
 
 
93
    virtual RenderObject* createRenderer(RenderArena*, RenderStyle *);
 
94
    virtual bool appendFormData(FormDataList&, bool);
 
95
 
 
96
    // get the actual listbox index of the optionIndexth option
 
97
    int optionToListIndex(int optionIndex) const;
 
98
    // reverse of optionToListIndex - get optionIndex from listboxIndex
 
99
    int listToOptionIndex(int listIndex) const;
 
100
 
 
101
    void setRecalcListItems();
 
102
 
 
103
    const Vector<HTMLElement*>& listItems() const
 
104
    {
 
105
        if (m_recalcListItems)
 
106
            recalcListItems();
 
107
        return m_listItems;
 
108
    }
 
109
    virtual void reset();
 
110
 
 
111
    virtual void defaultEventHandler(Event*);
 
112
    virtual void accessKeyAction(bool sendToAnyElement);
 
113
 
 
114
    void setMultiple(bool);
 
115
 
 
116
    void setSize(int);
 
117
 
 
118
    void setOption(unsigned index, HTMLOptionElement*, ExceptionCode&);
 
119
    void setLength(unsigned, ExceptionCode&);
 
120
 
 
121
    Node* namedItem(const String& name, bool caseSensitive = true);
 
122
    Node* item(unsigned index);
 
123
 
 
124
    HTMLCollection::CollectionInfo* collectionInfo() { return &m_collectionInfo; }
 
125
    
 
126
    void setActiveSelectionAnchorIndex(int index);
 
127
    void setActiveSelectionEndIndex(int index) { m_activeSelectionEndIndex = index; }
 
128
    void updateListBoxSelection(bool deselectOtherOptions);
 
129
    void listBoxOnChange();
 
130
    void menuListOnChange();
 
131
    
 
132
    int activeSelectionStartListIndex() const;
 
133
    int activeSelectionEndListIndex() const;
 
134
    
 
135
    void scrollToSelection();
 
136
 
 
137
private:
 
138
    void recalcListItems() const;
 
139
    void deselectItems(HTMLOptionElement* excludeElement = 0);
 
140
    bool usesMenuList() const { return !m_multiple && m_size <= 1; }
 
141
    int nextSelectableListIndex(int startIndex);
 
142
    int previousSelectableListIndex(int startIndex);
 
143
    void menuListDefaultEventHandler(Event*);
 
144
    void listBoxDefaultEventHandler(Event*);
 
145
    void typeAheadFind(KeyboardEvent*);
 
146
    void saveLastSelection();
 
147
 
 
148
    mutable Vector<HTMLElement*> m_listItems;
 
149
    Vector<bool> m_cachedStateForActiveSelection;
 
150
    Vector<bool> m_lastOnChangeSelection;
 
151
    int m_minwidth;
 
152
    int m_size;
 
153
    bool m_multiple;
 
154
    mutable bool m_recalcListItems;
 
155
    mutable int m_lastOnChangeIndex;
 
156
 
 
157
    int m_activeSelectionAnchorIndex;
 
158
    int m_activeSelectionEndIndex;
 
159
    bool m_activeSelectionState;
 
160
 
 
161
    // Instance variables for type-ahead find
 
162
    UChar m_repeatingChar;
 
163
    DOMTimeStamp m_lastCharTime;
 
164
    String m_typedString;
 
165
 
 
166
    HTMLCollection::CollectionInfo m_collectionInfo;
 
167
};
 
168
 
 
169
} // namespace
 
170
 
 
171
#endif