UnresolvedStyleValue.cpp 816 B

12345678910111213141516171819202122232425262728293031
  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. return MUST(String::join(' ', m_values));
  17. }
  18. bool UnresolvedStyleValue::equals(CSSStyleValue const& other) const
  19. {
  20. if (type() != other.type())
  21. return false;
  22. // This is a case where comparing the strings actually makes sense.
  23. return to_string() == other.to_string();
  24. }
  25. }