1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:57:45 +00:00

LibWeb: Port CSS::Supports to new Strings

This commit is contained in:
Sam Atkins 2023-02-14 20:03:49 +00:00 committed by Tim Flynn
parent fc3540c4b1
commit a381ce9519
4 changed files with 32 additions and 32 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -73,45 +73,45 @@ bool Supports::Feature::evaluate() const
});
}
DeprecatedString Supports::Declaration::to_deprecated_string() const
ErrorOr<String> Supports::Declaration::to_string() const
{
return DeprecatedString::formatted("({})", declaration);
return String::formatted("({})", declaration);
}
DeprecatedString Supports::Selector::to_deprecated_string() const
ErrorOr<String> Supports::Selector::to_string() const
{
return DeprecatedString::formatted("selector({})", selector);
return String::formatted("selector({})", selector);
}
DeprecatedString Supports::Feature::to_deprecated_string() const
ErrorOr<String> Supports::Feature::to_string() const
{
return value.visit([](auto& it) { return it.to_deprecated_string(); });
return value.visit([](auto& it) { return it.to_string(); });
}
DeprecatedString Supports::InParens::to_deprecated_string() const
ErrorOr<String> Supports::InParens::to_string() const
{
return value.visit(
[](NonnullOwnPtr<Condition> const& condition) -> DeprecatedString { return DeprecatedString::formatted("({})", condition->to_deprecated_string()); },
[](Supports::Feature const& it) -> DeprecatedString { return it.to_deprecated_string(); },
[](GeneralEnclosed const& it) -> DeprecatedString { return it.to_string(); });
[](NonnullOwnPtr<Condition> const& condition) -> ErrorOr<String> { return String::formatted("({})", TRY(condition->to_string())); },
[](Supports::Feature const& it) -> ErrorOr<String> { return it.to_string(); },
[](GeneralEnclosed const& it) -> ErrorOr<String> { return String::from_utf8(it.to_string()); });
}
DeprecatedString Supports::Condition::to_deprecated_string() const
ErrorOr<String> Supports::Condition::to_string() const
{
switch (type) {
case Type::Not:
return DeprecatedString::formatted("not {}", children.first().to_deprecated_string());
return String::formatted("not {}", TRY(children.first().to_string()));
case Type::And:
return DeprecatedString::join(" and "sv, children);
return String::join(" and "sv, children);
case Type::Or:
return DeprecatedString::join(" or "sv, children);
return String::join(" or "sv, children);
}
VERIFY_NOT_REACHED();
}
DeprecatedString Supports::to_deprecated_string() const
ErrorOr<String> Supports::to_string() const
{
return m_condition->to_deprecated_string();
return m_condition->to_string();
}
}