diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2015-11-18 15:44:30 +0530 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2015-11-18 15:44:30 +0530 |
commit | 7a87312121a69b590b364f9b5095f3145554e24b (patch) | |
tree | b90d213147d74d97a79ba65a31394ddc78fec95f /components/script/dom/blob.rs | |
parent | 247f586284ff3938430fd2be8de2ba2ac82eadc2 (diff) | |
parent | 0c61be7a577b99dc138eb6a2e46fb9276df0870d (diff) | |
download | servo-7a87312121a69b590b364f9b5095f3145554e24b.tar.gz servo-7a87312121a69b590b364f9b5095f3145554e24b.zip |
Auto merge of #8569 - Ms2ger:fmt-script, r=metajack
Rustfmt some of script.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8569)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/blob.rs')
-rw-r--r-- | components/script/dom/blob.rs | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs index c807fa58914..5e5c13516c4 100644 --- a/components/script/dom/blob.rs +++ b/components/script/dom/blob.rs @@ -11,7 +11,7 @@ use dom::bindings::reflector::{Reflector, reflect_dom_object}; use num::ToPrimitive; use std::ascii::AsciiExt; use std::borrow::ToOwned; -use std::cell::{Cell}; +use std::cell::Cell; use std::cmp::{max, min}; use std::sync::mpsc::Sender; use util::str::DOMString; @@ -23,29 +23,27 @@ pub struct Blob { bytes: Option<Vec<u8>>, typeString: String, global: GlobalField, - isClosed_: Cell<bool> + isClosed_: Cell<bool>, } fn is_ascii_printable(string: &str) -> bool { // Step 5.1 in Sec 5.1 of File API spec // http://dev.w3.org/2006/webapi/FileAPI/#constructorBlob - string.chars().all(|c| { c >= '\x20' && c <= '\x7E' }) + string.chars().all(|c| c >= '\x20' && c <= '\x7E') } impl Blob { - pub fn new_inherited(global: GlobalRef, - bytes: Option<Vec<u8>>, typeString: &str) -> Blob { + pub fn new_inherited(global: GlobalRef, bytes: Option<Vec<u8>>, typeString: &str) -> Blob { Blob { reflector_: Reflector::new(), bytes: bytes, typeString: typeString.to_owned(), global: GlobalField::from_rooted(&global), - isClosed_: Cell::new(false) + isClosed_: Cell::new(false), } } - pub fn new(global: GlobalRef, bytes: Option<Vec<u8>>, - typeString: &str) -> Root<Blob> { + pub fn new(global: GlobalRef, bytes: Option<Vec<u8>>, typeString: &str) -> Root<Blob> { reflect_dom_object(box Blob::new_inherited(global, bytes, typeString), global, BlobBinding::Wrap) @@ -57,9 +55,11 @@ impl Blob { } // http://dev.w3.org/2006/webapi/FileAPI/#constructorBlob - pub fn Constructor_(global: GlobalRef, blobParts: DOMString, - blobPropertyBag: &BlobBinding::BlobPropertyBag) -> Fallible<Root<Blob>> { - //TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView or Blob + pub fn Constructor_(global: GlobalRef, + blobParts: DOMString, + blobPropertyBag: &BlobBinding::BlobPropertyBag) + -> Fallible<Root<Blob>> { + // TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView or Blob // FIXME(ajeffrey): convert directly from a DOMString to a Vec<u8> let bytes: Option<Vec<u8>> = Some(String::from(blobParts).into_bytes()); let typeString = if is_ascii_printable(&blobPropertyBag.type_) { @@ -85,7 +85,7 @@ impl BlobMethods for Blob { fn Size(&self) -> u64 { match self.bytes { None => 0, - Some(ref bytes) => bytes.len() as u64 + Some(ref bytes) => bytes.len() as u64, } } @@ -95,8 +95,11 @@ impl BlobMethods for Blob { } // https://dev.w3.org/2006/webapi/FileAPI/#slice-method-algo - fn Slice(&self, start: Option<i64>, end: Option<i64>, - contentType: Option<DOMString>) -> Root<Blob> { + fn Slice(&self, + start: Option<i64>, + end: Option<i64>, + contentType: Option<DOMString>) + -> Root<Blob> { let size: i64 = self.Size().to_i64().unwrap(); let relativeStart: i64 = match start { None => 0, |