Auto merge of #25940 - pylbrecht:image.handling, r=jdm

Handle nonexistent images in CanvasRenderingContext2D.createPattern()

<!-- 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. -->
This commit is contained in:
bors-servo 2020-03-13 18:01:32 -04:00 committed by GitHub
commit 5737db81f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 36 additions and 15 deletions

View file

@ -167,13 +167,10 @@ impl HTMLImageElement {
// https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument
pub fn is_usable(&self) -> Fallible<bool> {
// If image has an intrinsic width or intrinsic height (or both) equal to zero, then return bad.
match &self.current_request.borrow().image {
Some(image) => {
if image.width == 0 || image.height == 0 {
return Ok(false);
}
},
None => return Ok(false),
if let Some(image) = &self.current_request.borrow().image {
if image.width == 0 || image.height == 0 {
return Ok(false);
}
}
match self.current_request.borrow().state {

View file

@ -0,0 +1,4 @@
[2d.drawImage.broken.html]
[Canvas test: 2d.drawImage.broken]
expected: FAIL

View file

@ -0,0 +1,4 @@
[2d.pattern.image.broken.html]
[Canvas test: 2d.pattern.image.broken]
expected: FAIL

View file

@ -1,4 +0,0 @@
[2d.pattern.image.nonexistent.html]
[Canvas test: 2d.pattern.image.nonexistent]
expected: FAIL

View file

@ -0,0 +1,4 @@
[2d.pattern.image.zeroheight.html]
[Canvas test: 2d.pattern.image.zeroheight]
expected: FAIL

View file

@ -0,0 +1,4 @@
[2d.pattern.image.zerowidth.html]
[Canvas test: 2d.pattern.image.zerowidth]
expected: FAIL

View file

@ -0,0 +1,4 @@
[2d.drawImage.broken.html]
[Canvas test: 2d.drawImage.broken]
expected: FAIL

View file

@ -0,0 +1,4 @@
[2d.pattern.image.broken.html]
[Canvas test: 2d.pattern.image.broken]
expected: FAIL

View file

@ -1,4 +0,0 @@
[2d.pattern.image.nonexistent.html]
[Canvas test: 2d.pattern.image.nonexistent]
expected: FAIL

View file

@ -0,0 +1,4 @@
[2d.pattern.image.zeroheight.html]
[Canvas test: 2d.pattern.image.zeroheight]
expected: FAIL

View file

@ -0,0 +1,4 @@
[2d.pattern.image.zerowidth.html]
[Canvas test: 2d.pattern.image.zerowidth]
expected: FAIL