mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
LibHTML: Rewrite inline and text layout
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.
This commit is contained in:
parent
5966fcff31
commit
1d65cf367f
12 changed files with 339 additions and 187 deletions
|
@ -1,4 +1,5 @@
|
|||
#include <LibHTML/DOM/Element.h>
|
||||
#include <LibHTML/Layout/LayoutBlock.h>
|
||||
#include <LibHTML/Layout/LayoutInline.h>
|
||||
|
||||
LayoutInline::LayoutInline(const Node& node, StyleProperties&& style_properties)
|
||||
|
@ -35,3 +36,14 @@ void LayoutInline::layout()
|
|||
rect().set_bottom(child.rect().bottom() + child.style().full_margin().bottom);
|
||||
});
|
||||
}
|
||||
|
||||
void LayoutInline::split_into_lines(LayoutBlock& container)
|
||||
{
|
||||
for_each_child([&](auto& child) {
|
||||
if (child.is_inline()) {
|
||||
static_cast<LayoutInline&>(child).split_into_lines(container);
|
||||
} else {
|
||||
// FIXME: Support block children of inlines.
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue