MathDepthStyleValue.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/CSS/StyleValue.h>
  8. namespace Web::CSS {
  9. class MathDepthStyleValue : public StyleValueWithDefaultOperators<MathDepthStyleValue> {
  10. public:
  11. static ValueComparingNonnullRefPtr<MathDepthStyleValue> create_auto_add();
  12. static ValueComparingNonnullRefPtr<MathDepthStyleValue> create_add(ValueComparingNonnullRefPtr<StyleValue const> integer_value);
  13. static ValueComparingNonnullRefPtr<MathDepthStyleValue> create_integer(ValueComparingNonnullRefPtr<StyleValue const> integer_value);
  14. virtual ~MathDepthStyleValue() override = default;
  15. bool is_auto_add() const { return m_type == MathDepthType::AutoAdd; }
  16. bool is_add() const { return m_type == MathDepthType::Add; }
  17. bool is_integer() const { return m_type == MathDepthType::Integer; }
  18. auto integer_value() const
  19. {
  20. VERIFY(!m_integer_value.is_null());
  21. return m_integer_value;
  22. }
  23. virtual String to_string() const override;
  24. bool properties_equal(MathDepthStyleValue const& other) const;
  25. private:
  26. enum class MathDepthType {
  27. AutoAdd,
  28. Add,
  29. Integer,
  30. };
  31. MathDepthStyleValue(MathDepthType type, ValueComparingRefPtr<StyleValue const> integer_value = nullptr);
  32. MathDepthType m_type;
  33. ValueComparingRefPtr<StyleValue const> m_integer_value;
  34. };
  35. }