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

Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -45,7 +45,7 @@ ErrorOr<void> AutoComplete::parse_google_autocomplete(Vector<JsonValue> const& j
if (!json[0].is_string())
return Error::from_string_view("Invalid JSON, expected first element to be a string"sv);
auto query = TRY(String::from_deprecated_string(json[0].as_string()));
auto query = TRY(String::from_byte_string(json[0].as_string()));
if (!json[1].is_array())
return Error::from_string_view("Invalid JSON, expected second element to be an array"sv);
@ -55,7 +55,7 @@ ErrorOr<void> AutoComplete::parse_google_autocomplete(Vector<JsonValue> const& j
return Error::from_string_view("Invalid JSON, query does not match"sv);
for (auto& suggestion : suggestions_array) {
m_auto_complete_model->add(TRY(String::from_deprecated_string(suggestion.as_string())));
m_auto_complete_model->add(TRY(String::from_byte_string(suggestion.as_string())));
}
return {};
@ -67,7 +67,7 @@ ErrorOr<void> AutoComplete::parse_duckduckgo_autocomplete(Vector<JsonValue> cons
auto maybe_value = suggestion.as_object().get("phrase"sv);
if (!maybe_value.has_value())
continue;
m_auto_complete_model->add(TRY(String::from_deprecated_string(maybe_value->as_string())));
m_auto_complete_model->add(TRY(String::from_byte_string(maybe_value->as_string())));
}
return {};
@ -77,7 +77,7 @@ ErrorOr<void> AutoComplete::parse_yahoo_autocomplete(JsonObject const& json)
{
if (!json.get("q"sv).has_value() || !json.get("q"sv)->is_string())
return Error::from_string_view("Invalid JSON, expected \"q\" to be a string"sv);
auto query = TRY(String::from_deprecated_string(json.get("q"sv)->as_string()));
auto query = TRY(String::from_byte_string(json.get("q"sv)->as_string()));
if (!json.get("r"sv).has_value() || !json.get("r"sv)->is_array())
return Error::from_string_view("Invalid JSON, expected \"r\" to be an object"sv);
@ -94,7 +94,7 @@ ErrorOr<void> AutoComplete::parse_yahoo_autocomplete(JsonObject const& json)
if (!suggestion.get("k"sv).has_value() || !suggestion.get("k"sv)->is_string())
return Error::from_string_view("Invalid JSON, expected \"k\" to be a string"sv);
m_auto_complete_model->add(TRY(String::from_deprecated_string(suggestion.get("k"sv)->as_string())));
m_auto_complete_model->add(TRY(String::from_byte_string(suggestion.get("k"sv)->as_string())));
};
return {};
@ -105,7 +105,7 @@ ErrorOr<void> AutoComplete::got_network_response(QNetworkReply* reply)
if (reply->error() == QNetworkReply::NetworkError::OperationCanceledError)
return {};
AK::JsonParser parser(ak_deprecated_string_from_qstring(reply->readAll()));
AK::JsonParser parser(ak_byte_string_from_qstring(reply->readAll()));
auto json = TRY(parser.parse());
auto engine_name = Settings::the()->autocomplete_engine().name;

View file

@ -331,7 +331,7 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
auto* disable_spoofing = add_user_agent("Disabled"sv, Web::default_user_agent);
disable_spoofing->setChecked(true);
for (auto const& user_agent : WebView::user_agents)
add_user_agent(user_agent.key, user_agent.value.to_deprecated_string());
add_user_agent(user_agent.key, user_agent.value.to_byte_string());
auto* custom_user_agent_action = new QAction("Custom...", this);
custom_user_agent_action->setCheckable(true);
@ -340,7 +340,7 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
QObject::connect(custom_user_agent_action, &QAction::triggered, this, [this, disable_spoofing] {
auto user_agent = QInputDialog::getText(this, "Custom User Agent", "Enter User Agent:");
if (!user_agent.isEmpty()) {
debug_request("spoof-user-agent", ak_deprecated_string_from_qstring(user_agent));
debug_request("spoof-user-agent", ak_byte_string_from_qstring(user_agent));
debug_request("clear-cache"); // clear the cache to ensure requests are re-done with the new user agent
} else {
disable_spoofing->activate(QAction::Trigger);
@ -455,7 +455,7 @@ void BrowserWindow::set_current_tab(Tab* tab)
update_displayed_zoom_level();
}
void BrowserWindow::debug_request(DeprecatedString const& request, DeprecatedString const& argument)
void BrowserWindow::debug_request(ByteString const& request, ByteString const& argument)
{
if (!m_current_tab)
return;
@ -505,7 +505,7 @@ Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab)
};
tab->view().on_tab_open_request = [this](auto url, auto activate_tab) {
auto& tab = new_tab(qstring_from_ak_string(url.to_deprecated_string()), activate_tab);
auto& tab = new_tab(qstring_from_ak_string(url.to_byte_string()), activate_tab);
return tab.view().handle();
};
@ -533,7 +533,7 @@ Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab)
return m_cookie_jar.get_named_cookie(url, name);
};
tab->view().on_get_cookie = [this](auto& url, auto source) -> DeprecatedString {
tab->view().on_get_cookie = [this](auto& url, auto source) -> ByteString {
return m_cookie_jar.get_cookie(url, source);
};

View file

@ -102,7 +102,7 @@ private:
Tab& create_new_tab(Web::HTML::ActivateTab activate_tab);
void debug_request(DeprecatedString const& request, DeprecatedString const& argument = "");
void debug_request(ByteString const& request, ByteString const& argument = "");
void set_current_tab(Tab* tab);
void update_displayed_zoom_level();

View file

@ -24,7 +24,7 @@ void RequestManagerQt::reply_finished(QNetworkReply* reply)
request->did_finish();
}
RefPtr<Web::ResourceLoaderConnectorRequest> RequestManagerQt::start_request(DeprecatedString const& method, AK::URL const& url, HashMap<DeprecatedString, DeprecatedString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const& proxy)
RefPtr<Web::ResourceLoaderConnectorRequest> RequestManagerQt::start_request(ByteString const& method, AK::URL const& url, HashMap<ByteString, ByteString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const& proxy)
{
if (!url.scheme().bytes_as_string_view().is_one_of_ignoring_ascii_case("http"sv, "https"sv)) {
return nullptr;
@ -38,9 +38,9 @@ RefPtr<Web::ResourceLoaderConnectorRequest> RequestManagerQt::start_request(Depr
return request;
}
ErrorOr<NonnullRefPtr<RequestManagerQt::Request>> RequestManagerQt::Request::create(QNetworkAccessManager& qnam, DeprecatedString const& method, AK::URL const& url, HashMap<DeprecatedString, DeprecatedString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&)
ErrorOr<NonnullRefPtr<RequestManagerQt::Request>> RequestManagerQt::Request::create(QNetworkAccessManager& qnam, ByteString const& method, AK::URL const& url, HashMap<ByteString, ByteString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&)
{
QNetworkRequest request { QString(url.to_deprecated_string().characters()) };
QNetworkRequest request { QString(url.to_byte_string().characters()) };
request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::ManualRedirectPolicy);
request.setAttribute(QNetworkRequest::CookieLoadControlAttribute, QNetworkRequest::Manual);
request.setAttribute(QNetworkRequest::CookieSaveControlAttribute, QNetworkRequest::Manual);
@ -87,11 +87,11 @@ void RequestManagerQt::Request::did_finish()
{
auto buffer = m_reply.readAll();
auto http_status_code = m_reply.attribute(QNetworkRequest::Attribute::HttpStatusCodeAttribute).toInt();
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> response_headers;
Vector<DeprecatedString> set_cookie_headers;
HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> response_headers;
Vector<ByteString> set_cookie_headers;
for (auto& it : m_reply.rawHeaderPairs()) {
auto name = DeprecatedString(it.first.data(), it.first.length());
auto value = DeprecatedString(it.second.data(), it.second.length());
auto name = ByteString(it.first.data(), it.first.length());
auto value = ByteString(it.second.data(), it.second.length());
if (name.equals_ignoring_ascii_case("set-cookie"sv)) {
// NOTE: Qt may have bundled multiple Set-Cookie headers into a single one.
// We have to extract the full list of cookies via QNetworkReply::header().
@ -104,7 +104,7 @@ void RequestManagerQt::Request::did_finish()
}
}
if (!set_cookie_headers.is_empty()) {
response_headers.set("set-cookie"sv, JsonArray { set_cookie_headers }.to_deprecated_string());
response_headers.set("set-cookie"sv, JsonArray { set_cookie_headers }.to_byte_string());
}
bool success = http_status_code != 0;
on_buffered_request_finish(success, buffer.length(), response_headers, http_status_code, ReadonlyBytes { buffer.data(), (size_t)buffer.size() });

View file

@ -27,7 +27,7 @@ public:
virtual void prefetch_dns(AK::URL const&) override { }
virtual void preconnect(AK::URL const&) override { }
virtual RefPtr<Web::ResourceLoaderConnectorRequest> start_request(DeprecatedString const& method, AK::URL const&, HashMap<DeprecatedString, DeprecatedString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&) override;
virtual RefPtr<Web::ResourceLoaderConnectorRequest> start_request(ByteString const& method, AK::URL const&, HashMap<ByteString, ByteString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&) override;
private slots:
void reply_finished(QNetworkReply*);
@ -38,7 +38,7 @@ private:
class Request
: public Web::ResourceLoaderConnectorRequest {
public:
static ErrorOr<NonnullRefPtr<Request>> create(QNetworkAccessManager& qnam, DeprecatedString const& method, AK::URL const& url, HashMap<DeprecatedString, DeprecatedString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&);
static ErrorOr<NonnullRefPtr<Request>> create(QNetworkAccessManager& qnam, ByteString const& method, AK::URL const& url, HashMap<ByteString, ByteString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&);
virtual ~Request() override;

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/OwnPtr.h>
#include <LibWebView/SearchEngine.h>
#include <QPoint>

View file

@ -6,9 +6,9 @@
#include "StringUtils.h"
AK::DeprecatedString ak_deprecated_string_from_qstring(QString const& qstring)
AK::ByteString ak_byte_string_from_qstring(QString const& qstring)
{
return AK::DeprecatedString(qstring.toUtf8().data());
return AK::ByteString(qstring.toUtf8().data());
}
String ak_string_from_qstring(QString const& qstring)

View file

@ -6,12 +6,12 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Error.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <QString>
AK::DeprecatedString ak_deprecated_string_from_qstring(QString const&);
AK::ByteString ak_byte_string_from_qstring(QString const&);
String ak_string_from_qstring(QString const&);
QString qstring_from_ak_string(StringView);

View file

@ -107,7 +107,7 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St
};
view().on_link_hover = [this](auto const& url) {
m_hover_label->setText(qstring_from_ak_string(url.to_deprecated_string()));
m_hover_label->setText(qstring_from_ak_string(url.to_byte_string()));
update_hover_label();
m_hover_label->show();
};
@ -123,7 +123,7 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St
m_history.replace_current(url, m_title.toUtf8().data());
}
m_location_edit->setText(url.to_deprecated_string().characters());
m_location_edit->setText(url.to_byte_string().characters());
m_location_edit->setCursorPosition(0);
// Don't add to history if back or forward is pressed
@ -648,7 +648,7 @@ void Tab::back()
m_is_history_navigation = true;
m_history.go_back();
view().load(m_history.current().url.to_deprecated_string());
view().load(m_history.current().url.to_byte_string());
}
void Tab::forward()
@ -658,7 +658,7 @@ void Tab::forward()
m_is_history_navigation = true;
m_history.go_forward();
view().load(m_history.current().url.to_deprecated_string());
view().load(m_history.current().url.to_byte_string());
}
void Tab::reload()
@ -667,7 +667,7 @@ void Tab::reload()
return;
m_is_history_navigation = true;
view().load(m_history.current().url.to_deprecated_string());
view().load(m_history.current().url.to_byte_string());
}
void Tab::open_link(URL const& url)
@ -703,7 +703,7 @@ int Tab::tab_index()
return m_window->tab_index(this);
}
void Tab::debug_request(DeprecatedString const& request, DeprecatedString const& argument)
void Tab::debug_request(ByteString const& request, ByteString const& argument)
{
if (request == "dump-history")
m_history.dump();

View file

@ -40,7 +40,7 @@ public:
void forward();
void reload();
void debug_request(DeprecatedString const& request, DeprecatedString const& argument);
void debug_request(ByteString const& request, ByteString const& argument);
void open_file();
void update_reset_zoom_button();

View file

@ -576,7 +576,7 @@ static Core::AnonymousBuffer make_system_theme_from_qt_palette(QWidget& widget,
auto theme_file = mode == WebContentView::PaletteMode::Default ? "Default"sv : "Dark"sv;
auto theme_ini = MUST(Core::Resource::load_from_uri(MUST(String::formatted("resource://themes/{}.ini", theme_file))));
auto theme = Gfx::load_system_theme(theme_ini->filesystem_path().to_deprecated_string()).release_value_but_fixme_should_propagate_errors();
auto theme = Gfx::load_system_theme(theme_ini->filesystem_path().to_byte_string()).release_value_but_fixme_should_propagate_errors();
auto palette_impl = Gfx::PaletteImpl::create_with_anonymous_buffer(theme);
auto palette = Gfx::Palette(move(palette_impl));
@ -752,7 +752,7 @@ bool WebContentView::event(QEvent* event)
ErrorOr<String> WebContentView::dump_layout_tree()
{
return String::from_deprecated_string(client().dump_layout_tree());
return String::from_byte_string(client().dump_layout_tree());
}
}

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Function.h>
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>

View file

@ -19,7 +19,7 @@ NonnullRefPtr<WebSocketClientManagerQt> WebSocketClientManagerQt::create()
WebSocketClientManagerQt::WebSocketClientManagerQt() = default;
WebSocketClientManagerQt::~WebSocketClientManagerQt() = default;
RefPtr<Web::WebSockets::WebSocketClientSocket> WebSocketClientManagerQt::connect(AK::URL const& url, DeprecatedString const& origin, Vector<DeprecatedString> const& protocols)
RefPtr<Web::WebSockets::WebSocketClientSocket> WebSocketClientManagerQt::connect(AK::URL const& url, ByteString const& origin, Vector<ByteString> const& protocols)
{
WebSocket::ConnectionInfo connection_info(url);
connection_info.set_origin(origin);

View file

@ -19,7 +19,7 @@ public:
static NonnullRefPtr<WebSocketClientManagerQt> create();
virtual ~WebSocketClientManagerQt() override;
virtual RefPtr<Web::WebSockets::WebSocketClientSocket> connect(AK::URL const&, DeprecatedString const& origin, Vector<DeprecatedString> const& protocols) override;
virtual RefPtr<Web::WebSockets::WebSocketClientSocket> connect(AK::URL const&, ByteString const& origin, Vector<ByteString> const& protocols) override;
private:
WebSocketClientManagerQt();

View file

@ -85,13 +85,13 @@ ErrorOr<ByteBuffer> WebSocketImplQt::read(int max_size)
return buffer.slice(0, bytes_read);
}
ErrorOr<DeprecatedString> WebSocketImplQt::read_line(size_t size)
ErrorOr<ByteString> WebSocketImplQt::read_line(size_t size)
{
auto buffer = TRY(ByteBuffer::create_uninitialized(size));
auto bytes_read = m_socket->readLine(reinterpret_cast<char*>(buffer.data()), buffer.size());
if (bytes_read == -1)
return Error::from_string_literal("WebSocketImplQt::read_line(): Error reading from socket");
return DeprecatedString::copy(buffer.span().slice(0, bytes_read));
return ByteString::copy(buffer.span().slice(0, bytes_read));
}
}

