LayoutPosition.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #include <AK/RefPtr.h>
  3. class LayoutNode;
  4. struct LayoutPosition {
  5. bool operator>=(const LayoutPosition& other) const
  6. {
  7. if (layout_node == other.layout_node)
  8. return index_in_node >= other.index_in_node;
  9. // FIXME: Implement.
  10. return true;
  11. }
  12. bool operator<=(const LayoutPosition& other) const
  13. {
  14. if (layout_node == other.layout_node)
  15. return index_in_node <= other.index_in_node;
  16. // FIXME: Implement.
  17. return false;
  18. }
  19. RefPtr<LayoutNode> layout_node;
  20. int index_in_node { 0 };
  21. };
  22. class LayoutRange {
  23. public:
  24. LayoutRange() {}
  25. LayoutRange(const LayoutPosition& start, const LayoutPosition& end)
  26. : m_start(start)
  27. , m_end(end)
  28. {
  29. }
  30. bool is_valid() const { return m_start.layout_node && m_end.layout_node; }
  31. void set(const LayoutPosition& start, const LayoutPosition& end)
  32. {
  33. m_start = start;
  34. m_end = end;
  35. }
  36. void set_start(const LayoutPosition& start) { m_start = start; }
  37. void set_end(const LayoutPosition& end) { m_end = end; }
  38. const LayoutPosition& start() const { return m_start; }
  39. const LayoutPosition& end() const { return m_end; }
  40. private:
  41. LayoutPosition m_start;
  42. LayoutPosition m_end;
  43. };