diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2020-02-11 08:11:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-11 08:11:40 -0500 |
commit | 55058b28755646d3305bd58a725205311ac9607d (patch) | |
tree | 1be5fe1a489206f0b61dfbf38e2aba52792b1cf0 /components/script/dom | |
parent | f3dbe7d388211ea899c0a84a21c8ae9bfb673c37 (diff) | |
parent | 70b2d31822c909ba9d0268c88d15abdfcec5393c (diff) | |
download | servo-55058b28755646d3305bd58a725205311ac9607d.tar.gz servo-55058b28755646d3305bd58a725205311ac9607d.zip |
Auto merge of #25710 - pylbrecht:pattern.incomplete, r=jdm
Make CanvasRenderingContext2D.createPattern() return null for incomplete images
<!-- Please describe your changes on the following line: -->
`createPattern()` should return `null` if the passed `image` argument is not usable.
References:
- https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createpattern
- https://html.spec.whatwg.org/multipage/canvas.html#check-the-usability-of-the-image-argument
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix part of #25331
<!-- Either: -->
- [x] There are tests for these changes
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/script/dom')
4 files changed, 4 insertions, 4 deletions
diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 371b31bbdb0..4c36a22f717 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -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) diff --git a/components/script/dom/offscreencanvasrenderingcontext2d.rs b/components/script/dom/offscreencanvasrenderingcontext2d.rs index 277b5925f27..31dc8b7dec5 100644 --- a/components/script/dom/offscreencanvasrenderingcontext2d.rs +++ b/components/script/dom/offscreencanvasrenderingcontext2d.rs @@ -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) diff --git a/components/script/dom/paintrenderingcontext2d.rs b/components/script/dom/paintrenderingcontext2d.rs index e4b0a3cf71e..b9adc23e52d 100644 --- a/components/script/dom/paintrenderingcontext2d.rs +++ b/components/script/dom/paintrenderingcontext2d.rs @@ -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) } diff --git a/components/script/dom/webidls/CanvasRenderingContext2D.webidl b/components/script/dom/webidls/CanvasRenderingContext2D.webidl index 52e532e3a8b..bcc1b56396c 100644 --- a/components/script/dom/webidls/CanvasRenderingContext2D.webidl +++ b/components/script/dom/webidls/CanvasRenderingContext2D.webidl @@ -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)] |