1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:58:11 +00:00

LibWeb: Add hack to avoid crashing on !child_display.is_flow_inside()

When encountering a box that claims to have block-level children, but
its CSS display type isn't actually "flow" inside, we would previously
crash due to a VERIFY() failure.

However, many sites choke on this due to freestanding table-related
boxes like those created by "table-row" and "table-row-group".
We're supposed to fix those up by wrapping them in a full set of table
boxes during layout tree construction, but that algorithm obviously
isn't working correctly in all cases. So let's work around the crashes
for now, allowing many more sites to load (even if visually incorrect.)

This is a rather monstrous hack, and we should get rid of it as soon as
it's not needed anymore.
This commit is contained in:
Andreas Kling 2022-02-21 16:53:38 +01:00
parent c61747fb2a
commit 0f15d1f947

View file

@ -100,8 +100,22 @@ OwnPtr<FormattingContext> FormattingContext::create_independent_formatting_conte
// The child box is a block container that doesn't create its own BFC.
// It will be formatted by this BFC.
VERIFY(child_display.is_flow_inside());
if (!child_display.is_flow_inside()) {
dbgln("FIXME: Child box doesn't create BFC, but inside is also not flow! display={}", child_display.to_string());
// HACK: Instead of crashing, create a dummy formatting context that does nothing.
// FIXME: Remove this once it's no longer needed. It currently swallows problem with standalone
// table-related boxes that don't get fixed up by CSS anonymous table box generation.
struct DummyFormattingContext : public FormattingContext {
DummyFormattingContext(FormattingState& state, Box const& box)
: FormattingContext(Type::Block, state, box)
{
}
virtual void run(Box const&, LayoutMode) override { }
};
return make<DummyFormattingContext>(m_state, child_box);
}
VERIFY(child_box.is_block_container());
VERIFY(child_display.is_flow_inside());
return {};
}