UnresolvedStyleValue.cpp 911 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
  3. * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
  4. * Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
  5. * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
  6. *
  7. * SPDX-License-Identifier: BSD-2-Clause
  8. */
  9. #include "UnresolvedStyleValue.h"
  10. #include <AK/StringBuilder.h>
  11. namespace Web::CSS {
  12. String UnresolvedStyleValue::to_string() const
  13. {
  14. if (m_original_source_text.has_value())
  15. return *m_original_source_text;
  16. StringBuilder builder;
  17. for (auto& value : m_values)
  18. builder.append(value.to_string());
  19. return MUST(builder.to_string());
  20. }
  21. bool UnresolvedStyleValue::equals(CSSStyleValue const& other) const
  22. {
  23. if (type() != other.type())
  24. return false;
  25. // This is a case where comparing the strings actually makes sense.
  26. return to_string() == other.to_string();
  27. }
  28. }