mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 15:55:07 +00:00
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:
parent
1fbf1073ab
commit
b9afea40e6
16 changed files with 55 additions and 126 deletions
|
@ -40,11 +40,8 @@ void SVGCircleElement::attribute_changed(FlyString const& name, Optional<String>
|
|||
}
|
||||
}
|
||||
|
||||
Gfx::Path& SVGCircleElement::get_path()
|
||||
Gfx::Path SVGCircleElement::get_path(CSSPixelSize viewport_size)
|
||||
{
|
||||
if (m_path.has_value())
|
||||
return m_path.value();
|
||||
|
||||
float cx = m_center_x.value_or(0);
|
||||
float cy = m_center_y.value_or(0);
|
||||
float r = m_radius.value_or(0);
|
||||
|
@ -52,10 +49,8 @@ Gfx::Path& SVGCircleElement::get_path()
|
|||
Gfx::Path path;
|
||||
|
||||
// A zero radius disables rendering.
|
||||
if (r == 0) {
|
||||
m_path = move(path);
|
||||
return m_path.value();
|
||||
}
|
||||
if (r == 0)
|
||||
return {};
|
||||
|
||||
bool large_arc = false;
|
||||
bool sweep = true;
|
||||
|
@ -75,8 +70,7 @@ Gfx::Path& SVGCircleElement::get_path()
|
|||
// 5. arc with a segment-completing close path operation.
|
||||
path.arc_to({ cx + r, cy }, r, large_arc, sweep);
|
||||
|
||||
m_path = move(path);
|
||||
return m_path.value();
|
||||
return path;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/SVG11/shapes.html#CircleElementCXAttribute
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue