diff options
Diffstat (limited to 'components/script/dom/blob.rs')
-rw-r--r-- | components/script/dom/blob.rs | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs index de7a7b8c35a..49fc47e8a68 100644 --- a/components/script/dom/blob.rs +++ b/components/script/dom/blob.rs @@ -117,29 +117,28 @@ impl Blob { } // https://w3c.github.io/FileAPI/#constructorBlob - pub fn Constructor(global: GlobalRef) -> Fallible<Root<Blob>> { - Ok(Blob::new(global, Vec::new(), "")) - } - - // https://w3c.github.io/FileAPI/#constructorBlob - pub fn Constructor_(global: GlobalRef, - blobParts: Vec<BlobOrString>, - blobPropertyBag: &BlobBinding::BlobPropertyBag) - -> Fallible<Root<Blob>> { + pub fn Constructor(global: GlobalRef, + blobParts: Option<Vec<BlobOrString>>, + blobPropertyBag: &BlobBinding::BlobPropertyBag) + -> Fallible<Root<Blob>> { // TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView - let bytes: Vec<u8> = blobParts.iter() - .flat_map(|bPart| { - match bPart { - &BlobOrString::String(ref s) => { - UTF_8.encode(s, EncoderTrap::Replace).unwrap() - }, - &BlobOrString::Blob(ref b) => { - b.get_data().get_bytes().to_vec() - }, - } - }) - .collect(); + let bytes: Vec<u8> = match blobParts { + None => Vec::new(), + Some(blobs) => { + blobs.iter().flat_map(|bPart| { + match bPart { + &BlobOrString::String(ref s) => { + UTF_8.encode(s, EncoderTrap::Replace).unwrap() + }, + &BlobOrString::Blob(ref b) => { + b.get_data().get_bytes().to_vec() + }, + } + }) + .collect() + } + }; let typeString = if is_ascii_printable(&blobPropertyBag.type_) { &*blobPropertyBag.type_ } else { |