| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2023-05-17 19:47:16 +02:00
										 |  |  |  * Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org> | 
					
						
							| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-15 18:55:47 +02:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | #include <AK/Badge.h>
 | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  | #include <AK/DeprecatedString.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-18 10:59:48 -04:00
										 |  |  | #include <AK/FlyString.h>
 | 
					
						
							| 
									
										
										
										
											2021-06-07 16:32:24 +01:00
										 |  |  | #include <AK/JsonObjectSerializer.h>
 | 
					
						
							| 
									
										
										
										
											2019-06-21 18:45:35 +02:00
										 |  |  | #include <AK/RefPtr.h>
 | 
					
						
							| 
									
										
										
										
											2020-07-26 17:16:18 +02:00
										 |  |  | #include <AK/TypeCasts.h>
 | 
					
						
							| 
									
										
										
										
											2019-06-15 18:55:47 +02:00
										 |  |  | #include <AK/Vector.h>
 | 
					
						
							| 
									
										
										
										
											2022-12-11 10:56:37 -06:00
										 |  |  | #include <LibWeb/DOM/AccessibilityTreeNode.h>
 | 
					
						
							| 
									
										
										
										
											2020-03-18 15:22:31 +01:00
										 |  |  | #include <LibWeb/DOM/EventTarget.h>
 | 
					
						
							| 
									
										
										
										
											2022-11-02 19:14:27 -04:00
										 |  |  | #include <LibWeb/DOMParsing/XMLSerializer.h>
 | 
					
						
							| 
									
										
										
										
											2022-09-25 17:03:42 +01:00
										 |  |  | #include <LibWeb/WebIDL/ExceptionOr.h>
 | 
					
						
							| 
									
										
										
										
											2019-06-15 18:55:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 19:37:56 +02:00
										 |  |  | namespace Web::DOM { | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-06 17:06:25 +00:00
										 |  |  | enum class NodeType : u16 { | 
					
						
							| 
									
										
										
										
											2019-06-15 18:55:47 +02:00
										 |  |  |     INVALID = 0, | 
					
						
							|  |  |  |     ELEMENT_NODE = 1, | 
					
						
							| 
									
										
										
										
											2021-03-06 17:06:25 +00:00
										 |  |  |     ATTRIBUTE_NODE = 2, | 
					
						
							| 
									
										
										
										
											2019-06-15 18:55:47 +02:00
										 |  |  |     TEXT_NODE = 3, | 
					
						
							| 
									
										
										
										
											2021-03-06 17:06:25 +00:00
										 |  |  |     CDATA_SECTION_NODE = 4, | 
					
						
							|  |  |  |     ENTITY_REFERENCE_NODE = 5, | 
					
						
							|  |  |  |     ENTITY_NODE = 6, | 
					
						
							|  |  |  |     PROCESSING_INSTRUCTION_NODE = 7, | 
					
						
							| 
									
										
										
										
											2019-10-12 23:26:47 +02:00
										 |  |  |     COMMENT_NODE = 8, | 
					
						
							| 
									
										
										
										
											2019-06-15 18:55:47 +02:00
										 |  |  |     DOCUMENT_NODE = 9, | 
					
						
							| 
									
										
										
										
											2019-10-09 20:17:01 +02:00
										 |  |  |     DOCUMENT_TYPE_NODE = 10, | 
					
						
							| 
									
										
										
										
											2019-11-06 20:27:53 +01:00
										 |  |  |     DOCUMENT_FRAGMENT_NODE = 11, | 
					
						
							| 
									
										
										
										
											2021-03-06 17:06:25 +00:00
										 |  |  |     NOTATION_NODE = 12 | 
					
						
							| 
									
										
										
										
											2019-06-15 18:55:47 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-05 11:21:59 -06:00
										 |  |  | enum class NameOrDescription { | 
					
						
							|  |  |  |     Name, | 
					
						
							|  |  |  |     Description | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-16 03:04:55 +01:00
										 |  |  | struct GetRootNodeOptions { | 
					
						
							|  |  |  |     bool composed { false }; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  | class Node : public EventTarget { | 
					
						
							|  |  |  |     WEB_PLATFORM_OBJECT(Node, EventTarget); | 
					
						
							| 
									
										
										
										
											2020-03-18 15:22:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2021-02-10 18:22:20 +01:00
										 |  |  |     ParentNode* parent_or_shadow_host(); | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     ParentNode const* parent_or_shadow_host() const { return const_cast<Node*>(this)->parent_or_shadow_host(); } | 
					
						
							| 
									
										
										
										
											2021-02-10 18:22:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-05 17:06:19 +01:00
										 |  |  |     Element* parent_or_shadow_host_element(); | 
					
						
							|  |  |  |     Element const* parent_or_shadow_host_element() const { return const_cast<Node*>(this)->parent_or_shadow_host_element(); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-15 18:55:47 +02:00
										 |  |  |     virtual ~Node(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     NodeType type() const { return m_type; } | 
					
						
							|  |  |  |     bool is_element() const { return type() == NodeType::ELEMENT_NODE; } | 
					
						
							|  |  |  |     bool is_text() const { return type() == NodeType::TEXT_NODE; } | 
					
						
							|  |  |  |     bool is_document() const { return type() == NodeType::DOCUMENT_NODE; } | 
					
						
							| 
									
										
										
										
											2019-10-09 20:17:01 +02:00
										 |  |  |     bool is_document_type() const { return type() == NodeType::DOCUMENT_TYPE_NODE; } | 
					
						
							| 
									
										
										
										
											2019-10-12 23:26:47 +02:00
										 |  |  |     bool is_comment() const { return type() == NodeType::COMMENT_NODE; } | 
					
						
							|  |  |  |     bool is_character_data() const { return type() == NodeType::TEXT_NODE || type() == NodeType::COMMENT_NODE; } | 
					
						
							| 
									
										
										
										
											2019-11-06 20:27:53 +01:00
										 |  |  |     bool is_document_fragment() const { return type() == NodeType::DOCUMENT_FRAGMENT_NODE; } | 
					
						
							| 
									
										
										
										
											2020-03-25 18:48:10 +01:00
										 |  |  |     bool is_parent_node() const { return is_element() || is_document() || is_document_fragment(); } | 
					
						
							| 
									
										
										
										
											2020-11-21 18:32:39 +00:00
										 |  |  |     bool is_slottable() const { return is_element() || is_text(); } | 
					
						
							| 
									
										
										
										
											2022-01-31 18:05:54 +00:00
										 |  |  |     bool is_attribute() const { return type() == NodeType::ATTRIBUTE_NODE; } | 
					
						
							| 
									
										
										
										
											2022-06-27 21:20:59 +01:00
										 |  |  |     bool is_cdata_section() const { return type() == NodeType::CDATA_SECTION_NODE; } | 
					
						
							| 
									
										
										
										
											2022-03-13 17:21:27 +01:00
										 |  |  |     virtual bool is_shadow_root() const { return false; } | 
					
						
							| 
									
										
										
										
											2019-06-15 18:55:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-05 10:26:09 +02:00
										 |  |  |     virtual bool requires_svg_container() const { return false; } | 
					
						
							|  |  |  |     virtual bool is_svg_container() const { return false; } | 
					
						
							| 
									
										
										
										
											2023-05-24 05:41:55 +02:00
										 |  |  |     virtual bool is_svg_element() const { return false; } | 
					
						
							| 
									
										
										
										
											2023-08-03 13:26:29 +02:00
										 |  |  |     virtual bool is_svg_graphics_element() const { return false; } | 
					
						
							| 
									
										
										
										
											2022-03-12 16:08:40 +01:00
										 |  |  |     virtual bool is_svg_svg_element() const { return false; } | 
					
						
							| 
									
										
										
										
											2023-06-23 02:15:03 +03:00
										 |  |  |     virtual bool is_svg_use_element() const { return false; } | 
					
						
							| 
									
										
										
										
											2021-08-05 10:26:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-29 22:23:28 +02:00
										 |  |  |     bool in_a_document_tree() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-06 17:06:25 +00:00
										 |  |  |     // NOTE: This is intended for the JS bindings.
 | 
					
						
							|  |  |  |     u16 node_type() const { return (u16)m_type; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-02 16:05:59 +02:00
										 |  |  |     virtual bool is_editable() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-13 19:54:03 +02:00
										 |  |  |     virtual bool is_dom_node() const final { return true; } | 
					
						
							| 
									
										
										
										
											2022-07-27 16:04:31 +02:00
										 |  |  |     virtual bool is_html_element() const { return false; } | 
					
						
							| 
									
										
										
										
											2021-10-27 17:58:57 +02:00
										 |  |  |     virtual bool is_html_html_element() const { return false; } | 
					
						
							| 
									
										
										
										
											2022-03-02 15:14:38 +01:00
										 |  |  |     virtual bool is_html_anchor_element() const { return false; } | 
					
						
							| 
									
										
										
										
											2022-07-27 16:03:43 +02:00
										 |  |  |     virtual bool is_html_base_element() const { return false; } | 
					
						
							| 
									
										
										
										
											2023-03-10 21:16:18 +01:00
										 |  |  |     virtual bool is_html_body_element() const { return false; } | 
					
						
							|  |  |  |     virtual bool is_html_input_element() const { return false; } | 
					
						
							|  |  |  |     virtual bool is_html_progress_element() const { return false; } | 
					
						
							| 
									
										
										
										
											2023-05-07 07:43:21 +02:00
										 |  |  |     virtual bool is_html_script_element() const { return false; } | 
					
						
							| 
									
										
										
										
											2021-09-16 00:52:10 +02:00
										 |  |  |     virtual bool is_html_template_element() const { return false; } | 
					
						
							| 
									
										
										
										
											2023-08-22 14:55:10 +02:00
										 |  |  |     virtual bool is_html_table_element() const { return false; } | 
					
						
							|  |  |  |     virtual bool is_html_table_section_element() const { return false; } | 
					
						
							|  |  |  |     virtual bool is_html_table_row_element() const { return false; } | 
					
						
							|  |  |  |     virtual bool is_html_table_cell_element() const { return false; } | 
					
						
							| 
									
										
										
										
											2022-12-12 12:20:02 +01:00
										 |  |  |     virtual bool is_navigable_container() const { return false; } | 
					
						
							| 
									
										
										
										
											2021-09-16 00:52:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-25 17:03:42 +01:00
										 |  |  |     WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> pre_insert(JS::NonnullGCPtr<Node>, JS::GCPtr<Node>); | 
					
						
							|  |  |  |     WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> pre_remove(JS::NonnullGCPtr<Node>); | 
					
						
							| 
									
										
										
										
											2021-04-06 19:34:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-25 17:03:42 +01:00
										 |  |  |     WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> append_child(JS::NonnullGCPtr<Node>); | 
					
						
							|  |  |  |     WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> remove_child(JS::NonnullGCPtr<Node>); | 
					
						
							| 
									
										
										
										
											2022-02-21 22:21:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     void insert_before(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child, bool suppress_observers = false); | 
					
						
							| 
									
										
										
										
											2021-04-06 19:34:49 +01:00
										 |  |  |     void remove(bool suppress_observers = false); | 
					
						
							|  |  |  |     void remove_all_children(bool suppress_observers = false); | 
					
						
							| 
									
										
										
										
											2023-03-30 11:14:26 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     enum DocumentPosition : u16 { | 
					
						
							|  |  |  |         DOCUMENT_POSITION_EQUAL = 0, | 
					
						
							|  |  |  |         DOCUMENT_POSITION_DISCONNECTED = 1, | 
					
						
							|  |  |  |         DOCUMENT_POSITION_PRECEDING = 2, | 
					
						
							|  |  |  |         DOCUMENT_POSITION_FOLLOWING = 4, | 
					
						
							|  |  |  |         DOCUMENT_POSITION_CONTAINS = 8, | 
					
						
							|  |  |  |         DOCUMENT_POSITION_CONTAINED_BY = 16, | 
					
						
							|  |  |  |         DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     u16 compare_document_position(JS::GCPtr<Node> other); | 
					
						
							| 
									
										
										
										
											2020-06-21 01:00:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-25 17:03:42 +01:00
										 |  |  |     WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> replace_child(JS::NonnullGCPtr<Node> node, JS::NonnullGCPtr<Node> child); | 
					
						
							| 
									
										
										
										
											2021-05-07 00:52:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     JS::NonnullGCPtr<Node> clone_node(Document* document = nullptr, bool clone_children = false); | 
					
						
							| 
									
										
										
										
											2022-09-25 17:03:42 +01:00
										 |  |  |     WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> clone_node_binding(bool deep); | 
					
						
							| 
									
										
										
										
											2021-04-14 01:25:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-06 17:06:25 +00:00
										 |  |  |     // NOTE: This is intended for the JS bindings.
 | 
					
						
							|  |  |  |     bool has_child_nodes() const { return has_children(); } | 
					
						
							| 
									
										
										
										
											2022-09-01 16:30:26 +02:00
										 |  |  |     JS::NonnullGCPtr<NodeList> child_nodes(); | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     Vector<JS::Handle<Node>> children_as_vector() const; | 
					
						
							| 
									
										
										
										
											2021-03-06 17:06:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  |     virtual DeprecatedFlyString node_name() const = 0; | 
					
						
							| 
									
										
										
										
											2019-09-28 22:59:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  |     DeprecatedString base_uri() const; | 
					
						
							| 
									
										
										
										
											2022-04-12 13:20:13 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  |     DeprecatedString descendant_text_content() const; | 
					
						
							|  |  |  |     DeprecatedString text_content() const; | 
					
						
							|  |  |  |     void set_text_content(DeprecatedString const&); | 
					
						
							| 
									
										
										
										
											2019-09-29 16:22:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  |     DeprecatedString node_value() const; | 
					
						
							|  |  |  |     void set_node_value(DeprecatedString const&); | 
					
						
							| 
									
										
										
										
											2022-02-18 22:11:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-23 00:21:59 +03:00
										 |  |  |     JS::GCPtr<HTML::Navigable> navigable() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-25 23:42:08 +02:00
										 |  |  |     Document& document() { return *m_document; } | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     Document const& document() const { return *m_document; } | 
					
						
							| 
									
										
										
										
											2019-09-29 11:43:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     JS::GCPtr<Document> owner_document() const; | 
					
						
							| 
									
										
										
										
											2021-05-02 21:03:50 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-28 18:20:36 +02:00
										 |  |  |     const HTML::HTMLAnchorElement* enclosing_link_element() const; | 
					
						
							|  |  |  |     const HTML::HTMLElement* enclosing_html_element() const; | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  |     const HTML::HTMLElement* enclosing_html_element_with_attribute(DeprecatedFlyString const&) const; | 
					
						
							| 
									
										
										
										
											2019-09-29 12:24:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  |     DeprecatedString child_text_content() const; | 
					
						
							| 
									
										
										
										
											2020-05-24 21:59:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-02 19:27:42 +01:00
										 |  |  |     Node& root(); | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     Node const& root() const | 
					
						
							| 
									
										
										
										
											2020-11-21 18:32:39 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         return const_cast<Node*>(this)->root(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-02 19:27:42 +01:00
										 |  |  |     Node& shadow_including_root(); | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     Node const& shadow_including_root() const | 
					
						
							| 
									
										
										
										
											2020-11-21 18:32:39 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         return const_cast<Node*>(this)->shadow_including_root(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-24 21:59:24 +02:00
										 |  |  |     bool is_connected() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-20 22:26:54 +02:00
										 |  |  |     Node* parent_node() { return parent(); } | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     Node const* parent_node() const { return parent(); } | 
					
						
							| 
									
										
										
										
											2020-06-20 22:26:54 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Element* parent_element(); | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     Element const* parent_element() const; | 
					
						
							| 
									
										
										
										
											2020-06-20 22:26:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-06 17:58:20 +01:00
										 |  |  |     virtual void inserted(); | 
					
						
							|  |  |  |     virtual void removed_from(Node*) { } | 
					
						
							| 
									
										
										
										
											2020-07-26 17:16:18 +02:00
										 |  |  |     virtual void children_changed() { } | 
					
						
							| 
									
										
										
										
											2021-07-05 05:33:35 +01:00
										 |  |  |     virtual void adopted_from(Document&) { } | 
					
						
							| 
									
										
										
										
											2021-07-05 05:30:24 +01:00
										 |  |  |     virtual void cloned(Node&, bool) {}; | 
					
						
							| 
									
										
										
										
											2019-09-29 17:40:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     Layout::Node const* layout_node() const { return m_layout_node; } | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     Layout::Node* layout_node() { return m_layout_node; } | 
					
						
							| 
									
										
										
										
											2019-10-04 21:05:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-20 16:01:16 +01:00
										 |  |  |     Painting::PaintableBox const* paintable_box() const; | 
					
						
							| 
									
										
										
										
											2023-08-07 00:59:23 +02:00
										 |  |  |     Painting::PaintableBox* paintable_box(); | 
					
						
							| 
									
										
										
										
											2022-03-10 22:46:35 +01:00
										 |  |  |     Painting::Paintable const* paintable() const; | 
					
						
							| 
									
										
										
										
											2023-08-19 09:29:04 +02:00
										 |  |  |     Painting::Paintable* paintable(); | 
					
						
							| 
									
										
										
										
											2022-03-09 23:53:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-19 12:00:42 +02:00
										 |  |  |     void set_paintable(JS::GCPtr<Painting::Paintable>); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-17 14:41:50 +02:00
										 |  |  |     void set_layout_node(Badge<Layout::Node>, JS::NonnullGCPtr<Layout::Node>); | 
					
						
							| 
									
										
										
										
											2023-08-01 08:23:13 +02:00
										 |  |  |     void detach_layout_node(Badge<Layout::TreeBuilder>); | 
					
						
							| 
									
										
										
										
											2019-10-04 21:05:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     virtual bool is_child_allowed(Node const&) const { return true; } | 
					
						
							| 
									
										
										
										
											2019-10-12 23:26:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-19 18:57:02 +02:00
										 |  |  |     bool needs_style_update() const { return m_needs_style_update; } | 
					
						
							| 
									
										
										
										
											2020-12-13 15:19:42 +01:00
										 |  |  |     void set_needs_style_update(bool); | 
					
						
							| 
									
										
										
										
											2019-10-19 18:57:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-14 12:04:30 +01:00
										 |  |  |     bool child_needs_style_update() const { return m_child_needs_style_update; } | 
					
						
							|  |  |  |     void set_child_needs_style_update(bool b) { m_child_needs_style_update = b; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-14 18:32:02 +02:00
										 |  |  |     void invalidate_style(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-25 23:42:08 +02:00
										 |  |  |     void set_document(Badge<Document>, Document&); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     virtual EventTarget* get_parent(Event const&) override; | 
					
						
							| 
									
										
										
										
											2020-11-21 18:32:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-17 09:34:01 +01:00
										 |  |  |     template<typename T> | 
					
						
							|  |  |  |     bool fast_is() const = delete; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-25 17:03:42 +01:00
										 |  |  |     WebIDL::ExceptionOr<void> ensure_pre_insertion_validity(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child) const; | 
					
						
							| 
									
										
										
										
											2021-04-06 19:34:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     bool is_host_including_inclusive_ancestor_of(Node const&) const; | 
					
						
							| 
									
										
										
										
											2021-04-06 19:34:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-30 22:28:28 +01:00
										 |  |  |     bool is_scripting_enabled() const; | 
					
						
							| 
									
										
										
										
											2021-07-05 03:59:47 +01:00
										 |  |  |     bool is_scripting_disabled() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     bool contains(JS::GCPtr<Node>) const; | 
					
						
							| 
									
										
										
										
											2021-07-05 05:55:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-07 16:32:24 +01:00
										 |  |  |     // Used for dumping the DOM Tree
 | 
					
						
							|  |  |  |     void serialize_tree_as_json(JsonObjectSerializer<StringBuilder>&) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-02 02:17:13 +01:00
										 |  |  |     bool is_shadow_including_descendant_of(Node const&) const; | 
					
						
							|  |  |  |     bool is_shadow_including_inclusive_descendant_of(Node const&) const; | 
					
						
							|  |  |  |     bool is_shadow_including_ancestor_of(Node const&) const; | 
					
						
							|  |  |  |     bool is_shadow_including_inclusive_ancestor_of(Node const&) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-30 15:52:08 +01:00
										 |  |  |     i32 id() const { return m_id; } | 
					
						
							|  |  |  |     static Node* from_id(i32 node_id); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  |     WebIDL::ExceptionOr<DeprecatedString> serialize_fragment(DOMParsing::RequireWellFormed) const; | 
					
						
							| 
									
										
										
										
											2021-09-13 22:42:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     void replace_all(JS::GCPtr<Node>); | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  |     void string_replace_all(DeprecatedString const&); | 
					
						
							| 
									
										
										
										
											2021-09-06 01:25:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-13 12:49:23 +02:00
										 |  |  |     bool is_same_node(Node const*) const; | 
					
						
							| 
									
										
										
										
											2021-09-13 12:54:24 +02:00
										 |  |  |     bool is_equal_node(Node const*) const; | 
					
						
							| 
									
										
										
										
											2021-09-13 12:49:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     JS::NonnullGCPtr<Node> get_root_node(GetRootNodeOptions const& options = {}); | 
					
						
							| 
									
										
										
										
											2021-10-16 03:04:55 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-02 19:20:57 +01:00
										 |  |  |     bool is_uninteresting_whitespace_node() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  |     DeprecatedString debug_description() const; | 
					
						
							| 
									
										
										
										
											2022-02-26 08:18:14 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-31 18:05:54 +00:00
										 |  |  |     size_t length() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-01 17:59:48 +02:00
										 |  |  |     auto& registered_observers_list() { return m_registered_observer_list; } | 
					
						
							|  |  |  |     auto const& registered_observers_list() const { return m_registered_observer_list; } | 
					
						
							| 
									
										
										
										
											2022-07-11 16:37:51 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     void add_registered_observer(RegisteredObserver& registered_observer) { m_registered_observer_list.append(registered_observer); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-17 19:47:16 +02:00
										 |  |  |     void queue_mutation_record(FlyString const& type, DeprecatedString attribute_name, DeprecatedString attribute_namespace, DeprecatedString old_value, Vector<JS::Handle<Node>> added_nodes, Vector<JS::Handle<Node>> removed_nodes, Node* previous_sibling, Node* next_sibling) const; | 
					
						
							| 
									
										
										
										
											2022-07-11 16:39:14 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-29 23:46:18 +01:00
										 |  |  |     // https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant
 | 
					
						
							|  |  |  |     template<typename Callback> | 
					
						
							|  |  |  |     IterationDecision for_each_shadow_including_inclusive_descendant(Callback); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-12 23:13:57 +02:00
										 |  |  |     // https://dom.spec.whatwg.org/#concept-shadow-including-descendant
 | 
					
						
							|  |  |  |     template<typename Callback> | 
					
						
							|  |  |  |     IterationDecision for_each_shadow_including_descendant(Callback); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     Node* parent() { return m_parent.ptr(); } | 
					
						
							|  |  |  |     Node const* parent() const { return m_parent.ptr(); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool has_children() const { return m_first_child; } | 
					
						
							|  |  |  |     Node* next_sibling() { return m_next_sibling.ptr(); } | 
					
						
							|  |  |  |     Node* previous_sibling() { return m_previous_sibling.ptr(); } | 
					
						
							|  |  |  |     Node* first_child() { return m_first_child.ptr(); } | 
					
						
							|  |  |  |     Node* last_child() { return m_last_child.ptr(); } | 
					
						
							|  |  |  |     Node const* next_sibling() const { return m_next_sibling.ptr(); } | 
					
						
							|  |  |  |     Node const* previous_sibling() const { return m_previous_sibling.ptr(); } | 
					
						
							|  |  |  |     Node const* first_child() const { return m_first_child.ptr(); } | 
					
						
							|  |  |  |     Node const* last_child() const { return m_last_child.ptr(); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     size_t child_count() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         size_t count = 0; | 
					
						
							|  |  |  |         for (auto* child = first_child(); child; child = child->next_sibling()) | 
					
						
							|  |  |  |             ++count; | 
					
						
							|  |  |  |         return count; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Node* child_at_index(int index) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int count = 0; | 
					
						
							|  |  |  |         for (auto* child = first_child(); child; child = child->next_sibling()) { | 
					
						
							|  |  |  |             if (count == index) | 
					
						
							|  |  |  |                 return child; | 
					
						
							|  |  |  |             ++count; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return nullptr; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Node const* child_at_index(int index) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return const_cast<Node*>(this)->child_at_index(index); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://dom.spec.whatwg.org/#concept-tree-index
 | 
					
						
							|  |  |  |     size_t index() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // The index of an object is its number of preceding siblings, or 0 if it has none.
 | 
					
						
							|  |  |  |         size_t index = 0; | 
					
						
							|  |  |  |         for (auto* node = previous_sibling(); node; node = node->previous_sibling()) | 
					
						
							|  |  |  |             ++index; | 
					
						
							|  |  |  |         return index; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Optional<size_t> index_of_child(Node const& search_child) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         VERIFY(search_child.parent() == this); | 
					
						
							|  |  |  |         size_t index = 0; | 
					
						
							|  |  |  |         auto* child = first_child(); | 
					
						
							|  |  |  |         VERIFY(child); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         do { | 
					
						
							|  |  |  |             if (child == &search_child) | 
					
						
							|  |  |  |                 return index; | 
					
						
							|  |  |  |             index++; | 
					
						
							|  |  |  |         } while (child && (child = child->next_sibling())); | 
					
						
							|  |  |  |         return {}; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename ChildType> | 
					
						
							|  |  |  |     Optional<size_t> index_of_child(Node const& search_child) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         VERIFY(search_child.parent() == this); | 
					
						
							|  |  |  |         size_t index = 0; | 
					
						
							|  |  |  |         auto* child = first_child(); | 
					
						
							|  |  |  |         VERIFY(child); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         do { | 
					
						
							|  |  |  |             if (!is<ChildType>(child)) | 
					
						
							|  |  |  |                 continue; | 
					
						
							|  |  |  |             if (child == &search_child) | 
					
						
							|  |  |  |                 return index; | 
					
						
							|  |  |  |             index++; | 
					
						
							|  |  |  |         } while (child && (child = child->next_sibling())); | 
					
						
							|  |  |  |         return {}; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool is_ancestor_of(Node const&) const; | 
					
						
							|  |  |  |     bool is_inclusive_ancestor_of(Node const&) const; | 
					
						
							|  |  |  |     bool is_descendant_of(Node const&) const; | 
					
						
							|  |  |  |     bool is_inclusive_descendant_of(Node const&) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool is_following(Node const&) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Node* next_in_pre_order() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (first_child()) | 
					
						
							|  |  |  |             return first_child(); | 
					
						
							|  |  |  |         Node* node; | 
					
						
							|  |  |  |         if (!(node = next_sibling())) { | 
					
						
							|  |  |  |             node = parent(); | 
					
						
							|  |  |  |             while (node && !node->next_sibling()) | 
					
						
							|  |  |  |                 node = node->parent(); | 
					
						
							|  |  |  |             if (node) | 
					
						
							|  |  |  |                 node = node->next_sibling(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return node; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Node* next_in_pre_order(Node const* stay_within) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (first_child()) | 
					
						
							|  |  |  |             return first_child(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         Node* node = static_cast<Node*>(this); | 
					
						
							|  |  |  |         Node* next = nullptr; | 
					
						
							|  |  |  |         while (!(next = node->next_sibling())) { | 
					
						
							|  |  |  |             node = node->parent(); | 
					
						
							|  |  |  |             if (!node || node == stay_within) | 
					
						
							|  |  |  |                 return nullptr; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return next; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Node const* next_in_pre_order() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return const_cast<Node*>(this)->next_in_pre_order(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Node const* next_in_pre_order(Node const* stay_within) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return const_cast<Node*>(this)->next_in_pre_order(stay_within); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Node* previous_in_pre_order() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (auto* node = previous_sibling()) { | 
					
						
							|  |  |  |             while (node->last_child()) | 
					
						
							|  |  |  |                 node = node->last_child(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             return node; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return parent(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Node const* previous_in_pre_order() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return const_cast<Node*>(this)->previous_in_pre_order(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool is_before(Node const& other) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (this == &other) | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         for (auto* node = this; node; node = node->next_in_pre_order()) { | 
					
						
							|  |  |  |             if (node == &other) | 
					
						
							|  |  |  |                 return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://dom.spec.whatwg.org/#concept-tree-preceding (Object A is 'typename U' and Object B is 'this')
 | 
					
						
							|  |  |  |     template<typename U> | 
					
						
							|  |  |  |     bool has_preceding_node_of_type_in_tree_order() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (auto* node = previous_in_pre_order(); node; node = node->previous_in_pre_order()) { | 
					
						
							|  |  |  |             if (is<U>(node)) | 
					
						
							|  |  |  |                 return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://dom.spec.whatwg.org/#concept-tree-following (Object A is 'typename U' and Object B is 'this')
 | 
					
						
							|  |  |  |     template<typename U> | 
					
						
							|  |  |  |     bool has_following_node_of_type_in_tree_order() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (auto* node = next_in_pre_order(); node; node = node->next_in_pre_order()) { | 
					
						
							|  |  |  |             if (is<U>(node)) | 
					
						
							|  |  |  |                 return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename Callback> | 
					
						
							|  |  |  |     IterationDecision for_each_in_inclusive_subtree(Callback callback) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (callback(static_cast<Node const&>(*this)) == IterationDecision::Break) | 
					
						
							|  |  |  |             return IterationDecision::Break; | 
					
						
							|  |  |  |         for (auto* child = first_child(); child; child = child->next_sibling()) { | 
					
						
							|  |  |  |             if (child->for_each_in_inclusive_subtree(callback) == IterationDecision::Break) | 
					
						
							|  |  |  |                 return IterationDecision::Break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return IterationDecision::Continue; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename Callback> | 
					
						
							|  |  |  |     IterationDecision for_each_in_inclusive_subtree(Callback callback) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (callback(static_cast<Node&>(*this)) == IterationDecision::Break) | 
					
						
							|  |  |  |             return IterationDecision::Break; | 
					
						
							|  |  |  |         for (auto* child = first_child(); child; child = child->next_sibling()) { | 
					
						
							|  |  |  |             if (child->for_each_in_inclusive_subtree(callback) == IterationDecision::Break) | 
					
						
							|  |  |  |                 return IterationDecision::Break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return IterationDecision::Continue; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U, typename Callback> | 
					
						
							|  |  |  |     IterationDecision for_each_in_inclusive_subtree_of_type(Callback callback) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-02-25 10:44:51 -07:00
										 |  |  |         if (is<U>(static_cast<Node&>(*this))) { | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |             if (callback(static_cast<U&>(*this)) == IterationDecision::Break) | 
					
						
							|  |  |  |                 return IterationDecision::Break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         for (auto* child = first_child(); child; child = child->next_sibling()) { | 
					
						
							|  |  |  |             if (child->template for_each_in_inclusive_subtree_of_type<U>(callback) == IterationDecision::Break) | 
					
						
							|  |  |  |                 return IterationDecision::Break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return IterationDecision::Continue; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U, typename Callback> | 
					
						
							|  |  |  |     IterationDecision for_each_in_inclusive_subtree_of_type(Callback callback) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (is<U>(static_cast<Node const&>(*this))) { | 
					
						
							|  |  |  |             if (callback(static_cast<U const&>(*this)) == IterationDecision::Break) | 
					
						
							|  |  |  |                 return IterationDecision::Break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         for (auto* child = first_child(); child; child = child->next_sibling()) { | 
					
						
							|  |  |  |             if (child->template for_each_in_inclusive_subtree_of_type<U>(callback) == IterationDecision::Break) | 
					
						
							|  |  |  |                 return IterationDecision::Break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return IterationDecision::Continue; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename Callback> | 
					
						
							|  |  |  |     IterationDecision for_each_in_subtree(Callback callback) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (auto* child = first_child(); child; child = child->next_sibling()) { | 
					
						
							|  |  |  |             if (child->for_each_in_inclusive_subtree(callback) == IterationDecision::Break) | 
					
						
							|  |  |  |                 return IterationDecision::Break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return IterationDecision::Continue; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename Callback> | 
					
						
							|  |  |  |     IterationDecision for_each_in_subtree(Callback callback) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (auto* child = first_child(); child; child = child->next_sibling()) { | 
					
						
							|  |  |  |             if (child->for_each_in_inclusive_subtree(callback) == IterationDecision::Break) | 
					
						
							|  |  |  |                 return IterationDecision::Break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return IterationDecision::Continue; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U, typename Callback> | 
					
						
							|  |  |  |     IterationDecision for_each_in_subtree_of_type(Callback callback) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (auto* child = first_child(); child; child = child->next_sibling()) { | 
					
						
							|  |  |  |             if (child->template for_each_in_inclusive_subtree_of_type<U>(callback) == IterationDecision::Break) | 
					
						
							|  |  |  |                 return IterationDecision::Break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return IterationDecision::Continue; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U, typename Callback> | 
					
						
							|  |  |  |     IterationDecision for_each_in_subtree_of_type(Callback callback) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (auto* child = first_child(); child; child = child->next_sibling()) { | 
					
						
							|  |  |  |             if (child->template for_each_in_inclusive_subtree_of_type<U>(callback) == IterationDecision::Break) | 
					
						
							|  |  |  |                 return IterationDecision::Break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return IterationDecision::Continue; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename Callback> | 
					
						
							|  |  |  |     void for_each_child(Callback callback) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return const_cast<Node*>(this)->template for_each_child(move(callback)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename Callback> | 
					
						
							|  |  |  |     void for_each_child(Callback callback) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (auto* node = first_child(); node; node = node->next_sibling()) | 
					
						
							|  |  |  |             callback(*node); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U, typename Callback> | 
					
						
							|  |  |  |     void for_each_child_of_type(Callback callback) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (auto* node = first_child(); node; node = node->next_sibling()) { | 
					
						
							|  |  |  |             if (is<U>(node)) | 
					
						
							|  |  |  |                 callback(verify_cast<U>(*node)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U, typename Callback> | 
					
						
							|  |  |  |     void for_each_child_of_type(Callback callback) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return const_cast<Node*>(this)->template for_each_child_of_type<U>(move(callback)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U> | 
					
						
							|  |  |  |     U const* next_sibling_of_type() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return const_cast<Node*>(this)->template next_sibling_of_type<U>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U> | 
					
						
							|  |  |  |     inline U* next_sibling_of_type() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (auto* sibling = next_sibling(); sibling; sibling = sibling->next_sibling()) { | 
					
						
							|  |  |  |             if (is<U>(*sibling)) | 
					
						
							|  |  |  |                 return &verify_cast<U>(*sibling); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return nullptr; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U> | 
					
						
							|  |  |  |     U const* previous_sibling_of_type() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return const_cast<Node*>(this)->template previous_sibling_of_type<U>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U> | 
					
						
							|  |  |  |     U* previous_sibling_of_type() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (auto* sibling = previous_sibling(); sibling; sibling = sibling->previous_sibling()) { | 
					
						
							|  |  |  |             if (is<U>(*sibling)) | 
					
						
							|  |  |  |                 return &verify_cast<U>(*sibling); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return nullptr; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U> | 
					
						
							|  |  |  |     U const* first_child_of_type() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return const_cast<Node*>(this)->template first_child_of_type<U>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U> | 
					
						
							|  |  |  |     U const* last_child_of_type() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return const_cast<Node*>(this)->template last_child_of_type<U>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U> | 
					
						
							|  |  |  |     U* first_child_of_type() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (auto* child = first_child(); child; child = child->next_sibling()) { | 
					
						
							|  |  |  |             if (is<U>(*child)) | 
					
						
							|  |  |  |                 return &verify_cast<U>(*child); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return nullptr; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U> | 
					
						
							|  |  |  |     U* last_child_of_type() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (auto* child = last_child(); child; child = child->previous_sibling()) { | 
					
						
							|  |  |  |             if (is<U>(*child)) | 
					
						
							|  |  |  |                 return &verify_cast<U>(*child); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return nullptr; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U> | 
					
						
							|  |  |  |     bool has_child_of_type() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return first_child_of_type<U>() != nullptr; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U> | 
					
						
							|  |  |  |     U const* first_ancestor_of_type() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return const_cast<Node*>(this)->template first_ancestor_of_type<U>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U> | 
					
						
							|  |  |  |     U* first_ancestor_of_type() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) { | 
					
						
							|  |  |  |             if (is<U>(*ancestor)) | 
					
						
							|  |  |  |                 return &verify_cast<U>(*ancestor); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return nullptr; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-28 18:27:35 +01:00
										 |  |  |     template<typename U> | 
					
						
							|  |  |  |     U const* shadow_including_first_ancestor_of_type() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return const_cast<Node*>(this)->template shadow_including_first_ancestor_of_type<U>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename U> | 
					
						
							|  |  |  |     U* shadow_including_first_ancestor_of_type(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     bool is_parent_of(Node const& other) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (auto* child = first_child(); child; child = child->next_sibling()) { | 
					
						
							|  |  |  |             if (&other == child) | 
					
						
							|  |  |  |                 return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-05 11:21:59 -06:00
										 |  |  |     ErrorOr<String> accessible_name(Document const&) const; | 
					
						
							|  |  |  |     ErrorOr<String> accessible_description(Document const&) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-15 18:55:47 +02:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     Node(JS::Realm&, Document&, NodeType); | 
					
						
							| 
									
										
										
										
											2019-09-29 11:43:07 +02:00
										 |  |  |     Node(Document&, NodeType); | 
					
						
							| 
									
										
										
										
											2019-06-15 18:55:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     virtual void visit_edges(Cell::Visitor&) override; | 
					
						
							| 
									
										
										
										
											2022-10-20 19:30:29 +02:00
										 |  |  |     virtual void finalize() override; | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     JS::GCPtr<Document> m_document; | 
					
						
							| 
									
										
										
										
											2022-10-17 14:41:50 +02:00
										 |  |  |     JS::GCPtr<Layout::Node> m_layout_node; | 
					
						
							| 
									
										
										
										
											2023-08-19 12:00:42 +02:00
										 |  |  |     JS::GCPtr<Painting::Paintable> m_paintable; | 
					
						
							| 
									
										
										
										
											2019-06-15 18:55:47 +02:00
										 |  |  |     NodeType m_type { NodeType::INVALID }; | 
					
						
							| 
									
										
										
										
											2020-12-14 12:04:30 +01:00
										 |  |  |     bool m_needs_style_update { false }; | 
					
						
							|  |  |  |     bool m_child_needs_style_update { false }; | 
					
						
							| 
									
										
										
										
											2021-08-30 15:52:08 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     i32 m_id; | 
					
						
							| 
									
										
										
										
											2022-07-11 16:37:51 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://dom.spec.whatwg.org/#registered-observer-list
 | 
					
						
							|  |  |  |     // "Nodes have a strong reference to registered observers in their registered observer list." https://dom.spec.whatwg.org/#garbage-collection
 | 
					
						
							| 
									
										
										
										
											2023-02-26 16:09:02 -07:00
										 |  |  |     Vector<JS::NonnullGCPtr<RegisteredObserver>> m_registered_observer_list; | 
					
						
							| 
									
										
										
										
											2022-07-11 16:39:14 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-25 10:44:51 -07:00
										 |  |  |     void build_accessibility_tree(AccessibilityTreeNode& parent); | 
					
						
							| 
									
										
										
										
											2022-12-11 10:56:37 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-05 11:21:59 -06:00
										 |  |  |     ErrorOr<String> name_or_description(NameOrDescription, Document const&, HashTable<i32>&) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-11 16:39:14 +01:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2023-05-17 19:47:16 +02:00
										 |  |  |     void queue_tree_mutation_record(Vector<JS::Handle<Node>> added_nodes, Vector<JS::Handle<Node>> removed_nodes, Node* previous_sibling, Node* next_sibling); | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     void insert_before_impl(JS::NonnullGCPtr<Node>, JS::GCPtr<Node> child); | 
					
						
							|  |  |  |     void append_child_impl(JS::NonnullGCPtr<Node>); | 
					
						
							|  |  |  |     void remove_child_impl(JS::NonnullGCPtr<Node>); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-05 11:21:59 -06:00
										 |  |  |     static Optional<StringView> first_valid_id(DeprecatedString const&, Document const&); | 
					
						
							|  |  |  |     static ErrorOr<void> append_without_space(StringBuilder, StringView const&); | 
					
						
							|  |  |  |     static ErrorOr<void> append_with_space(StringBuilder, StringView const&); | 
					
						
							|  |  |  |     static ErrorOr<void> prepend_without_space(StringBuilder, StringView const&); | 
					
						
							|  |  |  |     static ErrorOr<void> prepend_with_space(StringBuilder, StringView const&); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     JS::GCPtr<Node> m_parent; | 
					
						
							|  |  |  |     JS::GCPtr<Node> m_first_child; | 
					
						
							|  |  |  |     JS::GCPtr<Node> m_last_child; | 
					
						
							|  |  |  |     JS::GCPtr<Node> m_next_sibling; | 
					
						
							|  |  |  |     JS::GCPtr<Node> m_previous_sibling; | 
					
						
							| 
									
										
										
										
											2022-09-21 13:49:31 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     JS::GCPtr<NodeList> m_child_nodes; | 
					
						
							| 
									
										
										
										
											2019-06-15 18:55:47 +02:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2019-10-06 20:37:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2023-07-13 19:54:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | template<> | 
					
						
							|  |  |  | inline bool JS::Object::fast_is<Web::DOM::Node>() const { return is_dom_node(); } |