HTMLSelectElement.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. * Copyright (c) 2021-2022, Andreas Kling <kling@serenityos.org>
  4. * Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause
  7. */
  8. #pragma once
  9. #include <LibWeb/HTML/FormAssociatedElement.h>
  10. #include <LibWeb/HTML/HTMLElement.h>
  11. #include <LibWeb/HTML/HTMLOptionsCollection.h>
  12. namespace Web::HTML {
  13. class HTMLSelectElement final
  14. : public HTMLElement
  15. , public FormAssociatedElement {
  16. FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLSelectElement)
  17. public:
  18. using WrapperType = Bindings::HTMLSelectElementWrapper;
  19. HTMLSelectElement(DOM::Document&, DOM::QualifiedName);
  20. virtual ~HTMLSelectElement() override;
  21. RefPtr<HTMLOptionsCollection> const& options();
  22. DOM::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {});
  23. int selected_index() const;
  24. void set_selected_index(int);
  25. NonnullRefPtrVector<HTMLOptionElement> list_of_options() const;
  26. // ^EventTarget
  27. // https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-select-element
  28. virtual bool is_focusable() const override { return true; }
  29. // ^FormAssociatedElement
  30. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  31. virtual bool is_listed() const override { return true; }
  32. // https://html.spec.whatwg.org/multipage/forms.html#category-submit
  33. virtual bool is_submittable() const override { return true; }
  34. // https://html.spec.whatwg.org/multipage/forms.html#category-reset
  35. virtual bool is_resettable() const override { return true; }
  36. // https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
  37. virtual bool is_auto_capitalize_inheriting() const override { return true; }
  38. // ^HTMLElement
  39. // https://html.spec.whatwg.org/multipage/forms.html#category-label
  40. virtual bool is_labelable() const override { return true; }
  41. private:
  42. RefPtr<HTMLOptionsCollection> m_options;
  43. };
  44. }