mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:07:35 +00:00
LibWeb: Port CSS::Parser::ComponentValue to new Strings
This commit is contained in:
parent
05c1b09621
commit
a168cda4a7
4 changed files with 13 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2021, the SerenityOS developers.
|
||||
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -26,12 +26,12 @@ ComponentValue::ComponentValue(NonnullRefPtr<Block> block)
|
|||
|
||||
ComponentValue::~ComponentValue() = default;
|
||||
|
||||
DeprecatedString ComponentValue::to_deprecated_string() const
|
||||
ErrorOr<String> ComponentValue::to_string() const
|
||||
{
|
||||
return m_value.visit(
|
||||
[](Token const& token) { return token.to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string(); },
|
||||
[](NonnullRefPtr<Block> const& block) { return block->to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string(); },
|
||||
[](NonnullRefPtr<Function> const& function) { return function->to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string(); });
|
||||
[](Token const& token) { return token.to_string(); },
|
||||
[](NonnullRefPtr<Block> const& block) { return block->to_string(); },
|
||||
[](NonnullRefPtr<Function> const& function) { return function->to_string(); });
|
||||
}
|
||||
|
||||
ErrorOr<String> ComponentValue::to_debug_string() const
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2021, the SerenityOS developers.
|
||||
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -33,7 +33,7 @@ public:
|
|||
Token const& token() const { return m_value.get<Token>(); }
|
||||
operator Token() const { return m_value.get<Token>(); }
|
||||
|
||||
DeprecatedString to_deprecated_string() const;
|
||||
ErrorOr<String> to_string() const;
|
||||
ErrorOr<String> 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_deprecated_string());
|
||||
return Formatter<StringView>::format(builder, TRY(component_value.to_string()));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1405,7 +1405,7 @@ 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_deprecated_string());
|
||||
builder.append(item.to_string().release_value_but_fixme_should_propagate_errors());
|
||||
transaction.commit();
|
||||
return Supports::Feature {
|
||||
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_deprecated_string() };
|
||||
return GeneralEnclosed { first_token.to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string() };
|
||||
}
|
||||
|
||||
// `( <any-value>? )`
|
||||
if (first_token.is_block() && first_token.block().is_paren()) {
|
||||
transaction.commit();
|
||||
return GeneralEnclosed { first_token.to_deprecated_string() };
|
||||
return GeneralEnclosed { first_token.to_string().release_value_but_fixme_should_propagate_errors().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_deprecated_string();
|
||||
return component_value.to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
|
||||
};
|
||||
|
||||
auto create_unicode_range = [&](StringView text, auto& local_transaction) -> Optional<UnicodeRange> {
|
||||
|
|
|
@ -2518,7 +2518,7 @@ ErrorOr<String> UnresolvedStyleValue::to_string() const
|
|||
{
|
||||
StringBuilder builder;
|
||||
for (auto& value : m_values)
|
||||
TRY(builder.try_append(value.to_deprecated_string()));
|
||||
TRY(builder.try_append(TRY(value.to_string())));
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue