1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 01:51:03 +09: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
Notes: sideshowbarker 2024-07-18 04:38:32 +09:00
2006 changed files with 11635 additions and 11636 deletions

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;