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

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, 6 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/events/Event.h" 29 #include "core/events/Event.h"
30 #include "core/html/HTMLContentElement.h"
30 #include "core/html/HTMLFormControlElementWithState.h" 31 #include "core/html/HTMLFormControlElementWithState.h"
31 #include "core/html/HTMLOptionsCollection.h" 32 #include "core/html/HTMLOptionsCollection.h"
32 #include "core/html/forms/TypeAhead.h" 33 #include "core/html/forms/TypeAhead.h"
33 #include "wtf/Vector.h" 34 #include "wtf/Vector.h"
34 35
35 namespace WebCore { 36 namespace WebCore {
36 37
38 class AutoscrollController;
37 class ExceptionState; 39 class ExceptionState;
38 class HTMLOptionElement; 40 class HTMLOptionElement;
41 class MouseEvent;
39 42
40 class HTMLSelectElement FINAL : public HTMLFormControlElementWithState, public T ypeAheadDataSource { 43 class HTMLSelectElement FINAL : public HTMLFormControlElementWithState, public T ypeAheadDataSource {
41 public: 44 public:
42 static PassRefPtrWillBeRawPtr<HTMLSelectElement> create(Document&); 45 static PassRefPtrWillBeRawPtr<HTMLSelectElement> create(Document&);
43 static PassRefPtrWillBeRawPtr<HTMLSelectElement> create(Document&, HTMLFormE lement*); 46 static PassRefPtrWillBeRawPtr<HTMLSelectElement> create(Document&, HTMLFormE lement*);
44 47
45 int selectedIndex() const; 48 int selectedIndex() const;
46 void setSelectedIndex(int); 49 void setSelectedIndex(int);
47 int suggestedIndex() const; 50 int suggestedIndex() const;
48 void setSuggestedIndex(int); 51 void setSuggestedIndex(int);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 94
92 void setSize(int); 95 void setSize(int);
93 96
94 void setOption(unsigned index, HTMLOptionElement*, ExceptionState&); 97 void setOption(unsigned index, HTMLOptionElement*, ExceptionState&);
95 void setLength(unsigned, ExceptionState&); 98 void setLength(unsigned, ExceptionState&);
96 99
97 Element* namedItem(const AtomicString& name); 100 Element* namedItem(const AtomicString& name);
98 Element* item(unsigned index); 101 Element* item(unsigned index);
99 102
100 void scrollToSelection(); 103 void scrollToSelection();
104 void scrollTo(int listIndex);
101 105
102 void listBoxSelectItem(int listIndex, bool allowMultiplySelections, bool shi ft, bool fireOnChangeNow = true); 106 void listBoxSelectItem(int listIndex, bool allowMultiplySelections, bool shi ft, bool fireOnChangeNow = true);
103 107
104 bool canSelectAll() const; 108 bool canSelectAll() const;
105 void selectAll(); 109 void selectAll();
106 int listToOptionIndex(int listIndex) const; 110 int listToOptionIndex(int listIndex) const;
107 void listBoxOnChange(); 111 void listBoxOnChange();
108 int optionToListIndex(int optionIndex) const; 112 int optionToListIndex(int optionIndex) const;
109 int activeSelectionStartListIndex() const; 113 int activeSelectionStartListIndex() const;
110 int activeSelectionEndListIndex() const; 114 int activeSelectionEndListIndex() const;
111 void setActiveSelectionAnchorIndex(int); 115 void setActiveSelectionAnchorIndex(int);
112 void setActiveSelectionEndIndex(int); 116 void setActiveSelectionEndIndex(int);
113 void updateListBoxSelection(bool deselectOtherOptions); 117 void updateListBoxSelection(bool deselectOtherOptions);
114 118
115 // For use in the implementation of HTMLOptionElement. 119 // For use in the implementation of HTMLOptionElement.
116 void optionSelectionStateChanged(HTMLOptionElement*, bool optionIsSelected); 120 void optionSelectionStateChanged(HTMLOptionElement*, bool optionIsSelected);
121 void optionRemoved(HTMLOptionElement*);
117 bool anonymousIndexedSetter(unsigned, PassRefPtrWillBeRawPtr<HTMLOptionEleme nt>, ExceptionState&); 122 bool anonymousIndexedSetter(unsigned, PassRefPtrWillBeRawPtr<HTMLOptionEleme nt>, ExceptionState&);
118 123
119 void updateListOnRenderer(); 124 void updateListOnRenderer();
125 void updateView();
120 126
121 virtual void trace(Visitor*) OVERRIDE; 127 virtual void trace(Visitor*) OVERRIDE;
122 128
123 protected: 129 protected:
124 HTMLSelectElement(Document&, HTMLFormElement*); 130 HTMLSelectElement(Document&, HTMLFormElement*);
125 131
126 private: 132 private:
127 virtual const AtomicString& formControlType() const OVERRIDE; 133 virtual const AtomicString& formControlType() const OVERRIDE;
128 134
129 virtual bool shouldShowFocusRingOnMouseFocus() const OVERRIDE; 135 virtual bool shouldShowFocusRingOnMouseFocus() const OVERRIDE;
130 136
131 virtual void dispatchFocusEvent(Element* oldFocusedElement, FocusType) OVERR IDE; 137 virtual void dispatchFocusEvent(Element* oldFocusedElement, FocusType) OVERR IDE;
132 virtual void dispatchBlurEvent(Element* newFocusedElemnet) OVERRIDE; 138 virtual void dispatchBlurEvent(Element* newFocusedElemnet) OVERRIDE;
133 139
134 virtual bool canStartSelection() const OVERRIDE { return false; } 140 virtual bool canStartSelection() const OVERRIDE { return false; }
135 141
136 virtual bool isEnumeratable() const OVERRIDE { return true; } 142 virtual bool isEnumeratable() const OVERRIDE { return true; }
137 virtual bool isInteractiveContent() const OVERRIDE; 143 virtual bool isInteractiveContent() const OVERRIDE;
138 virtual bool supportsAutofocus() const OVERRIDE; 144 virtual bool supportsAutofocus() const OVERRIDE;
139 virtual bool supportLabels() const OVERRIDE { return true; } 145 virtual bool supportLabels() const OVERRIDE { return true; }
140 146
141 virtual FormControlState saveFormControlState() const OVERRIDE; 147 virtual FormControlState saveFormControlState() const OVERRIDE;
142 virtual void restoreFormControlState(const FormControlState&) OVERRIDE; 148 virtual void restoreFormControlState(const FormControlState&) OVERRIDE;
143 149
144 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE; 150 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE;
145 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE; 151 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
146 152
147 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; 153 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
148 virtual bool appendFormData(FormDataList&, bool) OVERRIDE; 154 virtual bool appendFormData(FormDataList&, bool) OVERRIDE;
155 virtual void didAddUserAgentShadowRoot(ShadowRoot&) OVERRIDE;
149 156
150 virtual void defaultEventHandler(Event*) OVERRIDE; 157 virtual void defaultEventHandler(Event*) OVERRIDE;
151 158
152 void dispatchInputAndChangeEventForMenuList(bool requiresUserGesture = true) ; 159 void dispatchInputAndChangeEventForMenuList(bool requiresUserGesture = true) ;
153 160
154 void recalcListItems(bool updateSelectedStates = true) const; 161 void recalcListItems(bool updateSelectedStates = true) const;
155 162
156 void typeAheadFind(KeyboardEvent*); 163 void typeAheadFind(KeyboardEvent*);
157 void saveLastSelection(); 164 void saveLastSelection();
158 165
(...skipping 24 matching lines...) Expand all
183 enum SkipDirection { 190 enum SkipDirection {
184 SkipBackwards = -1, 191 SkipBackwards = -1,
185 SkipForwards = 1 192 SkipForwards = 1
186 }; 193 };
187 int nextValidIndex(int listIndex, SkipDirection, int skip) const; 194 int nextValidIndex(int listIndex, SkipDirection, int skip) const;
188 int nextSelectableListIndex(int startIndex) const; 195 int nextSelectableListIndex(int startIndex) const;
189 int previousSelectableListIndex(int startIndex) const; 196 int previousSelectableListIndex(int startIndex) const;
190 int firstSelectableListIndex() const; 197 int firstSelectableListIndex() const;
191 int lastSelectableListIndex() const; 198 int lastSelectableListIndex() const;
192 int nextSelectableListIndexPageAway(int startIndex, SkipDirection) const; 199 int nextSelectableListIndexPageAway(int startIndex, SkipDirection) const;
200 int listIndexForMouseEvent(const MouseEvent&);
201 int listIndexForEvent(const Event&);
202 int listIndexForNode(const Node&);
203 AutoscrollController* autoscrollController() const;
193 204
194 virtual void childrenChanged(bool changedByParser = false, Node* beforeChang e = 0, Node* afterChange = 0, int childCountDelta = 0) OVERRIDE; 205 virtual void childrenChanged(bool changedByParser = false, Node* beforeChang e = 0, Node* afterChange = 0, int childCountDelta = 0) OVERRIDE;
195 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } 206 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
196 virtual void finishParsingChildren() OVERRIDE; 207 virtual void finishParsingChildren() OVERRIDE;
197 208
198 // TypeAheadDataSource functions. 209 // TypeAheadDataSource functions.
199 virtual int indexOfSelectedOption() const OVERRIDE; 210 virtual int indexOfSelectedOption() const OVERRIDE;
200 virtual int optionCount() const OVERRIDE; 211 virtual int optionCount() const OVERRIDE;
201 virtual String optionAtIndex(int index) const OVERRIDE; 212 virtual String optionAtIndex(int index) const OVERRIDE;
202 213
203 // m_listItems contains HTMLOptionElement, HTMLOptGroupElement, and HTMLHREl ement objects. 214 // m_listItems contains HTMLOptionElement, HTMLOptGroupElement, and HTMLHREl ement objects.
204 mutable WillBeHeapVector<RawPtrWillBeMember<HTMLElement> > m_listItems; 215 mutable WillBeHeapVector<RawPtrWillBeMember<HTMLElement> > m_listItems;
205 Vector<bool> m_lastOnChangeSelection; 216 Vector<bool> m_lastOnChangeSelection;
206 Vector<bool> m_cachedStateForActiveSelection; 217 Vector<bool> m_cachedStateForActiveSelection;
207 TypeAhead m_typeAhead; 218 TypeAhead m_typeAhead;
208 int m_size; 219 int m_size;
209 int m_lastOnChangeIndex; 220 int m_lastOnChangeIndex;
210 int m_activeSelectionAnchorIndex; 221 int m_activeSelectionAnchorIndex;
211 int m_activeSelectionEndIndex; 222 int m_activeSelectionEndIndex;
212 bool m_isProcessingUserDrivenChange; 223 bool m_isProcessingUserDrivenChange;
213 bool m_multiple; 224 bool m_multiple;
214 bool m_activeSelectionState; 225 bool m_activeSelectionState;
215 mutable bool m_shouldRecalcListItems; 226 mutable bool m_shouldRecalcListItems;
216 int m_suggestedIndex; 227 int m_suggestedIndex;
228 bool m_capturing;
217 }; 229 };
218 230
219 } // namespace 231 } // namespace
220 232
221 #endif 233 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698