LayoutBox.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #include <LibHTML/Layout/LayoutNode.h>
  3. class LayoutBox : public LayoutNodeWithStyleAndBoxModelMetrics {
  4. public:
  5. const Rect& rect() const { return m_rect; }
  6. Rect& rect() { return m_rect; }
  7. void set_rect(const Rect& rect) { m_rect = rect; }
  8. int x() const { return rect().x(); }
  9. int y() const { return rect().y(); }
  10. int width() const { return rect().width(); }
  11. int height() const { return rect().height(); }
  12. Size size() const { return rect().size(); }
  13. Point position() const { return rect().location(); }
  14. virtual HitTestResult hit_test(const Point& position) const override;
  15. virtual void set_needs_display() override;
  16. protected:
  17. LayoutBox(const Node* node, NonnullRefPtr<StyleProperties> style)
  18. : LayoutNodeWithStyleAndBoxModelMetrics(node, move(style))
  19. {
  20. }
  21. virtual void render(RenderingContext&) override;
  22. private:
  23. virtual bool is_box() const override { return true; }
  24. Rect m_rect;
  25. };
  26. template<>
  27. inline bool is<LayoutBox>(const LayoutNode& node)
  28. {
  29. return node.is_box();
  30. }