Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: Source/core/html/HTMLSelectElement.h

Issue 347773002: Implement select listbox using shadow DOM (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * (C) 1999 Antti Koivisto (koivisto@kde.org)
5 * (C) 2000 Dirk Mueller (mueller@kde.org) 5 * (C) 2000 Dirk Mueller (mueller@kde.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either 11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version. 12 * version 2 of the License, or (at your option) any later version.
13 * 13 *
14 * This library is distributed in the hope that it will be useful, 14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details. 17 * Library General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU Library General Public License 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 20 * along with this library; see the file COPYING.LIB. If not, write to
21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA. 22 * Boston, MA 02110-1301, USA.
23 * 23 *
24 */ 24 */
25 25
26 #ifndef HTMLSelectElement_h 26 #ifndef HTMLSelectElement_h
27 #define HTMLSelectElement_h 27 #define HTMLSelectElement_h
28 28
29 #include "core/html/HTMLContentElement.h"
29 #include "core/html/HTMLFormControlElementWithState.h" 30 #include "core/html/HTMLFormControlElementWithState.h"
30 #include "core/html/HTMLOptionsCollection.h" 31 #include "core/html/HTMLOptionsCollection.h"
31 #include "core/html/forms/TypeAhead.h" 32 #include "core/html/forms/TypeAhead.h"
32 #include "wtf/Vector.h" 33 #include "wtf/Vector.h"
33 34
34 namespace WebCore { 35 namespace WebCore {
35 36
37 class AutoscrollController;
36 class ExceptionState; 38 class ExceptionState;
37 class HTMLOptionElement; 39 class HTMLOptionElement;
40 class MouseEvent;
38 41
39 class HTMLSelectElement FINAL : public HTMLFormControlElementWithState, public T ypeAheadDataSource { 42 class HTMLSelectElement FINAL : public HTMLFormControlElementWithState, public T ypeAheadDataSource {
40 public: 43 public:
41 static PassRefPtrWillBeRawPtr<HTMLSelectElement> create(Document&); 44 static PassRefPtrWillBeRawPtr<HTMLSelectElement> create(Document&);
42 static PassRefPtrWillBeRawPtr<HTMLSelectElement> create(Document&, HTMLFormE lement*); 45 static PassRefPtrWillBeRawPtr<HTMLSelectElement> create(Document&, HTMLFormE lement*);
43 46
44 int selectedIndex() const; 47 int selectedIndex() const;
45 void setSelectedIndex(int); 48 void setSelectedIndex(int);
46 int suggestedIndex() const; 49 int suggestedIndex() const;
47 void setSuggestedIndex(int); 50 void setSuggestedIndex(int);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 93
91 void setSize(int); 94 void setSize(int);
92 95
93 void setOption(unsigned index, HTMLOptionElement*, ExceptionState&); 96 void setOption(unsigned index, HTMLOptionElement*, ExceptionState&);
94 void setLength(unsigned, ExceptionState&); 97 void setLength(unsigned, ExceptionState&);
95 98
96 Element* namedItem(const AtomicString& name); 99 Element* namedItem(const AtomicString& name);
97 Element* item(unsigned index); 100 Element* item(unsigned index);
98 101
99 void scrollToSelection(); 102 void scrollToSelection();
103 void scrollTo(int listIndex);
100 104
101 void listBoxSelectItem(int listIndex, bool allowMultiplySelections, bool shi ft, bool fireOnChangeNow = true); 105 void listBoxSelectItem(int listIndex, bool allowMultiplySelections, bool shi ft, bool fireOnChangeNow = true);
102 106
103 bool canSelectAll() const; 107 bool canSelectAll() const;
104 void selectAll(); 108 void selectAll();
105 int listToOptionIndex(int listIndex) const; 109 int listToOptionIndex(int listIndex) const;
106 void listBoxOnChange(); 110 void listBoxOnChange();
107 int optionToListIndex(int optionIndex) const; 111 int optionToListIndex(int optionIndex) const;
108 int activeSelectionStartListIndex() const; 112 int activeSelectionStartListIndex() const;
109 int activeSelectionEndListIndex() const; 113 int activeSelectionEndListIndex() const;
110 void setActiveSelectionAnchorIndex(int); 114 void setActiveSelectionAnchorIndex(int);
111 void setActiveSelectionEndIndex(int); 115 void setActiveSelectionEndIndex(int);
112 void updateListBoxSelection(bool deselectOtherOptions); 116 void updateListBoxSelection(bool deselectOtherOptions);
113 117
114 // For use in the implementation of HTMLOptionElement. 118 // For use in the implementation of HTMLOptionElement.
115 void optionSelectionStateChanged(HTMLOptionElement*, bool optionIsSelected); 119 void optionSelectionStateChanged(HTMLOptionElement*, bool optionIsSelected);
120 void optionRemoved(HTMLOptionElement*);
116 bool anonymousIndexedSetter(unsigned, PassRefPtrWillBeRawPtr<HTMLOptionEleme nt>, ExceptionState&); 121 bool anonymousIndexedSetter(unsigned, PassRefPtrWillBeRawPtr<HTMLOptionEleme nt>, ExceptionState&);
117 122
118 void updateListOnRenderer(); 123 void updateListOnRenderer();
119 124
120 virtual void trace(Visitor*) OVERRIDE; 125 virtual void trace(Visitor*) OVERRIDE;
121 126
122 protected: 127 protected:
123 HTMLSelectElement(Document&, HTMLFormElement*); 128 HTMLSelectElement(Document&, HTMLFormElement*);
124 129
125 private: 130 private:
(...skipping 12 matching lines...) Expand all
138 virtual bool supportLabels() const OVERRIDE { return true; } 143 virtual bool supportLabels() const OVERRIDE { return true; }
139 144
140 virtual FormControlState saveFormControlState() const OVERRIDE; 145 virtual FormControlState saveFormControlState() const OVERRIDE;
141 virtual void restoreFormControlState(const FormControlState&) OVERRIDE; 146 virtual void restoreFormControlState(const FormControlState&) OVERRIDE;
142 147
143 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE; 148 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE;
144 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE; 149 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
145 150
146 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; 151 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
147 virtual bool appendFormData(FormDataList&, bool) OVERRIDE; 152 virtual bool appendFormData(FormDataList&, bool) OVERRIDE;
153 virtual void didAddUserAgentShadowRoot(ShadowRoot&) OVERRIDE;
148 154
149 virtual void defaultEventHandler(Event*) OVERRIDE; 155 virtual void defaultEventHandler(Event*) OVERRIDE;
150 156
151 void dispatchInputAndChangeEventForMenuList(bool requiresUserGesture = true) ; 157 void dispatchInputAndChangeEventForMenuList(bool requiresUserGesture = true) ;
152 158
153 void recalcListItems(bool updateSelectedStates = true) const; 159 void recalcListItems(bool updateSelectedStates = true) const;
154 160
155 void typeAheadFind(KeyboardEvent*); 161 void typeAheadFind(KeyboardEvent*);
156 void saveLastSelection(); 162 void saveLastSelection();
157 163
(...skipping 24 matching lines...) Expand all
182 enum SkipDirection { 188 enum SkipDirection {
183 SkipBackwards = -1, 189 SkipBackwards = -1,
184 SkipForwards = 1 190 SkipForwards = 1
185 }; 191 };
186 int nextValidIndex(int listIndex, SkipDirection, int skip) const; 192 int nextValidIndex(int listIndex, SkipDirection, int skip) const;
187 int nextSelectableListIndex(int startIndex) const; 193 int nextSelectableListIndex(int startIndex) const;
188 int previousSelectableListIndex(int startIndex) const; 194 int previousSelectableListIndex(int startIndex) const;
189 int firstSelectableListIndex() const; 195 int firstSelectableListIndex() const;
190 int lastSelectableListIndex() const; 196 int lastSelectableListIndex() const;
191 int nextSelectableListIndexPageAway(int startIndex, SkipDirection) const; 197 int nextSelectableListIndexPageAway(int startIndex, SkipDirection) const;
198 int listIndexForEventTargetOption(const Event&);
199 int listIndexForOption(const HTMLOptionElement&);
200 AutoscrollController* autoscrollController() const;
192 201
193 virtual void childrenChanged(bool changedByParser = false, Node* beforeChang e = 0, Node* afterChange = 0, int childCountDelta = 0) OVERRIDE; 202 virtual void childrenChanged(bool changedByParser = false, Node* beforeChang e = 0, Node* afterChange = 0, int childCountDelta = 0) OVERRIDE;
194 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } 203 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
195 virtual void finishParsingChildren() OVERRIDE; 204 virtual void finishParsingChildren() OVERRIDE;
196 205
197 // TypeAheadDataSource functions. 206 // TypeAheadDataSource functions.
198 virtual int indexOfSelectedOption() const OVERRIDE; 207 virtual int indexOfSelectedOption() const OVERRIDE;
199 virtual int optionCount() const OVERRIDE; 208 virtual int optionCount() const OVERRIDE;
200 virtual String optionAtIndex(int index) const OVERRIDE; 209 virtual String optionAtIndex(int index) const OVERRIDE;
201 210
202 // m_listItems contains HTMLOptionElement, HTMLOptGroupElement, and HTMLHREl ement objects. 211 // m_listItems contains HTMLOptionElement, HTMLOptGroupElement, and HTMLHREl ement objects.
203 mutable WillBeHeapVector<RawPtrWillBeMember<HTMLElement> > m_listItems; 212 mutable WillBeHeapVector<RawPtrWillBeMember<HTMLElement> > m_listItems;
204 Vector<bool> m_lastOnChangeSelection; 213 Vector<bool> m_lastOnChangeSelection;
205 Vector<bool> m_cachedStateForActiveSelection; 214 Vector<bool> m_cachedStateForActiveSelection;
206 TypeAhead m_typeAhead; 215 TypeAhead m_typeAhead;
207 int m_size; 216 int m_size;
208 int m_lastOnChangeIndex; 217 int m_lastOnChangeIndex;
209 int m_activeSelectionAnchorIndex; 218 int m_activeSelectionAnchorIndex;
210 int m_activeSelectionEndIndex; 219 int m_activeSelectionEndIndex;
211 bool m_isProcessingUserDrivenChange; 220 bool m_isProcessingUserDrivenChange;
212 bool m_multiple; 221 bool m_multiple;
213 bool m_activeSelectionState; 222 bool m_activeSelectionState;
214 mutable bool m_shouldRecalcListItems; 223 mutable bool m_shouldRecalcListItems;
215 int m_suggestedIndex; 224 int m_suggestedIndex;
216 }; 225 };
217 226
218 } // namespace 227 } // namespace
219 228
220 #endif 229 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698