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

@ -17,7 +17,7 @@ Block::Block(Token token, Vector<ComponentValue>&& values)
Block::~Block() = default;
DeprecatedString Block::to_string() const
DeprecatedString Block::to_deprecated_string() const
{
StringBuilder builder;
@ -25,7 +25,7 @@ DeprecatedString Block::to_string() const
builder.join(' ', m_values);
builder.append(m_token.bracket_mirror_string());
return builder.to_string();
return builder.to_deprecated_string();
}
}

View file

@ -32,7 +32,7 @@ public:
Vector<ComponentValue> const& values() const { return m_values; }
DeprecatedString to_string() const;
DeprecatedString to_deprecated_string() const;
private:
Block(Token, Vector<ComponentValue>&&);

View file

@ -26,12 +26,12 @@ ComponentValue::ComponentValue(NonnullRefPtr<Block> block)
ComponentValue::~ComponentValue() = default;
DeprecatedString ComponentValue::to_string() const
DeprecatedString ComponentValue::to_deprecated_string() const
{
return m_value.visit(
[](Token const& token) { return token.to_string(); },
[](NonnullRefPtr<Block> const& block) { return block->to_string(); },
[](NonnullRefPtr<Function> const& function) { return function->to_string(); });
[](Token const& token) { return token.to_deprecated_string(); },
[](NonnullRefPtr<Block> const& block) { return block->to_deprecated_string(); },
[](NonnullRefPtr<Function> const& function) { return function->to_deprecated_string(); });
}
DeprecatedString ComponentValue::to_debug_string() const
@ -41,10 +41,10 @@ DeprecatedString ComponentValue::to_debug_string() const
return DeprecatedString::formatted("Token: {}", token.to_debug_string());
},
[](NonnullRefPtr<Block> const& block) {
return DeprecatedString::formatted("Block: {}", block->to_string());
return DeprecatedString::formatted("Block: {}", block->to_deprecated_string());
},
[](NonnullRefPtr<Function> const& function) {
return DeprecatedString::formatted("Function: {}", function->to_string());
return DeprecatedString::formatted("Function: {}", function->to_deprecated_string());
});
}

View file

@ -33,7 +33,7 @@ public:
Token const& token() const { return m_value.get<Token>(); }
operator Token() const { return m_value.get<Token>(); }
DeprecatedString to_string() const;
DeprecatedString to_deprecated_string() const;
DeprecatedString to_debug_string() const;
private:
@ -45,6 +45,6 @@ template<>
struct AK::Formatter<Web::CSS::Parser::ComponentValue> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, Web::CSS::Parser::ComponentValue const& component_value)
{
return Formatter<StringView>::format(builder, component_value.to_string());
return Formatter<StringView>::format(builder, component_value.to_deprecated_string());
}
};

View file

@ -19,7 +19,7 @@ Declaration::Declaration(FlyString name, Vector<ComponentValue> values, Importan
Declaration::~Declaration() = default;
DeprecatedString Declaration::to_string() const
DeprecatedString Declaration::to_deprecated_string() const
{
StringBuilder builder;
@ -30,7 +30,7 @@ DeprecatedString Declaration::to_string() const
if (m_important == Important::Yes)
builder.append(" !important"sv);
return builder.to_string();
return builder.to_deprecated_string();
}
}

View file

@ -22,7 +22,7 @@ public:
Vector<ComponentValue> const& values() const { return m_values; }
Important importance() const { return m_important; }
DeprecatedString to_string() const;
DeprecatedString to_deprecated_string() const;
private:
FlyString m_name;

View file

@ -24,20 +24,20 @@ DeclarationOrAtRule::DeclarationOrAtRule(Declaration declaration)
DeclarationOrAtRule::~DeclarationOrAtRule() = default;
DeprecatedString DeclarationOrAtRule::to_string() const
DeprecatedString DeclarationOrAtRule::to_deprecated_string() const
{
StringBuilder builder;
switch (m_type) {
default:
case DeclarationType::At:
builder.append(m_at->to_string());
builder.append(m_at->to_deprecated_string());
break;
case DeclarationType::Declaration:
builder.append(m_declaration->to_string());
builder.append(m_declaration->to_deprecated_string());
break;
}
return builder.to_string();
return builder.to_deprecated_string();
}
}

