Auto merge of #9967 - saurvs:master, r=Ms2ger

Convert directly from DOMString to Vec<u8>

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9967)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-03-12 01:19:04 +05:30
commit 00ab2e9f9e

View file

@ -124,14 +124,12 @@ impl Blob {
blobPropertyBag: &BlobBinding::BlobPropertyBag) blobPropertyBag: &BlobBinding::BlobPropertyBag)
-> Fallible<Root<Blob>> { -> Fallible<Root<Blob>> {
// TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView or Blob // TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView or Blob
// FIXME(ajeffrey): convert directly from a DOMString to a Vec<u8>
let bytes: Vec<u8> = String::from(blobParts).into_bytes();
let typeString = if is_ascii_printable(&blobPropertyBag.type_) { let typeString = if is_ascii_printable(&blobPropertyBag.type_) {
&*blobPropertyBag.type_ &*blobPropertyBag.type_
} else { } else {
"" ""
}; };
Ok(Blob::new(global, bytes, &typeString.to_ascii_lowercase())) Ok(Blob::new(global, blobParts.into(), &typeString.to_ascii_lowercase()))
} }
pub fn get_data(&self) -> &DataSlice { pub fn get_data(&self) -> &DataSlice {