HTMLTextAreaElement.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/DOM/Text.h>
  10. #include <LibWeb/HTML/FormAssociatedElement.h>
  11. #include <LibWeb/HTML/HTMLElement.h>
  12. namespace Web::HTML {
  13. class HTMLTextAreaElement final
  14. : public HTMLElement
  15. , public FormAssociatedElement
  16. , public DOM::EditableTextNodeOwner {
  17. WEB_PLATFORM_OBJECT(HTMLTextAreaElement, HTMLElement);
  18. FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLTextAreaElement)
  19. public:
  20. virtual ~HTMLTextAreaElement() override;
  21. virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
  22. DeprecatedString const& type() const
  23. {
  24. static DeprecatedString textarea = "textarea";
  25. return textarea;
  26. }
  27. // ^DOM::EditableTextNodeOwner
  28. virtual void did_edit_text_node(Badge<BrowsingContext>) override;
  29. // ^EventTarget
  30. // https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-textarea-element
  31. virtual bool is_focusable() const override { return true; }
  32. virtual void did_lose_focus() override;
  33. virtual void did_receive_focus() override;
  34. // ^FormAssociatedElement
  35. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  36. virtual bool is_listed() const override { return true; }
  37. // https://html.spec.whatwg.org/multipage/forms.html#category-submit
  38. virtual bool is_submittable() const override { return true; }
  39. // https://html.spec.whatwg.org/multipage/forms.html#category-reset
  40. virtual bool is_resettable() const override { return true; }
  41. // https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
  42. virtual bool is_auto_capitalize_inheriting() const override { return true; }
  43. // ^HTMLElement
  44. // https://html.spec.whatwg.org/multipage/forms.html#category-label
  45. virtual bool is_labelable() const override { return true; }
  46. virtual void reset_algorithm() override;
  47. virtual void form_associated_element_was_inserted() override;
  48. virtual void children_changed() override;
  49. // https://www.w3.org/TR/html-aria/#el-textarea
  50. virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::textbox; }
  51. private:
  52. HTMLTextAreaElement(DOM::Document&, DOM::QualifiedName);
  53. virtual void initialize(JS::Realm&) override;
  54. virtual void visit_edges(Cell::Visitor&) override;
  55. // ^DOM::Element
  56. virtual i32 default_tab_index_value() const override;
  57. void create_shadow_tree_if_needed();
  58. JS::GCPtr<DOM::Element> m_inner_text_element;
  59. JS::GCPtr<DOM::Text> m_text_node;
  60. bool m_dirty { false };
  61. DeprecatedString m_raw_value;
  62. };
  63. }