Frame.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include <LibHTML/DOM/Document.h>
  2. #include <LibHTML/Frame.h>
  3. #include <LibHTML/HtmlView.h>
  4. #include <LibHTML/Layout/LayoutDocument.h>
  5. Frame::Frame(HtmlView& html_view)
  6. : m_html_view(html_view.make_weak_ptr())
  7. {
  8. }
  9. Frame::~Frame()
  10. {
  11. }
  12. void Frame::set_document(Document* document)
  13. {
  14. if (m_document == document)
  15. return;
  16. if (m_document)
  17. m_document->detach_from_frame({}, *this);
  18. m_document = document;
  19. if (m_document)
  20. m_document->attach_to_frame({}, *this);
  21. }
  22. void Frame::set_size(const Size& size)
  23. {
  24. if (m_size == size)
  25. return;
  26. m_size = size;
  27. }
  28. void Frame::set_viewport_rect(const Rect& rect)
  29. {
  30. if (m_viewport_rect == rect)
  31. return;
  32. m_viewport_rect = rect;
  33. if (m_document && m_document->layout_node())
  34. m_document->layout_node()->did_set_viewport_rect({}, rect);
  35. }
  36. void Frame::set_needs_display(const Rect& rect)
  37. {
  38. if (!m_viewport_rect.intersects(rect))
  39. return;
  40. if (!on_set_needs_display)
  41. return;
  42. on_set_needs_display(rect);
  43. }