1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:47: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

@ -512,7 +512,7 @@ DeprecatedString BrowsingContext::selected_text() const
builder.append(text.substring(0, selection.end().index_in_node));
}
return builder.to_string();
return builder.to_deprecated_string();
}
void BrowsingContext::select_all()

View file

@ -28,7 +28,7 @@ public:
DeprecatedString fill_style() const
{
return my_drawing_state().fill_style.to_string();
return my_drawing_state().fill_style.to_deprecated_string();
}
void set_stroke_style(DeprecatedString style)
@ -39,7 +39,7 @@ public:
DeprecatedString stroke_style() const
{
return my_drawing_state().stroke_style.to_string();
return my_drawing_state().stroke_style.to_deprecated_string();
}
JS::NonnullGCPtr<CanvasGradient> create_radial_gradient(double x0, double y0, double r0, double x1, double y1, double r1)

View file

@ -31,7 +31,7 @@ JS::NonnullGCPtr<DOM::Document> DOMParser::parse_from_string(DeprecatedString co
{
// 1. Let document be a new Document, whose content type is type and url is this's relevant global object's associated Document's URL.
auto document = DOM::Document::create(realm(), verify_cast<HTML::Window>(relevant_global_object(*this)).associated_document().url());
document->set_content_type(Bindings::idl_enum_to_string(type));
document->set_content_type(Bindings::idl_enum_to_deprecated_string(type));
// 2. Switch on type:
if (type == Bindings::DOMParserSupportedType::Text_Html) {

View file

@ -74,7 +74,7 @@ Vector<DOMStringMap::NameValuePair> DOMStringMap::get_name_value_pairs() const
builder.append(current_character);
}
list.append({ builder.to_string(), value });
list.append({ builder.to_deprecated_string(), value });
});
// 4. Return list.
@ -139,7 +139,7 @@ WebIDL::ExceptionOr<void> DOMStringMap::set_value_of_new_named_property(Deprecat
builder.append(current_character);
}
auto data_name = builder.to_string();
auto data_name = builder.to_deprecated_string();
// FIXME: 4. If name does not match the XML Name production, throw an "InvalidCharacterError" DOMException.
@ -176,7 +176,7 @@ bool DOMStringMap::delete_existing_named_property(DeprecatedString const& name)
}
// Remove an attribute by name given name and the DOMStringMap's associated element.
auto data_name = builder.to_string();
auto data_name = builder.to_deprecated_string();
m_associated_element->remove_attribute(data_name);
// The spec doesn't have the step. This indicates that the deletion was successful.

View file

@ -94,7 +94,7 @@ DeprecatedString HTMLBaseElement::href() const
return url;
// 5. Return the serialization of urlRecord.
return url_record.to_string();
return url_record.to_deprecated_string();
}
// https://html.spec.whatwg.org/multipage/semantics.html#dom-base-href

View file

@ -177,7 +177,7 @@ DeprecatedString HTMLCanvasElement::to_data_url(DeprecatedString const& type, [[
if (type != "image/png")
return {};
auto encoded_bitmap = Gfx::PNGWriter::encode(*m_bitmap);
return AK::URL::create_with_data(type, encode_base64(encoded_bitmap), true).to_string();
return AK::URL::create_with_data(type, encode_base64(encoded_bitmap), true).to_deprecated_string();
}
void HTMLCanvasElement::present()

View file

@ -157,7 +157,7 @@ DeprecatedString HTMLElement::inner_text()
};
recurse(*layout_node());
return builder.to_string();
return builder.to_deprecated_string();
}
// // https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsettop

View file

@ -158,7 +158,7 @@ DeprecatedString HTMLFormElement::action() const
// Return the current URL if the action attribute is null or an empty string
if (value.is_null() || value.is_empty()) {
return document().url().to_string();
return document().url().to_deprecated_string();
}
return value;

View file

