GridTrackPlacement.h 1022 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. GridTrackPlacement(int, bool);
  12. GridTrackPlacement(int);
  13. GridTrackPlacement();
  14. static GridTrackPlacement make_auto() { return GridTrackPlacement(); };
  15. void set_position(int position)
  16. {
  17. m_is_auto = false;
  18. m_position = position;
  19. }
  20. int position() const { return m_position; }
  21. void set_has_span(bool has_span)
  22. {
  23. VERIFY(!m_is_auto);
  24. m_has_span = has_span;
  25. }
  26. bool has_span() const { return m_has_span; }
  27. bool is_auto() const { return m_is_auto; }
  28. String to_string() const;
  29. bool operator==(GridTrackPlacement const& other) const
  30. {
  31. return m_position == other.position() && m_has_span == other.has_span();
  32. }
  33. private:
  34. bool m_is_auto { false };
  35. int m_position { 0 };
  36. bool m_has_span { false };
  37. };
  38. }