HTMLOptionElement.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibWeb/HTML/HTMLElement.h>
  9. namespace Web::HTML {
  10. class HTMLOptionElement final : public HTMLElement {
  11. WEB_PLATFORM_OBJECT(HTMLOptionElement, HTMLElement);
  12. JS_DECLARE_ALLOCATOR(HTMLOptionElement);
  13. public:
  14. virtual ~HTMLOptionElement() override;
  15. bool selected() const { return m_selected; }
  16. void set_selected(bool);
  17. String value() const;
  18. WebIDL::ExceptionOr<void> set_value(String const&);
  19. String text() const;
  20. void set_text(String const&);
  21. int index() const;
  22. bool disabled() const;
  23. virtual Optional<ARIA::Role> default_role() const override;
  24. private:
  25. friend class Bindings::OptionConstructor;
  26. friend class HTMLSelectElement;
  27. HTMLOptionElement(DOM::Document&, DOM::QualifiedName);
  28. virtual void initialize(JS::Realm&) override;
  29. void attribute_changed(FlyString const& name, Optional<String> const& value) override;
  30. void ask_for_a_reset();
  31. // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-selectedness
  32. bool m_selected { false };
  33. // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-dirtiness
  34. bool m_dirty { false };
  35. };
  36. }