mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:37:35 +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
|
@ -46,6 +46,8 @@ public:
|
|||
Optional<Gfx::PaintStyle const&> fill_paint_style(SVGPaintContext const&) const;
|
||||
Optional<Gfx::PaintStyle const&> stroke_paint_style(SVGPaintContext const&) const;
|
||||
|
||||
JS::GCPtr<SVG::SVGMaskElement const> mask() const;
|
||||
|
||||
Optional<ViewBox> view_box() const;
|
||||
|
||||
protected:
|
||||
|
@ -62,6 +64,19 @@ protected:
|
|||
|
||||
Gfx::AffineTransform m_transform = {};
|
||||
|
||||
template<typename T>
|
||||
JS::GCPtr<T> try_resolve_url_to(AK::URL const& url) const
|
||||
{
|
||||
if (!url.fragment().has_value())
|
||||
return {};
|
||||
auto node = document().get_element_by_id(*url.fragment());
|
||||
if (!node)
|
||||
return {};
|
||||
if (is<T>(*node))
|
||||
return static_cast<T&>(*node);
|
||||
return {};
|
||||
}
|
||||
|
||||
private:
|
||||
virtual bool is_svg_graphics_element() const final { return true; }
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue