mirror of
https://github.com/servo/servo.git
synced 2025-07-23 23:33:43 +01:00
Fix createImageData with sizes < 1 pixel
This commit is contained in:
parent
0565df8596
commit
2fb5fda5d0
2 changed files with 4 additions and 6 deletions
|
@ -42,6 +42,7 @@ use num::{Float, ToPrimitive};
|
|||
use std::borrow::ToOwned;
|
||||
use std::cell::RefCell;
|
||||
use std::fmt;
|
||||
use std::cmp;
|
||||
use std::sync::mpsc::channel;
|
||||
|
||||
use util::str::DOMString;
|
||||
|
@ -954,7 +955,9 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
|||
return Err(IndexSize)
|
||||
}
|
||||
|
||||
Ok(ImageData::new(self.global.root().r(), sw.abs().to_u32().unwrap(), sh.abs().to_u32().unwrap(), None))
|
||||
let sw = cmp::max(1, sw.abs().to_u32().unwrap());
|
||||
let sh = cmp::max(1, sh.abs().to_u32().unwrap());
|
||||
Ok(ImageData::new(self.global.root().r(), sw, sh, None))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue