Make create_pattern() return None for incomplete images

This commit is contained in:
pylbrecht 2020-02-07 21:56:58 +01:00
parent 423b86e439
commit 481ef46167
10 changed files with 12 additions and 35 deletions

View file

@ -566,7 +566,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
&self,
image: CanvasImageSource,
repetition: DOMString,
) -> Fallible<DomRoot<CanvasPattern>> {
) -> Fallible<Option<DomRoot<CanvasPattern>>> {
self.canvas_state
.borrow()
.create_pattern(&self.global(), image, repetition)

View file

@ -210,7 +210,7 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
&self,
image: CanvasImageSource,
repetition: DOMString,
) -> Fallible<DomRoot<CanvasPattern>> {
) -> Fallible<Option<DomRoot<CanvasPattern>>> {
self.canvas_state
.borrow()
.create_pattern(&self.global(), image, repetition)

View file

@ -340,7 +340,7 @@ impl PaintRenderingContext2DMethods for PaintRenderingContext2D {
&self,
image: CanvasImageSource,
repetition: DOMString,
) -> Fallible<DomRoot<CanvasPattern>> {
) -> Fallible<Option<DomRoot<CanvasPattern>>> {
self.context.CreatePattern(image, repetition)
}

View file

@ -93,7 +93,7 @@ interface mixin CanvasFillStrokeStyles {
[Throws]
CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
[Throws]
CanvasPattern createPattern(CanvasImageSource image, [TreatNullAs=EmptyString] DOMString repetition);
CanvasPattern? createPattern(CanvasImageSource image, [TreatNullAs=EmptyString] DOMString repetition);
};
[Exposed=(PaintWorklet, Window, Worker)]