Adding for support Blob.{close,isClose} #6723

This commit is contained in:
farodin91 2015-07-28 08:57:08 +02:00
parent fff104bb41
commit 20f99e92d8
7 changed files with 67 additions and 61 deletions

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
use dom::bindings::codegen::Bindings::FileReaderBinding::{self, FileReaderConstants, FileReaderMethods};
use dom::bindings::codegen::InheritTypes::{EventCast, EventTargetCast};
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
@ -268,7 +269,6 @@ impl FileReader {
Ok(Some(output))
}
}
impl<'a> FileReaderMethods for &'a FileReader {
@ -287,13 +287,22 @@ impl<'a> FileReaderMethods for &'a FileReader {
if self.ready_state.get() == FileReaderReadyState::Loading {
return Err(InvalidState);
}
//TODO STEP 2 if isClosed implemented in Blob
// Step 2
if blob.IsClosed() {
let global = self.global.root();
let exception = DOMException::new(global.r(), DOMErrorName::InvalidStateError);
self.error.set(Some(JS::from_rooted(&exception)));
self.dispatch_progress_event("error".to_owned(), 0, None);
return Ok(());
}
// Step 3
self.change_ready_state(FileReaderReadyState::Loading);
let bytes = blob.read_out_buffer();
let type_ = blob.read_out_type();
let type_ = blob.Type();
let load_data = ReadData::new(bytes, type_, None, FileReaderFunction::ReadAsDataUrl);
@ -307,13 +316,22 @@ impl<'a> FileReaderMethods for &'a FileReader {
if self.ready_state.get() == FileReaderReadyState::Loading {
return Err(InvalidState);
}
//TODO STEP 2 if isClosed implemented in Blob
// Step 2
if blob.IsClosed() {
let global = self.global.root();
let exception = DOMException::new(global.r(), DOMErrorName::InvalidStateError);
self.error.set(Some(JS::from_rooted(&exception)));
self.dispatch_progress_event("error".to_owned(), 0, None);
return Ok(());
}
// Step 3
self.change_ready_state(FileReaderReadyState::Loading);
let bytes = blob.read_out_buffer();
let type_ = blob.read_out_type();
let type_ = blob.Type();
let load_data = ReadData::new(bytes, type_, label, FileReaderFunction::ReadAsText);