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

LibWeb: Create paintables for nodes whose parents don't have paintables

A Paintable is not created for an SVG <defs> element (nor should it),
but it can contain SVG <mask> 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.
This commit is contained in:
MacDue 2023-09-10 14:03:13 +01:00 committed by Andreas Kling
parent b340a85523
commit c5b50ec2f4

View file

@ -198,18 +198,19 @@ void LayoutState::resolve_relative_positions(Vector<Painting::PaintableWithLines
static void build_paint_tree(Node& node, Painting::Paintable* parent_paintable = nullptr)
{
if (!node.paintable())
return;
auto& paintable = const_cast<Painting::Paintable&>(*node.paintable());
if (parent_paintable) {
VERIFY(!paintable.parent());
parent_paintable->append_child(paintable);
Painting::Paintable* paintable = nullptr;
if (node.paintable()) {
paintable = const_cast<Painting::Paintable*>(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);
}
}