mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Add image usability checks to drawImage()
This commit is contained in:
parent
5f55cd5d71
commit
ed0973fb1c
9 changed files with 29 additions and 34 deletions
|
@ -388,6 +388,14 @@ impl CanvasState {
|
|||
self.draw_offscreen_canvas(&canvas, htmlcanvas, sx, sy, sw, sh, dx, dy, dw, dh)
|
||||
},
|
||||
CanvasImageSource::HTMLImageElement(ref image) => {
|
||||
// https://html.spec.whatwg.org/multipage/#drawing-images
|
||||
// 2. Let usability be the result of checking the usability of image.
|
||||
// 3. If usability is bad, then return (without drawing anything).
|
||||
if !image.is_usable()? {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// TODO(pylbrecht): is it possible for image.get_url() to return None after the usability check?
|
||||
// https://html.spec.whatwg.org/multipage/#img-error
|
||||
// If the image argument is an HTMLImageElement object that is in the broken state,
|
||||
// then throw an InvalidStateError exception
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue