LibWeb: Update SVG get_path() API to take a viewport size

This will allow resolving paths that use sizes that are relative to the
viewport. This necessarily removes the on element caching, which has
been redundant for a while as computed paths are stored on the
paintable.
This commit is contained in:
MacDue 2024-03-03 20:15:06 +00:00 committed by Andreas Kling
parent 1fbf1073ab
commit b9afea40e6
Notes: sideshowbarker 2024-07-19 01:59:31 +09:00
16 changed files with 55 additions and 126 deletions

View file

@ -28,23 +28,16 @@ void SVGPolygonElement::attribute_changed(FlyString const& name, Optional<String
{
SVGGeometryElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::points) {
if (name == SVG::AttributeNames::points)
m_points = AttributeParser::parse_points(value.value_or(String {}));
m_path.clear();
}
}
Gfx::Path& SVGPolygonElement::get_path()
Gfx::Path SVGPolygonElement::get_path(CSSPixelSize)
{
if (m_path.has_value())
return m_path.value();
Gfx::Path path;
if (m_points.is_empty()) {
m_path = move(path);
return m_path.value();
}
if (m_points.is_empty())
return path;
// 1. perform an absolute moveto operation to the first coordinate pair in the list of points
path.move_to(m_points.first());
@ -56,8 +49,7 @@ Gfx::Path& SVGPolygonElement::get_path()
// 3. perform a closepath command
path.close();
m_path = move(path);
return m_path.value();
return path;
}
}