GridTrackPlacement.h 1022 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/String.h>
  8. namespace Web::CSS {
  9. class GridTrackPlacement {
  10. public:
  11. enum class Type {
  12. Span,
  13. Position,
  14. Auto
  15. };
  16. GridTrackPlacement(int, bool = false);
  17. GridTrackPlacement();
  18. static GridTrackPlacement make_auto() { return GridTrackPlacement(); };
  19. bool is_span() const { return m_type == Type::Span; }
  20. bool is_position() const { return m_type == Type::Position; }
  21. bool is_auto() const { return m_type == Type::Auto; }
  22. bool is_auto_positioned() const { return m_type == Type::Auto || m_type == Type::Span; }
  23. int raw_value() const { return m_value; }
  24. Type type() const { return m_type; }
  25. String to_string() const;
  26. bool operator==(GridTrackPlacement const& other) const
  27. {
  28. return m_type == other.type() && m_value == other.raw_value();
  29. }
  30. private:
  31. Type m_type;
  32. int m_value { 0 };
  33. };
  34. }