EasingStyleValue.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
  4. * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
  5. * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
  6. * Copyright (c) 2023, Ali Mohammad Pur <mpfard@serenityos.org>
  7. *
  8. * SPDX-License-Identifier: BSD-2-Clause
  9. */
  10. #include "EasingStyleValue.h"
  11. #include <AK/StringBuilder.h>
  12. namespace Web::CSS {
  13. String EasingStyleValue::to_string() const
  14. {
  15. if (m_properties.easing_function == EasingFunction::StepStart)
  16. return "steps(1, start)"_string;
  17. if (m_properties.easing_function == EasingFunction::StepEnd)
  18. return "steps(1, end)"_string;
  19. StringBuilder builder;
  20. builder.append(CSS::to_string(m_properties.easing_function));
  21. if (m_properties.values.is_empty())
  22. return MUST(builder.to_string());
  23. builder.append('(');
  24. for (size_t i = 0; i < m_properties.values.size(); ++i) {
  25. builder.append(m_properties.values[i]->to_string());
  26. if (i != m_properties.values.size() - 1)
  27. builder.append(", "sv);
  28. }
  29. builder.append(')');
  30. return MUST(builder.to_string());
  31. }
  32. bool EasingStyleValue::Properties::operator==(Properties const& other) const
  33. {
  34. return easing_function == other.easing_function && values == other.values;
  35. }
  36. }