1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-26 01:55:08 +00:00

LibHTML: Make "children are inline" flag imperative

Instead of computing whether a block's children are inline based on the
first child, make it an imperatively-set flag.

This gives us some flexibility to ignore things like text nodes inside
a <table>, for example. I'm still unsure what the "correct" way to deal
with those will be. We'll find out sooner or later. :^)
This commit is contained in:
Andreas Kling 2019-10-17 23:32:08 +02:00
parent 41896ff521
commit 5e29238a49
4 changed files with 11 additions and 8 deletions

View file

@ -18,6 +18,7 @@ LayoutNode& LayoutBlock::inline_wrapper()
{
if (!last_child() || !last_child()->is_block() || last_child()->node() != nullptr) {
append_child(adopt(*new LayoutBlock(nullptr, style_for_anonymous_block())));
last_child()->set_children_are_inline(true);
}
return *last_child();
}
@ -40,7 +41,9 @@ void LayoutBlock::layout_block_children()
ASSERT(!children_are_inline());
int content_height = 0;
for_each_child([&](auto& child) {
ASSERT(is<LayoutBlock>(child));
// FIXME: What should we do here? Something like a <table> might have a bunch of useless text children..
if (child.is_inline())
return;
auto& child_block = static_cast<LayoutBlock&>(child);
child_block.layout();
content_height = child_block.rect().bottom() + child_block.box_model().full_margin().bottom - rect().top();
@ -238,11 +241,6 @@ void LayoutBlock::render(RenderingContext& context)
}
}
bool LayoutBlock::children_are_inline() const
{
return first_child() && first_child()->is_inline();
}
HitTestResult LayoutBlock::hit_test(const Point& position) const
{
if (!children_are_inline())