/* * Copyright (c) 2020-2021, the SerenityOS developers. * Copyright (c) 2021-2022, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include namespace Web::CSS::Parser { ComponentValue::ComponentValue(Token token) : m_value(token) { } ComponentValue::ComponentValue(NonnullRefPtr function) : m_value(function) { } ComponentValue::ComponentValue(NonnullRefPtr block) : m_value(block) { } ComponentValue::~ComponentValue() = default; DeprecatedString ComponentValue::to_deprecated_string() const { return m_value.visit( [](Token const& token) { return token.to_deprecated_string(); }, [](NonnullRefPtr const& block) { return block->to_deprecated_string(); }, [](NonnullRefPtr const& function) { return function->to_deprecated_string(); }); } DeprecatedString ComponentValue::to_debug_string() const { return m_value.visit( [](Token const& token) { return DeprecatedString::formatted("Token: {}", token.to_debug_string()); }, [](NonnullRefPtr const& block) { return DeprecatedString::formatted("Block: {}", block->to_deprecated_string()); }, [](NonnullRefPtr const& function) { return DeprecatedString::formatted("Function: {}", function->to_deprecated_string()); }); } }