Declaration.cpp 807 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2020-2021, the SerenityOS developers.
  3. * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #include <LibWeb/CSS/Parser/Declaration.h>
  8. #include <LibWeb/CSS/Serialize.h>
  9. namespace Web::CSS::Parser {
  10. Declaration::Declaration(FlyString name, Vector<ComponentValue> values, Important important)
  11. : m_name(move(name))
  12. , m_values(move(values))
  13. , m_important(move(important))
  14. {
  15. }
  16. Declaration::~Declaration() = default;
  17. String Declaration::to_string() const
  18. {
  19. StringBuilder builder;
  20. serialize_an_identifier(builder, m_name);
  21. builder.append(": "sv);
  22. builder.join(' ', m_values);
  23. if (m_important == Important::Yes)
  24. builder.append(" !important"sv);
  25. return MUST(builder.to_string());
  26. }
  27. }