diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 97fe9cc18f..f2f08f0802 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -720,7 +720,7 @@ DeprecatedString Document::title() const // element that is a child of the document element. if (auto const* document_element = this->document_element(); is(document_element)) { if (auto const* title_element = document_element->first_child_of_type()) - value = title_element->child_text_content(); + value = title_element->child_text_content().to_deprecated_string(); } // 2. Otherwise, let value be the child text content of the title element, or the empty string if the title element @@ -761,7 +761,7 @@ WebIDL::ExceptionOr Document::set_title(String const& title) } // 3. String replace all with the given value within element. - element->string_replace_all(title.to_deprecated_string()); + element->string_replace_all(title); } // -> If the document element is in the HTML namespace @@ -790,7 +790,7 @@ WebIDL::ExceptionOr Document::set_title(String const& title) } // 4. String replace all with the given value within element. - element->string_replace_all(title.to_deprecated_string()); + element->string_replace_all(title); } // -> Otherwise diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 6166a28929..609d4467b3 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -179,7 +179,7 @@ void Node::set_text_content(Optional const& maybe_content) { // The textContent setter steps are to, if the given value is null, act as if it was the empty string instead, // and then do as described below, switching on the interface this implements: - auto content = maybe_content.value_or(String {}).to_deprecated_string(); + auto content = maybe_content.value_or(String {}); // If DocumentFragment or Element, string replace all with the given value within this. if (is(this) || is(this)) { @@ -190,7 +190,7 @@ void Node::set_text_content(Optional const& maybe_content) else if (is(this)) { auto* character_data_node = verify_cast(this); - character_data_node->set_data(MUST(String::from_deprecated_string(content))); + character_data_node->set_data(content); // FIXME: CharacterData::set_data is not spec compliant. Make this match the spec when set_data becomes spec compliant. // Do note that this will make this function able to throw an exception. @@ -198,7 +198,7 @@ void Node::set_text_content(Optional const& maybe_content) // If Attr, set an existing attribute value with this and the given value. if (is(*this)) { - static_cast(*this).set_value(MUST(String::from_deprecated_string(content))); + static_cast(*this).set_value(content); } // Otherwise, do nothing. @@ -278,10 +278,10 @@ void Node::invalidate_style() document().schedule_style_update(); } -DeprecatedString Node::child_text_content() const +String Node::child_text_content() const { if (!is(*this)) - return DeprecatedString::empty(); + return String {}; StringBuilder builder; verify_cast(*this).for_each_child([&](auto& child) { @@ -291,7 +291,7 @@ DeprecatedString Node::child_text_content() const builder.append(maybe_content.value()); } }); - return builder.to_deprecated_string(); + return MUST(builder.to_string()); } // https://dom.spec.whatwg.org/#concept-tree-root @@ -1316,14 +1316,14 @@ void Node::replace_all(JS::GCPtr node) } // https://dom.spec.whatwg.org/#string-replace-all -void Node::string_replace_all(DeprecatedString const& string) +void Node::string_replace_all(String const& string) { // 1. Let node be null. JS::GCPtr node; // 2. If string is not the empty string, then set node to a new Text node whose data is string and node document is parent’s node document. if (!string.is_empty()) - node = heap().allocate(realm(), document(), MUST(String::from_deprecated_string(string))); + node = heap().allocate(realm(), document(), string); // 3. Replace all with node within parent. replace_all(node); @@ -1471,18 +1471,18 @@ JS::NonnullGCPtr Node::get_root_node(GetRootNodeOptions const& options) return root(); } -DeprecatedString Node::debug_description() const +String Node::debug_description() const { StringBuilder builder; builder.append(node_name().to_deprecated_fly_string().to_lowercase()); if (is_element()) { - auto& element = static_cast(*this); + auto const& element = static_cast(*this); if (auto id = element.get_attribute(HTML::AttributeNames::id); id.has_value()) builder.appendff("#{}", id.value()); for (auto const& class_name : element.class_names()) builder.appendff(".{}", class_name); } - return builder.to_deprecated_string(); + return MUST(builder.to_string()); } // https://dom.spec.whatwg.org/#concept-node-length @@ -1935,9 +1935,9 @@ ErrorOr Node::accessible_description(Document const& document) const return builder.to_string(); } -Optional Node::first_valid_id(DeprecatedString const& value, Document const& document) +Optional Node::first_valid_id(StringView value, Document const& document) { - auto id_list = value.split_view(Infra::is_ascii_whitespace); + auto id_list = value.split_view_if(Infra::is_ascii_whitespace); for (auto const& id : id_list) { if (document.get_element_by_id(MUST(FlyString::from_utf8(id)))) return id; diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h index 8710426dbe..74402a1ec6 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.h +++ b/Userland/Libraries/LibWeb/DOM/Node.h @@ -7,7 +7,6 @@ #pragma once #include -#include #include #include #include @@ -161,7 +160,7 @@ public: const HTML::HTMLElement* enclosing_html_element() const; const HTML::HTMLElement* enclosing_html_element_with_attribute(FlyString const&) const; - DeprecatedString child_text_content() const; + String child_text_content() const; Node& root(); Node const& root() const @@ -242,7 +241,7 @@ public: WebIDL::ExceptionOr serialize_fragment(DOMParsing::RequireWellFormed) const; void replace_all(JS::GCPtr); - void string_replace_all(DeprecatedString const&); + void string_replace_all(String const&); bool is_same_node(Node const*) const; bool is_equal_node(Node const*) const; @@ -251,7 +250,7 @@ public: bool is_uninteresting_whitespace_node() const; - DeprecatedString debug_description() const; + String debug_description() const; size_t length() const; @@ -707,7 +706,7 @@ private: void append_child_impl(JS::NonnullGCPtr); void remove_child_impl(JS::NonnullGCPtr); - static Optional first_valid_id(DeprecatedString const&, Document const&); + static Optional first_valid_id(StringView, Document const&); static ErrorOr append_without_space(StringBuilder, StringView const&); static ErrorOr append_with_space(StringBuilder, StringView const&); static ErrorOr prepend_without_space(StringBuilder, StringView const&); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp index 64c6c71931..aa72028b9f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp @@ -114,7 +114,7 @@ String HTMLAnchorElement::text() const void HTMLAnchorElement::set_text(String const& text) { // The text attribute's setter must string replace all with the given value within this element. - string_replace_all(text.to_deprecated_string()); + string_replace_all(text); } // https://html.spec.whatwg.org/multipage/text-level-semantics.html#dom-a-referrerpolicy diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp index 5b23ea8384..122c01685b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp @@ -106,7 +106,7 @@ String HTMLOptionElement::text() const // https://html.spec.whatwg.org/multipage/form-elements.html#dom-option-text void HTMLOptionElement::set_text(String const& text) { - string_replace_all(text.to_deprecated_string()); + string_replace_all(text); } // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-index diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 3bdac45d09..1e273fcf6a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -429,7 +429,7 @@ void HTMLScriptElement::prepare_script() // 2. Fetch an inline module script graph, given source text, base URL, settings object, options, and with the following steps given result: // FIXME: Pass options - fetch_inline_module_script_graph(realm(), m_document->url().to_deprecated_string(), source_text, base_url, document().relevant_settings_object(), steps); + fetch_inline_module_script_graph(realm(), m_document->url().to_deprecated_string(), source_text.to_deprecated_string(), base_url, document().relevant_settings_object(), steps); } // -> "importmap" else if (m_script_type == ScriptType::ImportMap) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp index b60caf47f0..d8b046805c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp @@ -38,14 +38,14 @@ void HTMLTitleElement::children_changed() DeprecatedString HTMLTitleElement::text() { // The text attribute's getter must return this title element's child text content. - return child_text_content(); + return child_text_content().to_deprecated_string(); } // https://html.spec.whatwg.org/multipage/semantics.html#dom-title-text void HTMLTitleElement::set_text(String const& value) { // The text attribute's setter must string replace all with the given value within this title element. - string_replace_all(value.to_deprecated_string()); + string_replace_all(value); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp index df177aaf1e..060d6c917f 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp @@ -47,7 +47,7 @@ Optional SVGTextContentElement::text_anchor() const DeprecatedString SVGTextContentElement::text_contents() const { - return child_text_content().trim_whitespace(); + return child_text_content().to_deprecated_string().trim_whitespace(); } // https://svgwg.org/svg2-draft/text.html#__svg__SVGTextContentElement__getNumberOfChars