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