mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Implement FileReader.{readAsText,readAsDataUrl}. Fixes #6172
This commit is contained in:
parent
f44d75e5b2
commit
27e760e28d
20 changed files with 565 additions and 326 deletions
|
@ -9,6 +9,8 @@ use dom::bindings::utils::{Reflector, reflect_dom_object};
|
|||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::codegen::Bindings::BlobBinding;
|
||||
use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
|
||||
use std::sync::mpsc;
|
||||
use std::sync::mpsc::Receiver;
|
||||
|
||||
use util::str::DOMString;
|
||||
|
||||
|
@ -79,6 +81,22 @@ impl Blob {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait BlobHelpers {
|
||||
fn read_out_buffer(self) -> Receiver<Option<Vec<u8>>> ;
|
||||
fn read_out_type(self) -> DOMString;
|
||||
}
|
||||
|
||||
impl<'a> BlobHelpers for &'a Blob {
|
||||
fn read_out_buffer(self) -> Receiver<Option<Vec<u8>>> {
|
||||
let (send, recv) = mpsc::channel();
|
||||
send.send(self.bytes.clone()).unwrap();
|
||||
recv
|
||||
}
|
||||
fn read_out_type(self) -> DOMString {
|
||||
self.typeString.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> BlobMethods for &'a Blob {
|
||||
// http://dev.w3.org/2006/webapi/FileAPI/#dfn-size
|
||||
fn Size(self) -> u64{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue