mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37: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) 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
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -26,12 +26,12 @@ ComponentValue::ComponentValue(NonnullRefPtr<Block> block)
|
||||||
|
|
||||||
ComponentValue::~ComponentValue() = default;
|
ComponentValue::~ComponentValue() = default;
|
||||||
|
|
||||||
DeprecatedString ComponentValue::to_deprecated_string() const
|
ErrorOr<String> ComponentValue::to_string() const
|
||||||
{
|
{
|
||||||
return m_value.visit(
|
return m_value.visit(
|
||||||
[](Token const& token) { return token.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().release_value_but_fixme_should_propagate_errors().to_deprecated_string(); },
|
[](NonnullRefPtr<Block> const& block) { return block->to_string(); },
|
||||||
[](NonnullRefPtr<Function> const& function) { return function->to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string(); });
|
[](NonnullRefPtr<Function> const& function) { return function->to_string(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<String> ComponentValue::to_debug_string() const
|
ErrorOr<String> ComponentValue::to_debug_string() const
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020-2021, the SerenityOS developers.
|
* 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
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -33,7 +33,7 @@ public:
|
||||||
Token const& token() const { return m_value.get<Token>(); }
|
Token const& token() const { return m_value.get<Token>(); }
|
||||||
operator 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;
|
ErrorOr<String> to_debug_string() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -45,6 +45,6 @@ template<>
|
||||||
struct AK::Formatter<Web::CSS::Parser::ComponentValue> : Formatter<StringView> {
|
struct AK::Formatter<Web::CSS::Parser::ComponentValue> : Formatter<StringView> {
|
||||||
ErrorOr<void> format(FormatBuilder& builder, Web::CSS::Parser::ComponentValue const& component_value)
|
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.
|
// FIXME: Parsing and then converting back to a string is weird.
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
for (auto const& item : first_token.function().values())
|
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();
|
transaction.commit();
|
||||||
return Supports::Feature {
|
return Supports::Feature {
|
||||||
Supports::Selector { builder.to_deprecated_string() }
|
Supports::Selector { builder.to_deprecated_string() }
|
||||||
|
@ -1425,13 +1425,13 @@ Optional<GeneralEnclosed> Parser::parse_general_enclosed(TokenStream<ComponentVa
|
||||||
// `[ <function-token> <any-value>? ) ]`
|
// `[ <function-token> <any-value>? ) ]`
|
||||||
if (first_token.is_function()) {
|
if (first_token.is_function()) {
|
||||||
transaction.commit();
|
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>? )`
|
// `( <any-value>? )`
|
||||||
if (first_token.is_block() && first_token.block().is_paren()) {
|
if (first_token.is_block() && first_token.block().is_paren()) {
|
||||||
transaction.commit();
|
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 {};
|
return {};
|
||||||
|
@ -3385,7 +3385,7 @@ Optional<UnicodeRange> Parser::parse_unicode_range(TokenStream<ComponentValue>&
|
||||||
return DeprecatedString::formatted("{:+}", int_value);
|
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> {
|
auto create_unicode_range = [&](StringView text, auto& local_transaction) -> Optional<UnicodeRange> {
|
||||||
|
|
|
@ -2518,7 +2518,7 @@ ErrorOr<String> UnresolvedStyleValue::to_string() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
for (auto& value : m_values)
|
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();
|
return builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue