HTMLTextAreaElement.h 2.8 KB

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