ListStyleStyleValue.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. *
  7. * SPDX-License-Identifier: BSD-2-Clause
  8. */
  9. #pragma once
  10. #include <LibWeb/CSS/StyleValue.h>
  11. namespace Web::CSS {
  12. class ListStyleStyleValue final : public StyleValueWithDefaultOperators<ListStyleStyleValue> {
  13. public:
  14. static ValueComparingNonnullRefPtr<ListStyleStyleValue> create(
  15. ValueComparingNonnullRefPtr<StyleValue> position,
  16. ValueComparingNonnullRefPtr<StyleValue> image,
  17. ValueComparingNonnullRefPtr<StyleValue> style_type)
  18. {
  19. return adopt_ref(*new ListStyleStyleValue(move(position), move(image), move(style_type)));
  20. }
  21. virtual ~ListStyleStyleValue() override = default;
  22. ValueComparingNonnullRefPtr<StyleValue> position() const { return m_properties.position; }
  23. ValueComparingNonnullRefPtr<StyleValue> image() const { return m_properties.image; }
  24. ValueComparingNonnullRefPtr<StyleValue> style_type() const { return m_properties.style_type; }
  25. virtual ErrorOr<String> to_string() const override;
  26. bool properties_equal(ListStyleStyleValue const& other) const { return m_properties == other.m_properties; }
  27. private:
  28. ListStyleStyleValue(
  29. ValueComparingNonnullRefPtr<StyleValue> position,
  30. ValueComparingNonnullRefPtr<StyleValue> image,
  31. ValueComparingNonnullRefPtr<StyleValue> style_type)
  32. : StyleValueWithDefaultOperators(Type::ListStyle)
  33. , m_properties { .position = move(position), .image = move(image), .style_type = move(style_type) }
  34. {
  35. }
  36. struct Properties {
  37. ValueComparingNonnullRefPtr<StyleValue> position;
  38. ValueComparingNonnullRefPtr<StyleValue> image;
  39. ValueComparingNonnullRefPtr<StyleValue> style_type;
  40. bool operator==(Properties const&) const = default;
  41. } m_properties;
  42. };
  43. }