LibWeb: Move XMLSerializer into HTML directory

The DOMParsing spec is in the process of being merged into the HTML one,
gradually. The linked spec change moves XMLSerializer, but many of the
algorithms are still in the DOMParsing spec so I've left the links to
those alone.

I've done my best to update the GN build but since I'm not actually
using it, I might have done that wrong.

Corresponds to 2edb8cc7ee
This commit is contained in:
Sam Atkins 2025-03-03 13:04:14 +00:00 committed by Tim Ledbetter
commit f148af0a93
Notes: github-actions[bot] 2025-03-04 16:45:51 +00:00
18 changed files with 25 additions and 32 deletions

View file

@ -865,7 +865,7 @@ WebIDL::ExceptionOr<void> Element::set_inner_html(StringView value)
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-element-innerhtml
WebIDL::ExceptionOr<String> Element::inner_html() const
{
return serialize_fragment(DOMParsing::RequireWellFormed::Yes);
return serialize_fragment(HTML::RequireWellFormed::Yes);
}
bool Element::is_focused() const
@ -1768,7 +1768,7 @@ WebIDL::ExceptionOr<GC::Ref<DOM::DocumentFragment>> Element::parse_fragment(Stri
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-element-outerhtml
WebIDL::ExceptionOr<String> Element::outer_html() const
{
return serialize_fragment(DOMParsing::RequireWellFormed::Yes, FragmentSerializationMode::Outer);
return serialize_fragment(HTML::RequireWellFormed::Yes, FragmentSerializationMode::Outer);
}
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-element-outerhtml

View file

@ -1815,7 +1815,7 @@ void Node::string_replace_all(String const& string)
}
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#fragment-serializing-algorithm-steps
WebIDL::ExceptionOr<String> Node::serialize_fragment(DOMParsing::RequireWellFormed require_well_formed, FragmentSerializationMode fragment_serialization_mode) const
WebIDL::ExceptionOr<String> Node::serialize_fragment(HTML::RequireWellFormed require_well_formed, FragmentSerializationMode fragment_serialization_mode) const
{
// 1. Let context document be the value of node's node document.
auto const& context_document = document();
@ -1830,12 +1830,12 @@ WebIDL::ExceptionOr<String> Node::serialize_fragment(DOMParsing::RequireWellForm
if (fragment_serialization_mode == FragmentSerializationMode::Inner) {
StringBuilder markup;
for (auto* child = first_child(); child; child = child->next_sibling()) {
auto child_markup = TRY(DOMParsing::serialize_node_to_xml_string(*child, require_well_formed));
auto child_markup = TRY(HTML::serialize_node_to_xml_string(*child, require_well_formed));
markup.append(child_markup.bytes_as_string_view());
}
return MUST(markup.to_string());
}
return DOMParsing::serialize_node_to_xml_string(*this, require_well_formed);
return HTML::serialize_node_to_xml_string(*this, require_well_formed);
}
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#unsafely-set-html

View file

@ -17,7 +17,7 @@
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/DOM/NodeType.h>
#include <LibWeb/DOM/Slottable.h>
#include <LibWeb/DOMParsing/XMLSerializer.h>
#include <LibWeb/HTML/XMLSerializer.h>
#include <LibWeb/TraversalDecision.h>
#include <LibWeb/TreeNode.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
@ -329,7 +329,7 @@ public:
[[nodiscard]] UniqueNodeID unique_id() const { return m_unique_id; }
static Node* from_unique_id(UniqueNodeID);
WebIDL::ExceptionOr<String> serialize_fragment(DOMParsing::RequireWellFormed, FragmentSerializationMode = FragmentSerializationMode::Inner) const;
WebIDL::ExceptionOr<String> serialize_fragment(HTML::RequireWellFormed, FragmentSerializationMode = FragmentSerializationMode::Inner) const;
WebIDL::ExceptionOr<void> unsafely_set_html(Element&, StringView);

View file

@ -64,7 +64,7 @@ EventTarget* ShadowRoot::get_parent(Event const& event)
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-innerhtml
WebIDL::ExceptionOr<String> ShadowRoot::inner_html() const
{
return serialize_fragment(DOMParsing::RequireWellFormed::Yes);
return serialize_fragment(HTML::RequireWellFormed::Yes);
}
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-shadowroot-innerhtml