mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:57:42 +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:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -18,7 +18,7 @@ JS::NonnullGCPtr<URL> URL::create(JS::Realm& realm, AK::URL url, JS::NonnullGCPt
|
|||
return *realm.heap().allocate<URL>(realm, realm, move(url), move(query));
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<URL>> URL::construct_impl(JS::Realm& realm, String const& url, String const& base)
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<URL>> URL::construct_impl(JS::Realm& realm, DeprecatedString const& url, DeprecatedString const& base)
|
||||
{
|
||||
// 1. Let parsedBase be null.
|
||||
Optional<AK::URL> parsed_base;
|
||||
|
@ -40,7 +40,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<URL>> URL::construct_impl(JS::Realm& realm,
|
|||
if (!parsed_url.is_valid())
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid URL"sv };
|
||||
// 5. Let query be parsedURL’s query, if that is non-null, and the empty string otherwise.
|
||||
auto& query = parsed_url.query().is_null() ? String::empty() : parsed_url.query();
|
||||
auto& query = parsed_url.query().is_null() ? DeprecatedString::empty() : parsed_url.query();
|
||||
// 6. Set this’s URL to parsedURL.
|
||||
// 7. Set this’s query object to a new URLSearchParams object.
|
||||
auto query_object = MUST(URLSearchParams::construct_impl(realm, query));
|
||||
|
@ -68,19 +68,19 @@ void URL::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(m_query.ptr());
|
||||
}
|
||||
|
||||
String URL::href() const
|
||||
DeprecatedString URL::href() const
|
||||
{
|
||||
// return the serialization of this’s URL.
|
||||
return m_url.serialize();
|
||||
}
|
||||
|
||||
String URL::to_json() const
|
||||
DeprecatedString URL::to_json() const
|
||||
{
|
||||
// return the serialization of this’s URL.
|
||||
return m_url.serialize();
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> URL::set_href(String const& href)
|
||||
WebIDL::ExceptionOr<void> URL::set_href(DeprecatedString const& href)
|
||||
{
|
||||
// 1. Let parsedURL be the result of running the basic URL parser on the given value.
|
||||
AK::URL parsed_url = href;
|
||||
|
@ -99,33 +99,33 @@ WebIDL::ExceptionOr<void> URL::set_href(String const& href)
|
|||
return {};
|
||||
}
|
||||
|
||||
String URL::origin() const
|
||||
DeprecatedString URL::origin() const
|
||||
{
|
||||
// return the serialization of this’s URL’s origin.
|
||||
return m_url.serialize_origin();
|
||||
}
|
||||
|
||||
String URL::protocol() const
|
||||
DeprecatedString URL::protocol() const
|
||||
{
|
||||
// return this’s URL’s scheme, followed by U+003A (:).
|
||||
return String::formatted("{}:", m_url.scheme());
|
||||
return DeprecatedString::formatted("{}:", m_url.scheme());
|
||||
}
|
||||
|
||||
void URL::set_protocol(String const& protocol)
|
||||
void URL::set_protocol(DeprecatedString const& protocol)
|
||||
{
|
||||
// basic URL parse the given value, followed by U+003A (:), with this’s URL as url and scheme start state as state override.
|
||||
auto result_url = URLParser::parse(String::formatted("{}:", protocol), nullptr, m_url, URLParser::State::SchemeStart);
|
||||
auto result_url = URLParser::parse(DeprecatedString::formatted("{}:", protocol), nullptr, m_url, URLParser::State::SchemeStart);
|
||||
if (result_url.is_valid())
|
||||
m_url = move(result_url);
|
||||
}
|
||||
|
||||
String URL::username() const
|
||||
DeprecatedString URL::username() const
|
||||
{
|
||||
// return this’s URL’s username.
|
||||
return m_url.username();
|
||||
}
|
||||
|
||||
void URL::set_username(String const& username)
|
||||
void URL::set_username(DeprecatedString const& username)
|
||||
{
|
||||
// 1. If this’s URL cannot have a username/password/port, then return.
|
||||
if (m_url.cannot_have_a_username_or_password_or_port())
|
||||
|
@ -134,13 +134,13 @@ void URL::set_username(String const& username)
|
|||
m_url.set_username(AK::URL::percent_encode(username, AK::URL::PercentEncodeSet::Userinfo));
|
||||
}
|
||||
|
||||
String URL::password() const
|
||||
DeprecatedString URL::password() const
|
||||
{
|
||||
// return this’s URL’s password.
|
||||
return m_url.password();
|
||||
}
|
||||
|
||||
void URL::set_password(String const& password)
|
||||
void URL::set_password(DeprecatedString const& password)
|
||||
{
|
||||
// 1. If this’s URL cannot have a username/password/port, then return.
|
||||
if (m_url.cannot_have_a_username_or_password_or_port())
|
||||
|
@ -149,21 +149,21 @@ void URL::set_password(String const& password)
|
|||
m_url.set_password(AK::URL::percent_encode(password, AK::URL::PercentEncodeSet::Userinfo));
|
||||
}
|
||||
|
||||
String URL::host() const
|
||||
DeprecatedString URL::host() const
|
||||
{
|
||||
// 1. Let url be this’s URL.
|
||||
auto& url = m_url;
|
||||
// 2. If url’s host is null, then return the empty string.
|
||||
if (url.host().is_null())
|
||||
return String::empty();
|
||||
return DeprecatedString::empty();
|
||||
// 3. If url’s port is null, return url’s host, serialized.
|
||||
if (!url.port().has_value())
|
||||
return url.host();
|
||||
// 4. Return url’s host, serialized, followed by U+003A (:) and url’s port, serialized.
|
||||
return String::formatted("{}:{}", url.host(), *url.port());
|
||||
return DeprecatedString::formatted("{}:{}", url.host(), *url.port());
|
||||
}
|
||||
|
||||
void URL::set_host(String const& host)
|
||||
void URL::set_host(DeprecatedString const& host)
|
||||
{
|
||||
// 1. If this’s URL’s cannot-be-a-base-URL is true, then return.
|
||||
if (m_url.cannot_be_a_base_url())
|
||||
|
@ -174,16 +174,16 @@ void URL::set_host(String const& host)
|
|||
m_url = move(result_url);
|
||||
}
|
||||
|
||||
String URL::hostname() const
|
||||
DeprecatedString URL::hostname() const
|
||||
{
|
||||
// 1. If this’s URL’s host is null, then return the empty string.
|
||||
if (m_url.host().is_null())
|
||||
return String::empty();
|
||||
return DeprecatedString::empty();
|
||||
// 2. Return this’s URL’s host, serialized.
|
||||
return m_url.host();
|
||||
}
|
||||
|
||||
void URL::set_hostname(String const& hostname)
|
||||
void URL::set_hostname(DeprecatedString const& hostname)
|
||||
{
|
||||
// 1. If this’s URL’s cannot-be-a-base-URL is true, then return.
|
||||
if (m_url.cannot_be_a_base_url())
|
||||
|
@ -194,17 +194,17 @@ void URL::set_hostname(String const& hostname)
|
|||
m_url = move(result_url);
|
||||
}
|
||||
|
||||
String URL::port() const
|
||||
DeprecatedString URL::port() const
|
||||
{
|
||||
// 1. If this’s URL’s port is null, then return the empty string.
|
||||
if (!m_url.port().has_value())
|
||||
return {};
|
||||
|
||||
// 2. Return this’s URL’s port, serialized.
|
||||
return String::formatted("{}", *m_url.port());
|
||||
return DeprecatedString::formatted("{}", *m_url.port());
|
||||
}
|
||||
|
||||
void URL::set_port(String const& port)
|
||||
void URL::set_port(DeprecatedString const& port)
|
||||
{
|
||||
// 1. If this’s URL cannot have a username/password/port, then return.
|
||||
if (m_url.cannot_have_a_username_or_password_or_port())
|
||||
|
@ -222,7 +222,7 @@ void URL::set_port(String const& port)
|
|||
m_url = move(result_url);
|
||||
}
|
||||
|
||||
String URL::pathname() const
|
||||
DeprecatedString URL::pathname() const
|
||||
{
|
||||
// 1. If this’s URL’s cannot-be-a-base-URL is true, then return this’s URL’s path[0].
|
||||
// 2. If this’s URL’s path is empty, then return the empty string.
|
||||
|
@ -230,7 +230,7 @@ String URL::pathname() const
|
|||
return m_url.path();
|
||||
}
|
||||
|
||||
void URL::set_pathname(String const& pathname)
|
||||
void URL::set_pathname(DeprecatedString const& pathname)
|
||||
{
|
||||
// 1. If this’s URL’s cannot-be-a-base-URL is true, then return.
|
||||
if (m_url.cannot_be_a_base_url())
|
||||
|
@ -244,16 +244,16 @@ void URL::set_pathname(String const& pathname)
|
|||
m_url = move(result_url);
|
||||
}
|
||||
|
||||
String URL::search() const
|
||||
DeprecatedString URL::search() const
|
||||
{
|
||||
// 1. If this’s URL’s query is either null or the empty string, then return the empty string.
|
||||
if (m_url.query().is_null() || m_url.query().is_empty())
|
||||
return String::empty();
|
||||
return DeprecatedString::empty();
|
||||
// 2. Return U+003F (?), followed by this’s URL’s query.
|
||||
return String::formatted("?{}", m_url.query());
|
||||
return DeprecatedString::formatted("?{}", m_url.query());
|
||||
}
|
||||
|
||||
void URL::set_search(String const& search)
|
||||
void URL::set_search(DeprecatedString const& search)
|
||||
{
|
||||
// 1. Let url be this’s URL.
|
||||
auto& url = m_url;
|
||||
|
@ -267,7 +267,7 @@ void URL::set_search(String const& search)
|
|||
auto input = search.substring_view(search.starts_with('?'));
|
||||
// 3. Set url’s query to the empty string.
|
||||
auto url_copy = url; // We copy the URL here to follow other browser's behaviour of reverting the search change if the parse failed.
|
||||
url_copy.set_query(String::empty());
|
||||
url_copy.set_query(DeprecatedString::empty());
|
||||
// 4. Basic URL parse input with url as url and query state as state override.
|
||||
auto result_url = URLParser::parse(input, nullptr, move(url_copy), URLParser::State::Query);
|
||||
if (result_url.is_valid()) {
|
||||
|
@ -282,16 +282,16 @@ URLSearchParams const* URL::search_params() const
|
|||
return m_query;
|
||||
}
|
||||
|
||||
String URL::hash() const
|
||||
DeprecatedString URL::hash() const
|
||||
{
|
||||
// 1. If this’s URL’s fragment is either null or the empty string, then return the empty string.
|
||||
if (m_url.fragment().is_null() || m_url.fragment().is_empty())
|
||||
return String::empty();
|
||||
return DeprecatedString::empty();
|
||||
// 2. Return U+0023 (#), followed by this’s URL’s fragment.
|
||||
return String::formatted("#{}", m_url.fragment());
|
||||
return DeprecatedString::formatted("#{}", m_url.fragment());
|
||||
}
|
||||
|
||||
void URL::set_hash(String const& hash)
|
||||
void URL::set_hash(DeprecatedString const& hash)
|
||||
{
|
||||
// 1. If the given value is the empty string, then set this’s URL’s fragment to null and return.
|
||||
if (hash.is_empty()) {
|
||||
|
@ -302,7 +302,7 @@ void URL::set_hash(String const& hash)
|
|||
auto input = hash.substring_view(hash.starts_with('#'));
|
||||
// 3. Set this’s URL’s fragment to the empty string.
|
||||
auto url = m_url; // We copy the URL here to follow other browser's behaviour of reverting the hash change if the parse failed.
|
||||
url.set_fragment(String::empty());
|
||||
url.set_fragment(DeprecatedString::empty());
|
||||
// 4. Basic URL parse input with this’s URL as url and fragment state as state override.
|
||||
auto result_url = URLParser::parse(input, nullptr, move(url), URLParser::State::Fragment);
|
||||
if (result_url.is_valid())
|
||||
|
@ -335,7 +335,7 @@ HTML::Origin url_origin(AK::URL const& url)
|
|||
if (url.scheme() == "file"sv) {
|
||||
// Unfortunate as it is, this is left as an exercise to the reader. When in doubt, return a new opaque origin.
|
||||
// Note: We must return an origin with the `file://' protocol for `file://' iframes to work from `file://' pages.
|
||||
return HTML::Origin(url.scheme(), String(), 0);
|
||||
return HTML::Origin(url.scheme(), DeprecatedString(), 0);
|
||||
}
|
||||
|
||||
// Return a new opaque origin.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue