1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 20:57:41 +00:00

LibWeb: Port CSS::Parser::Block to new Strings

This commit is contained in:
Sam Atkins 2023-02-14 18:49:25 +00:00 committed by Tim Flynn
parent e338ef4914
commit 86d23c63a4
4 changed files with 11 additions and 11 deletions

View file

@ -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
*/ */
@ -17,15 +17,15 @@ Block::Block(Token token, Vector<ComponentValue>&& values)
Block::~Block() = default; Block::~Block() = default;
DeprecatedString Block::to_deprecated_string() const ErrorOr<String> Block::to_string() const
{ {
StringBuilder builder; StringBuilder builder;
builder.append(m_token.bracket_string()); TRY(builder.try_append(m_token.bracket_string()));
builder.join(' ', m_values); TRY(builder.try_join(' ', m_values));
builder.append(m_token.bracket_mirror_string()); TRY(builder.try_append(m_token.bracket_mirror_string()));
return builder.to_deprecated_string(); return builder.to_string();
} }
} }

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2020-2021, the SerenityOS developers. * Copyright (c) 2020-2021, the SerenityOS developers.
* Copyright (c) 2021, 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
*/ */
@ -32,7 +32,7 @@ public:
Vector<ComponentValue> const& values() const { return m_values; } Vector<ComponentValue> const& values() const { return m_values; }
DeprecatedString to_deprecated_string() const; ErrorOr<String> to_string() const;
private: private:
Block(Token, Vector<ComponentValue>&&); Block(Token, Vector<ComponentValue>&&);

View file

@ -30,7 +30,7 @@ DeprecatedString ComponentValue::to_deprecated_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().release_value_but_fixme_should_propagate_errors().to_deprecated_string(); },
[](NonnullRefPtr<Block> const& block) { return block->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_deprecated_string(); }); [](NonnullRefPtr<Function> const& function) { return function->to_deprecated_string(); });
} }
@ -41,7 +41,7 @@ ErrorOr<String> ComponentValue::to_debug_string() const
return String::formatted("Token: {}", TRY(token.to_debug_string())); return String::formatted("Token: {}", TRY(token.to_debug_string()));
}, },
[](NonnullRefPtr<Block> const& block) -> ErrorOr<String> { [](NonnullRefPtr<Block> const& block) -> ErrorOr<String> {
return String::formatted("Block: {}", block->to_deprecated_string()); return String::formatted("Block: {}", TRY(block->to_string()));
}, },
[](NonnullRefPtr<Function> const& function) -> ErrorOr<String> { [](NonnullRefPtr<Function> const& function) -> ErrorOr<String> {
return String::formatted("Function: {}", function->to_deprecated_string()); return String::formatted("Function: {}", function->to_deprecated_string());

View file

@ -32,7 +32,7 @@ DeprecatedString Rule::to_deprecated_string() const
builder.join(' ', m_prelude); builder.join(' ', m_prelude);
if (m_block) if (m_block)
builder.append(m_block->to_deprecated_string()); builder.append(m_block->to_string().release_value_but_fixme_should_propagate_errors());
else else
builder.append(';'); builder.append(';');