mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:28:11 +00:00

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.
34 lines
945 B
C++
34 lines
945 B
C++
/*
|
|
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/Layout/ImageBox.h>
|
|
#include <LibWeb/Painting/SVGGraphicsPaintable.h>
|
|
#include <LibWeb/SVG/SVGMaskElement.h>
|
|
|
|
namespace Web::Painting {
|
|
|
|
JS::NonnullGCPtr<SVGGraphicsPaintable> SVGGraphicsPaintable::create(Layout::SVGGraphicsBox const& layout_box)
|
|
{
|
|
return layout_box.heap().allocate_without_realm<SVGGraphicsPaintable>(layout_box);
|
|
}
|
|
|
|
SVGGraphicsPaintable::SVGGraphicsPaintable(Layout::SVGGraphicsBox const& layout_box)
|
|
: SVGPaintable(layout_box)
|
|
{
|
|
}
|
|
|
|
bool SVGGraphicsPaintable::forms_unconnected_subtree() const
|
|
{
|
|
// Masks should not be painted (i.e. reachable) unless referenced by another element.
|
|
return is<SVG::SVGMaskElement>(dom_node());
|
|
}
|
|
|
|
Layout::SVGGraphicsBox const& SVGGraphicsPaintable::layout_box() const
|
|
{
|
|
return static_cast<Layout::SVGGraphicsBox const&>(layout_node());
|
|
}
|
|
|
|
}
|