aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/canvas_state.rs
diff options
context:
space:
mode:
authorpylbrecht <palbrecht@mailbox.org>2020-02-07 21:56:58 +0100
committerpylbrecht <palbrecht@mailbox.org>2020-02-10 14:23:38 +0100
commit481ef4616709840db0145f3bc4003f74f0ff126d (patch)
tree49ba30db14c96ad7cbf9a0b2e623d82101c3c095 /components/script/canvas_state.rs
parent423b86e439dc2bff1a9860511f3ace8b4778d85e (diff)
downloadservo-481ef4616709840db0145f3bc4003f74f0ff126d.tar.gz
servo-481ef4616709840db0145f3bc4003f74f0ff126d.zip
Make create_pattern() return None for incomplete images
Diffstat (limited to 'components/script/canvas_state.rs')
-rw-r--r--components/script/canvas_state.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/components/script/canvas_state.rs b/components/script/canvas_state.rs
index 34ea6741660..d596ff826fa 100644
--- a/components/script/canvas_state.rs
+++ b/components/script/canvas_state.rs
@@ -895,12 +895,14 @@ impl CanvasState {
global: &GlobalScope,
image: CanvasImageSource,
mut repetition: DOMString,
- ) -> Fallible<DomRoot<CanvasPattern>> {
+ ) -> Fallible<Option<DomRoot<CanvasPattern>>> {
let (image_data, image_size) = match image {
CanvasImageSource::HTMLImageElement(ref image) => {
- // 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
+ // https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument
+ if !image.is_usable()? {
+ return Ok(None);
+ }
+
image
.get_url()
.and_then(|url| {
@@ -933,13 +935,13 @@ impl CanvasState {
}
if let Ok(rep) = RepetitionStyle::from_str(&repetition) {
- Ok(CanvasPattern::new(
+ Ok(Some(CanvasPattern::new(
global,
image_data,
image_size,
rep,
self.is_origin_clean(image),
- ))
+ )))
} else {
Err(Error::Syntax)
}