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

Everywhere: Rename to_{string => deprecated_string}() where applicable

This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
This commit is contained in:
Linus Groh 2022-12-06 01:12:49 +00:00 committed by Andreas Kling
parent 6e19ab2bbc
commit 57dc179b1f
597 changed files with 1973 additions and 1972 deletions

View file

@ -186,8 +186,8 @@ void BookmarksBarWidget::model_did_update(unsigned)
int width = 0;
for (int item_index = 0; item_index < model()->row_count(); ++item_index) {
auto title = model()->index(item_index, 0).data().to_string();
auto url = model()->index(item_index, 1).data().to_string();
auto title = model()->index(item_index, 0).data().to_deprecated_string();
auto url = model()->index(item_index, 1).data().to_deprecated_string();
Gfx::IntRect rect { width, 0, font().width(title) + 32, height() };
@ -263,8 +263,8 @@ bool BookmarksBarWidget::contains_bookmark(DeprecatedString const& url)
{
for (int item_index = 0; item_index < model()->row_count(); ++item_index) {
auto item_title = model()->index(item_index, 0).data().to_string();
auto item_url = model()->index(item_index, 1).data().to_string();
auto item_title = model()->index(item_index, 0).data().to_deprecated_string();
auto item_url = model()->index(item_index, 1).data().to_deprecated_string();
if (item_url == url) {
return true;
}
@ -276,8 +276,8 @@ bool BookmarksBarWidget::remove_bookmark(DeprecatedString const& url)
{
for (int item_index = 0; item_index < model()->row_count(); ++item_index) {
auto item_title = model()->index(item_index, 0).data().to_string();
auto item_url = model()->index(item_index, 1).data().to_string();
auto item_title = model()->index(item_index, 0).data().to_deprecated_string();
auto item_url = model()->index(item_index, 1).data().to_deprecated_string();
if (item_url == url) {
auto& json_model = *static_cast<GUI::JsonArrayModel*>(model());
@ -309,8 +309,8 @@ bool BookmarksBarWidget::add_bookmark(DeprecatedString const& url, DeprecatedStr
bool BookmarksBarWidget::edit_bookmark(DeprecatedString const& url)
{
for (int item_index = 0; item_index < model()->row_count(); ++item_index) {
auto item_title = model()->index(item_index, 0).data().to_string();
auto item_url = model()->index(item_index, 1).data().to_string();
auto item_title = model()->index(item_index, 0).data().to_deprecated_string();
auto item_url = model()->index(item_index, 1).data().to_deprecated_string();
if (item_url == url) {
auto values = BookmarkEditor::edit_bookmark(window(), item_title, item_url);

View file

@ -51,7 +51,7 @@ static DeprecatedString bookmarks_file_path()
StringBuilder builder;
builder.append(Core::StandardPaths::config_directory());
builder.append("/bookmarks.json"sv);
return builder.to_string();
return builder.to_deprecated_string();
}
static DeprecatedString search_engines_file_path()
@ -59,7 +59,7 @@ static DeprecatedString search_engines_file_path()
StringBuilder builder;
builder.append(Core::StandardPaths::config_directory());
builder.append("/SearchEngines.json"sv);
return builder.to_string();
return builder.to_deprecated_string();
}
BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url)
@ -479,8 +479,8 @@ ErrorOr<void> BrowserWindow::load_search_engines(GUI::Menu& settings_menu)
if (!json_item.is_object())
continue;
auto search_engine = json_item.as_object();
auto name = search_engine.get("title"sv).to_string();
auto url_format = search_engine.get("url_format"sv).to_string();
auto name = search_engine.get("title"sv).to_deprecated_string();
auto url_format = search_engine.get("url_format"sv).to_deprecated_string();
auto action = GUI::Action::create_checkable(
name, [&, url_format](auto&) {
@ -543,7 +543,7 @@ void BrowserWindow::set_window_title_for_tab(Tab const& tab)
{
auto& title = tab.title();
auto url = tab.url();
set_title(DeprecatedString::formatted("{} - Browser", title.is_empty() ? url.to_string() : title));
set_title(DeprecatedString::formatted("{} - Browser", title.is_empty() ? url.to_deprecated_string() : title));
}
void BrowserWindow::create_new_tab(URL url, bool activate)
@ -742,7 +742,7 @@ ErrorOr<void> BrowserWindow::take_screenshot(ScreenshotType type)
return Error::from_string_view("Failed to take a screenshot of the current tab"sv);
LexicalPath path { Core::StandardPaths::downloads_directory() };
path = path.append(Core::DateTime::now().to_string("screenshot-%Y-%m-%d-%H-%M-%S.png"sv));
path = path.append(Core::DateTime::now().to_deprecated_string("screenshot-%Y-%m-%d-%H-%M-%S.png"sv));
auto encoded = Gfx::PNGWriter::encode(*bitmap.bitmap());

View file

@ -92,9 +92,9 @@ void CookieJar::dump_cookies() const
builder.appendff("{}{}{}\n", key_color, cookie.key.path, no_color);
builder.appendff("\t{}Value{} = {}\n", attribute_color, no_color, cookie.value.value);
builder.appendff("\t{}CreationTime{} = {}\n", attribute_color, no_color, cookie.value.creation_time.to_string());
builder.appendff("\t{}LastAccessTime{} = {}\n", attribute_color, no_color, cookie.value.last_access_time.to_string());
builder.appendff("\t{}ExpiryTime{} = {}\n", attribute_color, no_color, cookie.value.expiry_time.to_string());
builder.appendff("\t{}CreationTime{} = {}\n", attribute_color, no_color, cookie.value.creation_time.to_deprecated_string());
builder.appendff("\t{}LastAccessTime{} = {}\n", attribute_color, no_color, cookie.value.last_access_time.to_deprecated_string());
builder.appendff("\t{}ExpiryTime{} = {}\n", attribute_color, no_color, cookie.value.expiry_time.to_deprecated_string());
builder.appendff("\t{}Secure{} = {:s}\n", attribute_color, no_color, cookie.value.secure);
builder.appendff("\t{}HttpOnly{} = {:s}\n", attribute_color, no_color, cookie.value.http_only);
builder.appendff("\t{}HostOnly{} = {:s}\n", attribute_color, no_color, cookie.value.host_only);

View file

@ -80,7 +80,7 @@ GUI::Variant CookiesModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol
case Column::Value:
return cookie.value;
case Column::ExpiryTime:
return cookie.expiry_time.to_string();
return cookie.expiry_time.to_deprecated_string();
case Column::SameSite:
return Web::Cookie::same_site_to_string(cookie.same_site);
}

View file

@ -34,7 +34,7 @@ DownloadWidget::DownloadWidget(const URL& url)
builder.append(Core::StandardPaths::downloads_directory());
builder.append('/');
builder.append(m_url.basename());
m_destination_path = builder.to_string();
m_destination_path = builder.to_deprecated_string();
}
auto close_on_finish = Config::read_bool("Browser"sv, "Preferences"sv, "CloseDownloadWidgetOnFinish"sv, false);
@ -129,7 +129,7 @@ void DownloadWidget::did_progress(Optional<u32> total_size, u32 downloaded_size)
builder.append("Downloaded "sv);
builder.append(human_readable_size(downloaded_size));
builder.appendff(" in {} sec", m_elapsed_timer.elapsed() / 1000);
m_progress_label->set_text(builder.to_string());
m_progress_label->set_text(builder.to_deprecated_string());
}
{
@ -142,7 +142,7 @@ void DownloadWidget::did_progress(Optional<u32> total_size, u32 downloaded_size)
}
builder.append(" of "sv);
builder.append(m_url.basename());
window()->set_title(builder.to_string());
window()->set_title(builder.to_deprecated_string());
}
}

View file

@ -32,7 +32,7 @@ void InspectorWidget::set_selection(Selection selection)
auto* model = verify_cast<WebView::DOMTreeModel>(m_dom_tree_view->model());
auto index = model->index_for_node(selection.dom_node_id, selection.pseudo_element);
if (!index.is_valid()) {
dbgln("InspectorWidget told to inspect non-existent node: {}", selection.to_string());
dbgln("InspectorWidget told to inspect non-existent node: {}", selection.to_deprecated_string());
return;
}
@ -151,7 +151,7 @@ void InspectorWidget::clear_dom_json()
void InspectorWidget::set_dom_node_properties_json(Selection selection, DeprecatedString specified_values_json, DeprecatedString computed_values_json, DeprecatedString custom_properties_json, DeprecatedString node_box_sizing_json)
{
if (selection != m_selection) {
dbgln("Got data for the wrong node id! Wanted ({}), got ({})", m_selection.to_string(), selection.to_string());
dbgln("Got data for the wrong node id! Wanted ({}), got ({})", m_selection.to_deprecated_string(), selection.to_deprecated_string());
return;
}

View file

@ -29,7 +29,7 @@ public:
return dom_node_id == other.dom_node_id && pseudo_element == other.pseudo_element;
}
DeprecatedString to_string() const
DeprecatedString to_deprecated_string() const
{
if (pseudo_element.has_value())
return DeprecatedString::formatted("id: {}, pseudo: {}", dom_node_id, Web::CSS::pseudo_element_name(pseudo_element.value()));

View file

@ -77,7 +77,7 @@ void Tab::view_source(const URL& url, DeprecatedString const& source)
editor.set_syntax_highlighter(make<Web::HTML::SyntaxHighlighter>());
editor.set_ruler_visible(true);
window->resize(640, 480);
window->set_title(url.to_string());
window->set_title(url.to_deprecated_string());
window->set_icon(g_icon_bag.filetype_text);
window->set_window_mode(GUI::WindowMode::Modeless);
window->show();
@ -137,7 +137,7 @@ Tab::Tab(BrowserWindow& window)
m_go_back_context_menu = GUI::Menu::construct();
for (auto& url : m_history.get_back_title_history()) {
i++;
m_go_back_context_menu->add_action(GUI::Action::create(url.to_string(), g_icon_bag.filetype_html, [this, i](auto&) { go_back(i); }));
m_go_back_context_menu->add_action(GUI::Action::create(url.to_deprecated_string(), g_icon_bag.filetype_html, [this, i](auto&) { go_back(i); }));
}
m_go_back_context_menu->popup(go_back_button.screen_relative_rect().bottom_left());
};
@ -150,7 +150,7 @@ Tab::Tab(BrowserWindow& window)
m_go_forward_context_menu = GUI::Menu::construct();
for (auto& url : m_history.get_forward_title_history()) {
i++;
m_go_forward_context_menu->add_action(GUI::Action::create(url.to_string(), g_icon_bag.filetype_html, [this, i](auto&) { go_forward(i); }));
m_go_forward_context_menu->add_action(GUI::Action::create(url.to_deprecated_string(), g_icon_bag.filetype_html, [this, i](auto&) { go_forward(i); }));
}
m_go_forward_context_menu->popup(go_forward_button.screen_relative_rect().bottom_left());
};
@ -215,7 +215,7 @@ Tab::Tab(BrowserWindow& window)
update_status();
m_location_box->set_icon(nullptr);
m_location_box->set_text(url.to_string());
m_location_box->set_text(url.to_deprecated_string());
// don't add to history if back or forward is pressed
if (!m_is_history_navigation)
@ -223,7 +223,7 @@ Tab::Tab(BrowserWindow& window)
m_is_history_navigation = false;
update_actions();
update_bookmark_button(url.to_string());
update_bookmark_button(url.to_deprecated_string());
if (m_dom_inspector_widget)
m_dom_inspector_widget->clear_dom_json();
@ -309,7 +309,7 @@ Tab::Tab(BrowserWindow& window)
}));
m_link_context_menu->add_separator();
m_link_context_menu->add_action(GUI::Action::create("&Copy URL", g_icon_bag.copy, [this](auto&) {
GUI::Clipboard::the().set_plain_text(m_link_context_menu_url.to_string());
GUI::Clipboard::the().set_plain_text(m_link_context_menu_url.to_deprecated_string());
}));
m_link_context_menu->add_separator();
m_link_context_menu->add_action(GUI::Action::create("&Download", g_icon_bag.download, [this](auto&) {
@ -336,7 +336,7 @@ Tab::Tab(BrowserWindow& window)
GUI::Clipboard::the().set_bitmap(*m_image_context_menu_bitmap.bitmap());
}));
m_image_context_menu->add_action(GUI::Action::create("Copy Image &URL", g_icon_bag.copy, [this](auto&) {
GUI::Clipboard::the().set_plain_text(m_image_context_menu_url.to_string());
GUI::Clipboard::the().set_plain_text(m_image_context_menu_url.to_deprecated_string());
}));
m_image_context_menu->add_separator();
m_image_context_menu->add_action(GUI::Action::create("&Download", g_icon_bag.download, [this](auto&) {
@ -357,8 +357,8 @@ Tab::Tab(BrowserWindow& window)
view().on_title_change = [this](auto& title) {
if (title.is_null()) {
m_history.update_title(url().to_string());
m_title = url().to_string();
m_history.update_title(url().to_deprecated_string());
m_title = url().to_deprecated_string();
} else {
m_history.update_title(title);
m_title = title;
@ -436,7 +436,7 @@ Tab::Tab(BrowserWindow& window)
view().on_link_hover = [this](auto& url) {
if (url.is_valid())
update_status(url.to_string());
update_status(url.to_deprecated_string());
else
update_status();
};
@ -495,7 +495,7 @@ Optional<URL> Tab::url_from_location_bar(MayAppendTLD may_append_tld)
builder.append(".com"sv);
}
}
DeprecatedString final_text = builder.to_string();
DeprecatedString final_text = builder.to_deprecated_string();
auto url = url_from_user_input(final_text);
return url;
@ -543,7 +543,7 @@ void Tab::update_actions()
void Tab::bookmark_current_url()
{
auto url = this->url().to_string();
auto url = this->url().to_deprecated_string();
if (BookmarksBarWidget::the().contains_bookmark(url)) {
BookmarksBarWidget::the().remove_bookmark(url);
} else {