View file

@ -37,7 +37,7 @@ public:
return *m_declaration;
}
DeprecatedString to_string() const;
DeprecatedString to_deprecated_string() const;
private:
DeclarationType m_type;

View file

@ -18,7 +18,7 @@ Function::Function(FlyString name, Vector<ComponentValue>&& values)
Function::~Function() = default;
DeprecatedString Function::to_string() const
DeprecatedString Function::to_deprecated_string() const
{
StringBuilder builder;
@ -27,7 +27,7 @@ DeprecatedString Function::to_string() const
builder.join(' ', m_values);
builder.append(')');
return builder.to_string();
return builder.to_deprecated_string();
}
}

View file

@ -28,7 +28,7 @@ public:
StringView name() const { return m_name; }
Vector<ComponentValue> const& values() const { return m_values; }
DeprecatedString to_string() const;
DeprecatedString to_deprecated_string() const;
private:
Function(FlyString name, Vector<ComponentValue>&& values);

View file

@ -562,7 +562,7 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_pseudo_simple_selec
}
// FIXME: Support multiple, comma-separated, language ranges.
Vector<FlyString> languages;
languages.append(pseudo_function.values().first().token().to_string());
languages.append(pseudo_function.values().first().token().to_deprecated_string());
return Selector::SimpleSelector {
.type = Selector::SimpleSelector::Type::PseudoClass,
.value = Selector::SimpleSelector::PseudoClass {
@ -1395,7 +1395,7 @@ Optional<Supports::Feature> Parser::parse_supports_feature(TokenStream<Component
if (auto declaration = consume_a_declaration(block_tokens); declaration.has_value()) {
transaction.commit();
return Supports::Feature {
Supports::Declaration { declaration->to_string() }
Supports::Declaration { declaration->to_deprecated_string() }
};
}
}
@ -1405,10 +1405,10 @@ Optional<Supports::Feature> Parser::parse_supports_feature(TokenStream<Component
// FIXME: Parsing and then converting back to a string is weird.
StringBuilder builder;
for (auto const& item : first_token.function().values())
builder.append(item.to_string());
builder.append(item.to_deprecated_string());
transaction.commit();
return Supports::Feature {
Supports::Selector { builder.to_string() }
Supports::Selector { builder.to_deprecated_string() }
};
}
@ -1425,13 +1425,13 @@ Optional<GeneralEnclosed> Parser::parse_general_enclosed(TokenStream<ComponentVa
// `[ <function-token> <any-value>? ) ]`
if (first_token.is_function()) {
transaction.commit();
return GeneralEnclosed { first_token.to_string() };
return GeneralEnclosed { first_token.to_deprecated_string() };
}
// `( <any-value>? )`
if (first_token.is_block() && first_token.block().is_paren()) {
transaction.commit();
return GeneralEnclosed { first_token.to_string() };
return GeneralEnclosed { first_token.to_deprecated_string() };
}
return {};
@ -3385,7 +3385,7 @@ Optional<UnicodeRange> Parser::parse_unicode_range(TokenStream<ComponentValue>&
return DeprecatedString::formatted("{:+}", int_value);
}
return component_value.to_string();
return component_value.to_deprecated_string();
};
auto create_unicode_range = [&](StringView text, auto& local_transaction) -> Optional<UnicodeRange> {
@ -3920,13 +3920,13 @@ Optional<Color> Parser::parse_color(ComponentValue const& component_value)
serialization_builder.append(cv.token().dimension_unit());
// 5. If serialization consists of fewer than six characters, prepend zeros (U+0030) so that it becomes six characters.
serialization = serialization_builder.to_string();
serialization = serialization_builder.to_deprecated_string();
if (serialization_builder.length() < 6) {
StringBuilder builder;
for (size_t i = 0; i < (6 - serialization_builder.length()); i++)
builder.append('0');
builder.append(serialization_builder.string_view());
serialization = builder.to_string();
serialization = builder.to_deprecated_string();
}
}
// 3. Otherwise, cv is an <ident-token>; let serialization be cvs value.

View file

@ -20,7 +20,7 @@ Rule::Rule(Rule::Type type, FlyString name, Vector<ComponentValue> prelude, RefP
Rule::~Rule() = default;
DeprecatedString Rule::to_string() const
DeprecatedString Rule::to_deprecated_string() const
{
StringBuilder builder;
@ -32,11 +32,11 @@ DeprecatedString Rule::to_string() const
builder.join(' ', m_prelude);
if (m_block)
builder.append(m_block->to_string());
builder.append(m_block->to_deprecated_string());
else
builder.append(';');
return builder.to_string();
return builder.to_deprecated_string();
}
}

View file

@ -41,7 +41,7 @@ public:
RefPtr<Block const> block() const { return m_block; }
StringView at_rule_name() const { return m_at_rule_name; }
DeprecatedString to_string() const;
DeprecatedString to_deprecated_string() const;
private:
Rule(Type, FlyString name, Vector<ComponentValue> prelude, RefPtr<Block>);

View file

@ -11,7 +11,7 @@
namespace Web::CSS::Parser {
DeprecatedString Token::to_string() const
DeprecatedString Token::to_deprecated_string() const
{
StringBuilder builder;

View file

@ -145,7 +145,7 @@ public:
DeprecatedString bracket_string() const;
DeprecatedString bracket_mirror_string() const;
DeprecatedString to_string() const;
DeprecatedString to_deprecated_string() const;
DeprecatedString to_debug_string() const;
Position const& start_position() const { return m_start_position; }

View file

@ -237,7 +237,7 @@ Tokenizer::Tokenizer(StringView input, DeprecatedString const& encoding)
last_was_carriage_return = false;
}
});
return builder.to_string();
return builder.to_deprecated_string();
};
m_decoded_input = filter_code_points(input, encoding);
@ -367,7 +367,7 @@ Token Tokenizer::create_value_token(Token::Type type, u32 value)
// FIXME: Avoid temporary StringBuilder here
StringBuilder builder;
builder.append_code_point(value);
token.m_value = builder.to_string();
token.m_value = builder.to_deprecated_string();
return token;
}
@ -400,7 +400,7 @@ u32 Tokenizer::consume_escaped_code_point()
}
// Interpret the hex digits as a hexadecimal number.
auto unhexed = strtoul(builder.to_string().characters(), nullptr, 16);
auto unhexed = strtoul(builder.to_deprecated_string().characters(), nullptr, 16);
// If this number is zero, or is for a surrogate, or is greater than the maximum allowed
// code point, return U+FFFD REPLACEMENT CHARACTER (<28>).
if (unhexed == 0 || is_unicode_surrogate(unhexed) || is_greater_than_maximum_allowed_code_point(unhexed)) {
@ -617,7 +617,7 @@ DeprecatedString Tokenizer::consume_an_ident_sequence()
break;
}
return result.to_string();
return result.to_deprecated_string();
}
// https://www.w3.org/TR/css-syntax-3/#consume-url-token
@ -640,7 +640,7 @@ Token Tokenizer::consume_a_url_token()
consume_as_much_whitespace_as_possible();
auto make_token = [&]() {
token.m_value = builder.to_string();
token.m_value = builder.to_deprecated_string();
return token;
};
@ -931,7 +931,7 @@ Token Tokenizer::consume_string_token(u32 ending_code_point)
StringBuilder builder;
auto make_token = [&]() {
token.m_value = builder.to_string();
token.m_value = builder.to_deprecated_string();
return token;
};