mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:27:45 +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:
parent
650180811e
commit
909bcfe9a4
12 changed files with 123 additions and 17 deletions
|
@ -58,16 +58,18 @@ void SVGTextPaintable::paint(PaintContext& context, PaintPhase phase) const
|
|||
|
||||
auto child_text_content = dom_node.child_text_content();
|
||||
|
||||
auto transform = layout_box().layout_transform();
|
||||
if (!transform.has_value())
|
||||
auto maybe_transform = layout_box().layout_transform();
|
||||
if (!maybe_transform.has_value())
|
||||
return;
|
||||
|
||||
auto transform = Gfx::AffineTransform(context.svg_transform()).multiply(*maybe_transform);
|
||||
|
||||
// FIXME: Support arbitrary path transforms for fonts.
|
||||
// FIMXE: This assumes transform->x_scale() == transform->y_scale().
|
||||
auto& scaled_font = layout_node().scaled_font(static_cast<float>(context.device_pixels_per_css_pixel()) * transform->x_scale());
|
||||
auto& scaled_font = layout_node().scaled_font(static_cast<float>(context.device_pixels_per_css_pixel()) * transform.x_scale());
|
||||
|
||||
Utf8View text_content { child_text_content };
|
||||
auto text_offset = context.floored_device_point(dom_node.get_offset().transformed(*transform).to_type<CSSPixels>());
|
||||
auto text_offset = context.floored_device_point(dom_node.get_offset().transformed(transform).to_type<CSSPixels>());
|
||||
|
||||
// FIXME: Once SVGFormattingContext does text layout this logic should move there.
|
||||
// https://svgwg.org/svg2-draft/text.html#TextAnchoringProperties
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue