diff options
Diffstat (limited to 'components/script/dom/blob.rs')
-rw-r--r-- | components/script/dom/blob.rs | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs index 1ba7b929eaf..4213b8ff2a6 100644 --- a/components/script/dom/blob.rs +++ b/components/script/dom/blob.rs @@ -18,6 +18,7 @@ use num::ToPrimitive; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::cmp::{min, max}; +use std::cell::{Cell}; #[derive(JSTraceable)] pub enum BlobTypeId { @@ -32,8 +33,8 @@ pub struct Blob { type_: BlobTypeId, bytes: Option<Vec<u8>>, typeString: DOMString, - global: GlobalField - // isClosed_: bool + global: GlobalField, + isClosed_: Cell<bool> } fn is_ascii_printable(string: &DOMString) -> bool{ @@ -50,8 +51,8 @@ impl Blob { type_: type_, bytes: bytes, typeString: typeString.to_owned(), - global: GlobalField::from_rooted(&global) - //isClosed_: false + global: GlobalField::from_rooted(&global), + isClosed_: Cell::new(false) } } @@ -83,7 +84,6 @@ impl Blob { pub trait BlobHelpers { fn read_out_buffer(self) -> Receiver<Vec<u8>>; - fn read_out_type(self) -> DOMString; } impl<'a> BlobHelpers for &'a Blob { @@ -92,9 +92,6 @@ impl<'a> BlobHelpers for &'a Blob { send.send(self.bytes.clone().unwrap_or(vec![])).unwrap(); recv } - fn read_out_type(self) -> DOMString { - self.typeString.clone() - } } impl<'a> BlobMethods for &'a Blob { @@ -159,15 +156,24 @@ impl<'a> BlobMethods for &'a Blob { } } - // http://dev.w3.org/2006/webapi/FileAPI/#dfn-isClosed - //fn IsClosed(self) -> bool { - // self.isClosed_.clone() - //} + // https://dev.w3.org/2006/webapi/FileAPI/#dfn-isClosed + fn IsClosed(self) -> bool { + self.isClosed_.get() + } + + // https://dev.w3.org/2006/webapi/FileAPI/#dfn-close + fn Close(self) { + // Step 1 + if self.isClosed_.get() { + return; + } + + // Step 2 + self.isClosed_.set(true); - // http://dev.w3.org/2006/webapi/FileAPI/#dfn-close - //fn Close(self) { - // TODO - //} + // TODO Step 3 if Blob URL Store is implemented + + } } impl FileDerived for Blob { |