1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:47:44 +00:00

LibWeb: Resolve and paint simple SVG masks

This allows applying SVG <mask>s to elements. It is only implemented for
the simplest (and default) case:

	- mask-type = luminance
 	- maskContentUnits = maskContentUnits
 	- maskUnits = objectBoundingBox
	- Default masking area

It should be possible to extend to cover more cases. Though the layout
for maskContentUnits = objectBoundingBox will be tricky to figure out.
This commit is contained in:
MacDue 2023-09-10 14:10:55 +01:00 committed by Andreas Kling
parent 650180811e
commit 909bcfe9a4
12 changed files with 123 additions and 17 deletions

View file

@ -33,7 +33,7 @@ Optional<HitTestResult> SVGGeometryPaintable::hit_test(CSSPixelPoint position, H
if (!result.has_value())
return {};
auto& geometry_element = layout_box().dom_node();
if (auto transform = layout_box().layout_transform(); transform.has_value()) {
if (auto transform = layout_box().layout_transform({}); transform.has_value()) {
auto transformed_bounding_box = transform->map_to_quad(
const_cast<SVG::SVGGeometryElement&>(geometry_element).get_path().bounding_box());
if (!transformed_bounding_box.contains(position.to_type<float>()))
@ -78,7 +78,7 @@ void SVGGeometryPaintable::paint(PaintContext& context, PaintPhase phase) const
auto maybe_view_box = geometry_element.view_box();
auto transform = layout_box().layout_transform();
auto transform = layout_box().layout_transform(context.svg_transform());
if (!transform.has_value())
return;