HTMLOutputElement.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. JS_DECLARE_ALLOCATOR(HTMLOutputElement);
  17. FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLOutputElement)
  18. public:
  19. virtual ~HTMLOutputElement() override;
  20. JS::NonnullGCPtr<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. // https://www.w3.org/TR/html-aria/#el-output
  42. virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::status; }
  43. private:
  44. HTMLOutputElement(DOM::Document&, DOM::QualifiedName);
  45. virtual void initialize(JS::Realm&) override;
  46. virtual void visit_edges(Cell::Visitor& visitor) override;
  47. virtual void form_associated_element_attribute_changed(FlyString const& name, Optional<String> const& value) override;
  48. JS::GCPtr<DOM::DOMTokenList> m_html_for;
  49. Optional<String> m_default_value_override {};
  50. };
  51. }