mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
canvas: ensure there is a subpath in PathBuilderRef
(#37251)
This is also required by spec: https://html.spec.whatwg.org/multipage/canvas.html#ensure-there-is-a-subpath and if we not ensure it vello will trigger debug asserts. Enforcing this at `PathBuilderRef` is the lowest possible level that avoids misuse (and avoids IPC messages if we were to do this in content process) while still keeping it from backend. Testing: There are tests in WPT Split of https://github.com/servo/servo/pull/36821 try run: https://github.com/sagudev/servo/actions/runs/15449044694 --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
b13f49ab09
commit
ffe9163892
3 changed files with 33 additions and 10 deletions
|
@ -710,7 +710,7 @@ impl GenericPathBuilder<RaqoteBackend> for PathBuilder {
|
|||
PathOp::MoveTo(point) | PathOp::LineTo(point) => Some(Point2D::new(point.x, point.y)),
|
||||
PathOp::CubicTo(_, _, point) => Some(Point2D::new(point.x, point.y)),
|
||||
PathOp::QuadTo(_, point) => Some(Point2D::new(point.x, point.y)),
|
||||
PathOp::Close => None,
|
||||
PathOp::Close => path.ops.first().and_then(get_first_point),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -733,6 +733,15 @@ impl GenericPathBuilder<RaqoteBackend> for PathBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_first_point(op: &PathOp) -> Option<euclid::Point2D<f32, euclid::UnknownUnit>> {
|
||||
match op {
|
||||
PathOp::MoveTo(point) | PathOp::LineTo(point) => Some(Point2D::new(point.x, point.y)),
|
||||
PathOp::CubicTo(point, _, _) => Some(Point2D::new(point.x, point.y)),
|
||||
PathOp::QuadTo(point, _) => Some(Point2D::new(point.x, point.y)),
|
||||
PathOp::Close => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ToRaqoteStyle {
|
||||
type Target;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue