HTMLSelectElement.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 : public FormAssociatedElement {
  14. public:
  15. using WrapperType = Bindings::HTMLSelectElementWrapper;
  16. HTMLSelectElement(DOM::Document&, DOM::QualifiedName);
  17. virtual ~HTMLSelectElement() override;
  18. RefPtr<HTMLOptionsCollection> const& options();
  19. DOM::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {});
  20. int selected_index() const;
  21. void set_selected_index(int);
  22. NonnullRefPtrVector<HTMLOptionElement> list_of_options() const;
  23. // ^FormAssociatedElement
  24. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  25. virtual bool is_listed() const override { return true; }
  26. // https://html.spec.whatwg.org/multipage/forms.html#category-submit
  27. virtual bool is_submittable() const override { return true; }
  28. // https://html.spec.whatwg.org/multipage/forms.html#category-reset
  29. virtual bool is_resettable() const override { return true; }
  30. // https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
  31. virtual bool is_auto_capitalize_inheriting() const override { return true; }
  32. // ^HTMLElement
  33. // https://html.spec.whatwg.org/multipage/forms.html#category-label
  34. virtual bool is_labelable() const override { return true; }
  35. private:
  36. RefPtr<HTMLOptionsCollection> m_options;
  37. };
  38. }