summaryrefslogtreecommitdiff
path: root/Libraries/LibHTML/Layout/LayoutBlock.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-10-17 23:32:08 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-10-17 23:39:31 +0200
commit5e29238a49c261c2b373453fc15adb2bcfa48b69 (patch)
treefc7502cfdeb7fefc9d4a1a922f82e72cc2863aa5 /Libraries/LibHTML/Layout/LayoutBlock.cpp
parent41896ff5213a9716f63117b9bc4948a8f90e9097 (diff)
downloadserenity-5e29238a49c261c2b373453fc15adb2bcfa48b69.zip
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. :^)
Diffstat (limited to 'Libraries/LibHTML/Layout/LayoutBlock.cpp')
-rw-r--r--Libraries/LibHTML/Layout/LayoutBlock.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/Libraries/LibHTML/Layout/LayoutBlock.cpp b/Libraries/LibHTML/Layout/LayoutBlock.cpp
index 5102b111ce..73a374ec65 100644
--- a/Libraries/LibHTML/Layout/LayoutBlock.cpp
+++ b/Libraries/LibHTML/Layout/LayoutBlock.cpp
@@ -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())