From 86d23c63a49dd5493e5ee9801cc92b0403907b25 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Tue, 14 Feb 2023 18:49:25 +0000 Subject: LibWeb: Port CSS::Parser::Block to new Strings --- Userland/Libraries/LibWeb/CSS/Parser/Block.cpp | 12 ++++++------ Userland/Libraries/LibWeb/CSS/Parser/Block.h | 4 ++-- Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp | 4 ++-- Userland/Libraries/LibWeb/CSS/Parser/Rule.cpp | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Block.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Block.cpp index be951d037a..4093a9df97 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Block.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Block.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2020-2021, the SerenityOS developers. - * Copyright (c) 2021-2022, Sam Atkins + * Copyright (c) 2021-2023, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ @@ -17,15 +17,15 @@ Block::Block(Token token, Vector&& values) Block::~Block() = default; -DeprecatedString Block::to_deprecated_string() const +ErrorOr Block::to_string() const { StringBuilder builder; - builder.append(m_token.bracket_string()); - builder.join(' ', m_values); - builder.append(m_token.bracket_mirror_string()); + TRY(builder.try_append(m_token.bracket_string())); + TRY(builder.try_join(' ', m_values)); + TRY(builder.try_append(m_token.bracket_mirror_string())); - return builder.to_deprecated_string(); + return builder.to_string(); } } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Block.h b/Userland/Libraries/LibWeb/CSS/Parser/Block.h index 8168dc7078..1d343aca91 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Block.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Block.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2020-2021, the SerenityOS developers. - * Copyright (c) 2021, Sam Atkins + * Copyright (c) 2021-2023, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ @@ -32,7 +32,7 @@ public: Vector const& values() const { return m_values; } - DeprecatedString to_deprecated_string() const; + ErrorOr to_string() const; private: Block(Token, Vector&&); diff --git a/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp b/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp index fec362999e..9b9a4adca4 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp @@ -30,7 +30,7 @@ DeprecatedString ComponentValue::to_deprecated_string() const { return m_value.visit( [](Token const& token) { return token.to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string(); }, - [](NonnullRefPtr const& block) { return block->to_deprecated_string(); }, + [](NonnullRefPtr const& block) { return block->to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string(); }, [](NonnullRefPtr const& function) { return function->to_deprecated_string(); }); } @@ -41,7 +41,7 @@ ErrorOr ComponentValue::to_debug_string() const return String::formatted("Token: {}", TRY(token.to_debug_string())); }, [](NonnullRefPtr const& block) -> ErrorOr { - return String::formatted("Block: {}", block->to_deprecated_string()); + return String::formatted("Block: {}", TRY(block->to_string())); }, [](NonnullRefPtr const& function) -> ErrorOr { return String::formatted("Function: {}", function->to_deprecated_string()); diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Rule.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Rule.cpp index e9cbfc1d59..9e22b28459 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Rule.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Rule.cpp @@ -32,7 +32,7 @@ DeprecatedString Rule::to_deprecated_string() const builder.join(' ', m_prelude); if (m_block) - builder.append(m_block->to_deprecated_string()); + builder.append(m_block->to_string().release_value_but_fixme_should_propagate_errors()); else builder.append(';'); -- cgit v1.2.3