diff options
Diffstat (limited to 'components/script/dom/imagedata.rs')
-rw-r--r-- | components/script/dom/imagedata.rs | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/components/script/dom/imagedata.rs b/components/script/dom/imagedata.rs index e80914d8aea..d37e0092ba4 100644 --- a/components/script/dom/imagedata.rs +++ b/components/script/dom/imagedata.rs @@ -28,11 +28,12 @@ pub struct ImageData { impl ImageData { #[allow(unsafe_code)] - pub fn new(global: &GlobalScope, - width: u32, - height: u32, - mut data: Option<Vec<u8>>) - -> Fallible<DomRoot<ImageData>> { + pub fn new( + global: &GlobalScope, + width: u32, + height: u32, + mut data: Option<Vec<u8>>, + ) -> Fallible<DomRoot<ImageData>> { let len = width * height * 4; unsafe { let cx = global.get_cx(); @@ -50,11 +51,12 @@ impl ImageData { } #[allow(unsafe_code)] - unsafe fn new_with_jsobject(global: &GlobalScope, - width: u32, - mut opt_height: Option<u32>, - opt_jsobject: Option<*mut JSObject>) - -> Fallible<DomRoot<ImageData>> { + unsafe fn new_with_jsobject( + global: &GlobalScope, + width: u32, + mut opt_height: Option<u32>, + opt_jsobject: Option<*mut JSObject>, + ) -> Fallible<DomRoot<ImageData>> { assert!(opt_jsobject.is_some() || opt_height.is_some()); if width == 0 { @@ -65,8 +67,9 @@ impl ImageData { if let Some(jsobject) = opt_jsobject { let cx = global.get_cx(); typedarray!(in(cx) let array_res: Uint8ClampedArray = jsobject); - let array = array_res - .map_err(|_| Error::Type("Argument to Image data is not an Uint8ClampedArray".to_owned()))?; + let array = array_res.map_err(|_| { + Error::Type("Argument to Image data is not an Uint8ClampedArray".to_owned()) + })?; let byte_len = array.as_slice().len() as u32; if byte_len % 4 != 0 { @@ -108,7 +111,11 @@ impl ImageData { (*imagedata).data.set(array.get()); } - Ok(reflect_dom_object(imagedata, global, ImageDataBinding::Wrap)) + Ok(reflect_dom_object( + imagedata, + global, + ImageDataBinding::Wrap, + )) } // https://html.spec.whatwg.org/multipage/#pixel-manipulation:dom-imagedata-3 @@ -120,12 +127,13 @@ impl ImageData { // https://html.spec.whatwg.org/multipage/#pixel-manipulation:dom-imagedata-4 #[allow(unsafe_code)] #[allow(unused_variables)] - pub unsafe fn Constructor_(cx: *mut JSContext, - global: &GlobalScope, - jsobject: *mut JSObject, - width: u32, - opt_height: Option<u32>) - -> Fallible<DomRoot<Self>> { + pub unsafe fn Constructor_( + cx: *mut JSContext, + global: &GlobalScope, + jsobject: *mut JSObject, + width: u32, + opt_height: Option<u32>, + ) -> Fallible<DomRoot<Self>> { Self::new_with_jsobject(global, width, opt_height, Some(jsobject)) } |