mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:57:44 +00:00
LibWeb: Port XMLSerializer from DeprecatedString to String
This commit is contained in:
parent
e28fb5c64c
commit
6c42de3e8b
9 changed files with 46 additions and 52 deletions
|
@ -721,8 +721,7 @@ WebIDL::ExceptionOr<void> Element::set_inner_html(StringView markup)
|
|||
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
|
||||
WebIDL::ExceptionOr<String> Element::inner_html() const
|
||||
{
|
||||
auto inner_html = TRY(serialize_fragment(DOMParsing::RequireWellFormed::Yes));
|
||||
return MUST(String::from_deprecated_string(inner_html));
|
||||
return serialize_fragment(DOMParsing::RequireWellFormed::Yes);
|
||||
}
|
||||
|
||||
bool Element::is_focused() const
|
||||
|
|
|
@ -1330,14 +1330,14 @@ void Node::string_replace_all(DeprecatedString const& string)
|
|||
}
|
||||
|
||||
// https://w3c.github.io/DOM-Parsing/#dfn-fragment-serializing-algorithm
|
||||
WebIDL::ExceptionOr<DeprecatedString> Node::serialize_fragment(DOMParsing::RequireWellFormed require_well_formed) const
|
||||
WebIDL::ExceptionOr<String> Node::serialize_fragment(DOMParsing::RequireWellFormed require_well_formed) const
|
||||
{
|
||||
// 1. Let context document be the value of node's node document.
|
||||
auto const& context_document = document();
|
||||
|
||||
// 2. If context document is an HTML document, return an HTML serialization of node.
|
||||
if (context_document.is_html_document())
|
||||
return HTML::HTMLParser::serialize_html_fragment(*this).to_deprecated_string();
|
||||
return HTML::HTMLParser::serialize_html_fragment(*this);
|
||||
|
||||
// 3. Otherwise, context document is an XML document; return an XML serialization of node passing the flag require well-formed.
|
||||
return DOMParsing::serialize_node_to_xml_string(*this, require_well_formed);
|
||||
|
|
|
@ -238,7 +238,7 @@ public:
|
|||
i32 unique_id() const { return m_unique_id; }
|
||||
static Node* from_unique_id(i32);
|
||||
|
||||
WebIDL::ExceptionOr<DeprecatedString> serialize_fragment(DOMParsing::RequireWellFormed) const;
|
||||
WebIDL::ExceptionOr<String> serialize_fragment(DOMParsing::RequireWellFormed) const;
|
||||
|
||||
void replace_all(JS::GCPtr<Node>);
|
||||
void string_replace_all(DeprecatedString const&);
|
||||
|
|
|
@ -40,7 +40,7 @@ EventTarget* ShadowRoot::get_parent(Event const& event)
|
|||
}
|
||||
|
||||
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
|
||||
WebIDL::ExceptionOr<DeprecatedString> ShadowRoot::inner_html() const
|
||||
WebIDL::ExceptionOr<String> ShadowRoot::inner_html() const
|
||||
{
|
||||
return serialize_fragment(DOMParsing::RequireWellFormed::Yes);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
// ^EventTarget
|
||||
virtual EventTarget* get_parent(Event const&) override;
|
||||
|
||||
WebIDL::ExceptionOr<DeprecatedString> inner_html() const;
|
||||
WebIDL::ExceptionOr<String> inner_html() const;
|
||||
WebIDL::ExceptionOr<void> set_inner_html(StringView);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue