#ifndef HTMLSelectElement_h
#define HTMLSelectElement_h
-#include "core/events/Event.h"
+#include "core/html/HTMLContentElement.h"
#include "core/html/HTMLFormControlElementWithState.h"
#include "core/html/HTMLOptionsCollection.h"
#include "core/html/forms/TypeAhead.h"
#include "wtf/Vector.h"
-namespace WebCore {
+namespace blink {
+class AutoscrollController;
class ExceptionState;
class HTMLOptionElement;
+class MouseEvent;
class HTMLSelectElement FINAL : public HTMLFormControlElementWithState, public TypeAheadDataSource {
+ DEFINE_WRAPPERTYPEINFO();
public:
- static PassRefPtr<HTMLSelectElement> create(Document&);
- static PassRefPtr<HTMLSelectElement> create(Document&, HTMLFormElement*, bool createdByParser);
+ static PassRefPtrWillBeRawPtr<HTMLSelectElement> create(Document&);
+ static PassRefPtrWillBeRawPtr<HTMLSelectElement> create(Document&, HTMLFormElement*);
int selectedIndex() const;
void setSelectedIndex(int);
+ int suggestedIndex() const;
+ void setSuggestedIndex(int);
void optionSelectedByUser(int index, bool dispatchChangeEvent, bool allowMultipleSelection = false);
bool usesMenuList() const;
void add(HTMLElement*, HTMLElement* beforeElement, ExceptionState&);
+ void addBeforeOptionAtIndex(HTMLElement*, int beforeIndex, ExceptionState&);
using Node::remove;
void remove(int index);
- void remove(HTMLOptionElement*);
String value() const;
- void setValue(const String&);
+ void setValue(const String&, bool sendEvents = false);
+ String suggestedValue() const;
+ void setSuggestedValue(const String&);
- PassRefPtr<HTMLOptionsCollection> options();
- PassRefPtr<HTMLCollection> selectedOptions();
+ PassRefPtrWillBeRawPtr<HTMLOptionsCollection> options();
+ PassRefPtrWillBeRawPtr<HTMLCollection> selectedOptions();
void optionElementChildrenChanged();
void invalidateSelectedItems();
void updateListItemSelectedStates();
- const Vector<HTMLElement*>& listItems() const;
+ const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems() const;
virtual void accessKeyAction(bool sendMouseEvents) OVERRIDE;
void accessKeySetSelectedIndex(int);
void setOption(unsigned index, HTMLOptionElement*, ExceptionState&);
void setLength(unsigned, ExceptionState&);
- Node* namedItem(const AtomicString& name);
- Node* item(unsigned index);
+ Element* namedItem(const AtomicString& name);
+ HTMLOptionElement* item(unsigned index);
void scrollToSelection();
+ void scrollTo(int listIndex);
void listBoxSelectItem(int listIndex, bool allowMultiplySelections, bool shift, bool fireOnChangeNow = true);
// For use in the implementation of HTMLOptionElement.
void optionSelectionStateChanged(HTMLOptionElement*, bool optionIsSelected);
- bool isParsingInProgress() const { return m_isParsingInProgress; }
- bool anonymousIndexedSetter(unsigned, PassRefPtr<HTMLOptionElement>, ExceptionState&);
- bool anonymousIndexedSetterRemove(unsigned, ExceptionState&);
+ void optionRemoved(const HTMLOptionElement&);
+ bool anonymousIndexedSetter(unsigned, PassRefPtrWillBeRawPtr<HTMLOptionElement>, ExceptionState&);
+
+ void updateListOnRenderer();
+
+ HTMLOptionElement* spatialNavigationFocusedOption();
+ void handleMouseRelease();
+
+ virtual void trace(Visitor*) OVERRIDE;
protected:
- HTMLSelectElement(Document&, HTMLFormElement*, bool createdByParser);
+ HTMLSelectElement(Document&, HTMLFormElement*);
private:
virtual const AtomicString& formControlType() const OVERRIDE;
virtual bool shouldShowFocusRingOnMouseFocus() const OVERRIDE;
- virtual void dispatchFocusEvent(Element* oldFocusedElement, FocusDirection) OVERRIDE;
+ virtual void dispatchFocusEvent(Element* oldFocusedElement, FocusType) OVERRIDE;
virtual void dispatchBlurEvent(Element* newFocusedElemnet) OVERRIDE;
virtual bool canStartSelection() const OVERRIDE { return false; }
virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
virtual bool appendFormData(FormDataList&, bool) OVERRIDE;
+ virtual void didAddUserAgentShadowRoot(ShadowRoot&) OVERRIDE;
virtual void defaultEventHandler(Event*) OVERRIDE;
- void dispatchChangeEventForMenuList();
+ void dispatchInputAndChangeEventForMenuList(bool requiresUserGesture = true);
void recalcListItems(bool updateSelectedStates = true) const;
enum SelectOptionFlag {
DeselectOtherOptions = 1 << 0,
- DispatchChangeEvent = 1 << 1,
+ DispatchInputAndChangeEvent = 1 << 1,
UserDriven = 1 << 2,
};
typedef unsigned SelectOptionFlags;
int lastSelectedListIndex() const;
void updateSelectedState(int listIndex, bool multi, bool shift);
void menuListDefaultEventHandler(Event*);
- bool platformHandleKeydownEvent(KeyboardEvent*);
+ void handlePopupOpenKeyboardEvent(Event*);
+ bool shouldOpenPopupForKeyDownEvent(KeyboardEvent*);
+ bool shouldOpenPopupForKeyPressEvent(KeyboardEvent*);
void listBoxDefaultEventHandler(Event*);
void setOptionsChangedOnRenderer();
size_t searchOptionsForValue(const String&, size_t listIndexStart, size_t listIndexEnd) const;
int firstSelectableListIndex() const;
int lastSelectableListIndex() const;
int nextSelectableListIndexPageAway(int startIndex, SkipDirection) const;
+ int listIndexForEventTargetOption(const Event&);
+ int listIndexForOption(const HTMLOptionElement&);
+ AutoscrollController* autoscrollController() const;
- virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0) OVERRIDE;
+ virtual void childrenChanged(const ChildrenChange&) OVERRIDE;
virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
virtual void finishParsingChildren() OVERRIDE;
virtual String optionAtIndex(int index) const OVERRIDE;
// m_listItems contains HTMLOptionElement, HTMLOptGroupElement, and HTMLHRElement objects.
- mutable Vector<HTMLElement*> m_listItems;
+ mutable WillBeHeapVector<RawPtrWillBeMember<HTMLElement> > m_listItems;
Vector<bool> m_lastOnChangeSelection;
Vector<bool> m_cachedStateForActiveSelection;
TypeAhead m_typeAhead;
bool m_multiple;
bool m_activeSelectionState;
mutable bool m_shouldRecalcListItems;
- bool m_isParsingInProgress;
+ int m_suggestedIndex;
};
-DEFINE_NODE_TYPE_CASTS(HTMLSelectElement, hasTagName(HTMLNames::selectTag));
-
-} // namespace
+} // namespace blink
-#endif
+#endif // HTMLSelectElement_h