View file

@ -22,7 +22,7 @@ public:
virtual void connect(WebSocket::ConnectionInfo const&) override;
virtual bool can_read_line() override;
virtual ErrorOr<DeprecatedString> read_line(size_t) override;
virtual ErrorOr<ByteString> read_line(size_t) override;
virtual ErrorOr<ByteBuffer> read(int max_size) override;
virtual bool send(ReadonlyBytes) override;
virtual bool eof() override;

View file

@ -50,7 +50,7 @@ WebSocketQt::WebSocketQt(NonnullRefPtr<WebSocket::WebSocket> underlying_socket)
}
}
};
m_websocket->on_close = [weak_this = make_weak_ptr()](u16 code, DeprecatedString reason, bool was_clean) {
m_websocket->on_close = [weak_this = make_weak_ptr()](u16 code, ByteString reason, bool was_clean) {
if (auto strong_this = weak_this.strong_ref())
if (strong_this->on_close)
strong_this->on_close(code, move(reason), was_clean);
@ -74,7 +74,7 @@ Web::WebSockets::WebSocket::ReadyState WebSocketQt::ready_state()
VERIFY_NOT_REACHED();
}
DeprecatedString WebSocketQt::subprotocol_in_use()
ByteString WebSocketQt::subprotocol_in_use()
{
return m_websocket->subprotocol_in_use();
}
@ -89,7 +89,7 @@ void WebSocketQt::send(StringView message)
m_websocket->send(WebSocket::Message(message));
}
void WebSocketQt::close(u16 code, DeprecatedString reason)
void WebSocketQt::close(u16 code, ByteString reason)
{
m_websocket->close(code, reason);
}

View file

@ -21,10 +21,10 @@ public:
virtual ~WebSocketQt() override;
virtual Web::WebSockets::WebSocket::ReadyState ready_state() override;
virtual DeprecatedString subprotocol_in_use() override;
virtual ByteString subprotocol_in_use() override;
virtual void send(ByteBuffer binary_or_text_message, bool is_text) override;
virtual void send(StringView message) override;
virtual void close(u16 code, DeprecatedString reason) override;
virtual void close(u16 code, ByteString reason) override;
private:
explicit WebSocketQt(NonnullRefPtr<WebSocket::WebSocket>);