
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.
32 lines
748 B
C++
32 lines
748 B
C++
#pragma once
|
|
|
|
#include <LibDraw/Rect.h>
|
|
|
|
class LayoutNode;
|
|
class RenderingContext;
|
|
|
|
class LineBoxFragment {
|
|
friend class LineBox;
|
|
public:
|
|
LineBoxFragment(const LayoutNode& layout_node, int start, int length, const Rect& rect)
|
|
: m_layout_node(layout_node)
|
|
, m_start(start)
|
|
, m_length(length)
|
|
, m_rect(rect)
|
|
{
|
|
}
|
|
|
|
const LayoutNode& layout_node() const { return m_layout_node; }
|
|
int start() const { return m_start; }
|
|
int length() const { return m_length; }
|
|
const Rect& rect() const { return m_rect; }
|
|
Rect& rect() { return m_rect; }
|
|
|
|
void render(RenderingContext&);
|
|
|
|
private:
|
|
const LayoutNode& m_layout_node;
|
|
int m_start { 0 };
|
|
int m_length { 0 };
|
|
Rect m_rect;
|
|
};
|