1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:27:35 +00:00

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -13,12 +13,12 @@
namespace Web::DOM {
JS::NonnullGCPtr<Attr> Attr::create(Document& document, FlyString local_name, String value, Element const* owner_element)
JS::NonnullGCPtr<Attr> Attr::create(Document& document, FlyString local_name, DeprecatedString value, Element const* owner_element)
{
return *document.heap().allocate<Attr>(document.realm(), document, move(local_name), move(value), owner_element);
}
Attr::Attr(Document& document, FlyString local_name, String value, Element const* owner_element)
Attr::Attr(Document& document, FlyString local_name, DeprecatedString value, Element const* owner_element)
: Node(document, NodeType::ATTRIBUTE_NODE)
, m_qualified_name(move(local_name), {}, {})
, m_value(move(value))
@ -49,7 +49,7 @@ void Attr::set_owner_element(Element const* owner_element)
}
// https://dom.spec.whatwg.org/#set-an-existing-attribute-value
void Attr::set_value(String value)
void Attr::set_value(DeprecatedString value)
{
// 1. If attributes element is null, then set attributes value to value.
if (!owner_element()) {
@ -67,7 +67,7 @@ void Attr::set_value(String value)
}
// https://dom.spec.whatwg.org/#handle-attribute-changes
void Attr::handle_attribute_changes(Element& element, String const& old_value, [[maybe_unused]] String const& new_value)
void Attr::handle_attribute_changes(Element& element, DeprecatedString const& old_value, [[maybe_unused]] DeprecatedString const& new_value)
{
// 1. Queue a mutation record of "attributes" for element with attributes local name, attributes namespace, oldValue, « », « », null, and null.
element.queue_mutation_record(MutationType::attributes, local_name(), namespace_uri(), old_value, StaticNodeList::create(realm(), {}), StaticNodeList::create(realm(), {}), nullptr, nullptr);

View file

@ -18,7 +18,7 @@ class Attr final : public Node {
WEB_PLATFORM_OBJECT(Attr, Node);
public:
static JS::NonnullGCPtr<Attr> create(Document&, FlyString local_name, String value, Element const* = nullptr);
static JS::NonnullGCPtr<Attr> create(Document&, FlyString local_name, DeprecatedString value, Element const* = nullptr);
virtual ~Attr() override = default;
@ -27,10 +27,10 @@ public:
FlyString const& namespace_uri() const { return m_qualified_name.namespace_(); }
FlyString const& prefix() const { return m_qualified_name.prefix(); }
FlyString const& local_name() const { return m_qualified_name.local_name(); }
String const& name() const { return m_qualified_name.as_string(); }
DeprecatedString const& name() const { return m_qualified_name.as_string(); }
String const& value() const { return m_value; }
void set_value(String value);
DeprecatedString const& value() const { return m_value; }
void set_value(DeprecatedString value);
Element* owner_element();
Element const* owner_element() const;
@ -39,15 +39,15 @@ public:
// Always returns true: https://dom.spec.whatwg.org/#dom-attr-specified
constexpr bool specified() const { return true; }
void handle_attribute_changes(Element&, String const& old_value, String const& new_value);
void handle_attribute_changes(Element&, DeprecatedString const& old_value, DeprecatedString const& new_value);
private:
Attr(Document&, FlyString local_name, String value, Element const*);
Attr(Document&, FlyString local_name, DeprecatedString value, Element const*);
virtual void visit_edges(Cell::Visitor&) override;
QualifiedName m_qualified_name;
String m_value;
DeprecatedString m_value;
JS::GCPtr<Element> m_owner_element;
};

View file

@ -9,7 +9,7 @@
namespace Web::DOM {
CDATASection::CDATASection(Document& document, String const& data)
CDATASection::CDATASection(Document& document, DeprecatedString const& data)
: Text(document, NodeType::CDATA_SECTION_NODE, data)
{
set_prototype(&Bindings::cached_web_prototype(realm(), "CDATASection"));

View file

@ -21,7 +21,7 @@ public:
virtual FlyString node_name() const override { return "#cdata-section"; }
private:
CDATASection(Document&, String const&);
CDATASection(Document&, DeprecatedString const&);
};
template<>

View file

@ -13,7 +13,7 @@
namespace Web::DOM {
CharacterData::CharacterData(Document& document, NodeType type, String const& data)
CharacterData::CharacterData(Document& document, NodeType type, DeprecatedString const& data)
: Node(document, type)
, m_data(data)
{
@ -21,7 +21,7 @@ CharacterData::CharacterData(Document& document, NodeType type, String const& da
}
// https://dom.spec.whatwg.org/#dom-characterdata-data
void CharacterData::set_data(String data)
void CharacterData::set_data(DeprecatedString data)
{
// [The data] setter must replace data with node this, offset 0, count thiss length, and data new value.
// NOTE: Since the offset is 0, it can never be above data's length, so this can never throw.
@ -31,7 +31,7 @@ void CharacterData::set_data(String data)
}
// https://dom.spec.whatwg.org/#concept-cd-substring
WebIDL::ExceptionOr<String> CharacterData::substring_data(size_t offset, size_t count) const
WebIDL::ExceptionOr<DeprecatedString> CharacterData::substring_data(size_t offset, size_t count) const
{
// 1. Let length be nodes length.
auto length = this->length();
@ -50,7 +50,7 @@ WebIDL::ExceptionOr<String> CharacterData::substring_data(size_t offset, size_t
}
// https://dom.spec.whatwg.org/#concept-cd-replace
WebIDL::ExceptionOr<void> CharacterData::replace_data(size_t offset, size_t count, String const& data)
WebIDL::ExceptionOr<void> CharacterData::replace_data(size_t offset, size_t count, DeprecatedString const& data)
{
// 1. Let length be nodes length.
auto length = this->length();
@ -109,14 +109,14 @@ WebIDL::ExceptionOr<void> CharacterData::replace_data(size_t offset, size_t coun
}
// https://dom.spec.whatwg.org/#dom-characterdata-appenddata
WebIDL::ExceptionOr<void> CharacterData::append_data(String const& data)
WebIDL::ExceptionOr<void> CharacterData::append_data(DeprecatedString const& data)
{
// The appendData(data) method steps are to replace data with node this, offset thiss length, count 0, and data data.
return replace_data(m_data.length(), 0, data);
}
// https://dom.spec.whatwg.org/#dom-characterdata-insertdata
WebIDL::ExceptionOr<void> CharacterData::insert_data(size_t offset, String const& data)
WebIDL::ExceptionOr<void> CharacterData::insert_data(size_t offset, DeprecatedString const& data)
{
// The insertData(offset, data) method steps are to replace data with node this, offset offset, count 0, and data data.
return replace_data(offset, 0, data);
@ -126,7 +126,7 @@ WebIDL::ExceptionOr<void> CharacterData::insert_data(size_t offset, String const
WebIDL::ExceptionOr<void> CharacterData::delete_data(size_t offset, size_t count)
{
// The deleteData(offset, count) method steps are to replace data with node this, offset offset, count count, and data the empty string.
return replace_data(offset, count, String::empty());
return replace_data(offset, count, DeprecatedString::empty());
}
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <LibWeb/DOM/ChildNode.h>
#include <LibWeb/DOM/Node.h>
#include <LibWeb/DOM/NonDocumentTypeChildNode.h>
@ -22,22 +22,22 @@ class CharacterData
public:
virtual ~CharacterData() override = default;
String const& data() const { return m_data; }
void set_data(String);
DeprecatedString const& data() const { return m_data; }
void set_data(DeprecatedString);
unsigned length() const { return m_data.length(); }
WebIDL::ExceptionOr<String> substring_data(size_t offset, size_t count) const;
WebIDL::ExceptionOr<void> append_data(String const&);
WebIDL::ExceptionOr<void> insert_data(size_t offset, String const&);
WebIDL::ExceptionOr<DeprecatedString> substring_data(size_t offset, size_t count) const;
WebIDL::ExceptionOr<void> append_data(DeprecatedString const&);
WebIDL::ExceptionOr<void> insert_data(size_t offset, DeprecatedString const&);
WebIDL::ExceptionOr<void> delete_data(size_t offset, size_t count);
WebIDL::ExceptionOr<void> replace_data(size_t offset, size_t count, String const&);
WebIDL::ExceptionOr<void> replace_data(size_t offset, size_t count, DeprecatedString const&);
protected:
CharacterData(Document&, NodeType, String const&);
CharacterData(Document&, NodeType, DeprecatedString const&);
private:
String m_data;
DeprecatedString m_data;
};
}

View file

@ -16,7 +16,7 @@ template<typename NodeType>
class ChildNode {
public:
// https://dom.spec.whatwg.org/#dom-childnode-before
WebIDL::ExceptionOr<void> before(Vector<Variant<JS::Handle<Node>, String>> const& nodes)
WebIDL::ExceptionOr<void> before(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes)
{
auto* node = static_cast<NodeType*>(this);
@ -46,7 +46,7 @@ public:
}
// https://dom.spec.whatwg.org/#dom-childnode-after
WebIDL::ExceptionOr<void> after(Vector<Variant<JS::Handle<Node>, String>> const& nodes)
WebIDL::ExceptionOr<void> after(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes)
{
auto* node = static_cast<NodeType*>(this);
@ -70,7 +70,7 @@ public:
}
// https://dom.spec.whatwg.org/#dom-childnode-replacewith
WebIDL::ExceptionOr<void> replace_with(Vector<Variant<JS::Handle<Node>, String>> const& nodes)
WebIDL::ExceptionOr<void> replace_with(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes)
{
auto* node = static_cast<NodeType*>(this);
@ -117,7 +117,7 @@ protected:
ChildNode() = default;
private:
JS::GCPtr<Node> viable_previous_sibling_for_insertion(Vector<Variant<JS::Handle<Node>, String>> const& nodes) const
JS::GCPtr<Node> viable_previous_sibling_for_insertion(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes) const
{
auto* node = static_cast<NodeType const*>(this);
@ -142,7 +142,7 @@ private:
return nullptr;
}
JS::GCPtr<Node> viable_nest_sibling_for_insertion(Vector<Variant<JS::Handle<Node>, String>> const& nodes) const
JS::GCPtr<Node> viable_nest_sibling_for_insertion(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes) const
{
auto* node = static_cast<NodeType const*>(this);

View file

@ -10,13 +10,13 @@
namespace Web::DOM {
Comment::Comment(Document& document, String const& data)
Comment::Comment(Document& document, DeprecatedString const& data)
: CharacterData(document, NodeType::COMMENT_NODE, data)
{
}
// https://dom.spec.whatwg.org/#dom-comment-comment
JS::NonnullGCPtr<Comment> Comment::construct_impl(JS::Realm& realm, String const& data)
JS::NonnullGCPtr<Comment> Comment::construct_impl(JS::Realm& realm, DeprecatedString const& data)
{
auto& window = verify_cast<HTML::Window>(realm.global_object());
return *realm.heap().allocate<Comment>(realm, window.associated_document(), data);

View file

@ -15,13 +15,13 @@ class Comment final : public CharacterData {
WEB_PLATFORM_OBJECT(Comment, CharacterData);
public:
static JS::NonnullGCPtr<Comment> construct_impl(JS::Realm&, String const& data);
static JS::NonnullGCPtr<Comment> construct_impl(JS::Realm&, DeprecatedString const& data);
virtual ~Comment() override = default;
virtual FlyString node_name() const override { return "#comment"; }
private:
Comment(Document&, String const&);
Comment(Document&, DeprecatedString const&);
};
template<>

View file

@ -37,7 +37,7 @@ void CustomEvent::visit_edges(JS::Cell::Visitor& visitor)
}
// https://dom.spec.whatwg.org/#dom-customevent-initcustomevent
void CustomEvent::init_custom_event(String const& type, bool bubbles, bool cancelable, JS::Value detail)
void CustomEvent::init_custom_event(DeprecatedString const& type, bool bubbles, bool cancelable, JS::Value detail)
{
// 1. If thiss dispatch flag is set, then return.
if (dispatched())

View file

@ -30,7 +30,7 @@ public:
virtual void visit_edges(JS::Cell::Visitor&) override;
void init_custom_event(String const& type, bool bubbles, bool cancelable, JS::Value detail);
void init_custom_event(DeprecatedString const& type, bool bubbles, bool cancelable, JS::Value detail);
private:
CustomEvent(JS::Realm&, FlyString const& event_name, CustomEventInit const& event_init);

View file

@ -38,7 +38,7 @@ void DOMImplementation::visit_edges(Cell::Visitor& visitor)
}
// https://dom.spec.whatwg.org/#dom-domimplementation-createdocument
WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> DOMImplementation::create_document(String const& namespace_, String const& qualified_name, JS::GCPtr<DocumentType> doctype) const
WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> DOMImplementation::create_document(DeprecatedString const& namespace_, DeprecatedString const& qualified_name, JS::GCPtr<DocumentType> doctype) const
{
// FIXME: This should specifically be an XML document.
auto xml_document = Document::create(realm());
@ -69,7 +69,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> DOMImplementation::create_docume
}
// https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(String const& title) const
JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(DeprecatedString const& title) const
{
auto html_document = Document::create(realm());
@ -103,7 +103,7 @@ JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(String const&
}
// https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentType>> DOMImplementation::create_document_type(String const& qualified_name, String const& public_id, String const& system_id)
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentType>> DOMImplementation::create_document_type(DeprecatedString const& qualified_name, DeprecatedString const& public_id, DeprecatedString const& system_id)
{
TRY(Document::validate_qualified_name(realm(), qualified_name));
auto document_type = DocumentType::create(document());

View file

@ -20,9 +20,9 @@ public:
static JS::NonnullGCPtr<DOMImplementation> create(Document&);
virtual ~DOMImplementation();
WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> create_document(String const&, String const&, JS::GCPtr<DocumentType>) const;
JS::NonnullGCPtr<Document> create_html_document(String const& title) const;
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentType>> create_document_type(String const& qualified_name, String const& public_id, String const& system_id);
WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> create_document(DeprecatedString const&, DeprecatedString const&, JS::GCPtr<DocumentType>) const;
JS::NonnullGCPtr<Document> create_html_document(DeprecatedString const& title) const;
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentType>> create_document_type(DeprecatedString const& qualified_name, DeprecatedString const& public_id, DeprecatedString const& system_id);
// https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
bool has_feature() const { return true; }

View file

@ -15,20 +15,20 @@
namespace {
// https://infra.spec.whatwg.org/#set-append
inline void append_to_ordered_set(Vector<String>& set, String item)
inline void append_to_ordered_set(Vector<DeprecatedString>& set, DeprecatedString item)
{
if (!set.contains_slow(item))
set.append(move(item));
}
// https://infra.spec.whatwg.org/#list-remove
inline void remove_from_ordered_set(Vector<String>& set, StringView item)
inline void remove_from_ordered_set(Vector<DeprecatedString>& set, StringView item)
{
set.remove_first_matching([&](auto const& value) { return value == item; });
}
// https://infra.spec.whatwg.org/#set-replace
inline void replace_in_ordered_set(Vector<String>& set, StringView item, String replacement)
inline void replace_in_ordered_set(Vector<DeprecatedString>& set, StringView item, DeprecatedString replacement)
{
auto item_index = set.find_first_index(item);
VERIFY(item_index.has_value());
@ -88,9 +88,9 @@ bool DOMTokenList::is_supported_property_index(u32 index) const
}
// https://dom.spec.whatwg.org/#dom-domtokenlist-item
String const& DOMTokenList::item(size_t index) const
DeprecatedString const& DOMTokenList::item(size_t index) const
{
static const String null_string {};
static const DeprecatedString null_string {};
// 1. If index is equal to or greater than thiss token sets size, then return null.
if (index >= m_token_set.size())
@ -107,7 +107,7 @@ bool DOMTokenList::contains(StringView token)
}
// https://dom.spec.whatwg.org/#dom-domtokenlist-add
WebIDL::ExceptionOr<void> DOMTokenList::add(Vector<String> const& tokens)
WebIDL::ExceptionOr<void> DOMTokenList::add(Vector<DeprecatedString> const& tokens)
{
// 1. For each token in tokens:
for (auto const& token : tokens) {
@ -125,7 +125,7 @@ WebIDL::ExceptionOr<void> DOMTokenList::add(Vector<String> const& tokens)
}
// https://dom.spec.whatwg.org/#dom-domtokenlist-remove
WebIDL::ExceptionOr<void> DOMTokenList::remove(Vector<String> const& tokens)
WebIDL::ExceptionOr<void> DOMTokenList::remove(Vector<DeprecatedString> const& tokens)
{
// 1. For each token in tokens:
for (auto const& token : tokens) {
@ -143,7 +143,7 @@ WebIDL::ExceptionOr<void> DOMTokenList::remove(Vector<String> const& tokens)
}
// https://dom.spec.whatwg.org/#dom-domtokenlist-toggle
WebIDL::ExceptionOr<bool> DOMTokenList::toggle(String const& token, Optional<bool> force)
WebIDL::ExceptionOr<bool> DOMTokenList::toggle(DeprecatedString const& token, Optional<bool> force)
{
// 1. If token is the empty string, then throw a "SyntaxError" DOMException.
// 2. If token contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
@ -174,7 +174,7 @@ WebIDL::ExceptionOr<bool> DOMTokenList::toggle(String const& token, Optional<boo
}
// https://dom.spec.whatwg.org/#dom-domtokenlist-replace
WebIDL::ExceptionOr<bool> DOMTokenList::replace(String const& token, String const& new_token)
WebIDL::ExceptionOr<bool> DOMTokenList::replace(DeprecatedString const& token, DeprecatedString const& new_token)
{
// 1. If either token or newToken is the empty string, then throw a "SyntaxError" DOMException.
// 2. If either token or newToken contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
@ -204,7 +204,7 @@ WebIDL::ExceptionOr<bool> DOMTokenList::supports([[maybe_unused]] StringView tok
// 1. If the associated attributes local name does not define supported tokens, throw a TypeError.
return WebIDL::SimpleException {
WebIDL::SimpleExceptionType::TypeError,
String::formatted("Attribute {} does not define any supported tokens", m_associated_attribute)
DeprecatedString::formatted("Attribute {} does not define any supported tokens", m_associated_attribute)
};
// 2. Let lowercase token be a copy of token, in ASCII lowercase.
@ -213,7 +213,7 @@ WebIDL::ExceptionOr<bool> DOMTokenList::supports([[maybe_unused]] StringView tok
}
// https://dom.spec.whatwg.org/#dom-domtokenlist-value
String DOMTokenList::value() const
DeprecatedString DOMTokenList::value() const
{
StringBuilder builder;
builder.join(' ', m_token_set);
@ -221,7 +221,7 @@ String DOMTokenList::value() const
}
// https://dom.spec.whatwg.org/#ref-for-concept-element-attributes-set-value%E2%91%A2
void DOMTokenList::set_value(String value)
void DOMTokenList::set_value(DeprecatedString value)
{
JS::GCPtr<DOM::Element> associated_element = m_associated_element.ptr();
if (!associated_element)

View file

@ -7,9 +7,9 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/FlyString.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <AK/Vector.h>
#include <LibWeb/Bindings/LegacyPlatformObject.h>
@ -32,15 +32,15 @@ public:
virtual JS::Value item_value(size_t index) const override;
size_t length() const { return m_token_set.size(); }
String const& item(size_t index) const;
DeprecatedString const& item(size_t index) const;
bool contains(StringView token);
WebIDL::ExceptionOr<void> add(Vector<String> const& tokens);
WebIDL::ExceptionOr<void> remove(Vector<String> const& tokens);
WebIDL::ExceptionOr<bool> toggle(String const& token, Optional<bool> force);
WebIDL::ExceptionOr<bool> replace(String const& token, String const& new_token);
WebIDL::ExceptionOr<void> add(Vector<DeprecatedString> const& tokens);
WebIDL::ExceptionOr<void> remove(Vector<DeprecatedString> const& tokens);
WebIDL::ExceptionOr<bool> toggle(DeprecatedString const& token, Optional<bool> force);
WebIDL::ExceptionOr<bool> replace(DeprecatedString const& token, DeprecatedString const& new_token);
WebIDL::ExceptionOr<bool> supports(StringView token);
String value() const;
void set_value(String value);
DeprecatedString value() const;
void set_value(DeprecatedString value);
private:
DOMTokenList(Element const& associated_element, FlyString associated_attribute);
@ -50,7 +50,7 @@ private:
WeakPtr<Element> m_associated_element;
FlyString m_associated_attribute;
Vector<String> m_token_set;
Vector<DeprecatedString> m_token_set;
};
}

View file

@ -124,7 +124,7 @@ static JS::NonnullGCPtr<HTML::BrowsingContext> obtain_a_browsing_context_to_use_
}
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#initialise-the-document-object
JS::NonnullGCPtr<Document> Document::create_and_initialize(Type type, String content_type, HTML::NavigationParams navigation_params)
JS::NonnullGCPtr<Document> Document::create_and_initialize(Type type, DeprecatedString content_type, HTML::NavigationParams navigation_params)
{
// 1. Let browsingContext be the result of the obtaining a browsing context to use for a navigation response
// given navigationParams's browsing context, navigationParams's final sandboxing flag set,
@ -250,7 +250,7 @@ JS::NonnullGCPtr<Document> Document::create_and_initialize(Type type, String con
// 12. If navigationParams's request is non-null, then:
if (navigation_params.request) {
// 1. Set document's referrer to the empty string.
document->m_referrer = String::empty();
document->m_referrer = DeprecatedString::empty();
// 2. Let referrer be navigationParams's request's referrer.
auto& referrer = navigation_params.request->referrer();
@ -375,7 +375,7 @@ JS::GCPtr<Selection::Selection> Document::get_selection()
}
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-write
WebIDL::ExceptionOr<void> Document::write(Vector<String> const& strings)
WebIDL::ExceptionOr<void> Document::write(Vector<DeprecatedString> const& strings)
{
StringBuilder builder;
builder.join(""sv, strings);
@ -384,7 +384,7 @@ WebIDL::ExceptionOr<void> Document::write(Vector<String> const& strings)
}
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-writeln
WebIDL::ExceptionOr<void> Document::writeln(Vector<String> const& strings)
WebIDL::ExceptionOr<void> Document::writeln(Vector<DeprecatedString> const& strings)
{
StringBuilder builder;
builder.join(""sv, strings);
@ -394,7 +394,7 @@ WebIDL::ExceptionOr<void> Document::writeln(Vector<String> const& strings)
}
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document-write-steps
WebIDL::ExceptionOr<void> Document::run_the_document_write_steps(String input)
WebIDL::ExceptionOr<void> Document::run_the_document_write_steps(DeprecatedString input)
{
// 1. If document is an XML document, then throw an "InvalidStateError" DOMException.
if (m_type == Type::XML)
@ -429,7 +429,7 @@ WebIDL::ExceptionOr<void> Document::run_the_document_write_steps(String input)
}
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-open
WebIDL::ExceptionOr<Document*> Document::open(String const&, String const&)
WebIDL::ExceptionOr<Document*> Document::open(DeprecatedString const&, DeprecatedString const&)
{
// 1. If document is an XML document, then throw an "InvalidStateError" DOMException exception.
if (m_type == Type::XML)
@ -500,7 +500,7 @@ WebIDL::ExceptionOr<Document*> Document::open(String const&, String const&)
}
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-open-window
WebIDL::ExceptionOr<JS::GCPtr<HTML::WindowProxy>> Document::open(String const& url, String const& name, String const& features)
WebIDL::ExceptionOr<JS::GCPtr<HTML::WindowProxy>> Document::open(DeprecatedString const& url, DeprecatedString const& name, DeprecatedString const& features)
{
// 1. If this is not fully active, then throw an "InvalidAccessError" DOMException exception.
if (!is_fully_active())
@ -639,7 +639,7 @@ WebIDL::ExceptionOr<void> Document::set_body(HTML::HTMLElement* new_body)
return {};
}
String Document::title() const
DeprecatedString Document::title() const
{
auto* head_element = head();
if (!head_element)
@ -666,7 +666,7 @@ String Document::title() const
return builder.to_string();
}
void Document::set_title(String const& title)
void Document::set_title(DeprecatedString const& title)
{
auto* head_element = const_cast<HTML::HTMLHeadElement*>(head());
if (!head_element)
@ -787,7 +787,7 @@ AK::URL Document::base_url() const
}
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#parse-a-url
AK::URL Document::parse_url(String const& url) const
AK::URL Document::parse_url(DeprecatedString const& url) const
{
// FIXME: Pass in document's character encoding.
return base_url().complete_url(url);
@ -1010,7 +1010,7 @@ void Document::set_hovered_node(Node* node)
}
}
JS::NonnullGCPtr<HTMLCollection> Document::get_elements_by_name(String const& name)
JS::NonnullGCPtr<HTMLCollection> Document::get_elements_by_name(DeprecatedString const& name)
{
return HTMLCollection::create(*this, [name](Element const& element) {
return element.name() == name;
@ -1206,7 +1206,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element(FlyStrin
// https://dom.spec.whatwg.org/#dom-document-createelementns
// https://dom.spec.whatwg.org/#internal-createelementns-steps
// FIXME: This only implements step 4 of the algorithm and does not take in options.
WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element_ns(String const& namespace_, String const& qualified_name)
WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element_ns(DeprecatedString const& namespace_, DeprecatedString const& qualified_name)
{
// 1. Let namespace, prefix, and localName be the result of passing namespace and qualifiedName to validate and extract.
auto extracted_qualified_name = TRY(validate_and_extract(realm(), namespace_, qualified_name));
@ -1223,12 +1223,12 @@ JS::NonnullGCPtr<DocumentFragment> Document::create_document_fragment()
return *heap().allocate<DocumentFragment>(realm(), *this);
}
JS::NonnullGCPtr<Text> Document::create_text_node(String const& data)
JS::NonnullGCPtr<Text> Document::create_text_node(DeprecatedString const& data)
{
return *heap().allocate<Text>(realm(), *this, data);
}
JS::NonnullGCPtr<Comment> Document::create_comment(String const& data)
JS::NonnullGCPtr<Comment> Document::create_comment(DeprecatedString const& data)
{
return *heap().allocate<Comment>(realm(), *this, data);
}
@ -1239,7 +1239,7 @@ JS::NonnullGCPtr<Range> Document::create_range()
}
// https://dom.spec.whatwg.org/#dom-document-createevent
WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Document::create_event(String const& interface)
WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Document::create_event(DeprecatedString const& interface)
{
auto& realm = this->realm();
@ -1425,10 +1425,10 @@ DocumentType const* Document::doctype() const
return first_child_of_type<DocumentType>();
}
String const& Document::compat_mode() const
DeprecatedString const& Document::compat_mode() const
{
static String back_compat = "BackCompat";
static String css1_compat = "CSS1Compat";
static DeprecatedString back_compat = "BackCompat";
static DeprecatedString css1_compat = "CSS1Compat";
if (m_quirks_mode == QuirksMode::Yes)
return back_compat;
@ -1477,7 +1477,7 @@ void Document::set_active_element(Element* element)
m_layout_root->set_needs_display();
}
String Document::ready_state() const
DeprecatedString Document::ready_state() const
{
switch (m_readiness) {
case HTML::DocumentReadyState::Loading:
@ -1571,14 +1571,14 @@ void Document::completely_finish_loading()
}
}
String Document::cookie(Cookie::Source source)
DeprecatedString Document::cookie(Cookie::Source source)
{
if (auto* page = this->page())
return page->client().page_did_request_cookie(m_url, source);
return {};
}
void Document::set_cookie(String const& cookie_string, Cookie::Source source)
void Document::set_cookie(DeprecatedString const& cookie_string, Cookie::Source source)
{
auto cookie = Cookie::parse_cookie(cookie_string);
if (!cookie.has_value())
@ -1588,7 +1588,7 @@ void Document::set_cookie(String const& cookie_string, Cookie::Source source)
page->client().page_did_set_cookie(m_url, cookie.value(), source);
}
String Document::dump_dom_tree_as_json() const
DeprecatedString Document::dump_dom_tree_as_json() const
{
StringBuilder builder;
auto json = MUST(JsonObjectSerializer<>::try_create(builder));
@ -1612,12 +1612,12 @@ bool Document::has_a_style_sheet_that_is_blocking_scripts() const
return browsing_context()->container_document()->m_script_blocking_style_sheet_counter > 0;
}
String Document::referrer() const
DeprecatedString Document::referrer() const
{
return m_referrer;
}
void Document::set_referrer(String referrer)
void Document::set_referrer(DeprecatedString referrer)
{
m_referrer = referrer;
}
@ -1667,7 +1667,7 @@ bool Document::hidden() const
}
// https://html.spec.whatwg.org/multipage/interaction.html#dom-document-visibilitystate
String Document::visibility_state() const
DeprecatedString Document::visibility_state() const
{
switch (m_visibility_state) {
case HTML::VisibilityState::Hidden:
@ -1856,7 +1856,7 @@ static inline bool is_valid_name_character(u32 code_point)
|| (code_point >= 0x203f && code_point <= 0x2040);
}
bool Document::is_valid_name(String const& name)
bool Document::is_valid_name(DeprecatedString const& name)
{
if (name.is_empty())
return false;
@ -1873,7 +1873,7 @@ bool Document::is_valid_name(String const& name)
}
// https://dom.spec.whatwg.org/#validate
WebIDL::ExceptionOr<Document::PrefixAndTagName> Document::validate_qualified_name(JS::Realm& realm, String const& qualified_name)
WebIDL::ExceptionOr<Document::PrefixAndTagName> Document::validate_qualified_name(JS::Realm& realm, DeprecatedString const& qualified_name)
{
if (qualified_name.is_empty())
return WebIDL::InvalidCharacterError::create(realm, "Empty string is not a valid qualified name.");
@ -2042,31 +2042,31 @@ JS::NonnullGCPtr<HTML::History> Document::history()
}
// https://html.spec.whatwg.org/multipage/origin.html#dom-document-domain
String Document::domain() const
DeprecatedString Document::domain() const
{
// 1. Let effectiveDomain be this's origin's effective domain.
auto effective_domain = origin().effective_domain();
// 2. If effectiveDomain is null, then return the empty string.
if (!effective_domain.has_value())
return String::empty();
return DeprecatedString::empty();
// 3. Return effectiveDomain, serialized.
// FIXME: Implement host serialization.
return effective_domain.release_value();
}
void Document::set_domain(String const& domain)
void Document::set_domain(DeprecatedString const& domain)
{
dbgln("(STUBBED) Document::set_domain(domain='{}')", domain);
}
void Document::set_navigation_id(Optional<AK::String> navigation_id)
void Document::set_navigation_id(Optional<AK::DeprecatedString> navigation_id)
{
m_navigation_id = move(navigation_id);
}
Optional<String> Document::navigation_id() const
Optional<DeprecatedString> Document::navigation_id() const
{
return m_navigation_id;
}
@ -2295,7 +2295,7 @@ void Document::did_stop_being_active_document_in_browsing_context(Badge<HTML::Br
}
// https://w3c.github.io/editing/docs/execCommand/#querycommandsupported()
bool Document::query_command_supported(String const& command) const
bool Document::query_command_supported(DeprecatedString const& command) const
{
dbgln("(STUBBED) Document::query_command_supported(command='{}')", command);
return false;

View file

@ -6,12 +6,12 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/FlyString.h>
#include <AK/Function.h>
#include <AK/HashMap.h>
#include <AK/NonnullRefPtrVector.h>
#include <AK/OwnPtr.h>
#include <AK/String.h>
#include <AK/URL.h>
#include <AK/Vector.h>
#include <AK/WeakPtr.h>
@ -82,7 +82,7 @@ public:
HTML
};
static JS::NonnullGCPtr<Document> create_and_initialize(Type, String content_type, HTML::NavigationParams);
static JS::NonnullGCPtr<Document> create_and_initialize(Type, DeprecatedString content_type, HTML::NavigationParams);
static JS::NonnullGCPtr<Document> create(JS::Realm&, AK::URL const& url = "about:blank"sv);
static JS::NonnullGCPtr<Document> construct_impl(JS::Realm&);
@ -94,11 +94,11 @@ public:
size_t next_layout_node_serial_id(Badge<Layout::Node>) { return m_next_layout_node_serial_id++; }
size_t layout_node_count() const { return m_next_layout_node_serial_id; }
String cookie(Cookie::Source = Cookie::Source::NonHttp);
void set_cookie(String const&, Cookie::Source = Cookie::Source::NonHttp);
DeprecatedString cookie(Cookie::Source = Cookie::Source::NonHttp);
void set_cookie(DeprecatedString const&, Cookie::Source = Cookie::Source::NonHttp);
String referrer() const;
void set_referrer(String);
DeprecatedString referrer() const;
void set_referrer(DeprecatedString);
void set_url(const AK::URL& url) { m_url = url; }
AK::URL url() const { return m_url; }
@ -108,8 +108,8 @@ public:
void update_base_element(Badge<HTML::HTMLBaseElement>);
JS::GCPtr<HTML::HTMLBaseElement> first_base_element_with_href_in_tree_order() const;
String url_string() const { return m_url.to_string(); }
String document_uri() const { return m_url.to_string(); }
DeprecatedString url_string() const { return m_url.to_string(); }
DeprecatedString document_uri() const { return m_url.to_string(); }
HTML::Origin origin() const;
void set_origin(HTML::Origin const& origin);
@ -117,7 +117,7 @@ public:
HTML::CrossOriginOpenerPolicy const& cross_origin_opener_policy() const { return m_cross_origin_opener_policy; }
void set_cross_origin_opener_policy(HTML::CrossOriginOpenerPolicy policy) { m_cross_origin_opener_policy = move(policy); }
AK::URL parse_url(String const&) const;
AK::URL parse_url(DeprecatedString const&) const;
CSS::StyleComputer& style_computer() { return *m_style_computer; }
const CSS::StyleComputer& style_computer() const { return *m_style_computer; }
@ -161,8 +161,8 @@ public:
WebIDL::ExceptionOr<void> set_body(HTML::HTMLElement* new_body);
String title() const;
void set_title(String const&);
DeprecatedString title() const;
void set_title(DeprecatedString const&);
HTML::BrowsingContext* browsing_context() { return m_browsing_context.ptr(); }
HTML::BrowsingContext const* browsing_context() const { return m_browsing_context.ptr(); }
@ -202,7 +202,7 @@ public:
void schedule_style_update();
void schedule_layout_update();
JS::NonnullGCPtr<HTMLCollection> get_elements_by_name(String const&);
JS::NonnullGCPtr<HTMLCollection> get_elements_by_name(DeprecatedString const&);
JS::NonnullGCPtr<HTMLCollection> get_elements_by_class_name(FlyString const&);
JS::NonnullGCPtr<HTMLCollection> applets();
@ -215,19 +215,19 @@ public:
JS::NonnullGCPtr<HTMLCollection> scripts();
JS::NonnullGCPtr<HTMLCollection> all();
String const& source() const { return m_source; }
void set_source(String source) { m_source = move(source); }
DeprecatedString const& source() const { return m_source; }
void set_source(DeprecatedString source) { m_source = move(source); }
HTML::EnvironmentSettingsObject& relevant_settings_object();
JS::Value run_javascript(StringView source, StringView filename = "(unknown)"sv);
WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(FlyString const& local_name);
WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element_ns(String const& namespace_, String const& qualified_name);
WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element_ns(DeprecatedString const& namespace_, DeprecatedString const& qualified_name);
JS::NonnullGCPtr<DocumentFragment> create_document_fragment();
JS::NonnullGCPtr<Text> create_text_node(String const& data);
JS::NonnullGCPtr<Comment> create_comment(String const& data);
WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> create_event(String const& interface);
JS::NonnullGCPtr<Text> create_text_node(DeprecatedString const& data);
JS::NonnullGCPtr<Comment> create_comment(DeprecatedString const& data);
WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> create_event(DeprecatedString const& interface);
JS::NonnullGCPtr<Range> create_range();
void set_pending_parsing_blocking_script(Badge<HTML::HTMLScriptElement>, HTML::HTMLScriptElement*);
@ -264,7 +264,7 @@ public:
WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> adopt_node_binding(JS::NonnullGCPtr<Node>);
DocumentType const* doctype() const;
String const& compat_mode() const;
DeprecatedString const& compat_mode() const;
void set_editable(bool editable) { m_editable = editable; }
virtual bool is_editable() const final;
@ -282,35 +282,35 @@ public:
JS::NonnullGCPtr<Document> appropriate_template_contents_owner_document();
String ready_state() const;
DeprecatedString ready_state() const;
void update_readiness(HTML::DocumentReadyState);
HTML::Window& window() const { return const_cast<HTML::Window&>(*m_window); }
void set_window(Badge<HTML::BrowsingContext>, HTML::Window&);
WebIDL::ExceptionOr<void> write(Vector<String> const& strings);
WebIDL::ExceptionOr<void> writeln(Vector<String> const& strings);
WebIDL::ExceptionOr<void> write(Vector<DeprecatedString> const& strings);
WebIDL::ExceptionOr<void> writeln(Vector<DeprecatedString> const& strings);
WebIDL::ExceptionOr<Document*> open(String const& = "", String const& = "");
WebIDL::ExceptionOr<JS::GCPtr<HTML::WindowProxy>> open(String const& url, String const& name, String const& features);
WebIDL::ExceptionOr<Document*> open(DeprecatedString const& = "", DeprecatedString const& = "");
WebIDL::ExceptionOr<JS::GCPtr<HTML::WindowProxy>> open(DeprecatedString const& url, DeprecatedString const& name, DeprecatedString const& features);
WebIDL::ExceptionOr<void> close();
HTML::Window* default_view() { return m_window.ptr(); }
HTML::Window const* default_view() const { return m_window.ptr(); }
String const& content_type() const { return m_content_type; }
void set_content_type(String const& content_type) { m_content_type = content_type; }
DeprecatedString const& content_type() const { return m_content_type; }
void set_content_type(DeprecatedString const& content_type) { m_content_type = content_type; }
bool has_encoding() const { return m_encoding.has_value(); }
Optional<String> const& encoding() const { return m_encoding; }
String encoding_or_default() const { return m_encoding.value_or("UTF-8"); }
void set_encoding(Optional<String> const& encoding) { m_encoding = encoding; }
Optional<DeprecatedString> const& encoding() const { return m_encoding; }
DeprecatedString encoding_or_default() const { return m_encoding.value_or("UTF-8"); }
void set_encoding(Optional<DeprecatedString> const& encoding) { m_encoding = encoding; }
// NOTE: These are intended for the JS bindings
String character_set() const { return encoding_or_default(); }
String charset() const { return encoding_or_default(); }
String input_encoding() const { return encoding_or_default(); }
DeprecatedString character_set() const { return encoding_or_default(); }
DeprecatedString charset() const { return encoding_or_default(); }
DeprecatedString input_encoding() const { return encoding_or_default(); }
bool ready_for_post_load_tasks() const { return m_ready_for_post_load_tasks; }
void set_ready_for_post_load_tasks(bool ready) { m_ready_for_post_load_tasks = ready; }
@ -328,7 +328,7 @@ public:
virtual EventTarget* get_parent(Event const&) override;
String dump_dom_tree_as_json() const;
DeprecatedString dump_dom_tree_as_json() const;
bool has_a_style_sheet_that_is_blocking_scripts() const;
@ -347,7 +347,7 @@ public:
void set_page_showing(bool value) { m_page_showing = value; }
bool hidden() const;
String visibility_state() const;
DeprecatedString visibility_state() const;
// https://html.spec.whatwg.org/multipage/interaction.html#update-the-visibility-state
void update_the_visibility_state(HTML::VisibilityState);
@ -366,13 +366,13 @@ public:
void set_parser(Badge<HTML::HTMLParser>, HTML::HTMLParser&);
void detach_parser(Badge<HTML::HTMLParser>);
static bool is_valid_name(String const&);
static bool is_valid_name(DeprecatedString const&);
struct PrefixAndTagName {
FlyString prefix;
FlyString tag_name;
};
static WebIDL::ExceptionOr<PrefixAndTagName> validate_qualified_name(JS::Realm&, String const& qualified_name);
static WebIDL::ExceptionOr<PrefixAndTagName> validate_qualified_name(JS::Realm&, DeprecatedString const& qualified_name);
JS::NonnullGCPtr<NodeIterator> create_node_iterator(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter>);
JS::NonnullGCPtr<TreeWalker> create_tree_walker(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter>);
@ -397,8 +397,8 @@ public:
bool is_initial_about_blank() const { return m_is_initial_about_blank; }
void set_is_initial_about_blank(bool b) { m_is_initial_about_blank = b; }
String domain() const;
void set_domain(String const& domain);
DeprecatedString domain() const;
void set_domain(DeprecatedString const& domain);
auto& pending_scroll_event_targets() { return m_pending_scroll_event_targets; }
auto& pending_scrollend_event_targets() { return m_pending_scrollend_event_targets; }
@ -407,8 +407,8 @@ public:
bool is_completely_loaded() const;
// https://html.spec.whatwg.org/multipage/dom.html#concept-document-navigation-id
Optional<String> navigation_id() const;
void set_navigation_id(Optional<String>);
Optional<DeprecatedString> navigation_id() const;
void set_navigation_id(Optional<DeprecatedString>);
// https://html.spec.whatwg.org/multipage/origin.html#active-sandboxing-flag-set
HTML::SandboxingFlagSet active_sandboxing_flag_set() const;
@ -443,7 +443,7 @@ public:
void did_stop_being_active_document_in_browsing_context(Badge<HTML::BrowsingContext>);
bool query_command_supported(String const&) const;
bool query_command_supported(DeprecatedString const&) const;
protected:
virtual void visit_edges(Cell::Visitor&) override;
@ -458,7 +458,7 @@ private:
void evaluate_media_rules();
WebIDL::ExceptionOr<void> run_the_document_write_steps(String);
WebIDL::ExceptionOr<void> run_the_document_write_steps(DeprecatedString);
size_t m_next_layout_node_serial_id { 0 };
@ -484,7 +484,7 @@ private:
JS::GCPtr<HTML::HTMLParser> m_parser;
bool m_active_parser_was_aborted { false };
String m_source;
DeprecatedString m_source;
JS::GCPtr<HTML::HTMLScriptElement> m_pending_parsing_blocking_script;
@ -511,8 +511,8 @@ private:
JS::GCPtr<Document> m_appropriate_template_contents_owner_document;
HTML::DocumentReadyState m_readiness { HTML::DocumentReadyState::Loading };
String m_content_type { "application/xml" };
Optional<String> m_encoding;
DeprecatedString m_content_type { "application/xml" };
Optional<DeprecatedString> m_encoding;
bool m_ready_for_post_load_tasks { false };
@ -567,7 +567,7 @@ private:
HTML::CrossOriginOpenerPolicy m_cross_origin_opener_policy;
// https://html.spec.whatwg.org/multipage/dom.html#the-document's-referrer
String m_referrer { "" };
DeprecatedString m_referrer { "" };
// https://dom.spec.whatwg.org/#concept-document-origin
HTML::Origin m_origin;
@ -585,7 +585,7 @@ private:
Optional<AK::Time> m_completely_loaded_time;
// https://html.spec.whatwg.org/multipage/dom.html#concept-document-navigation-id
Optional<String> m_navigation_id;
Optional<DeprecatedString> m_navigation_id;
// https://html.spec.whatwg.org/multipage/origin.html#active-sandboxing-flag-set
HTML::SandboxingFlagSet m_active_sandboxing_flag_set;

View file

@ -24,21 +24,21 @@ public:
virtual FlyString node_name() const override { return "#doctype"; }
String const& name() const { return m_name; }
void set_name(String const& name) { m_name = name; }
DeprecatedString const& name() const { return m_name; }
void set_name(DeprecatedString const& name) { m_name = name; }
String const& public_id() const { return m_public_id; }
void set_public_id(String const& public_id) { m_public_id = public_id; }
DeprecatedString const& public_id() const { return m_public_id; }
void set_public_id(DeprecatedString const& public_id) { m_public_id = public_id; }
String const& system_id() const { return m_system_id; }
void set_system_id(String const& system_id) { m_system_id = system_id; }
DeprecatedString const& system_id() const { return m_system_id; }
void set_system_id(DeprecatedString const& system_id) { m_system_id = system_id; }
private:
explicit DocumentType(Document&);
String m_name;
String m_public_id;
String m_system_id;
DeprecatedString m_name;
DeprecatedString m_public_id;
DeprecatedString m_system_id;
};
template<>

View file

@ -80,7 +80,7 @@ void Element::visit_edges(Cell::Visitor& visitor)
}
// https://dom.spec.whatwg.org/#dom-element-getattribute
String Element::get_attribute(FlyString const& name) const
DeprecatedString Element::get_attribute(FlyString const& name) const
{
// 1. Let attr be the result of getting an attribute given qualifiedName and this.
auto const* attribute = m_attributes->get_attribute(name);
@ -101,7 +101,7 @@ JS::GCPtr<Attr> Element::get_attribute_node(FlyString const& name) const
}
// https://dom.spec.whatwg.org/#dom-element-setattribute
WebIDL::ExceptionOr<void> Element::set_attribute(FlyString const& name, String const& value)
WebIDL::ExceptionOr<void> Element::set_attribute(FlyString const& name, DeprecatedString const& value)
{
// 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException.
// FIXME: Proper name validation
@ -179,7 +179,7 @@ WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Realm& realm, FlyStr
}
// https://dom.spec.whatwg.org/#dom-element-setattributens
WebIDL::ExceptionOr<void> Element::set_attribute_ns(FlyString const& namespace_, FlyString const& qualified_name, String const& value)
WebIDL::ExceptionOr<void> Element::set_attribute_ns(FlyString const& namespace_, FlyString const& qualified_name, DeprecatedString const& value)
{
// 1. Let namespace, prefix, and localName be the result of passing namespace and qualifiedName to validate and extract.
auto extracted_qualified_name = TRY(validate_and_extract(realm(), namespace_, qualified_name));
@ -253,10 +253,10 @@ WebIDL::ExceptionOr<bool> Element::toggle_attribute(FlyString const& name, Optio
}
// https://dom.spec.whatwg.org/#dom-element-getattributenames
Vector<String> Element::get_attribute_names() const
Vector<DeprecatedString> Element::get_attribute_names() const
{
// The getAttributeNames() method steps are to return the qualified names of the attributes in thiss attribute list, in order; otherwise a new list.
Vector<String> names;
Vector<DeprecatedString> names;
for (size_t i = 0; i < m_attributes->length(); ++i) {
auto const* attribute = m_attributes->item(i);
names.append(attribute->name());
@ -330,7 +330,7 @@ CSS::CSSStyleDeclaration const* Element::inline_style() const
return m_inline_style.ptr();
}
void Element::parse_attribute(FlyString const& name, String const& value)
void Element::parse_attribute(FlyString const& name, DeprecatedString const& value)
{
if (name == HTML::AttributeNames::class_) {
auto new_classes = value.split_view(Infra::is_ascii_whitespace);
@ -492,14 +492,14 @@ WebIDL::ExceptionOr<DOM::Element const*> Element::closest(StringView selectors)
return nullptr;
}
WebIDL::ExceptionOr<void> Element::set_inner_html(String const& markup)
WebIDL::ExceptionOr<void> Element::set_inner_html(DeprecatedString const& markup)
{
TRY(DOMParsing::inner_html_setter(*this, markup));
return {};
}
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
WebIDL::ExceptionOr<String> Element::inner_html() const
WebIDL::ExceptionOr<DeprecatedString> Element::inner_html() const
{
return serialize_fragment(DOMParsing::RequireWellFormed::Yes);
}
@ -730,7 +730,7 @@ void Element::serialize_pseudo_elements_as_json(JsonArraySerializer<StringBuilde
if (!pseudo_element_node)
continue;
auto object = MUST(children_array.add_object());
MUST(object.add("name"sv, String::formatted("::{}", CSS::pseudo_element_name(static_cast<CSS::Selector::PseudoElement>(i)))));
MUST(object.add("name"sv, DeprecatedString::formatted("::{}", CSS::pseudo_element_name(static_cast<CSS::Selector::PseudoElement>(i)))));
MUST(object.add("type"sv, "pseudo-element"));
MUST(object.add("parent-id"sv, id()));
MUST(object.add("pseudo-element"sv, i));
@ -761,7 +761,7 @@ i32 Element::tab_index() const
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
void Element::set_tab_index(i32 tab_index)
{
MUST(set_attribute(HTML::AttributeNames::tabindex, String::number(tab_index)));
MUST(set_attribute(HTML::AttributeNames::tabindex, DeprecatedString::number(tab_index)));
}
// https://drafts.csswg.org/cssom-view/#potentially-scrollable
@ -1045,7 +1045,7 @@ bool Element::is_actually_disabled() const
}
// https://w3c.github.io/DOM-Parsing/#dom-element-insertadjacenthtml
WebIDL::ExceptionOr<void> Element::insert_adjacent_html(String position, String text)
WebIDL::ExceptionOr<void> Element::insert_adjacent_html(DeprecatedString position, DeprecatedString text)
{
JS::GCPtr<Node> context;
// 1. Use the first matching item from this list:
@ -1118,7 +1118,7 @@ WebIDL::ExceptionOr<void> Element::insert_adjacent_html(String position, String
}
// https://dom.spec.whatwg.org/#insert-adjacent
WebIDL::ExceptionOr<JS::GCPtr<Node>> Element::insert_adjacent(String const& where, JS::NonnullGCPtr<Node> node)
WebIDL::ExceptionOr<JS::GCPtr<Node>> Element::insert_adjacent(DeprecatedString const& where, JS::NonnullGCPtr<Node> node)
{
// To insert adjacent, given an element element, string where, and a node node, run the steps associated with the first ASCII case-insensitive match for where:
if (where.equals_ignoring_case("beforebegin"sv)) {
@ -1155,11 +1155,11 @@ WebIDL::ExceptionOr<JS::GCPtr<Node>> Element::insert_adjacent(String const& wher
// -> Otherwise
// Throw a "SyntaxError" DOMException.
return WebIDL::SyntaxError::create(realm(), String::formatted("Unknown position '{}'. Must be one of 'beforebegin', 'afterbegin', 'beforeend' or 'afterend'"sv, where));
return WebIDL::SyntaxError::create(realm(), DeprecatedString::formatted("Unknown position '{}'. Must be one of 'beforebegin', 'afterbegin', 'beforeend' or 'afterend'"sv, where));
}
// https://dom.spec.whatwg.org/#dom-element-insertadjacentelement
WebIDL::ExceptionOr<JS::GCPtr<Element>> Element::insert_adjacent_element(String const& where, JS::NonnullGCPtr<Element> element)
WebIDL::ExceptionOr<JS::GCPtr<Element>> Element::insert_adjacent_element(DeprecatedString const& where, JS::NonnullGCPtr<Element> element)
{
// The insertAdjacentElement(where, element) method steps are to return the result of running insert adjacent, give this, where, and element.
auto returned_node = TRY(insert_adjacent(where, move(element)));
@ -1169,7 +1169,7 @@ WebIDL::ExceptionOr<JS::GCPtr<Element>> Element::insert_adjacent_element(String
}
// https://dom.spec.whatwg.org/#dom-element-insertadjacenttext
WebIDL::ExceptionOr<void> Element::insert_adjacent_text(String const& where, String const& data)
WebIDL::ExceptionOr<void> Element::insert_adjacent_text(DeprecatedString const& where, DeprecatedString const& data)
{
// 1. Let text be a new Text node whose data is data and node document is thiss node document.
JS::NonnullGCPtr<Text> text = *heap().allocate<DOM::Text>(realm(), document(), data);

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/FlyString.h>
#include <AK/String.h>
#include <LibWeb/Bindings/ElementPrototype.h>
#include <LibWeb/CSS/CSSStyleDeclaration.h>
#include <LibWeb/CSS/StyleComputer.h>
@ -46,13 +46,13 @@ class Element
public:
virtual ~Element() override;
String const& qualified_name() const { return m_qualified_name.as_string(); }
String const& html_uppercased_qualified_name() const { return m_html_uppercased_qualified_name; }
DeprecatedString const& qualified_name() const { return m_qualified_name.as_string(); }
DeprecatedString const& html_uppercased_qualified_name() const { return m_html_uppercased_qualified_name; }
virtual FlyString node_name() const final { return html_uppercased_qualified_name(); }
FlyString const& local_name() const { return m_qualified_name.local_name(); }
// NOTE: This is for the JS bindings
String const& tag_name() const { return html_uppercased_qualified_name(); }
DeprecatedString const& tag_name() const { return html_uppercased_qualified_name(); }
FlyString const& prefix() const { return m_qualified_name.prefix(); }
FlyString const& namespace_() const { return m_qualified_name.namespace_(); }
@ -62,15 +62,15 @@ public:
bool has_attribute(FlyString const& name) const;
bool has_attributes() const { return !m_attributes->is_empty(); }
String attribute(FlyString const& name) const { return get_attribute(name); }
String get_attribute(FlyString const& name) const;
WebIDL::ExceptionOr<void> set_attribute(FlyString const& name, String const& value);
WebIDL::ExceptionOr<void> set_attribute_ns(FlyString const& namespace_, FlyString const& qualified_name, String const& value);
DeprecatedString attribute(FlyString const& name) const { return get_attribute(name); }
DeprecatedString get_attribute(FlyString const& name) const;
WebIDL::ExceptionOr<void> set_attribute(FlyString const& name, DeprecatedString const& value);
WebIDL::ExceptionOr<void> set_attribute_ns(FlyString const& namespace_, FlyString const& qualified_name, DeprecatedString const& value);
void remove_attribute(FlyString const& name);
WebIDL::ExceptionOr<bool> toggle_attribute(FlyString const& name, Optional<bool> force);
size_t attribute_list_size() const { return m_attributes->length(); }
NamedNodeMap const* attributes() const { return m_attributes.ptr(); }
Vector<String> get_attribute_names() const;
Vector<DeprecatedString> get_attribute_names() const;
JS::GCPtr<Attr> get_attribute_node(FlyString const& name) const;
@ -97,7 +97,7 @@ public:
Vector<FlyString> const& class_names() const { return m_classes; }
virtual void apply_presentational_hints(CSS::StyleProperties&) const { }
virtual void parse_attribute(FlyString const& name, String const& value);
virtual void parse_attribute(FlyString const& name, DeprecatedString const& value);
virtual void did_remove_attribute(FlyString const&);
enum class NeedsRelayout {
@ -109,7 +109,7 @@ public:
Layout::NodeWithStyle* layout_node() { return static_cast<Layout::NodeWithStyle*>(Node::layout_node()); }
Layout::NodeWithStyle const* layout_node() const { return static_cast<Layout::NodeWithStyle const*>(Node::layout_node()); }
String name() const { return attribute(HTML::AttributeNames::name); }
DeprecatedString name() const { return attribute(HTML::AttributeNames::name); }
CSS::StyleProperties const* computed_css_values() const { return m_computed_css_values.ptr(); }
void set_computed_css_values(RefPtr<CSS::StyleProperties> style) { m_computed_css_values = move(style); }
@ -119,10 +119,10 @@ public:
CSS::CSSStyleDeclaration* style_for_bindings();
WebIDL::ExceptionOr<String> inner_html() const;
WebIDL::ExceptionOr<void> set_inner_html(String const&);
WebIDL::ExceptionOr<DeprecatedString> inner_html() const;
WebIDL::ExceptionOr<void> set_inner_html(DeprecatedString const&);
WebIDL::ExceptionOr<void> insert_adjacent_html(String position, String text);
WebIDL::ExceptionOr<void> insert_adjacent_html(DeprecatedString position, DeprecatedString text);
bool is_focused() const;
bool is_active() const;
@ -171,8 +171,8 @@ public:
bool is_actually_disabled() const;
WebIDL::ExceptionOr<JS::GCPtr<Element>> insert_adjacent_element(String const& where, JS::NonnullGCPtr<Element> element);
WebIDL::ExceptionOr<void> insert_adjacent_text(String const& where, String const& data);
WebIDL::ExceptionOr<JS::GCPtr<Element>> insert_adjacent_element(DeprecatedString const& where, JS::NonnullGCPtr<Element> element);
WebIDL::ExceptionOr<void> insert_adjacent_text(DeprecatedString const& where, DeprecatedString const& data);
// https://w3c.github.io/csswg-drafts/cssom-view-1/#dom-element-scrollintoview
void scroll_into_view(Optional<Variant<bool, ScrollIntoViewOptions>> = {});
@ -191,10 +191,10 @@ private:
void invalidate_style_after_attribute_change(FlyString const& attribute_name);
WebIDL::ExceptionOr<JS::GCPtr<Node>> insert_adjacent(String const& where, JS::NonnullGCPtr<Node> node);
WebIDL::ExceptionOr<JS::GCPtr<Node>> insert_adjacent(DeprecatedString const& where, JS::NonnullGCPtr<Node> node);
QualifiedName m_qualified_name;
String m_html_uppercased_qualified_name;
DeprecatedString m_html_uppercased_qualified_name;
JS::GCPtr<NamedNodeMap> m_attributes;
JS::GCPtr<CSS::ElementInlineCSSStyleDeclaration> m_inline_style;

View file

@ -92,7 +92,7 @@ void Event::set_cancelled_flag()
}
// https://dom.spec.whatwg.org/#concept-event-initialize
void Event::initialize_event(String const& type, bool bubbles, bool cancelable)
void Event::initialize_event(DeprecatedString const& type, bool bubbles, bool cancelable)
{
// 1. Set events initialized flag.
m_initialized = true;
@ -119,7 +119,7 @@ void Event::initialize_event(String const& type, bool bubbles, bool cancelable)
}
// https://dom.spec.whatwg.org/#dom-event-initevent
void Event::init_event(String const& type, bool bubbles, bool cancelable)
void Event::init_event(DeprecatedString const& type, bool bubbles, bool cancelable)
{
// 1. If thiss dispatch flag is set, then return.
if (m_dispatch)

View file

@ -137,14 +137,14 @@ public:
m_stop_immediate_propagation = true;
}
void init_event(String const&, bool, bool);
void init_event(DeprecatedString const&, bool, bool);
void set_time_stamp(double time_stamp) { m_time_stamp = time_stamp; }
Vector<JS::Handle<EventTarget>> composed_path() const;
protected:
void initialize_event(String const&, bool, bool);
void initialize_event(DeprecatedString const&, bool, bool);
virtual void visit_edges(Visitor&) override;
private:

View file

@ -332,7 +332,7 @@ WebIDL::CallbackType* EventTarget::get_current_value_of_event_handler(FlyString
auto& event_handler = event_handler_iterator->value;
// 3. If eventHandler's value is an internal raw uncompiled handler, then:
if (event_handler->value.has<String>()) {
if (event_handler->value.has<DeprecatedString>()) {
// 1. If eventTarget is an element, then let element be eventTarget, and document be element's node document.
// Otherwise, eventTarget is a Window object, let element be null, and document be eventTarget's associated Document.
JS::GCPtr<Element> element;
@ -355,7 +355,7 @@ WebIDL::CallbackType* EventTarget::get_current_value_of_event_handler(FlyString
return nullptr;
// 3. Let body be the uncompiled script body in eventHandler's value.
auto& body = event_handler->value.get<String>();
auto& body = event_handler->value.get<DeprecatedString>();
// FIXME: 4. Let location be the location where the script body originated, as given by eventHandler's value.
@ -680,7 +680,7 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(FlyStri
}
// https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-attributes:concept-element-attributes-change-ext
void EventTarget::element_event_handler_attribute_changed(FlyString const& local_name, String const& value)
void EventTarget::element_event_handler_attribute_changed(FlyString const& local_name, DeprecatedString const& value)
{
// NOTE: Step 1 of this algorithm was handled in HTMLElement::parse_attribute.

View file

@ -59,7 +59,7 @@ public:
protected:
explicit EventTarget(JS::Realm&);
void element_event_handler_attribute_changed(FlyString const& local_name, String const& value);
void element_event_handler_attribute_changed(FlyString const& local_name, DeprecatedString const& value);
virtual void visit_edges(Cell::Visitor&) override;

View file

@ -80,10 +80,10 @@ Element* HTMLCollection::named_item(FlyString const& name) const
}
// https://dom.spec.whatwg.org/#ref-for-dfn-supported-property-names
Vector<String> HTMLCollection::supported_property_names() const
Vector<DeprecatedString> HTMLCollection::supported_property_names() const
{
// 1. Let result be an empty list.
Vector<String> result;
Vector<DeprecatedString> result;
// 2. For each element represented by the collection, in tree order:
auto elements = collect_matching_elements();

View file

@ -41,7 +41,7 @@ public:
virtual JS::Value item_value(size_t index) const override;
virtual JS::Value named_item_value(FlyString const& name) const override;
virtual Vector<String> supported_property_names() const override;
virtual Vector<DeprecatedString> supported_property_names() const override;
virtual bool is_supported_property_index(u32) const override;
protected:

View file

@ -24,7 +24,7 @@ struct MutationObserverInit {
bool subtree { false };
Optional<bool> attribute_old_value;
Optional<bool> character_data_old_value;
Optional<Vector<String>> attribute_filter;
Optional<Vector<DeprecatedString>> attribute_filter;
};
// https://dom.spec.whatwg.org/#mutationobserver

View file

@ -12,12 +12,12 @@
namespace Web::DOM {
JS::NonnullGCPtr<MutationRecord> MutationRecord::create(JS::Realm& realm, FlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, String const& attribute_name, String const& attribute_namespace, String const& old_value)
JS::NonnullGCPtr<MutationRecord> MutationRecord::create(JS::Realm& realm, FlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value)
{
return *realm.heap().allocate<MutationRecord>(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value);
}
MutationRecord::MutationRecord(JS::Realm& realm, FlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, String const& attribute_name, String const& attribute_namespace, String const& old_value)
MutationRecord::MutationRecord(JS::Realm& realm, FlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value)
: PlatformObject(realm)
, m_type(type)
, m_target(JS::make_handle(target))

View file

@ -15,7 +15,7 @@ class MutationRecord : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(MutationRecord, Bindings::PlatformObject);
public:
static JS::NonnullGCPtr<MutationRecord> create(JS::Realm&, FlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, String const& attribute_name, String const& attribute_namespace, String const& old_value);
static JS::NonnullGCPtr<MutationRecord> create(JS::Realm&, FlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value);
virtual ~MutationRecord() override;
@ -25,12 +25,12 @@ public:
NodeList const* removed_nodes() const { return m_removed_nodes; }
Node const* previous_sibling() const { return m_previous_sibling; }
Node const* next_sibling() const { return m_next_sibling; }
String const& attribute_name() const { return m_attribute_name; }
String const& attribute_namespace() const { return m_attribute_namespace; }
String const& old_value() const { return m_old_value; }
DeprecatedString const& attribute_name() const { return m_attribute_name; }
DeprecatedString const& attribute_namespace() const { return m_attribute_namespace; }
DeprecatedString const& old_value() const { return m_old_value; }
private:
MutationRecord(JS::Realm& realm, FlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, String const& attribute_name, String const& attribute_namespace, String const& old_value);
MutationRecord(JS::Realm& realm, FlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value);
virtual void visit_edges(Cell::Visitor&) override;
FlyString m_type;
@ -39,9 +39,9 @@ private:
JS::GCPtr<NodeList> m_removed_nodes;
JS::GCPtr<Node> m_previous_sibling;
JS::GCPtr<Node> m_next_sibling;
String m_attribute_name;
String m_attribute_namespace;
String m_old_value;
DeprecatedString m_attribute_name;
DeprecatedString m_attribute_namespace;
DeprecatedString m_old_value;
};
}

View file

@ -39,10 +39,10 @@ bool NamedNodeMap::is_supported_property_index(u32 index) const
}
// https://dom.spec.whatwg.org/#ref-for-dfn-supported-property-names%E2%91%A0
Vector<String> NamedNodeMap::supported_property_names() const
Vector<DeprecatedString> NamedNodeMap::supported_property_names() const
{
// 1. Let names be the qualified names of the attributes in this NamedNodeMap objects attribute list, with duplicates omitted, in order.
Vector<String> names;
Vector<DeprecatedString> names;
names.ensure_capacity(m_attributes.size());
for (auto const& attribute : m_attributes) {
@ -93,7 +93,7 @@ WebIDL::ExceptionOr<Attr const*> NamedNodeMap::remove_named_item(StringView qual
// 2. If attr is null, then throw a "NotFoundError" DOMException.
if (!attribute)
return WebIDL::NotFoundError::create(realm(), String::formatted("Attribute with name '{}' not found", qualified_name));
return WebIDL::NotFoundError::create(realm(), DeprecatedString::formatted("Attribute with name '{}' not found", qualified_name));
// 3. Return attr.
return nullptr;

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/NonnullRefPtrVector.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <LibWeb/Bindings/LegacyPlatformObject.h>
#include <LibWeb/Forward.h>
@ -25,7 +25,7 @@ public:
~NamedNodeMap() = default;
virtual bool is_supported_property_index(u32 index) const override;
virtual Vector<String> supported_property_names() const override;
virtual Vector<DeprecatedString> supported_property_names() const override;
virtual JS::Value item_value(size_t index) const override;
virtual JS::Value named_item_value(FlyString const& name) const override;

View file

@ -102,7 +102,7 @@ void Node::visit_edges(Cell::Visitor& visitor)
}
// https://dom.spec.whatwg.org/#dom-node-baseuri
String Node::base_uri() const
DeprecatedString Node::base_uri() const
{
// Return thiss node documents document base URL, serialized.
return document().base_url().to_string();
@ -135,7 +135,7 @@ const HTML::HTMLElement* Node::enclosing_html_element_with_attribute(FlyString c
}
// https://dom.spec.whatwg.org/#concept-descendant-text-content
String Node::descendant_text_content() const
DeprecatedString Node::descendant_text_content() const
{
StringBuilder builder;
for_each_in_subtree_of_type<Text>([&](auto& text_node) {
@ -146,7 +146,7 @@ String Node::descendant_text_content() const
}
// https://dom.spec.whatwg.org/#dom-node-textcontent
String Node::text_content() const
DeprecatedString Node::text_content() const
{
// The textContent getter steps are to return the following, switching on the interface this implements:
@ -167,7 +167,7 @@ String Node::text_content() const
}
// https://dom.spec.whatwg.org/#ref-for-dom-node-textcontent%E2%91%A0
void Node::set_text_content(String const& content)
void Node::set_text_content(DeprecatedString const& 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:
@ -198,7 +198,7 @@ void Node::set_text_content(String const& content)
}
// https://dom.spec.whatwg.org/#dom-node-nodevalue
String Node::node_value() const
DeprecatedString Node::node_value() const
{
// The nodeValue getter steps are to return the following, switching on the interface this implements:
@ -217,7 +217,7 @@ String Node::node_value() const
}
// https://dom.spec.whatwg.org/#ref-for-dom-node-nodevalue%E2%91%A0
void Node::set_node_value(String const& value)
void Node::set_node_value(DeprecatedString const& value)
{
// The nodeValue 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:
@ -259,10 +259,10 @@ void Node::invalidate_style()
document().schedule_style_update();
}
String Node::child_text_content() const
DeprecatedString Node::child_text_content() const
{
if (!is<ParentNode>(*this))
return String::empty();
return DeprecatedString::empty();
StringBuilder builder;
verify_cast<ParentNode>(*this).for_each_child([&](auto& child) {
@ -1171,7 +1171,7 @@ void Node::replace_all(JS::GCPtr<Node> node)
}
// https://dom.spec.whatwg.org/#string-replace-all
void Node::string_replace_all(String const& string)
void Node::string_replace_all(DeprecatedString const& string)
{
// 1. Let node be null.
JS::GCPtr<Node> node;
@ -1185,7 +1185,7 @@ void Node::string_replace_all(String const& string)
}
// https://w3c.github.io/DOM-Parsing/#dfn-fragment-serializing-algorithm
WebIDL::ExceptionOr<String> Node::serialize_fragment(DOMParsing::RequireWellFormed require_well_formed) const
WebIDL::ExceptionOr<DeprecatedString> 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();
@ -1307,7 +1307,7 @@ JS::NonnullGCPtr<Node> Node::get_root_node(GetRootNodeOptions const& options)
return root();
}
String Node::debug_description() const
DeprecatedString Node::debug_description() const
{
StringBuilder builder;
builder.append(node_name().to_lowercase());
@ -1355,7 +1355,7 @@ Painting::PaintableBox const* Node::paint_box() const
}
// https://dom.spec.whatwg.org/#queue-a-mutation-record
void Node::queue_mutation_record(FlyString const& type, String attribute_name, String attribute_namespace, String old_value, JS::NonnullGCPtr<NodeList> added_nodes, JS::NonnullGCPtr<NodeList> removed_nodes, Node* previous_sibling, Node* next_sibling)
void Node::queue_mutation_record(FlyString const& type, DeprecatedString attribute_name, DeprecatedString attribute_namespace, DeprecatedString old_value, JS::NonnullGCPtr<NodeList> added_nodes, JS::NonnullGCPtr<NodeList> removed_nodes, Node* previous_sibling, Node* next_sibling)
{
// NOTE: We defer garbage collection until the end of the scope, since we can't safely use MutationObserver* as a hashmap key otherwise.
// FIXME: This is a total hack.
@ -1363,7 +1363,7 @@ void Node::queue_mutation_record(FlyString const& type, String attribute_name, S
// 1. Let interestedObservers be an empty map.
// mutationObserver -> mappedOldValue
OrderedHashMap<MutationObserver*, String> interested_observers;
OrderedHashMap<MutationObserver*, DeprecatedString> interested_observers;
// 2. Let nodes be the inclusive ancestors of target.
Vector<JS::Handle<Node>> nodes;

View file

@ -7,9 +7,9 @@
#pragma once
#include <AK/Badge.h>
#include <AK/DeprecatedString.h>
#include <AK/JsonObjectSerializer.h>
#include <AK/RefPtr.h>
#include <AK/String.h>
#include <AK/TypeCasts.h>
#include <AK/Vector.h>
#include <LibWeb/DOM/EventTarget.h>
@ -108,14 +108,14 @@ public:
virtual FlyString node_name() const = 0;
String base_uri() const;
DeprecatedString base_uri() const;
String descendant_text_content() const;
String text_content() const;
void set_text_content(String const&);
DeprecatedString descendant_text_content() const;
DeprecatedString text_content() const;
void set_text_content(DeprecatedString const&);
String node_value() const;
void set_node_value(String const&);
DeprecatedString node_value() const;
void set_node_value(DeprecatedString const&);
Document& document() { return *m_document; }
Document const& document() const { return *m_document; }
@ -126,7 +126,7 @@ public:
const HTML::HTMLElement* enclosing_html_element() const;
const HTML::HTMLElement* enclosing_html_element_with_attribute(FlyString const&) const;
String child_text_content() const;
DeprecatedString child_text_content() const;
Node& root();
Node const& root() const
@ -200,10 +200,10 @@ public:
i32 id() const { return m_id; }
static Node* from_id(i32 node_id);
WebIDL::ExceptionOr<String> serialize_fragment(DOMParsing::RequireWellFormed) const;
WebIDL::ExceptionOr<DeprecatedString> serialize_fragment(DOMParsing::RequireWellFormed) const;
void replace_all(JS::GCPtr<Node>);
void string_replace_all(String const&);
void string_replace_all(DeprecatedString const&);
bool is_same_node(Node const*) const;
bool is_equal_node(Node const*) const;
@ -212,7 +212,7 @@ public:
bool is_uninteresting_whitespace_node() const;
String debug_description() const;
DeprecatedString debug_description() const;
size_t length() const;
@ -221,7 +221,7 @@ public:
void add_registered_observer(RegisteredObserver& registered_observer) { m_registered_observer_list.append(registered_observer); }
void queue_mutation_record(FlyString const& type, String attribute_name, String attribute_namespace, String old_value, JS::NonnullGCPtr<NodeList> added_nodes, JS::NonnullGCPtr<NodeList> removed_nodes, Node* previous_sibling, Node* next_sibling);
void queue_mutation_record(FlyString const& type, DeprecatedString attribute_name, DeprecatedString attribute_namespace, DeprecatedString old_value, JS::NonnullGCPtr<NodeList> added_nodes, JS::NonnullGCPtr<NodeList> removed_nodes, Node* previous_sibling, Node* next_sibling);
// https://dom.spec.whatwg.org/#concept-shadow-including-descendant
template<typename Callback>

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/Vector.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/DocumentFragment.h>
@ -14,7 +14,7 @@
namespace Web::DOM {
// https://dom.spec.whatwg.org/#converting-nodes-into-a-node
WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> convert_nodes_to_single_node(Vector<Variant<JS::Handle<Node>, String>> const& nodes, DOM::Document& document)
WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> convert_nodes_to_single_node(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes, DOM::Document& document)
{
// 1. Let node be null.
// 2. Replace each string in nodes with a new Text node whose data is the string and node document is document.
@ -22,11 +22,11 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> convert_nodes_to_single_node(Vector<
// 4. Otherwise, set node to a new DocumentFragment node whose node document is document, and then append each node in nodes, if any, to it.
// 5. Return node.
auto potentially_convert_string_to_text_node = [&document](Variant<JS::Handle<Node>, String> const& node) -> JS::NonnullGCPtr<Node> {
auto potentially_convert_string_to_text_node = [&document](Variant<JS::Handle<Node>, DeprecatedString> const& node) -> JS::NonnullGCPtr<Node> {
if (node.has<JS::Handle<Node>>())
return *node.get<JS::Handle<Node>>();
return *document.heap().allocate<DOM::Text>(document.realm(), document, node.get<String>());
return *document.heap().allocate<DOM::Text>(document.realm(), document, node.get<DeprecatedString>());
};
if (nodes.size() == 1)

View file

@ -12,6 +12,6 @@
namespace Web::DOM {
WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> convert_nodes_to_single_node(Vector<Variant<JS::Handle<Node>, String>> const& nodes, DOM::Document& document);
WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> convert_nodes_to_single_node(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes, DOM::Document& document);
}

View file

@ -135,7 +135,7 @@ JS::NonnullGCPtr<HTMLCollection> ParentNode::get_elements_by_tag_name(FlyString
JS::NonnullGCPtr<HTMLCollection> ParentNode::get_elements_by_tag_name_ns(FlyString const& nullable_namespace, FlyString const& local_name)
{
// 1. If namespace is the empty string, set it to null.
String namespace_ = nullable_namespace;
DeprecatedString namespace_ = nullable_namespace;
if (namespace_.is_empty())
namespace_ = {};
@ -167,7 +167,7 @@ JS::NonnullGCPtr<HTMLCollection> ParentNode::get_elements_by_tag_name_ns(FlyStri
}
// https://dom.spec.whatwg.org/#dom-parentnode-prepend
WebIDL::ExceptionOr<void> ParentNode::prepend(Vector<Variant<JS::Handle<Node>, String>> const& nodes)
WebIDL::ExceptionOr<void> ParentNode::prepend(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes)
{
// 1. Let node be the result of converting nodes into a node given nodes and thiss node document.
auto node = TRY(convert_nodes_to_single_node(nodes, document()));
@ -178,7 +178,7 @@ WebIDL::ExceptionOr<void> ParentNode::prepend(Vector<Variant<JS::Handle<Node>, S
return {};
}
WebIDL::ExceptionOr<void> ParentNode::append(Vector<Variant<JS::Handle<Node>, String>> const& nodes)
WebIDL::ExceptionOr<void> ParentNode::append(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes)
{
// 1. Let node be the result of converting nodes into a node given nodes and thiss node document.
auto node = TRY(convert_nodes_to_single_node(nodes, document()));
@ -189,7 +189,7 @@ WebIDL::ExceptionOr<void> ParentNode::append(Vector<Variant<JS::Handle<Node>, St
return {};
}
WebIDL::ExceptionOr<void> ParentNode::replace_children(Vector<Variant<JS::Handle<Node>, String>> const& nodes)
WebIDL::ExceptionOr<void> ParentNode::replace_children(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes)
{
// 1. Let node be the result of converting nodes into a node given nodes and thiss node document.
auto node = TRY(convert_nodes_to_single_node(nodes, document()));

View file

@ -31,9 +31,9 @@ public:
JS::NonnullGCPtr<HTMLCollection> get_elements_by_tag_name(FlyString const&);
JS::NonnullGCPtr<HTMLCollection> get_elements_by_tag_name_ns(FlyString const&, FlyString const&);
WebIDL::ExceptionOr<void> prepend(Vector<Variant<JS::Handle<Node>, String>> const& nodes);
WebIDL::ExceptionOr<void> append(Vector<Variant<JS::Handle<Node>, String>> const& nodes);
WebIDL::ExceptionOr<void> replace_children(Vector<Variant<JS::Handle<Node>, String>> const& nodes);
WebIDL::ExceptionOr<void> prepend(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes);
WebIDL::ExceptionOr<void> append(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes);
WebIDL::ExceptionOr<void> replace_children(Vector<Variant<JS::Handle<Node>, DeprecatedString>> const& nodes);
protected:
ParentNode(JS::Realm& realm, Document& document, NodeType type)

View file

@ -18,11 +18,11 @@ Position::Position(Node& node, unsigned offset)
{
}
String Position::to_string() const
DeprecatedString Position::to_string() const
{
if (!node())
return String::formatted("DOM::Position(nullptr, {})", offset());
return String::formatted("DOM::Position({} ({})), {})", node()->node_name(), node(), offset());
return DeprecatedString::formatted("DOM::Position(nullptr, {})", offset());
return DeprecatedString::formatted("DOM::Position({} ({})), {})", node()->node_name(), node(), offset());
}
bool Position::increment_offset()

View file

@ -35,7 +35,7 @@ public:
return m_node.ptr() == other.m_node.ptr() && m_offset == other.m_offset;
}
String to_string() const;
DeprecatedString to_string() const;
private:
JS::Handle<Node> m_node;

View file

@ -9,7 +9,7 @@
namespace Web::DOM {
ProcessingInstruction::ProcessingInstruction(Document& document, String const& data, String const& target)
ProcessingInstruction::ProcessingInstruction(Document& document, DeprecatedString const& data, DeprecatedString const& target)
: CharacterData(document, NodeType::PROCESSING_INSTRUCTION_NODE, data)
, m_target(target)
{

View file

@ -19,12 +19,12 @@ public:
virtual FlyString node_name() const override { return m_target; }
String const& target() const { return m_target; }
DeprecatedString const& target() const { return m_target; }
private:
ProcessingInstruction(Document&, String const& data, String const& target);
ProcessingInstruction(Document&, DeprecatedString const& data, DeprecatedString const& target);
String m_target;
DeprecatedString m_target;
};
template<>

View file

@ -67,7 +67,7 @@ void QualifiedName::Impl::make_internal_string()
return;
}
as_string = String::formatted("{}:{}", prefix, local_name);
as_string = DeprecatedString::formatted("{}:{}", prefix, local_name);
}
}

View file

@ -19,7 +19,7 @@ public:
FlyString const& prefix() const { return m_impl->prefix; }
FlyString const& namespace_() const { return m_impl->namespace_; }
String const& as_string() const { return m_impl->as_string; }
DeprecatedString const& as_string() const { return m_impl->as_string; }
struct Impl : public RefCounted<Impl> {
Impl(FlyString const& local_name, FlyString const& prefix, FlyString const& namespace_);
@ -29,7 +29,7 @@ public:
FlyString local_name;
FlyString prefix;
FlyString namespace_;
String as_string;
DeprecatedString as_string;
};
private:

View file

@ -137,7 +137,7 @@ WebIDL::ExceptionOr<void> Range::set_start_or_end(Node& node, u32 offset, StartO
// 2. If offset is greater than nodes length, then throw an "IndexSizeError" DOMException.
if (offset > node.length())
return WebIDL::IndexSizeError::create(realm(), String::formatted("Node does not contain a child at offset {}", offset));
return WebIDL::IndexSizeError::create(realm(), DeprecatedString::formatted("Node does not contain a child at offset {}", offset));
// 3. Let bp be the boundary point (node, offset).
@ -250,7 +250,7 @@ WebIDL::ExceptionOr<i16> Range::compare_boundary_points(u16 how, Range const& so
// - END_TO_START,
// then throw a "NotSupportedError" DOMException.
if (how != HowToCompareBoundaryPoints::START_TO_START && how != HowToCompareBoundaryPoints::START_TO_END && how != HowToCompareBoundaryPoints::END_TO_END && how != HowToCompareBoundaryPoints::END_TO_START)
return WebIDL::NotSupportedError::create(realm(), String::formatted("Expected 'how' to be one of START_TO_START (0), START_TO_END (1), END_TO_END (2) or END_TO_START (3), got {}", how));
return WebIDL::NotSupportedError::create(realm(), DeprecatedString::formatted("Expected 'how' to be one of START_TO_START (0), START_TO_END (1), END_TO_END (2) or END_TO_START (3), got {}", how));
// 2. If thiss root is not the same as sourceRanges root, then throw a "WrongDocumentError" DOMException.
if (&root() != &source_range.root())
@ -474,7 +474,7 @@ WebIDL::ExceptionOr<bool> Range::is_point_in_range(Node const& node, u32 offset)
// 3. If offset is greater than nodes length, then throw an "IndexSizeError" DOMException.
if (offset > node.length())
return WebIDL::IndexSizeError::create(realm(), String::formatted("Node does not contain a child at offset {}", offset));
return WebIDL::IndexSizeError::create(realm(), DeprecatedString::formatted("Node does not contain a child at offset {}", offset));
// 4. If (node, offset) is before start or after end, return false.
auto relative_position_to_start = position_of_boundary_point_relative_to_other_boundary_point(node, offset, m_start_container, m_start_offset);
@ -499,7 +499,7 @@ WebIDL::ExceptionOr<i16> Range::compare_point(Node const& node, u32 offset) cons
// 3. If offset is greater than nodes length, then throw an "IndexSizeError" DOMException.
if (offset > node.length())
return WebIDL::IndexSizeError::create(realm(), String::formatted("Node does not contain a child at offset {}", offset));
return WebIDL::IndexSizeError::create(realm(), DeprecatedString::formatted("Node does not contain a child at offset {}", offset));
// 4. If (node, offset) is before start, return 1.
auto relative_position_to_start = position_of_boundary_point_relative_to_other_boundary_point(node, offset, m_start_container, m_start_offset);
@ -516,7 +516,7 @@ WebIDL::ExceptionOr<i16> Range::compare_point(Node const& node, u32 offset) cons
}
// https://dom.spec.whatwg.org/#dom-range-stringifier
String Range::to_string() const
DeprecatedString Range::to_string() const
{
// 1. Let s be the empty string.
StringBuilder builder;

View file

@ -78,7 +78,7 @@ public:
WebIDL::ExceptionOr<void> insert_node(JS::NonnullGCPtr<Node>);
WebIDL::ExceptionOr<void> surround_contents(JS::NonnullGCPtr<Node> new_parent);
String to_string() const;
DeprecatedString to_string() const;
static HashTable<Range*>& live_ranges();

View file

@ -31,13 +31,13 @@ EventTarget* ShadowRoot::get_parent(Event const& event)
}
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
WebIDL::ExceptionOr<String> ShadowRoot::inner_html() const
WebIDL::ExceptionOr<DeprecatedString> ShadowRoot::inner_html() const
{
return serialize_fragment(DOMParsing::RequireWellFormed::Yes);
}
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
WebIDL::ExceptionOr<void> ShadowRoot::set_inner_html(String const& markup)
WebIDL::ExceptionOr<void> ShadowRoot::set_inner_html(DeprecatedString const& markup)
{
TRY(DOMParsing::inner_html_setter(*this, markup));

View file

@ -26,10 +26,10 @@ public:
virtual EventTarget* get_parent(Event const&) override;
// NOTE: This is intended for the JS bindings.
String mode() const { return m_closed ? "closed" : "open"; }
DeprecatedString mode() const { return m_closed ? "closed" : "open"; }
WebIDL::ExceptionOr<String> inner_html() const;
WebIDL::ExceptionOr<void> set_inner_html(String const&);
WebIDL::ExceptionOr<DeprecatedString> inner_html() const;
WebIDL::ExceptionOr<void> set_inner_html(DeprecatedString const&);
private:
ShadowRoot(Document&, Element&);

View file

@ -14,13 +14,13 @@
namespace Web::DOM {
Text::Text(Document& document, String const& data)
Text::Text(Document& document, DeprecatedString const& data)
: CharacterData(document, NodeType::TEXT_NODE, data)
{
set_prototype(&Bindings::cached_web_prototype(realm(), "Text"));
}
Text::Text(Document& document, NodeType type, String const& data)
Text::Text(Document& document, NodeType type, DeprecatedString const& data)
: CharacterData(document, type, data)
{
set_prototype(&Bindings::cached_web_prototype(realm(), "Text"));
@ -33,7 +33,7 @@ void Text::visit_edges(Cell::Visitor& visitor)
}
// https://dom.spec.whatwg.org/#dom-text-text
JS::NonnullGCPtr<Text> Text::construct_impl(JS::Realm& realm, String const& data)
JS::NonnullGCPtr<Text> Text::construct_impl(JS::Realm& realm, DeprecatedString const& data)
{
// The new Text(data) constructor steps are to set thiss data to data and thiss node document to current global objects associated Document.
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/FlyString.h>
#include <AK/String.h>
#include <LibWeb/DOM/CharacterData.h>
namespace Web::DOM {
@ -18,7 +18,7 @@ class Text : public CharacterData {
public:
virtual ~Text() override = default;
static JS::NonnullGCPtr<Text> construct_impl(JS::Realm& realm, String const& data);
static JS::NonnullGCPtr<Text> construct_impl(JS::Realm& realm, DeprecatedString const& data);
// ^Node
virtual FlyString node_name() const override { return "#text"; }
@ -35,8 +35,8 @@ public:
void set_is_password_input(Badge<HTML::HTMLInputElement>, bool b) { m_is_password_input = b; }
protected:
Text(Document&, String const&);
Text(Document&, NodeType, String const&);
Text(Document&, DeprecatedString const&);
Text(Document&, NodeType, DeprecatedString const&);
virtual void visit_edges(Cell::Visitor&) override;