From 3b12a13f172d63c5d752b872d6669037532c05a3 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 17 Sep 2023 11:35:34 +1200 Subject: [PATCH] LibWeb: Add String variants of functions in ChildNode This is required in porting over CharacterData from DeprecatedString to String. Unfortunately, as with ParentNode, we cannot yet remove the DeprecatedString variants of these functions as the Element interface includes ChildNode and has not yet been ported over from DeprecatedString. --- Userland/Libraries/LibWeb/DOM/ChildNode.h | 31 +++++++++++++++++------ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/ChildNode.h b/Userland/Libraries/LibWeb/DOM/ChildNode.h index 734ef52922..bf4a29200f 100644 --- a/Userland/Libraries/LibWeb/DOM/ChildNode.h +++ b/Userland/Libraries/LibWeb/DOM/ChildNode.h @@ -16,7 +16,7 @@ template class ChildNode { public: // https://dom.spec.whatwg.org/#dom-childnode-before - WebIDL::ExceptionOr before(Vector, DeprecatedString>> const& nodes) + WebIDL::ExceptionOr before(Vector, String>> const& nodes) { auto* node = static_cast(this); @@ -31,7 +31,7 @@ public: auto viable_previous_sibling = viable_previous_sibling_for_insertion(nodes); // 4. Let node be the result of converting nodes into a node, given nodes and this’s node document. - auto node_to_insert = TRY(convert_nodes_to_single_node(from_deprecated_nodes(nodes), node->document())); + auto node_to_insert = TRY(convert_nodes_to_single_node(nodes, node->document())); // 5. If viablePreviousSibling is null, then set it to parent’s first child; otherwise to viablePreviousSibling’s next sibling. if (!viable_previous_sibling) @@ -46,7 +46,7 @@ public: } // https://dom.spec.whatwg.org/#dom-childnode-after - WebIDL::ExceptionOr after(Vector, DeprecatedString>> const& nodes) + WebIDL::ExceptionOr after(Vector, String>> const& nodes) { auto* node = static_cast(this); @@ -61,7 +61,7 @@ public: auto viable_next_sibling = viable_nest_sibling_for_insertion(nodes); // 4. Let node be the result of converting nodes into a node, given nodes and this’s node document. - auto node_to_insert = TRY(convert_nodes_to_single_node(from_deprecated_nodes(nodes), node->document())); + auto node_to_insert = TRY(convert_nodes_to_single_node(nodes, node->document())); // 5. Pre-insert node into parent before viableNextSibling. (void)TRY(parent->pre_insert(node_to_insert, viable_next_sibling)); @@ -70,7 +70,7 @@ public: } // https://dom.spec.whatwg.org/#dom-childnode-replacewith - WebIDL::ExceptionOr replace_with(Vector, DeprecatedString>> const& nodes) + WebIDL::ExceptionOr replace_with(Vector, String>> const& nodes) { auto* node = static_cast(this); @@ -85,7 +85,7 @@ public: auto viable_next_sibling = viable_nest_sibling_for_insertion(nodes); // 4. Let node be the result of converting nodes into a node, given nodes and this’s node document. - auto node_to_insert = TRY(convert_nodes_to_single_node(from_deprecated_nodes(nodes), node->document())); + auto node_to_insert = TRY(convert_nodes_to_single_node(nodes, node->document())); // 5. If this’s parent is parent, replace this with node within parent. // Note: This could have been inserted into node. @@ -113,11 +113,26 @@ public: node->remove(); } + WebIDL::ExceptionOr before(Vector, DeprecatedString>> const& nodes) + { + return before(from_deprecated_nodes(nodes)); + } + + WebIDL::ExceptionOr after(Vector, DeprecatedString>> const& nodes) + { + return after(from_deprecated_nodes(nodes)); + } + + WebIDL::ExceptionOr replace_with(Vector, DeprecatedString>> const& nodes) + { + return replace_with(from_deprecated_nodes(nodes)); + } + protected: ChildNode() = default; private: - JS::GCPtr viable_previous_sibling_for_insertion(Vector, DeprecatedString>> const& nodes) + JS::GCPtr viable_previous_sibling_for_insertion(Vector, String>> const& nodes) { auto* node = static_cast(this); @@ -142,7 +157,7 @@ private: return nullptr; } - JS::GCPtr viable_nest_sibling_for_insertion(Vector, DeprecatedString>> const& nodes) + JS::GCPtr viable_nest_sibling_for_insertion(Vector, String>> const& nodes) { auto* node = static_cast(this);