LayoutDocument.cpp 784 B

12345678910111213141516171819202122232425262728293031
  1. #include <LibHTML/Frame.h>
  2. #include <LibHTML/Dump.h>
  3. #include <LibHTML/Layout/LayoutDocument.h>
  4. LayoutDocument::LayoutDocument(const Document& document, NonnullRefPtr<StyleProperties> style)
  5. : LayoutBlock(&document, move(style))
  6. {
  7. }
  8. LayoutDocument::~LayoutDocument()
  9. {
  10. }
  11. void LayoutDocument::layout()
  12. {
  13. ASSERT(document().frame());
  14. rect().set_width(document().frame()->size().width());
  15. LayoutNode::layout();
  16. ASSERT(!children_are_inline());
  17. int lowest_bottom = 0;
  18. for_each_child([&](auto& child) {
  19. ASSERT(is<LayoutBlock>(child));
  20. auto& child_block = to<LayoutBlock>(child);
  21. if (child_block.rect().bottom() > lowest_bottom)
  22. lowest_bottom = child_block.rect().bottom();
  23. });
  24. rect().set_bottom(lowest_bottom);
  25. }