TextDecorationStyleValue.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 TextDecorationStyleValue final : public StyleValueWithDefaultOperators<TextDecorationStyleValue> {
  13. public:
  14. static ValueComparingNonnullRefPtr<TextDecorationStyleValue> create(
  15. ValueComparingNonnullRefPtr<StyleValue> line,
  16. ValueComparingNonnullRefPtr<StyleValue> thickness,
  17. ValueComparingNonnullRefPtr<StyleValue> style,
  18. ValueComparingNonnullRefPtr<StyleValue> color)
  19. {
  20. return adopt_ref(*new TextDecorationStyleValue(move(line), move(thickness), move(style), move(color)));
  21. }
  22. virtual ~TextDecorationStyleValue() override = default;
  23. ValueComparingNonnullRefPtr<StyleValue> line() const { return m_properties.line; }
  24. ValueComparingNonnullRefPtr<StyleValue> thickness() const { return m_properties.thickness; }
  25. ValueComparingNonnullRefPtr<StyleValue> style() const { return m_properties.style; }
  26. ValueComparingNonnullRefPtr<StyleValue> color() const { return m_properties.color; }
  27. virtual ErrorOr<String> to_string() const override;
  28. bool properties_equal(TextDecorationStyleValue const& other) const { return m_properties == other.m_properties; }
  29. private:
  30. TextDecorationStyleValue(
  31. ValueComparingNonnullRefPtr<StyleValue> line,
  32. ValueComparingNonnullRefPtr<StyleValue> thickness,
  33. ValueComparingNonnullRefPtr<StyleValue> style,
  34. ValueComparingNonnullRefPtr<StyleValue> color)
  35. : StyleValueWithDefaultOperators(Type::TextDecoration)
  36. , m_properties { .line = move(line), .thickness = move(thickness), .style = move(style), .color = move(color) }
  37. {
  38. }
  39. struct Properties {
  40. ValueComparingNonnullRefPtr<StyleValue> line;
  41. ValueComparingNonnullRefPtr<StyleValue> thickness;
  42. ValueComparingNonnullRefPtr<StyleValue> style;
  43. ValueComparingNonnullRefPtr<StyleValue> color;
  44. bool operator==(Properties const&) const = default;
  45. } m_properties;
  46. };
  47. }