Rustfmt some of script.

This commit is contained in:
Ms2ger 2015-11-17 16:52:17 +01:00
parent ceb72e54e4
commit 0c61be7a57
50 changed files with 1499 additions and 885 deletions

View file

@ -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,