OverflowStyleValue.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 OverflowStyleValue final : public StyleValueWithDefaultOperators<OverflowStyleValue> {
  13. public:
  14. static ValueComparingNonnullRefPtr<OverflowStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> overflow_x, ValueComparingNonnullRefPtr<StyleValue> overflow_y)
  15. {
  16. return adopt_ref(*new OverflowStyleValue(move(overflow_x), move(overflow_y)));
  17. }
  18. virtual ~OverflowStyleValue() override = default;
  19. ValueComparingNonnullRefPtr<StyleValue> overflow_x() const { return m_properties.overflow_x; }
  20. ValueComparingNonnullRefPtr<StyleValue> overflow_y() const { return m_properties.overflow_y; }
  21. virtual ErrorOr<String> to_string() const override;
  22. bool properties_equal(OverflowStyleValue const& other) const { return m_properties == other.m_properties; }
  23. private:
  24. OverflowStyleValue(ValueComparingNonnullRefPtr<StyleValue> overflow_x, ValueComparingNonnullRefPtr<StyleValue> overflow_y)
  25. : StyleValueWithDefaultOperators(Type::Overflow)
  26. , m_properties { .overflow_x = move(overflow_x), .overflow_y = move(overflow_y) }
  27. {
  28. }
  29. struct Properties {
  30. ValueComparingNonnullRefPtr<StyleValue> overflow_x;
  31. ValueComparingNonnullRefPtr<StyleValue> overflow_y;
  32. bool operator==(Properties const&) const = default;
  33. } m_properties;
  34. };
  35. }