@ -504,7 +504,7 @@ void HTMLHyperlinkElementUtils::follow_the_hyperlink(Optional<DeprecatedString>
auto url = source->active_document()->parse_url(href());
// 10. If that is successful, let URL be the resulting URL string.
auto url_string = url.to_string();
auto url_string = url.to_deprecated_string();
// 11. Otherwise, if parsing the URL failed, the user agent may report the
// error to the user in a user-agent-specific manner, may queue an element
@ -519,7 +519,7 @@ void HTMLHyperlinkElementUtils::follow_the_hyperlink(Optional<DeprecatedString>
url_builder.append(url_string);
url_builder.append(*hyperlink_suffix);
url_string = url_builder.to_string();
url_string = url_builder.to_deprecated_string();
}
// FIXME: 13. Let request be a new request whose URL is URL and whose

View file

@ -352,7 +352,7 @@ Optional<DeprecatedString> HTMLInputElement::placeholder_value() const
if (ch != '\r' && ch != '\n')
builder.append(ch);
}
placeholder = builder.to_string();
placeholder = builder.to_deprecated_string();
}
return placeholder;
@ -477,7 +477,7 @@ DeprecatedString HTMLInputElement::value_sanitization_algorithm(DeprecatedString
if (!(c == '\r' || c == '\n'))
builder.append(c);
}
return builder.to_string();
return builder.to_deprecated_string();
}
} else if (type_state() == HTMLInputElement::TypeAttributeState::URL) {
// Strip newlines from the value, then strip leading and trailing ASCII whitespace from the value.

View file

@ -36,7 +36,7 @@ void HTMLObjectElement::parse_attribute(FlyString const& name, DeprecatedString
DeprecatedString HTMLObjectElement::data() const
{
auto data = attribute(HTML::AttributeNames::data);
return document().parse_url(data).to_string();
return document().parse_url(data).to_deprecated_string();
}
JS::GCPtr<Layout::Node> HTMLObjectElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)

View file

@ -361,7 +361,7 @@ void HTMLScriptElement::prepare_script()
if (m_script_type == ScriptType::Classic) {
// 1. Let script be the result of creating a classic script using source text, settings object, base URL, and options.
// FIXME: Pass options.
auto script = ClassicScript::create(m_document->url().to_string(), source_text, settings_object, base_url, m_source_line_number);
auto script = ClassicScript::create(m_document->url().to_deprecated_string(), source_text, settings_object, base_url, m_source_line_number);
// 2. Mark as ready el given script.
mark_as_ready(Result(move(script)));
@ -373,7 +373,7 @@ void HTMLScriptElement::prepare_script()
// 2. Fetch an inline module script graph, given source text, base URL, settings object, options, and with the following steps given result:
// FIXME: Pass options
fetch_inline_module_script_graph(m_document->url().to_string(), source_text, base_url, document().relevant_settings_object(), [this](auto const* result) {
fetch_inline_module_script_graph(m_document->url().to_deprecated_string(), source_text, base_url, document().relevant_settings_object(), [this](auto const* result) {
// 1. Mark as ready el given result.
if (!result)
mark_as_ready(ResultState::Null {});
@ -510,7 +510,7 @@ void HTMLScriptElement::resource_did_load()
}
}
auto script = ClassicScript::create(resource()->url().to_string(), data, document().relevant_settings_object(), AK::URL());
auto script = ClassicScript::create(resource()->url().to_deprecated_string(), data, document().relevant_settings_object(), AK::URL());
// When the chosen algorithm asynchronously completes, set the script's script to the result. At that time, the script is ready.
mark_as_ready(Result(script));

View file

@ -89,7 +89,7 @@ public:
result.append(DeprecatedString::number(port()));
}
// 6. Return result
return result.to_string();
return result.to_deprecated_string();
}
// https://html.spec.whatwg.org/multipage/origin.html#concept-origin-effective-domain

View file

@ -109,7 +109,7 @@ JS::GCPtr<DOM::Attr> prescan_get_attribute(DOM::Document& document, ByteBuffer c
} else if (input[position] == '\t' || input[position] == '\n' || input[position] == '\f' || input[position] == '\r' || input[position] == ' ')
goto spaces;
else if (input[position] == '/' || input[position] == '>')
return *DOM::Attr::create(document, attribute_name.to_string(), "");
return *DOM::Attr::create(document, attribute_name.to_deprecated_string(), "");
else
attribute_name.append_as_lowercase(input[position]);
++position;
@ -121,7 +121,7 @@ spaces:
if (!prescan_skip_whitespace_and_slashes(input, position))
return {};
if (input[position] != '=')
return DOM::Attr::create(document, attribute_name.to_string(), "");
return DOM::Attr::create(document, attribute_name.to_deprecated_string(), "");
++position;
value:
@ -134,13 +134,13 @@ value:
++position;
for (; !prescan_should_abort(input, position); ++position) {
if (input[position] == quote_character)
return DOM::Attr::create(document, attribute_name.to_string(), attribute_value.to_string());
return DOM::Attr::create(document, attribute_name.to_deprecated_string(), attribute_value.to_deprecated_string());
else
attribute_value.append_as_lowercase(input[position]);
}
return {};
} else if (input[position] == '>')
return DOM::Attr::create(document, attribute_name.to_string(), "");
return DOM::Attr::create(document, attribute_name.to_deprecated_string(), "");
else
attribute_value.append_as_lowercase(input[position]);
@ -150,7 +150,7 @@ value:
for (; !prescan_should_abort(input, position); ++position) {
if (input[position] == '\t' || input[position] == '\n' || input[position] == '\f' || input[position] == '\r' || input[position] == ' ' || input[position] == '>')
return DOM::Attr::create(document, attribute_name.to_string(), attribute_value.to_string());
return DOM::Attr::create(document, attribute_name.to_deprecated_string(), attribute_value.to_deprecated_string());
else
attribute_value.append_as_lowercase(input[position]);
}

View file

@ -170,7 +170,7 @@ void HTMLParser::run()
break;
auto& token = optional_token.value();
dbgln_if(HTML_PARSER_DEBUG, "[{}] {}", insertion_mode_name(), token.to_string());
dbgln_if(HTML_PARSER_DEBUG, "[{}] {}", insertion_mode_name(), token.to_deprecated_string());
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
// As each token is emitted from the tokenizer, the user agent must follow the appropriate steps from the following list, known as the tree construction dispatcher:
@ -954,7 +954,7 @@ void HTMLParser::flush_character_insertions()
{
if (m_character_insertion_builder.is_empty())
return;
m_character_insertion_node->set_data(m_character_insertion_builder.to_string());
m_character_insertion_node->set_data(m_character_insertion_builder.to_deprecated_string());
m_character_insertion_node->parent()->children_changed();
m_character_insertion_builder.clear();
}
@ -3604,7 +3604,7 @@ DeprecatedString HTMLParser::serialize_html_fragment(DOM::Node const& node)
else
builder.append(ch);
}
return builder.to_string();
return builder.to_deprecated_string();
};
// 2. Let s be a string, and initialize it to the empty string.
@ -3752,7 +3752,7 @@ DeprecatedString HTMLParser::serialize_html_fragment(DOM::Node const& node)
});
// 5. Return s.
return builder.to_string();
return builder.to_deprecated_string();
}
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#current-dimension-value

