HTMLOptionElement.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. void set_selected_internal(bool);
  18. String value() const;
  19. WebIDL::ExceptionOr<void> set_value(String const&);
  20. String text() const;
  21. void set_text(String const&);
  22. int index() const;
  23. bool disabled() const;
  24. JS::GCPtr<HTML::HTMLFormElement> form() const;
  25. virtual Optional<ARIA::Role> default_role() const override;
  26. private:
  27. friend class Bindings::OptionConstructor;
  28. friend class HTMLSelectElement;
  29. HTMLOptionElement(DOM::Document&, DOM::QualifiedName);
  30. virtual void initialize(JS::Realm&) override;
  31. void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value) override;
  32. void ask_for_a_reset();
  33. // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-selectedness
  34. bool m_selected { false };
  35. // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-dirtiness
  36. bool m_dirty { false };
  37. };
  38. }