summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/SVG
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-15 20:03:28 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-15 20:57:43 +0200
commit422d725c79fdb95ff67292e1d6a04a6518d277ff (patch)
treed2b04201ac0bac351a3a36fef68c9bd81243bd0e /Userland/Libraries/LibWeb/SVG
parent09d13e437badde4437f6b58852fb5623a573f614 (diff)
downloadserenity-422d725c79fdb95ff67292e1d6a04a6518d277ff.zip
LibWeb: Support "c" and "C" curves in SVG <path> data
These instructions now generate cubic Bézier curves.
Diffstat (limited to 'Userland/Libraries/LibWeb/SVG')
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp
index d9da8fb676..c37b32702a 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp
@@ -584,7 +584,19 @@ Gfx::Path& SVGPathElement::get_path()
break;
}
- case PathInstructionType::Curve:
+ case PathInstructionType::Curve: {
+ Gfx::FloatPoint c1 = { data[0], data[1] };
+ Gfx::FloatPoint c2 = { data[2], data[3] };
+ Gfx::FloatPoint p2 = { data[4], data[5] };
+ if (!absolute) {
+ p2 += path.segments().last().point();
+ c1 += path.segments().last().point();
+ c2 += path.segments().last().point();
+ }
+ path.cubic_bezier_curve_to(c1, c2, p2);
+ break;
+ }
+
case PathInstructionType::SmoothCurve:
// Instead of crashing the browser every time we come across an SVG
// with these path instructions, let's just skip them