Frame.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include <AK/Function.h>
  3. #include <AK/Noncopyable.h>
  4. #include <AK/RefPtr.h>
  5. #include <AK/WeakPtr.h>
  6. #include <LibDraw/Rect.h>
  7. #include <LibDraw/Size.h>
  8. #include <LibHTML/TreeNode.h>
  9. class Document;
  10. class HtmlView;
  11. class Frame : public TreeNode<Frame> {
  12. public:
  13. static NonnullRefPtr<Frame> create(HtmlView& html_view) { return adopt(*new Frame(html_view)); }
  14. ~Frame();
  15. const Document* document() const { return m_document; }
  16. Document* document() { return m_document; }
  17. void set_document(Document*);
  18. HtmlView* html_view() { return m_html_view; }
  19. const HtmlView* html_view() const { return m_html_view; }
  20. const Size& size() const { return m_size; }
  21. void set_size(const Size&);
  22. void set_needs_display(const Rect&);
  23. Function<void(const Rect&)> on_set_needs_display;
  24. void set_viewport_rect(const Rect&);
  25. Rect viewport_rect() const { return m_viewport_rect; }
  26. private:
  27. explicit Frame(HtmlView&);
  28. WeakPtr<HtmlView> m_html_view;
  29. RefPtr<Document> m_document;
  30. Size m_size;
  31. Rect m_viewport_rect;
  32. };