HTMLOutputElement.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. * Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibWeb/ARIA/Roles.h>
  9. #include <LibWeb/HTML/FormAssociatedElement.h>
  10. #include <LibWeb/HTML/HTMLElement.h>
  11. namespace Web::HTML {
  12. class HTMLOutputElement final
  13. : public HTMLElement
  14. , public FormAssociatedElement {
  15. WEB_PLATFORM_OBJECT(HTMLOutputElement, HTMLElement);
  16. GC_DECLARE_ALLOCATOR(HTMLOutputElement);
  17. FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLOutputElement)
  18. public:
  19. virtual ~HTMLOutputElement() override;
  20. GC::Ref<DOM::DOMTokenList> html_for();
  21. String const& type() const
  22. {
  23. static String const output = "output"_string;
  24. return output;
  25. }
  26. String default_value() const;
  27. void set_default_value(String const&);
  28. String value() const override;
  29. void set_value(String const&);
  30. // ^FormAssociatedElement
  31. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  32. virtual bool is_listed() const override { return true; }
  33. // https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
  34. virtual bool is_resettable() const override { return true; }
  35. // https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
  36. virtual bool is_auto_capitalize_inheriting() const override { return true; }
  37. // ^HTMLElement
  38. // https://html.spec.whatwg.org/multipage/forms.html#category-label
  39. virtual bool is_labelable() const override { return true; }
  40. virtual void reset_algorithm() override;
  41. virtual void clear_algorithm() override;
  42. // https://www.w3.org/TR/html-aria/#el-output
  43. virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::status; }
  44. private:
  45. HTMLOutputElement(DOM::Document&, DOM::QualifiedName);
  46. virtual void initialize(JS::Realm&) override;
  47. virtual void visit_edges(Cell::Visitor& visitor) override;
  48. virtual void form_associated_element_attribute_changed(FlyString const& name, Optional<String> const& value) override;
  49. GC::Ptr<DOM::DOMTokenList> m_html_for;
  50. Optional<String> m_default_value_override {};
  51. };
  52. }