TransitionStyleValue.cpp 995 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/CSS/PropertyID.h>
  7. #include <LibWeb/CSS/StyleValues/TransitionStyleValue.h>
  8. namespace Web::CSS {
  9. String TransitionStyleValue::to_string() const
  10. {
  11. StringBuilder builder;
  12. bool first = true;
  13. for (auto const& transition : m_transitions) {
  14. if (!first)
  15. builder.append(", "sv);
  16. first = false;
  17. builder.appendff("{} {} {} {}", transition.property_name->to_string(), transition.duration, transition.easing->to_string(), transition.delay);
  18. }
  19. return MUST(builder.to_string());
  20. }
  21. bool TransitionStyleValue::properties_equal(TransitionStyleValue const& other) const
  22. {
  23. if (m_transitions.size() != other.m_transitions.size())
  24. return false;
  25. for (size_t i = 0; i < m_transitions.size(); i++) {
  26. if (m_transitions[i] != other.m_transitions[i])
  27. return false;
  28. }
  29. return true;
  30. }
  31. }