1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 21:35:06 +00:00

LibWeb: Don't put block boxes inside inlines

Inline layout nodes cannot have block children (except inline-block,
of course.)

When encountering a block box child of an inline, we now hoist the
block up to the inline's containing block, and also wrap any preceding
inline siblings in an anonymous wrapper block.

This improves the ACID2 situation quite a bit (although we still need
floats to really bring it home.)

I also took this opportunity to move all tree building logic into
Layout::TreeBuilder, to continue the theme of absolving our LayoutNode
objects of responsibilities. :^)
This commit is contained in:
Andreas Kling 2020-11-26 21:18:34 +01:00
parent ffa4405083
commit ddbfd77e2c
6 changed files with 108 additions and 61 deletions

View file

@ -47,15 +47,6 @@ BlockBox::~BlockBox()
{
}
Node& BlockBox::inline_wrapper()
{
if (!last_child() || !last_child()->is_block() || last_child()->dom_node() != nullptr) {
append_child(adopt(*new BlockBox(document(), nullptr, style_for_anonymous_block())));
last_child()->set_children_are_inline(true);
}
return *last_child();
}
void BlockBox::paint(PaintContext& context, PaintPhase phase)
{
if (!is_visible())
@ -119,18 +110,6 @@ HitTestResult BlockBox::hit_test(const Gfx::IntPoint& position, HitTestType type
return { absolute_rect().contains(position.x(), position.y()) ? this : nullptr };
}
NonnullRefPtr<CSS::StyleProperties> BlockBox::style_for_anonymous_block() const
{
auto new_style = CSS::StyleProperties::create();
specified_style().for_each_property([&](auto property_id, auto& value) {
if (CSS::StyleResolver::is_inherited_property(property_id))
new_style->set_property(property_id, value);
});
return new_style;
}
void BlockBox::split_into_lines(BlockBox& container, LayoutMode layout_mode)
{
auto* line_box = &container.ensure_last_line_box();