diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp
index feadcac595..4a521bc1e4 100644
--- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp
+++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Andreas Kling
+ * Copyright (c) 2020-2022, Andreas Kling
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -189,6 +189,11 @@ void CanvasRenderingContext2D::quadratic_curve_to(float cx, float cy, float x, f
m_path.quadratic_bezier_curve_to({ cx, cy }, { x, y });
}
+void CanvasRenderingContext2D::bezier_curve_to(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y)
+{
+ m_path.cubic_bezier_curve_to(Gfx::FloatPoint(cp1x, cp1y), Gfx::FloatPoint(cp2x, cp2y), Gfx::FloatPoint(x, y));
+}
+
DOM::ExceptionOr CanvasRenderingContext2D::arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise)
{
if (radius < 0)
diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h
index 2e0d502657..f7713a0633 100644
--- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h
+++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Andreas Kling
+ * Copyright (c) 2020-2022, Andreas Kling
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -56,6 +56,7 @@ public:
void move_to(float x, float y);
void line_to(float x, float y);
void quadratic_curve_to(float cx, float cy, float x, float y);
+ void bezier_curve_to(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
DOM::ExceptionOr arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise);
DOM::ExceptionOr ellipse(float x, float y, float radius_x, float radius_y, float rotation, float start_angle, float end_angle, bool counter_clockwise);
diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl
index fc0e9b3ad6..6eaada5149 100644
--- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl
+++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl
@@ -15,6 +15,7 @@ interface CanvasRenderingContext2D {
undefined moveTo(double x, double y);
undefined lineTo(double x, double y);
undefined quadraticCurveTo(double cpx, double cpy, double x, double y);
+ undefined bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
undefined arc(double x, double y, double radius, double startAngle, double endAngle, optional boolean counterclockwise = false);
undefined ellipse(double x, double y, double radiusX, double radiusY, double rotation, double startAngle, double endAngle, optional boolean counterclockwise = false);