summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-02-14 19:04:12 +0000
committerTim Flynn <trflynn89@pm.me>2023-02-15 12:48:26 -0500
commita168cda4a789b32d4d627daf344e081db6d1848f (patch)
treec993705d09e485509387c22e1442763ed9dd1ecc /Userland/Libraries/LibWeb
parent05c1b0962184d00ff140063d61c9317dcdca9a31 (diff)
downloadserenity-a168cda4a789b32d4d627daf344e081db6d1848f.zip
LibWeb: Port CSS::Parser::ComponentValue to new Strings
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp10
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.h6
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp8
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleValue.cpp2
4 files changed, 13 insertions, 13 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp b/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp
index 2505db04e7..f37f54e025 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp
@@ -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
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.h b/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.h
index 8bec23ad22..a7f9a75a57 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.h
@@ -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()));
}
};
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index e433e50ad2..2b12a82016 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -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> {
diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp
index 83d0630870..290fe3b7d2 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp
@@ -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();
}