HTMLSelectElement.h [plain text]
#ifndef HTMLSelectElement_h
#define HTMLSelectElement_h
#include "HTMLFormControlElementWithState.h"
#include "TypeAhead.h"
namespace WebCore {
class HTMLOptionsCollection;
class HTMLSelectElement : public HTMLFormControlElementWithState, private TypeAheadDataSource {
public:
static Ref<HTMLSelectElement> create(const QualifiedName&, Document&, HTMLFormElement*);
WEBCORE_EXPORT int selectedIndex() const;
void setSelectedIndex(int);
WEBCORE_EXPORT void optionSelectedByUser(int index, bool dispatchChangeEvent, bool allowMultipleSelection = false);
String validationMessage() const final;
bool valueMissing() const final;
unsigned length() const;
unsigned size() const { return m_size; }
bool multiple() const { return m_multiple; }
bool usesMenuList() const;
void add(HTMLElement&, HTMLElement* beforeElement, ExceptionCode&);
void add(HTMLElement&, int beforeIndex, ExceptionCode&);
using Node::remove;
void remove(HTMLOptionElement&);
void removeByIndex(int);
WEBCORE_EXPORT String value() const;
void setValue(const String&);
Ref<HTMLOptionsCollection> options();
Ref<HTMLCollection> selectedOptions();
void optionElementChildrenChanged();
void setRecalcListItems();
void invalidateSelectedItems();
void updateListItemSelectedStates();
WEBCORE_EXPORT const Vector<HTMLElement*>& listItems() const;
void accessKeyAction(bool sendMouseEvents) final;
void accessKeySetSelectedIndex(int);
void setMultiple(bool);
void setSize(unsigned);
void setOption(unsigned index, HTMLOptionElement&, ExceptionCode&);
void setLength(unsigned, ExceptionCode&);
HTMLOptionElement* namedItem(const AtomicString& name);
HTMLOptionElement* item(unsigned index);
void scrollToSelection();
void listBoxSelectItem(int listIndex, bool allowMultiplySelections, bool shift, bool fireOnChangeNow = true);
bool canSelectAll() const;
void selectAll();
int listToOptionIndex(int listIndex) const;
void listBoxOnChange();
int optionToListIndex(int optionIndex) const;
int activeSelectionStartListIndex() const;
int activeSelectionEndListIndex() const;
void setActiveSelectionAnchorIndex(int);
void setActiveSelectionEndIndex(int);
void updateListBoxSelection(bool deselectOtherOptions);
void optionSelectionStateChanged(HTMLOptionElement&, bool optionIsSelected);
bool allowsNonContiguousSelection() const { return m_allowsNonContiguousSelection; };
protected:
HTMLSelectElement(const QualifiedName&, Document&, HTMLFormElement*);
private:
const AtomicString& formControlType() const final;
bool isKeyboardFocusable(KeyboardEvent*) const final;
bool isMouseFocusable() const final;
void dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection) final;
void dispatchBlurEvent(RefPtr<Element>&& newFocusedElement) final;
bool canStartSelection() const final { return false; }
bool isEnumeratable() const final { return true; }
bool supportLabels() const final { return true; }
FormControlState saveFormControlState() const final;
void restoreFormControlState(const FormControlState&) final;
void parseAttribute(const QualifiedName&, const AtomicString&) final;
bool isPresentationAttribute(const QualifiedName&) const final;
bool childShouldCreateRenderer(const Node&) const final;
RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
bool appendFormData(FormDataList&, bool) final;
void reset() final;
void defaultEventHandler(Event*) final;
bool willRespondToMouseClickEvents() final;
void dispatchChangeEventForMenuList();
void didRecalcStyle(Style::Change) final;
void recalcListItems(bool updateSelectedStates = true) const;
void deselectItems(HTMLOptionElement* excludeElement = nullptr);
void typeAheadFind(KeyboardEvent&);
void saveLastSelection();
InsertionNotificationRequest insertedInto(ContainerNode&) final;
bool isOptionalFormControl() const final { return !isRequiredFormControl(); }
bool isRequiredFormControl() const final;
bool hasPlaceholderLabelOption() const;
enum SelectOptionFlag {
DeselectOtherOptions = 1 << 0,
DispatchChangeEvent = 1 << 1,
UserDriven = 1 << 2,
};
typedef unsigned SelectOptionFlags;
void selectOption(int optionIndex, SelectOptionFlags = 0);
void deselectItemsWithoutValidation(HTMLElement* elementToExclude = nullptr);
void parseMultipleAttribute(const AtomicString&);
int lastSelectedListIndex() const;
void updateSelectedState(int listIndex, bool multi, bool shift);
void menuListDefaultEventHandler(Event*);
bool platformHandleKeydownEvent(KeyboardEvent*);
void listBoxDefaultEventHandler(Event*);
void setOptionsChangedOnRenderer();
size_t searchOptionsForValue(const String&, size_t listIndexStart, size_t listIndexEnd) const;
enum SkipDirection { SkipBackwards = -1, SkipForwards = 1 };
int nextValidIndex(int listIndex, SkipDirection, int skip) const;
int nextSelectableListIndex(int startIndex) const;
int previousSelectableListIndex(int startIndex) const;
int firstSelectableListIndex() const;
int lastSelectableListIndex() const;
int nextSelectableListIndexPageAway(int startIndex, SkipDirection) const;
void childrenChanged(const ChildChange&) final;
int indexOfSelectedOption() const final;
int optionCount() const final;
String optionAtIndex(int index) const final;
mutable Vector<HTMLElement*> m_listItems;
Vector<bool> m_lastOnChangeSelection;
Vector<bool> m_cachedStateForActiveSelection;
TypeAhead m_typeAhead;
unsigned m_size;
int m_lastOnChangeIndex;
int m_activeSelectionAnchorIndex;
int m_activeSelectionEndIndex;
bool m_isProcessingUserDrivenChange;
bool m_multiple;
bool m_activeSelectionState;
bool m_allowsNonContiguousSelection;
mutable bool m_shouldRecalcListItems;
};
}
#endif