mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Make createRadialGradient throw for negative radii
This commit is contained in:
parent
0565df8596
commit
75e444c3b2
3 changed files with 9 additions and 9 deletions
|
@ -1019,10 +1019,14 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createradialgradient
|
||||
fn CreateRadialGradient(self, x0: Finite<f64>, y0: Finite<f64>, r0: Finite<f64>,
|
||||
x1: Finite<f64>, y1: Finite<f64>, r1: Finite<f64>)
|
||||
-> Root<CanvasGradient> {
|
||||
CanvasGradient::new(self.global.root().r(),
|
||||
CanvasGradientStyle::Radial(
|
||||
RadialGradientStyle::new(*x0, *y0, *r0, *x1, *y1, *r1, Vec::new())))
|
||||
-> Fallible<Root<CanvasGradient>> {
|
||||
if *r0 < 0. || *r1 < 0. {
|
||||
return Err(IndexSize);
|
||||
}
|
||||
|
||||
Ok(CanvasGradient::new(self.global.root().r(),
|
||||
CanvasGradientStyle::Radial(
|
||||
RadialGradientStyle::new(*x0, *y0, *r0, *x1, *y1, *r1, Vec::new()))))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createpattern
|
||||
|
|
|
@ -59,6 +59,7 @@ interface CanvasRenderingContext2D {
|
|||
attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle; // (default black)
|
||||
attribute (DOMString or CanvasGradient or CanvasPattern) fillStyle; // (default black)
|
||||
CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
|
||||
[Throws]
|
||||
CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
|
||||
[Throws]
|
||||
CanvasPattern createPattern(CanvasImageSource image, [TreatNullAs=EmptyString] DOMString repetition);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue