
Inline layout is now done by LayoutBlock. Blocks with inline children will split them into line boxes during layout. A LayoutBlock can have zero or more LineBox objects. Each LineBox represents one visual line. A LineBox can have any number of LineBoxFragment children. A fragment is an offset+length into a specific LayoutNode. To paint a LayoutBlock with inline children, we walk its line boxes, and walk their fragments, painting each fragment at a time by calling LineBoxFragment::render(), which in turn calls the LayoutNode via LayoutText::render_fragment(). Hit testing works similarly. This is very incomplete and has many bugs, but should make it easier for us to move forward with this code.
14 lines
704 B
C++
14 lines
704 B
C++
#include <LibHTML/Layout/LineBox.h>
|
|
|
|
void LineBox::add_fragment(const LayoutNode& layout_node, int start, int length, int width, int height)
|
|
{
|
|
if (!m_fragments.is_empty() && &m_fragments.last().layout_node() == &layout_node) {
|
|
// The fragment we're adding is from the last LayoutNode on the line.
|
|
// Expand the last fragment instead of adding a new one with the same LayoutNode.
|
|
m_fragments.last().m_length = (start - m_fragments.last().m_start) + length;
|
|
m_fragments.last().m_rect.set_width(m_fragments.last().m_rect.width() + width);
|
|
} else {
|
|
m_fragments.empend(layout_node, start, length, Rect(m_width, 0, width, height));
|
|
}
|
|
m_width += width;
|
|
}
|