2022-04-12 10:14:00 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020-2021, the SerenityOS developers.
|
2023-02-15 08:28:23 -03:00
|
|
|
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
2022-04-12 10:14:00 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibWeb/CSS/Parser/Declaration.h>
|
|
|
|
|
#include <LibWeb/CSS/Serialize.h>
|
|
|
|
|
|
2022-04-12 10:51:19 -03:00
|
|
|
namespace Web::CSS::Parser {
|
2022-04-12 10:14:00 -03:00
|
|
|
|
2023-02-15 08:28:23 -03:00
|
|
|
Declaration::Declaration(FlyString name, Vector<ComponentValue> values, Important important)
|
2022-04-12 12:16:55 -03:00
|
|
|
: m_name(move(name))
|
|
|
|
|
, m_values(move(values))
|
|
|
|
|
, m_important(move(important))
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-12 10:14:00 -03:00
|
|
|
Declaration::~Declaration() = default;
|
|
|
|
|
|
2023-08-22 09:00:28 -03:00
|
|
|
String Declaration::to_string() const
|
2022-04-12 10:14:00 -03:00
|
|
|
{
|
|
|
|
|
StringBuilder builder;
|
|
|
|
|
|
2023-08-22 08:05:44 -03:00
|
|
|
serialize_an_identifier(builder, m_name);
|
2023-08-22 09:00:28 -03:00
|
|
|
builder.append(": "sv);
|
|
|
|
|
builder.join(' ', m_values);
|
2022-04-12 10:14:00 -03:00
|
|
|
|
|
|
|
|
if (m_important == Important::Yes)
|
2023-08-22 09:00:28 -03:00
|
|
|
builder.append(" !important"sv);
|
2022-04-12 10:14:00 -03:00
|
|
|
|
2023-08-22 09:00:28 -03:00
|
|
|
return MUST(builder.to_string());
|
2022-04-12 10:14:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|