LayoutNode.cpp 691 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <LibHTML/Layout/LayoutNode.h>
  2. LayoutNode::LayoutNode(const Node* node)
  3. : m_node(node)
  4. {
  5. }
  6. LayoutNode::~LayoutNode()
  7. {
  8. }
  9. void LayoutNode::retain()
  10. {
  11. ASSERT(m_retain_count);
  12. ++m_retain_count;
  13. }
  14. void LayoutNode::release()
  15. {
  16. ASSERT(m_retain_count);
  17. if (!--m_retain_count)
  18. delete this;
  19. }
  20. void LayoutNode::append_child(Retained<LayoutNode> node)
  21. {
  22. if (m_last_child)
  23. m_last_child->set_next_sibling(node.ptr());
  24. node->m_parent_node = this;
  25. m_last_child = &node.leak_ref();
  26. if (!m_first_child)
  27. m_first_child = m_last_child;
  28. }
  29. void LayoutNode::layout()
  30. {
  31. for_each_child([](auto& child) {
  32. child.layout();
  33. });
  34. }