aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/canvas_state.rs
diff options
context:
space:
mode:
authorpylbrecht <palbrecht@mailbox.org>2020-02-02 19:24:39 +0100
committerpylbrecht <palbrecht@mailbox.org>2020-02-03 20:46:03 +0100
commited0973fb1c87e344c6660a0e9fa282866c0ecf00 (patch)
tree7222140aeb3725e28281e8a5250f79f9f5c3aaec /components/script/canvas_state.rs
parent5f55cd5d71df9c555fbc24777168396ddd539f28 (diff)
downloadservo-ed0973fb1c87e344c6660a0e9fa282866c0ecf00.tar.gz
servo-ed0973fb1c87e344c6660a0e9fa282866c0ecf00.zip
Add image usability checks to drawImage()
Diffstat (limited to 'components/script/canvas_state.rs')
-rw-r--r--components/script/canvas_state.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/components/script/canvas_state.rs b/components/script/canvas_state.rs
index c9492ed5da5..ebf36bad32b 100644
--- a/components/script/canvas_state.rs
+++ b/components/script/canvas_state.rs
@@ -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