LayoutInline.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <LibHTML/DOM/Element.h>
  2. #include <LibHTML/Layout/LayoutInline.h>
  3. LayoutInline::LayoutInline(const Node& node, StyleProperties&& style_properties)
  4. : LayoutNode(&node, move(style_properties))
  5. {
  6. }
  7. LayoutInline::~LayoutInline()
  8. {
  9. }
  10. void LayoutInline::layout()
  11. {
  12. Point origin;
  13. if (previous_sibling() != nullptr) {
  14. auto& previous_sibling_rect = previous_sibling()->rect();
  15. auto& previous_sibling_style = previous_sibling()->style();
  16. origin = previous_sibling_rect.location();
  17. // FIXME: Implement proper inline positioning when
  18. // there are nodes with different heights. And don't
  19. // hardcode font size like we do here.
  20. origin.move_by(previous_sibling_rect.width(), previous_sibling_rect.height());
  21. origin.move_by(previous_sibling_style.full_margin().right, -11);
  22. } else {
  23. origin = parent()->rect().location();
  24. }
  25. rect().set_location(origin);
  26. for_each_child([&](auto& child) {
  27. child.layout();
  28. rect().set_right(child.rect().right() + child.style().full_margin().right);
  29. rect().set_bottom(child.rect().bottom() + child.style().full_margin().bottom);
  30. });
  31. }