LineBoxFragment.h 938 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #include <LibDraw/FloatRect.h>
  3. class LayoutNode;
  4. class RenderingContext;
  5. class LineBoxFragment {
  6. friend class LineBox;
  7. public:
  8. LineBoxFragment(const LayoutNode& layout_node, int start, int length, const FloatRect& rect)
  9. : m_layout_node(layout_node)
  10. , m_start(start)
  11. , m_length(length)
  12. , m_rect(rect)
  13. {
  14. }
  15. const LayoutNode& layout_node() const { return m_layout_node; }
  16. int start() const { return m_start; }
  17. int length() const { return m_length; }
  18. const FloatRect& rect() const { return m_rect; }
  19. FloatRect& rect() { return m_rect; }
  20. float width() const { return m_rect.width(); }
  21. void render(RenderingContext&);
  22. bool is_justifiable_whitespace() const;
  23. StringView text() const;
  24. int text_index_at(float x) const;
  25. private:
  26. const LayoutNode& m_layout_node;
  27. int m_start { 0 };
  28. int m_length { 0 };
  29. FloatRect m_rect;
  30. };