• 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, 2009 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 HTMLSelectElement_h
25 #define HTMLSelectElement_h
26 
27 #include "CollectionCache.h"
28 #include "HTMLFormControlElement.h"
29 #include "SelectElement.h"
30 
31 namespace WebCore {
32 
33 class HTMLOptionElement;
34 class HTMLOptionsCollection;
35 class KeyboardEvent;
36 
37 class HTMLSelectElement : public HTMLFormControlElementWithState, public SelectElement {
38 public:
39     HTMLSelectElement(const QualifiedName&, Document*, HTMLFormElement* = 0);
40 
41     virtual int selectedIndex() const;
42     virtual void setSelectedIndex(int index, bool deselect = true);
43     virtual void setSelectedIndexByUser(int index, bool deselect = true, bool fireOnChangeNow = false);
44 
45     unsigned length() const;
46 
size()47     virtual int size() const { return m_data.size(); }
multiple()48     virtual bool multiple() const { return m_data.multiple(); }
49 
50     void add(HTMLElement* element, HTMLElement* before, ExceptionCode&);
51     void remove(int index);
52 
53     String value();
54     void setValue(const String&);
55 
56     PassRefPtr<HTMLOptionsCollection> options();
57 
58     virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
59 
60     void setRecalcListItems();
61 
listItems()62     virtual const Vector<Element*>& listItems() const { return m_data.listItems(this); }
63 
64     virtual void accessKeyAction(bool sendToAnyElement);
65     void accessKeySetSelectedIndex(int);
66 
67     void setMultiple(bool);
68 
69     void setSize(int);
70 
71     void setOption(unsigned index, HTMLOptionElement*, ExceptionCode&);
72     void setLength(unsigned, ExceptionCode&);
73 
74     Node* namedItem(const AtomicString& name);
75     Node* item(unsigned index);
76 
collectionInfo()77     CollectionCache* collectionInfo() { return &m_collectionInfo; }
78 
79     void scrollToSelection();
80 
81 private:
tagPriority()82     virtual int tagPriority() const { return 6; }
83     virtual bool checkDTD(const Node* newChild);
84 
85     virtual const AtomicString& formControlType() const;
86 
87     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
88     virtual bool isMouseFocusable() const;
89     virtual bool canSelectAll() const;
90     virtual void selectAll();
91 
92     virtual void recalcStyle(StyleChange);
93 
94     virtual void dispatchFocusEvent();
95     virtual void dispatchBlurEvent();
96 
canStartSelection()97     virtual bool canStartSelection() const { return false; }
98 
isEnumeratable()99     virtual bool isEnumeratable() const { return true; }
100 
101     virtual bool saveFormControlState(String& value) const;
102     virtual void restoreFormControlState(const String&);
103 
104     virtual void parseMappedAttribute(MappedAttribute*);
105 
106     virtual RenderObject* createRenderer(RenderArena*, RenderStyle *);
107     virtual bool appendFormData(FormDataList&, bool);
108 
109     virtual int listToOptionIndex(int listIndex) const;
110     virtual int optionToListIndex(int optionIndex) const;
111 
112     virtual void reset();
113 
114     virtual void defaultEventHandler(Event*);
115 
116     virtual void setActiveSelectionAnchorIndex(int index);
117     virtual void setActiveSelectionEndIndex(int index);
118     virtual void updateListBoxSelection(bool deselectOtherOptions);
119     virtual void listBoxOnChange();
120     virtual void menuListOnChange();
121 
122     virtual int activeSelectionStartListIndex() const;
123     virtual int activeSelectionEndListIndex() const;
124 
125     void recalcListItems(bool updateSelectedStates = true) const;
126 
127     void deselectItems(HTMLOptionElement* excludeElement = 0);
128     void typeAheadFind(KeyboardEvent*);
129     void saveLastSelection();
130 
131     virtual void insertedIntoTree(bool);
132 
isOptionalFormControl()133     virtual bool isOptionalFormControl() const { return true; }
134 
135     SelectElementData m_data;
136     CollectionCache m_collectionInfo;
137 };
138 
139 } // namespace
140 
141 #endif
142