From dfeb4550d54a7cb341a0196fdca7e4fef06657cf Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 6 Oct 2021 21:42:42 +0200 Subject: [PATCH] LibWeb: Don't attempt to layout the inside of childless boxes Some boxes cannot have children (most commonly replaced elements), and so there is nothing meaningful inside them to layout. We now use the can_have_children() flag to quickly skip over such boxes instead of creating a formatting context and other pointless busywork. --- Userland/Libraries/LibWeb/Layout/FormattingContext.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index e0188565ec..e42fd77ddb 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -76,6 +76,9 @@ bool FormattingContext::creates_block_formatting_context(const Box& box) void FormattingContext::layout_inside(Box& child_box, LayoutMode layout_mode) { + if (!child_box.can_have_children()) + return; + if (is(child_box)) { SVGFormattingContext context(child_box, this); context.run(child_box, layout_mode);