| 
									
										
										
										
											2020-08-01 03:07:00 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2021-04-28 22:46:44 +02:00
										 |  |  |  * Copyright (c) 2020, the SerenityOS developers. | 
					
						
							| 
									
										
										
										
											2022-03-01 21:03:30 +00:00
										 |  |  |  * Copyright (c) 2022, Luke Wilde <lukew@serenityos.org> | 
					
						
							| 
									
										
										
										
											2024-03-01 08:49:04 +01:00
										 |  |  |  * Copyright (c) 2024, Bastiaan van der Plaat <bastiaan.v.d.plaat@gmail.com> | 
					
						
							| 
									
										
										
										
											2024-11-01 12:14:53 +01:00
										 |  |  |  * Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org> | 
					
						
							| 
									
										
										
										
											2020-08-01 03:07:00 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-08-01 03:07:00 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-16 11:44:18 +01:00
										 |  |  | #include <LibCore/Timer.h>
 | 
					
						
							| 
									
										
										
										
											2023-01-28 22:23:16 +00:00
										 |  |  | #include <LibWeb/ARIA/Roles.h>
 | 
					
						
							| 
									
										
										
										
											2023-08-30 17:10:38 +01:00
										 |  |  | #include <LibWeb/DOM/Text.h>
 | 
					
						
							| 
									
										
										
										
											2021-10-14 16:18:49 +01:00
										 |  |  | #include <LibWeb/HTML/FormAssociatedElement.h>
 | 
					
						
							| 
									
										
										
										
											2022-03-23 18:55:54 -04:00
										 |  |  | #include <LibWeb/HTML/HTMLElement.h>
 | 
					
						
							| 
									
										
										
										
											2024-03-01 08:49:04 +01:00
										 |  |  | #include <LibWeb/WebIDL/Types.h>
 | 
					
						
							| 
									
										
										
										
											2020-08-01 03:07:00 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::HTML { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-23 18:55:54 -04:00
										 |  |  | class HTMLTextAreaElement final | 
					
						
							|  |  |  |     : public HTMLElement | 
					
						
							| 
									
										
										
										
											2024-11-06 16:46:50 +01:00
										 |  |  |     , public FormAssociatedTextControlElement { | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     WEB_PLATFORM_OBJECT(HTMLTextAreaElement, HTMLElement); | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     GC_DECLARE_ALLOCATOR(HTMLTextAreaElement); | 
					
						
							| 
									
										
										
										
											2022-03-23 18:55:54 -04:00
										 |  |  |     FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLTextAreaElement) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-01 03:07:00 +01:00
										 |  |  | public: | 
					
						
							|  |  |  |     virtual ~HTMLTextAreaElement() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-20 11:32:17 +01:00
										 |  |  |     virtual void adjust_computed_style(CSS::ComputedProperties&) override; | 
					
						
							| 
									
										
										
										
											2023-08-30 17:10:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-26 10:59:52 +13:00
										 |  |  |     String const& type() const | 
					
						
							| 
									
										
										
										
											2020-09-18 09:49:51 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-11-26 10:59:52 +13:00
										 |  |  |         static String const textarea = "textarea"_string; | 
					
						
							| 
									
										
										
										
											2020-08-01 03:07:00 +01:00
										 |  |  |         return textarea; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-03-01 21:03:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-26 18:05:48 +00:00
										 |  |  |     // ^EventTarget
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-textarea-element
 | 
					
						
							| 
									
										
										
										
											2024-11-02 19:17:20 +01:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/interaction.html#focusable-area
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/semantics-other.html#concept-element-disabled
 | 
					
						
							|  |  |  |     virtual bool is_focusable() const override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-30 17:10:38 +01:00
										 |  |  |     virtual void did_lose_focus() override; | 
					
						
							|  |  |  |     virtual void did_receive_focus() override; | 
					
						
							| 
									
										
										
										
											2022-03-26 18:05:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-01 21:03:30 +00:00
										 |  |  |     // ^FormAssociatedElement
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/forms.html#category-listed
 | 
					
						
							|  |  |  |     virtual bool is_listed() const override { return true; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/forms.html#category-submit
 | 
					
						
							|  |  |  |     virtual bool is_submittable() const override { return true; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/forms.html#category-reset
 | 
					
						
							|  |  |  |     virtual bool is_resettable() const override { return true; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
 | 
					
						
							|  |  |  |     virtual bool is_auto_capitalize_inheriting() const override { return true; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/forms.html#category-label
 | 
					
						
							|  |  |  |     virtual bool is_labelable() const override { return true; } | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-22 19:58:21 -05:00
										 |  |  |     virtual void reset_algorithm() override; | 
					
						
							| 
									
										
										
										
											2024-10-11 10:38:43 -04:00
										 |  |  |     virtual void clear_algorithm() override; | 
					
						
							| 
									
										
										
										
											2022-12-22 19:58:21 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-11 17:37:08 +00:00
										 |  |  |     virtual WebIDL::ExceptionOr<void> cloned(Node&, bool) const override; | 
					
						
							| 
									
										
										
										
											2024-08-21 12:27:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-30 17:10:38 +01:00
										 |  |  |     virtual void form_associated_element_was_inserted() override; | 
					
						
							| 
									
										
										
										
											2023-11-29 18:22:16 -05:00
										 |  |  |     virtual void form_associated_element_was_removed(DOM::Node*) override; | 
					
						
							| 
									
										
										
										
											2024-12-12 19:48:32 +00:00
										 |  |  |     virtual void form_associated_element_attribute_changed(FlyString const&, Optional<String> const&, Optional<FlyString> const&) override; | 
					
						
							| 
									
										
										
										
											2023-08-30 17:10:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     virtual void children_changed() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  |     // https://www.w3.org/TR/html-aria/#el-textarea
 | 
					
						
							| 
									
										
										
										
											2023-01-28 22:23:16 +00:00
										 |  |  |     virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::textbox; } | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-10 17:48:42 +01:00
										 |  |  |     String default_value() const; | 
					
						
							|  |  |  |     void set_default_value(String const&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     String value() const override; | 
					
						
							|  |  |  |     void set_value(String const&); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-22 15:20:24 +02:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element:concept-fe-api-value-3
 | 
					
						
							|  |  |  |     String api_value() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-30 17:22:58 +01:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-textarea/input-relevant-value
 | 
					
						
							|  |  |  |     virtual String relevant_value() override { return api_value(); } | 
					
						
							| 
									
										
										
										
											2024-08-30 17:22:58 +01:00
										 |  |  |     virtual WebIDL::ExceptionOr<void> set_relevant_value(String const& value) override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual void set_dirty_value_flag(bool flag) override { m_dirty_value = flag; } | 
					
						
							| 
									
										
										
										
											2024-08-30 17:22:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-10 17:48:42 +01:00
										 |  |  |     u32 text_length() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-06 14:44:05 -05:00
										 |  |  |     bool check_validity(); | 
					
						
							|  |  |  |     bool report_validity(); | 
					
						
							|  |  |  |     void set_custom_validity(String const& error); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-01 08:49:04 +01:00
										 |  |  |     WebIDL::Long max_length() const; | 
					
						
							|  |  |  |     WebIDL::ExceptionOr<void> set_max_length(WebIDL::Long); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     WebIDL::Long min_length() const; | 
					
						
							|  |  |  |     WebIDL::ExceptionOr<void> set_min_length(WebIDL::Long); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-28 16:08:14 +00:00
										 |  |  |     WebIDL::UnsignedLong cols() const; | 
					
						
							| 
									
										
										
										
											2023-12-10 17:48:42 +01:00
										 |  |  |     WebIDL::ExceptionOr<void> set_cols(unsigned); | 
					
						
							| 
									
										
										
										
											2023-11-24 17:39:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-28 16:08:14 +00:00
										 |  |  |     WebIDL::UnsignedLong rows() const; | 
					
						
							|  |  |  |     WebIDL::ExceptionOr<void> set_rows(WebIDL::UnsignedLong); | 
					
						
							| 
									
										
										
										
											2023-11-24 17:39:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-22 15:20:24 +02:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-textarea/input-selectionstart
 | 
					
						
							|  |  |  |     WebIDL::UnsignedLong selection_start_binding() const; | 
					
						
							|  |  |  |     WebIDL::ExceptionOr<void> set_selection_start_binding(WebIDL::UnsignedLong const&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-textarea/input-selectionend
 | 
					
						
							|  |  |  |     WebIDL::UnsignedLong selection_end_binding() const; | 
					
						
							|  |  |  |     WebIDL::ExceptionOr<void> set_selection_end_binding(WebIDL::UnsignedLong const&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-textarea/input-selectiondirection
 | 
					
						
							|  |  |  |     String selection_direction_binding() const; | 
					
						
							| 
									
										
										
										
											2024-10-04 12:12:39 +01:00
										 |  |  |     void set_selection_direction_binding(String const& direction); | 
					
						
							| 
									
										
										
										
											2024-08-22 15:20:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-30 17:22:58 +01:00
										 |  |  |     void set_dirty_value_flag(Badge<FormAssociatedElement>, bool flag) { m_dirty_value = flag; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-06 16:46:50 +01:00
										 |  |  |     // ^FormAssociatedTextControlElement
 | 
					
						
							|  |  |  |     virtual void did_edit_text_node() override; | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     virtual GC::Ptr<DOM::Text> form_associated_element_to_text_node() override { return m_text_node; } | 
					
						
							| 
									
										
										
										
											2024-08-26 14:08:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  | private: | 
					
						
							|  |  |  |     HTMLTextAreaElement(DOM::Document&, DOM::QualifiedName); | 
					
						
							| 
									
										
										
										
											2022-11-05 03:58:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-07 08:41:28 +02:00
										 |  |  |     virtual void initialize(JS::Realm&) override; | 
					
						
							| 
									
										
										
										
											2023-08-30 17:10:38 +01:00
										 |  |  |     virtual void visit_edges(Cell::Visitor&) override; | 
					
						
							| 
									
										
										
										
											2023-01-10 06:28:20 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-14 07:26:26 -04:00
										 |  |  |     void set_raw_value(String); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-05 03:58:14 +00:00
										 |  |  |     // ^DOM::Element
 | 
					
						
							|  |  |  |     virtual i32 default_tab_index_value() const override; | 
					
						
							| 
									
										
										
										
											2023-08-30 17:10:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     void create_shadow_tree_if_needed(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-26 19:12:32 +01:00
										 |  |  |     void handle_readonly_attribute(Optional<String> const& value); | 
					
						
							| 
									
										
										
										
											2024-03-01 08:49:04 +01:00
										 |  |  |     void handle_maxlength_attribute(); | 
					
						
							| 
									
										
										
										
											2024-02-26 19:12:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-06 15:14:20 -05:00
										 |  |  |     void queue_firing_input_event(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-21 18:13:16 +01:00
										 |  |  |     void update_placeholder_visibility(); | 
					
						
							| 
									
										
										
										
											2024-08-22 15:20:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     GC::Ptr<DOM::Element> m_placeholder_element; | 
					
						
							|  |  |  |     GC::Ptr<DOM::Text> m_placeholder_text_node; | 
					
						
							| 
									
										
										
										
											2023-12-21 18:13:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     GC::Ptr<DOM::Element> m_inner_text_element; | 
					
						
							|  |  |  |     GC::Ptr<DOM::Text> m_text_node; | 
					
						
							| 
									
										
										
										
											2023-08-30 17:10:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-16 11:44:18 +01:00
										 |  |  |     RefPtr<Core::Timer> m_input_event_timer; | 
					
						
							| 
									
										
										
										
											2024-03-06 15:14:20 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-26 19:12:32 +01:00
										 |  |  |     // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fe-dirty
 | 
					
						
							|  |  |  |     bool m_dirty_value { false }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/form-elements.html#concept-textarea-raw-value
 | 
					
						
							| 
									
										
										
										
											2023-11-26 10:59:52 +13:00
										 |  |  |     String m_raw_value; | 
					
						
							| 
									
										
										
										
											2024-03-14 07:26:26 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fe-api-value
 | 
					
						
							|  |  |  |     mutable Optional<String> m_api_value; | 
					
						
							| 
									
										
										
										
											2020-08-01 03:07:00 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |