URLStyleValue.h 949 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2023, MacDue <macdue@dueutil.tech>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/URL.h>
  8. #include <LibWeb/CSS/Serialize.h>
  9. #include <LibWeb/CSS/StyleValue.h>
  10. namespace Web::CSS {
  11. class URLStyleValue final : public StyleValueWithDefaultOperators<URLStyleValue> {
  12. public:
  13. static ValueComparingNonnullRefPtr<URLStyleValue> create(AK::URL const& url)
  14. {
  15. return adopt_ref(*new (nothrow) URLStyleValue(url));
  16. }
  17. virtual ~URLStyleValue() override = default;
  18. AK::URL const& url() const { return m_url; }
  19. bool properties_equal(URLStyleValue const& other) const { return m_url == other.m_url; }
  20. virtual String to_string() const override
  21. {
  22. return serialize_a_url(m_url.to_deprecated_string());
  23. }
  24. private:
  25. URLStyleValue(AK::URL const& url)
  26. : StyleValueWithDefaultOperators(Type::URL)
  27. , m_url(url)
  28. {
  29. }
  30. AK::URL m_url;
  31. };
  32. }