OLD | NEW |
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 |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "core/html/HTMLOptionsCollection.h" | 31 #include "core/html/HTMLOptionsCollection.h" |
32 #include "core/html/forms/TypeAhead.h" | 32 #include "core/html/forms/TypeAhead.h" |
33 #include "wtf/Vector.h" | 33 #include "wtf/Vector.h" |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
37 class AutoscrollController; | 37 class AutoscrollController; |
38 class ExceptionState; | 38 class ExceptionState; |
39 class HTMLOptionElement; | 39 class HTMLOptionElement; |
40 | 40 |
41 class HTMLSelectElement FINAL : public HTMLFormControlElementWithState, public T
ypeAheadDataSource { | 41 class HTMLSelectElement final : public HTMLFormControlElementWithState, public T
ypeAheadDataSource { |
42 DEFINE_WRAPPERTYPEINFO(); | 42 DEFINE_WRAPPERTYPEINFO(); |
43 public: | 43 public: |
44 static PassRefPtrWillBeRawPtr<HTMLSelectElement> create(Document&); | 44 static PassRefPtrWillBeRawPtr<HTMLSelectElement> create(Document&); |
45 static PassRefPtrWillBeRawPtr<HTMLSelectElement> create(Document&, HTMLFormE
lement*); | 45 static PassRefPtrWillBeRawPtr<HTMLSelectElement> create(Document&, HTMLFormE
lement*); |
46 | 46 |
47 int selectedIndex() const; | 47 int selectedIndex() const; |
48 void setSelectedIndex(int); | 48 void setSelectedIndex(int); |
49 int suggestedIndex() const; | 49 int suggestedIndex() const; |
50 void setSuggestedIndex(int); | 50 void setSuggestedIndex(int); |
51 | 51 |
52 void optionSelectedByUser(int index, bool dispatchChangeEvent, bool allowMul
tipleSelection = false); | 52 void optionSelectedByUser(int index, bool dispatchChangeEvent, bool allowMul
tipleSelection = false); |
53 | 53 |
54 // For ValidityState | 54 // For ValidityState |
55 virtual String validationMessage() const OVERRIDE; | 55 virtual String validationMessage() const override; |
56 virtual bool valueMissing() const OVERRIDE; | 56 virtual bool valueMissing() const override; |
57 | 57 |
58 virtual void resetImpl() OVERRIDE; | 58 virtual void resetImpl() override; |
59 | 59 |
60 unsigned length() const; | 60 unsigned length() const; |
61 | 61 |
62 int size() const { return m_size; } | 62 int size() const { return m_size; } |
63 bool multiple() const { return m_multiple; } | 63 bool multiple() const { return m_multiple; } |
64 | 64 |
65 bool usesMenuList() const; | 65 bool usesMenuList() const; |
66 | 66 |
67 void add(HTMLElement*, HTMLElement* beforeElement, ExceptionState&); | 67 void add(HTMLElement*, HTMLElement* beforeElement, ExceptionState&); |
68 void addBeforeOptionAtIndex(HTMLElement*, int beforeIndex, ExceptionState&); | 68 void addBeforeOptionAtIndex(HTMLElement*, int beforeIndex, ExceptionState&); |
(...skipping 10 matching lines...) Expand all Loading... |
79 PassRefPtrWillBeRawPtr<HTMLCollection> selectedOptions(); | 79 PassRefPtrWillBeRawPtr<HTMLCollection> selectedOptions(); |
80 | 80 |
81 void optionElementChildrenChanged(); | 81 void optionElementChildrenChanged(); |
82 | 82 |
83 void setRecalcListItems(); | 83 void setRecalcListItems(); |
84 void invalidateSelectedItems(); | 84 void invalidateSelectedItems(); |
85 void updateListItemSelectedStates(); | 85 void updateListItemSelectedStates(); |
86 | 86 |
87 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems() const; | 87 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems() const; |
88 | 88 |
89 virtual void accessKeyAction(bool sendMouseEvents) OVERRIDE; | 89 virtual void accessKeyAction(bool sendMouseEvents) override; |
90 void accessKeySetSelectedIndex(int); | 90 void accessKeySetSelectedIndex(int); |
91 | 91 |
92 void setMultiple(bool); | 92 void setMultiple(bool); |
93 | 93 |
94 void setSize(int); | 94 void setSize(int); |
95 | 95 |
96 void setOption(unsigned index, HTMLOptionElement*, ExceptionState&); | 96 void setOption(unsigned index, HTMLOptionElement*, ExceptionState&); |
97 void setLength(unsigned, ExceptionState&); | 97 void setLength(unsigned, ExceptionState&); |
98 | 98 |
99 Element* namedItem(const AtomicString& name); | 99 Element* namedItem(const AtomicString& name); |
(...skipping 18 matching lines...) Expand all Loading... |
118 // For use in the implementation of HTMLOptionElement. | 118 // For use in the implementation of HTMLOptionElement. |
119 void optionSelectionStateChanged(HTMLOptionElement*, bool optionIsSelected); | 119 void optionSelectionStateChanged(HTMLOptionElement*, bool optionIsSelected); |
120 void optionRemoved(const HTMLOptionElement&); | 120 void optionRemoved(const HTMLOptionElement&); |
121 bool anonymousIndexedSetter(unsigned, PassRefPtrWillBeRawPtr<HTMLOptionEleme
nt>, ExceptionState&); | 121 bool anonymousIndexedSetter(unsigned, PassRefPtrWillBeRawPtr<HTMLOptionEleme
nt>, ExceptionState&); |
122 | 122 |
123 void updateListOnRenderer(); | 123 void updateListOnRenderer(); |
124 | 124 |
125 HTMLOptionElement* spatialNavigationFocusedOption(); | 125 HTMLOptionElement* spatialNavigationFocusedOption(); |
126 void handleMouseRelease(); | 126 void handleMouseRelease(); |
127 | 127 |
128 virtual void trace(Visitor*) OVERRIDE; | 128 virtual void trace(Visitor*) override; |
129 | 129 |
130 protected: | 130 protected: |
131 HTMLSelectElement(Document&, HTMLFormElement*); | 131 HTMLSelectElement(Document&, HTMLFormElement*); |
132 | 132 |
133 private: | 133 private: |
134 virtual const AtomicString& formControlType() const OVERRIDE; | 134 virtual const AtomicString& formControlType() const override; |
135 | 135 |
136 virtual bool shouldShowFocusRingOnMouseFocus() const OVERRIDE; | 136 virtual bool shouldShowFocusRingOnMouseFocus() const override; |
137 | 137 |
138 virtual void dispatchFocusEvent(Element* oldFocusedElement, FocusType) OVERR
IDE; | 138 virtual void dispatchFocusEvent(Element* oldFocusedElement, FocusType) overr
ide; |
139 virtual void dispatchBlurEvent(Element* newFocusedElemnet) OVERRIDE; | 139 virtual void dispatchBlurEvent(Element* newFocusedElemnet) override; |
140 | 140 |
141 virtual bool canStartSelection() const OVERRIDE { return false; } | 141 virtual bool canStartSelection() const override { return false; } |
142 | 142 |
143 virtual bool isEnumeratable() const OVERRIDE { return true; } | 143 virtual bool isEnumeratable() const override { return true; } |
144 virtual bool isInteractiveContent() const OVERRIDE; | 144 virtual bool isInteractiveContent() const override; |
145 virtual bool supportsAutofocus() const OVERRIDE; | 145 virtual bool supportsAutofocus() const override; |
146 virtual bool supportLabels() const OVERRIDE { return true; } | 146 virtual bool supportLabels() const override { return true; } |
147 | 147 |
148 virtual FormControlState saveFormControlState() const OVERRIDE; | 148 virtual FormControlState saveFormControlState() const override; |
149 virtual void restoreFormControlState(const FormControlState&) OVERRIDE; | 149 virtual void restoreFormControlState(const FormControlState&) override; |
150 | 150 |
151 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR
IDE; | 151 virtual void parseAttribute(const QualifiedName&, const AtomicString&) overr
ide; |
152 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE; | 152 virtual bool isPresentationAttribute(const QualifiedName&) const override; |
153 | 153 |
154 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; | 154 virtual RenderObject* createRenderer(RenderStyle*) override; |
155 virtual bool appendFormData(FormDataList&, bool) OVERRIDE; | 155 virtual bool appendFormData(FormDataList&, bool) override; |
156 virtual void didAddUserAgentShadowRoot(ShadowRoot&) OVERRIDE; | 156 virtual void didAddUserAgentShadowRoot(ShadowRoot&) override; |
157 | 157 |
158 virtual void defaultEventHandler(Event*) OVERRIDE; | 158 virtual void defaultEventHandler(Event*) override; |
159 | 159 |
160 void dispatchInputAndChangeEventForMenuList(bool requiresUserGesture = true)
; | 160 void dispatchInputAndChangeEventForMenuList(bool requiresUserGesture = true)
; |
161 | 161 |
162 void recalcListItems(bool updateSelectedStates = true) const; | 162 void recalcListItems(bool updateSelectedStates = true) const; |
163 | 163 |
164 void typeAheadFind(KeyboardEvent*); | 164 void typeAheadFind(KeyboardEvent*); |
165 void saveLastSelection(); | 165 void saveLastSelection(); |
166 | 166 |
167 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; | 167 virtual InsertionNotificationRequest insertedInto(ContainerNode*) override; |
168 | 168 |
169 virtual bool isOptionalFormControl() const OVERRIDE { return !isRequiredForm
Control(); } | 169 virtual bool isOptionalFormControl() const override { return !isRequiredForm
Control(); } |
170 virtual bool isRequiredFormControl() const OVERRIDE; | 170 virtual bool isRequiredFormControl() const override; |
171 | 171 |
172 bool hasPlaceholderLabelOption() const; | 172 bool hasPlaceholderLabelOption() const; |
173 | 173 |
174 enum SelectOptionFlag { | 174 enum SelectOptionFlag { |
175 DeselectOtherOptions = 1 << 0, | 175 DeselectOtherOptions = 1 << 0, |
176 DispatchInputAndChangeEvent = 1 << 1, | 176 DispatchInputAndChangeEvent = 1 << 1, |
177 UserDriven = 1 << 2, | 177 UserDriven = 1 << 2, |
178 }; | 178 }; |
179 typedef unsigned SelectOptionFlags; | 179 typedef unsigned SelectOptionFlags; |
180 void selectOption(int optionIndex, SelectOptionFlags = 0); | 180 void selectOption(int optionIndex, SelectOptionFlags = 0); |
(...skipping 16 matching lines...) Expand all Loading... |
197 int nextValidIndex(int listIndex, SkipDirection, int skip) const; | 197 int nextValidIndex(int listIndex, SkipDirection, int skip) const; |
198 int nextSelectableListIndex(int startIndex) const; | 198 int nextSelectableListIndex(int startIndex) const; |
199 int previousSelectableListIndex(int startIndex) const; | 199 int previousSelectableListIndex(int startIndex) const; |
200 int firstSelectableListIndex() const; | 200 int firstSelectableListIndex() const; |
201 int lastSelectableListIndex() const; | 201 int lastSelectableListIndex() const; |
202 int nextSelectableListIndexPageAway(int startIndex, SkipDirection) const; | 202 int nextSelectableListIndexPageAway(int startIndex, SkipDirection) const; |
203 int listIndexForEventTargetOption(const Event&); | 203 int listIndexForEventTargetOption(const Event&); |
204 int listIndexForOption(const HTMLOptionElement&); | 204 int listIndexForOption(const HTMLOptionElement&); |
205 AutoscrollController* autoscrollController() const; | 205 AutoscrollController* autoscrollController() const; |
206 | 206 |
207 virtual void childrenChanged(const ChildrenChange&) OVERRIDE; | 207 virtual void childrenChanged(const ChildrenChange&) override; |
208 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } | 208 virtual bool areAuthorShadowsAllowed() const override { return false; } |
209 virtual void finishParsingChildren() OVERRIDE; | 209 virtual void finishParsingChildren() override; |
210 | 210 |
211 // TypeAheadDataSource functions. | 211 // TypeAheadDataSource functions. |
212 virtual int indexOfSelectedOption() const OVERRIDE; | 212 virtual int indexOfSelectedOption() const override; |
213 virtual int optionCount() const OVERRIDE; | 213 virtual int optionCount() const override; |
214 virtual String optionAtIndex(int index) const OVERRIDE; | 214 virtual String optionAtIndex(int index) const override; |
215 | 215 |
216 // m_listItems contains HTMLOptionElement, HTMLOptGroupElement, and HTMLHREl
ement objects. | 216 // m_listItems contains HTMLOptionElement, HTMLOptGroupElement, and HTMLHREl
ement objects. |
217 mutable WillBeHeapVector<RawPtrWillBeMember<HTMLElement> > m_listItems; | 217 mutable WillBeHeapVector<RawPtrWillBeMember<HTMLElement> > m_listItems; |
218 Vector<bool> m_lastOnChangeSelection; | 218 Vector<bool> m_lastOnChangeSelection; |
219 Vector<bool> m_cachedStateForActiveSelection; | 219 Vector<bool> m_cachedStateForActiveSelection; |
220 TypeAhead m_typeAhead; | 220 TypeAhead m_typeAhead; |
221 int m_size; | 221 int m_size; |
222 int m_lastOnChangeIndex; | 222 int m_lastOnChangeIndex; |
223 int m_activeSelectionAnchorIndex; | 223 int m_activeSelectionAnchorIndex; |
224 int m_activeSelectionEndIndex; | 224 int m_activeSelectionEndIndex; |
225 bool m_isProcessingUserDrivenChange; | 225 bool m_isProcessingUserDrivenChange; |
226 bool m_multiple; | 226 bool m_multiple; |
227 bool m_activeSelectionState; | 227 bool m_activeSelectionState; |
228 mutable bool m_shouldRecalcListItems; | 228 mutable bool m_shouldRecalcListItems; |
229 int m_suggestedIndex; | 229 int m_suggestedIndex; |
230 bool m_isAutofilledByPreview; | 230 bool m_isAutofilledByPreview; |
231 }; | 231 }; |
232 | 232 |
233 } // namespace blink | 233 } // namespace blink |
234 | 234 |
235 #endif // HTMLSelectElement_h | 235 #endif // HTMLSelectElement_h |
OLD | NEW |