CompositeStyleValue.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2023, Ali Mohammad Pur <mpfard@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "CompositeStyleValue.h"
  7. #include <LibWeb/CSS/StyleValues/StyleValueList.h>
  8. namespace Web::CSS {
  9. CompositeStyleValue::CompositeStyleValue(Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values)
  10. : StyleValueWithDefaultOperators(Type::Composite)
  11. , m_properties { move(sub_properties), move(values) }
  12. {
  13. if (m_properties.sub_properties.size() != m_properties.values.size()) {
  14. dbgln("CompositeStyleValue: sub_properties and values must be the same size! {} != {}", m_properties.sub_properties.size(), m_properties.values.size());
  15. VERIFY_NOT_REACHED();
  16. }
  17. }
  18. CompositeStyleValue::~CompositeStyleValue() = default;
  19. ErrorOr<String> CompositeStyleValue::to_string() const
  20. {
  21. StringBuilder builder;
  22. auto first = true;
  23. for (auto& value : m_properties.values) {
  24. if (first)
  25. first = false;
  26. else
  27. builder.append(' ');
  28. builder.append(TRY(value->to_string()));
  29. }
  30. return builder.to_string();
  31. }
  32. }