View file

@ -8,7 +8,7 @@
namespace Web::HTML {
DeprecatedString HTMLToken::to_string() const
DeprecatedString HTMLToken::to_deprecated_string() const
{
StringBuilder builder;
@ -70,7 +70,7 @@ DeprecatedString HTMLToken::to_string() const
builder.appendff("@{}:{}-{}:{}", m_start_position.line, m_start_position.column, m_end_position.line, m_end_position.column);
}
return builder.to_string();
return builder.to_deprecated_string();
}
}

View file

@ -315,7 +315,7 @@ public:
Type type() const { return m_type; }
DeprecatedString to_string() const;
DeprecatedString to_deprecated_string() const;
Position const& start_position() const { return m_start_position; }
Position const& end_position() const { return m_end_position; }

View file

@ -2887,7 +2887,7 @@ void HTMLTokenizer::restore_to(Utf8CodePointIterator const& new_iterator)
DeprecatedString HTMLTokenizer::consume_current_builder()
{
auto string = m_current_builder.to_string();
auto string = m_current_builder.to_deprecated_string();
m_current_builder.clear();
return string;
}

View file

@ -53,7 +53,7 @@ JS::NonnullGCPtr<ClassicScript> ClassicScript::create(DeprecatedString filename,
// 11. If result is a list of errors, then:
if (result.is_error()) {
auto& parse_error = result.error().first();
dbgln_if(HTML_SCRIPT_DEBUG, "ClassicScript: Failed to parse: {}", parse_error.to_string());
dbgln_if(HTML_SCRIPT_DEBUG, "ClassicScript: Failed to parse: {}", parse_error.to_deprecated_string());
// FIXME: 1. Set script's parse error and its error to rethrow to result[0].
// We do not have parse error as it would currently go unused.
@ -90,7 +90,7 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors)
// 5. If script's error to rethrow is not null, then set evaluationStatus to Completion { [[Type]]: throw, [[Value]]: script's error to rethrow, [[Target]]: empty }.
if (m_error_to_rethrow.has_value()) {
evaluation_status = vm.throw_completion<JS::SyntaxError>(m_error_to_rethrow.value().to_string());
evaluation_status = vm.throw_completion<JS::SyntaxError>(m_error_to_rethrow.value().to_deprecated_string());
} else {
auto timer = Core::ElapsedTimer::start_new();

View file

@ -74,7 +74,7 @@ template<>
struct Traits<Web::HTML::ModuleLocationTuple> : public GenericTraits<Web::HTML::ModuleLocationTuple> {
static unsigned hash(Web::HTML::ModuleLocationTuple const& tuple)
{
return pair_int_hash(tuple.url().to_string().hash(), tuple.type().hash());
return pair_int_hash(tuple.url().to_deprecated_string().hash(), tuple.type().hash());
}
};

View file

@ -57,7 +57,7 @@ JS::GCPtr<JavaScriptModuleScript> JavaScriptModuleScript::create(DeprecatedStrin
// 8. If result is a list of errors, then:
if (result.is_error()) {
auto& parse_error = result.error().first();
dbgln("JavaScriptModuleScript: Failed to parse: {}", parse_error.to_string());
dbgln("JavaScriptModuleScript: Failed to parse: {}", parse_error.to_deprecated_string());
// FIXME: 1. Set script's parse error to result[0].

View file

@ -71,7 +71,7 @@ void SyntaxHighlighter::rehighlight(Palette const& palette)
auto token = tokenizer.next_token();
if (!token.has_value() || token.value().is_end_of_file())
break;
dbgln_if(SYNTAX_HIGHLIGHTING_DEBUG, "(HTML::SyntaxHighlighter) got token of type {}", token->to_string());
dbgln_if(SYNTAX_HIGHLIGHTING_DEBUG, "(HTML::SyntaxHighlighter) got token of type {}", token->to_deprecated_string());
if (token->is_start_tag()) {
if (token->tag_name() == "script"sv) {

View file

@ -247,7 +247,7 @@ void Worker::run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_setti
// Asynchronously complete the perform the fetch steps with response.
dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Script ready!");
auto script = ClassicScript::create(url.to_string(), data, *m_inner_settings, AK::URL());
auto script = ClassicScript::create(url.to_deprecated_string(), data, *m_inner_settings, AK::URL());
// NOTE: Steps 15-31 below pick up after step 14 in the main context, steps 1-10 above
// are only for validation when used in a top-level case (ie: from a Window)