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

LibWeb: Layout SVG <mask> elements (but don't paint them)

This allows SVG mask elements to have layout computed, but not connected
to the main paint tree. They should only be reachable if (and painted)
if referenced by the "mask" attribute of another element.

This is controlled by the forms_unconnected_subtree() function on the
paintable, which (if it returns true) prevents the paintable from being
added as a child to what would be its parent.
This commit is contained in:
MacDue 2023-09-17 15:32:24 +01:00 committed by Andreas Kling
parent c5b50ec2f4
commit 0af8d81f48
8 changed files with 19 additions and 29 deletions

View file

@ -5,6 +5,7 @@
*/
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Layout/SVGBox.h>
#include <LibWeb/SVG/SVGDefsElement.h>
namespace Web::SVG {
@ -24,9 +25,10 @@ void SVGDefsElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGDefsElementPrototype>(realm, "SVGDefsElement"));
}
JS::GCPtr<Layout::Node> SVGDefsElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties>)
JS::GCPtr<Layout::Node> SVGDefsElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
{
return nullptr;
// FIXME: We need this layout node so any <mask>s inside this element get layout computed.
return heap().allocate_without_realm<Layout::SVGBox>(document(), *this, move(style));
}
}