| 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 |
| 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 Loading... |
| 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(const 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 |
| 125 HTMLOptionElement* spatialNavigationFocusedOption(); |
| 126 void handleMouseRelease(); |
| 127 |
| 120 virtual void trace(Visitor*) OVERRIDE; | 128 virtual void trace(Visitor*) OVERRIDE; |
| 121 | 129 |
| 122 protected: | 130 protected: |
| 123 HTMLSelectElement(Document&, HTMLFormElement*); | 131 HTMLSelectElement(Document&, HTMLFormElement*); |
| 124 | 132 |
| 125 private: | 133 private: |
| 126 virtual const AtomicString& formControlType() const OVERRIDE; | 134 virtual const AtomicString& formControlType() const OVERRIDE; |
| 127 | 135 |
| 128 virtual bool shouldShowFocusRingOnMouseFocus() const OVERRIDE; | 136 virtual bool shouldShowFocusRingOnMouseFocus() const OVERRIDE; |
| 129 | 137 |
| 130 virtual void dispatchFocusEvent(Element* oldFocusedElement, FocusType) OVERR
IDE; | 138 virtual void dispatchFocusEvent(Element* oldFocusedElement, FocusType) OVERR
IDE; |
| 131 virtual void dispatchBlurEvent(Element* newFocusedElemnet) OVERRIDE; | 139 virtual void dispatchBlurEvent(Element* newFocusedElemnet) OVERRIDE; |
| 132 | 140 |
| 133 virtual bool canStartSelection() const OVERRIDE { return false; } | 141 virtual bool canStartSelection() const OVERRIDE { return false; } |
| 134 | 142 |
| 135 virtual bool isEnumeratable() const OVERRIDE { return true; } | 143 virtual bool isEnumeratable() const OVERRIDE { return true; } |
| 136 virtual bool isInteractiveContent() const OVERRIDE; | 144 virtual bool isInteractiveContent() const OVERRIDE; |
| 137 virtual bool supportsAutofocus() const OVERRIDE; | 145 virtual bool supportsAutofocus() const OVERRIDE; |
| 138 virtual bool supportLabels() const OVERRIDE { return true; } | 146 virtual bool supportLabels() const OVERRIDE { return true; } |
| 139 | 147 |
| 140 virtual FormControlState saveFormControlState() const OVERRIDE; | 148 virtual FormControlState saveFormControlState() const OVERRIDE; |
| 141 virtual void restoreFormControlState(const FormControlState&) OVERRIDE; | 149 virtual void restoreFormControlState(const FormControlState&) OVERRIDE; |
| 142 | 150 |
| 143 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR
IDE; | 151 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR
IDE; |
| 144 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE; | 152 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE; |
| 145 | 153 |
| 146 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; | 154 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; |
| 147 virtual bool appendFormData(FormDataList&, bool) OVERRIDE; | 155 virtual bool appendFormData(FormDataList&, bool) OVERRIDE; |
| 156 virtual void didAddUserAgentShadowRoot(ShadowRoot&) OVERRIDE; |
| 148 | 157 |
| 149 virtual void defaultEventHandler(Event*) OVERRIDE; | 158 virtual void defaultEventHandler(Event*) OVERRIDE; |
| 150 | 159 |
| 151 void dispatchInputAndChangeEventForMenuList(bool requiresUserGesture = true)
; | 160 void dispatchInputAndChangeEventForMenuList(bool requiresUserGesture = true)
; |
| 152 | 161 |
| 153 void recalcListItems(bool updateSelectedStates = true) const; | 162 void recalcListItems(bool updateSelectedStates = true) const; |
| 154 | 163 |
| 155 void typeAheadFind(KeyboardEvent*); | 164 void typeAheadFind(KeyboardEvent*); |
| 156 void saveLastSelection(); | 165 void saveLastSelection(); |
| 157 | 166 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 184 enum SkipDirection { | 193 enum SkipDirection { |
| 185 SkipBackwards = -1, | 194 SkipBackwards = -1, |
| 186 SkipForwards = 1 | 195 SkipForwards = 1 |
| 187 }; | 196 }; |
| 188 int nextValidIndex(int listIndex, SkipDirection, int skip) const; | 197 int nextValidIndex(int listIndex, SkipDirection, int skip) const; |
| 189 int nextSelectableListIndex(int startIndex) const; | 198 int nextSelectableListIndex(int startIndex) const; |
| 190 int previousSelectableListIndex(int startIndex) const; | 199 int previousSelectableListIndex(int startIndex) const; |
| 191 int firstSelectableListIndex() const; | 200 int firstSelectableListIndex() const; |
| 192 int lastSelectableListIndex() const; | 201 int lastSelectableListIndex() const; |
| 193 int nextSelectableListIndexPageAway(int startIndex, SkipDirection) const; | 202 int nextSelectableListIndexPageAway(int startIndex, SkipDirection) const; |
| 203 int listIndexForEventTargetOption(const Event&); |
| 204 int listIndexForOption(const HTMLOptionElement&); |
| 205 AutoscrollController* autoscrollController() const; |
| 194 | 206 |
| 195 virtual void childrenChanged(const ChildrenChange&) OVERRIDE; | 207 virtual void childrenChanged(const ChildrenChange&) OVERRIDE; |
| 196 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } | 208 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } |
| 197 virtual void finishParsingChildren() OVERRIDE; | 209 virtual void finishParsingChildren() OVERRIDE; |
| 198 | 210 |
| 199 // TypeAheadDataSource functions. | 211 // TypeAheadDataSource functions. |
| 200 virtual int indexOfSelectedOption() const OVERRIDE; | 212 virtual int indexOfSelectedOption() const OVERRIDE; |
| 201 virtual int optionCount() const OVERRIDE; | 213 virtual int optionCount() const OVERRIDE; |
| 202 virtual String optionAtIndex(int index) const OVERRIDE; | 214 virtual String optionAtIndex(int index) const OVERRIDE; |
| 203 | 215 |
| 204 // m_listItems contains HTMLOptionElement, HTMLOptGroupElement, and HTMLHREl
ement objects. | 216 // m_listItems contains HTMLOptionElement, HTMLOptGroupElement, and HTMLHREl
ement objects. |
| 205 mutable WillBeHeapVector<RawPtrWillBeMember<HTMLElement> > m_listItems; | 217 mutable WillBeHeapVector<RawPtrWillBeMember<HTMLElement> > m_listItems; |
| 206 Vector<bool> m_lastOnChangeSelection; | 218 Vector<bool> m_lastOnChangeSelection; |
| 207 Vector<bool> m_cachedStateForActiveSelection; | 219 Vector<bool> m_cachedStateForActiveSelection; |
| 208 TypeAhead m_typeAhead; | 220 TypeAhead m_typeAhead; |
| 209 int m_size; | 221 int m_size; |
| 210 int m_lastOnChangeIndex; | 222 int m_lastOnChangeIndex; |
| 211 int m_activeSelectionAnchorIndex; | 223 int m_activeSelectionAnchorIndex; |
| 212 int m_activeSelectionEndIndex; | 224 int m_activeSelectionEndIndex; |
| 213 bool m_isProcessingUserDrivenChange; | 225 bool m_isProcessingUserDrivenChange; |
| 214 bool m_multiple; | 226 bool m_multiple; |
| 215 bool m_activeSelectionState; | 227 bool m_activeSelectionState; |
| 216 mutable bool m_shouldRecalcListItems; | 228 mutable bool m_shouldRecalcListItems; |
| 217 int m_suggestedIndex; | 229 int m_suggestedIndex; |
| 218 }; | 230 }; |
| 219 | 231 |
| 220 } // namespace | 232 } // namespace |
| 221 | 233 |
| 222 #endif | 234 #endif |
| OLD | NEW |