From e7c209820d29cb422668ac0b142d030080aa7767 Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 15 Oct 2024 18:53:19 +0200 Subject: [PATCH] LibWeb: Layout all math elements using InternalDummy context Always create a new formatting context for elements. Previously that didn't happen if they only had inline children, e.g. mtable. This fixes a crash in the WPT MathML test mathml/crashtests/children-with-negative-block-sizes.html --- Tests/LibWeb/Text/expected/math-with-inline-child.txt | 1 + Tests/LibWeb/Text/input/math-with-inline-child.html | 11 +++++++++++ .../Libraries/LibWeb/Layout/FormattingContext.cpp | 4 ++++ 3 files changed, 16 insertions(+) create mode 100644 Tests/LibWeb/Text/expected/math-with-inline-child.txt create mode 100644 Tests/LibWeb/Text/input/math-with-inline-child.html diff --git a/Tests/LibWeb/Text/expected/math-with-inline-child.txt b/Tests/LibWeb/Text/expected/math-with-inline-child.txt new file mode 100644 index 00000000000..aaecaf93c4a --- /dev/null +++ b/Tests/LibWeb/Text/expected/math-with-inline-child.txt @@ -0,0 +1 @@ +PASS (didn't crash) diff --git a/Tests/LibWeb/Text/input/math-with-inline-child.html b/Tests/LibWeb/Text/input/math-with-inline-child.html new file mode 100644 index 00000000000..b8d3a4c9eb0 --- /dev/null +++ b/Tests/LibWeb/Text/input/math-with-inline-child.html @@ -0,0 +1,11 @@ + + + + + + diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index 477ec6b20d7..d2b25311403 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -136,6 +136,10 @@ Optional FormattingContext::formatting_context_type_cre if (display.is_grid_inside()) return Type::Grid; + if (display.is_math_inside()) + // HACK: Instead of crashing, create a dummy formatting context that does nothing. + return Type::InternalDummy; + if (creates_block_formatting_context(box)) return Type::Block;