mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Add canvas usability checks to drawImage()
This commit is contained in:
parent
ed0973fb1c
commit
423b86e439
5 changed files with 14 additions and 13 deletions
|
@ -382,9 +382,19 @@ impl CanvasState {
|
|||
) -> ErrorResult {
|
||||
let result = match image {
|
||||
CanvasImageSource::HTMLCanvasElement(ref canvas) => {
|
||||
// https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument
|
||||
if !canvas.is_valid() {
|
||||
return Err(Error::InvalidState);
|
||||
}
|
||||
|
||||
self.draw_html_canvas_element(&canvas, htmlcanvas, sx, sy, sw, sh, dx, dy, dw, dh)
|
||||
},
|
||||
CanvasImageSource::OffscreenCanvas(ref canvas) => {
|
||||
// https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument
|
||||
if !canvas.is_valid() {
|
||||
return Err(Error::InvalidState);
|
||||
}
|
||||
|
||||
self.draw_offscreen_canvas(&canvas, htmlcanvas, sx, sy, sw, sh, dx, dy, dw, dh)
|
||||
},
|
||||
CanvasImageSource::HTMLImageElement(ref image) => {
|
||||
|
|
|
@ -138,6 +138,10 @@ impl OffscreenCanvas {
|
|||
));
|
||||
Some(context)
|
||||
}
|
||||
|
||||
pub fn is_valid(&self) -> bool {
|
||||
self.Width() != 0 && self.Height() != 0
|
||||
}
|
||||
}
|
||||
|
||||
impl OffscreenCanvasMethods for OffscreenCanvas {
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[2d.drawImage.zerocanvas.html]
|
||||
type: testharness
|
||||
[Canvas test: 2d.drawImage.zerocanvas]
|
||||
expected: FAIL
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
[2d.drawImage.zerocanvas.html]
|
||||
[OffscreenCanvas test: 2d.drawImage.zerocanvas]
|
||||
expected: FAIL
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
[2d.drawImage.zerocanvas.worker.html]
|
||||
[2d]
|
||||
expected: FAIL
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue