LibWeb: Move line boxes from Layout::Box to BlockContainer

Per the spec, only a BlockContainer" can have line boxes, so let's not
clutter up every Layout::Box with line boxes.

This also allows us to establish an invariant that BFC and IFC always
operate on a Layout::BlockContainer.

Note that if BlockContainer has all block-level children, its line boxes
are not used for anything. They are only used in the all inline-level
children scenario.
This commit is contained in:
Andreas Kling 2021-10-06 21:53:25 +02:00
commit f73aa8e2bd
Notes: sideshowbarker 2024-07-18 02:59:33 +09:00
13 changed files with 80 additions and 74 deletions

View file

@ -147,4 +147,17 @@ bool BlockContainer::handle_mousewheel(Badge<EventHandler>, const Gfx::IntPoint&
return true;
}
LineBox& BlockContainer::ensure_last_line_box()
{
if (m_line_boxes.is_empty())
return add_line_box();
return m_line_boxes.last();
}
LineBox& BlockContainer::add_line_box()
{
m_line_boxes.append(LineBox());
return m_line_boxes.last();
}
}