1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:47:34 +00:00

LibWeb: Port GeneralEnclosed to new Strings

This commit is contained in:
Sam Atkins 2023-02-17 12:13:49 +00:00 committed by Linus Groh
parent b5eb2ee478
commit 33e9c4e1b2
3 changed files with 7 additions and 7 deletions

View file

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <AK/DeprecatedString.h> #include <AK/String.h>
namespace Web::CSS { namespace Web::CSS {
@ -71,15 +71,15 @@ inline MatchResult evaluate_or(Collection& collection, Evaluate evaluate)
// https://www.w3.org/TR/mediaqueries-4/#typedef-general-enclosed // https://www.w3.org/TR/mediaqueries-4/#typedef-general-enclosed
class GeneralEnclosed { class GeneralEnclosed {
public: public:
GeneralEnclosed(DeprecatedString serialized_contents) GeneralEnclosed(String serialized_contents)
: m_serialized_contents(move(serialized_contents)) : m_serialized_contents(move(serialized_contents))
{ {
} }
MatchResult evaluate() const { return MatchResult::Unknown; } MatchResult evaluate() const { return MatchResult::Unknown; }
StringView to_string() const { return m_serialized_contents.view(); } String const& to_string() const { return m_serialized_contents; }
private: private:
DeprecatedString m_serialized_contents; String m_serialized_contents;
}; };
} }

View file

@ -1427,13 +1427,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_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string() }; return GeneralEnclosed { first_token.to_string().release_value_but_fixme_should_propagate_errors() };
} }
// `( <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_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string() }; return GeneralEnclosed { first_token.to_string().release_value_but_fixme_should_propagate_errors() };
} }
return {}; return {};

View file

@ -93,7 +93,7 @@ ErrorOr<String> Supports::InParens::to_string() const
return value.visit( return value.visit(
[](NonnullOwnPtr<Condition> const& condition) -> ErrorOr<String> { return String::formatted("({})", TRY(condition->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(); }, [](Supports::Feature const& it) -> ErrorOr<String> { return it.to_string(); },
[](GeneralEnclosed const& it) -> ErrorOr<String> { return String::from_utf8(it.to_string()); }); [](GeneralEnclosed const& it) -> ErrorOr<String> { return it.to_string(); });
} }
ErrorOr<String> Supports::Condition::to_string() const ErrorOr<String> Supports::Condition::to_string() const