From c5b50ec2f4e6de7d141c3e606e4fc1f41d9a4bad Mon Sep 17 00:00:00 2001 From: MacDue Date: Sun, 10 Sep 2023 14:03:13 +0100 Subject: [PATCH] LibWeb: Create paintables for nodes whose parents don't have paintables A Paintable is not created for an SVG element (nor should it), but it can contain SVG elements that need a paintable. This change forces those paintables to be created (without a parent). The masks are then only painted by being referenced from another element. --- .../Libraries/LibWeb/Layout/LayoutState.cpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/LayoutState.cpp b/Userland/Libraries/LibWeb/Layout/LayoutState.cpp index c88a021ce3..4db316074a 100644 --- a/Userland/Libraries/LibWeb/Layout/LayoutState.cpp +++ b/Userland/Libraries/LibWeb/Layout/LayoutState.cpp @@ -198,18 +198,19 @@ void LayoutState::resolve_relative_positions(Vector(*node.paintable()); - if (parent_paintable) { - VERIFY(!paintable.parent()); - parent_paintable->append_child(paintable); + Painting::Paintable* paintable = nullptr; + if (node.paintable()) { + paintable = const_cast(node.paintable()); + if (parent_paintable) { + VERIFY(!paintable->parent()); + parent_paintable->append_child(*paintable); + } + paintable->set_dom_node(node.dom_node()); + if (node.dom_node()) + node.dom_node()->set_paintable(paintable); } - paintable.set_dom_node(node.dom_node()); - if (node.dom_node()) - node.dom_node()->set_paintable(&paintable); for (auto* child = node.first_child(); child; child = child->next_sibling()) { - build_paint_tree(*child, &paintable); + build_paint_tree(*child, paintable); } }