Remove support for Blob::{close, isClosed}

This commit is contained in:
Charles Vandevoorde 2017-02-28 17:14:14 +01:00
parent 050d9d9097
commit 44e05e224c
5 changed files with 5 additions and 59 deletions

View file

@ -18,7 +18,6 @@ use ipc_channel::ipc;
use net_traits::{CoreResourceMsg, IpcSend}; use net_traits::{CoreResourceMsg, IpcSend};
use net_traits::blob_url_store::{BlobBuf, get_blob_origin}; use net_traits::blob_url_store::{BlobBuf, get_blob_origin};
use net_traits::filemanager_thread::{FileManagerThreadMsg, ReadFileProgress, RelativePos}; use net_traits::filemanager_thread::{FileManagerThreadMsg, ReadFileProgress, RelativePos};
use std::cell::Cell;
use std::mem; use std::mem;
use std::ops::Index; use std::ops::Index;
use std::path::PathBuf; use std::path::PathBuf;
@ -75,7 +74,6 @@ pub struct Blob {
blob_impl: DOMRefCell<BlobImpl>, blob_impl: DOMRefCell<BlobImpl>,
/// content-type string /// content-type string
type_string: String, type_string: String,
is_closed: Cell<bool>,
} }
impl Blob { impl Blob {
@ -95,7 +93,6 @@ impl Blob {
// NOTE: Guarding the format correctness here, // NOTE: Guarding the format correctness here,
// https://w3c.github.io/FileAPI/#dfn-type // https://w3c.github.io/FileAPI/#dfn-type
type_string: normalize_type_string(&type_string), type_string: normalize_type_string(&type_string),
is_closed: Cell::new(false),
} }
} }
@ -297,11 +294,9 @@ impl Blob {
impl Drop for Blob { impl Drop for Blob {
fn drop(&mut self) { fn drop(&mut self) {
if !self.IsClosed() {
self.clean_up_file_resource(); self.clean_up_file_resource();
} }
} }
}
fn read_file(global: &GlobalScope, id: Uuid) -> Result<Vec<u8>, ()> { fn read_file(global: &GlobalScope, id: Uuid) -> Result<Vec<u8>, ()> {
let resource_threads = global.resource_threads(); let resource_threads = global.resource_threads();
@ -375,25 +370,6 @@ impl BlobMethods for Blob {
let rel_pos = RelativePos::from_opts(start, end); let rel_pos = RelativePos::from_opts(start, end);
Blob::new_sliced(self, rel_pos, content_type.unwrap_or(DOMString::from(""))) Blob::new_sliced(self, rel_pos, content_type.unwrap_or(DOMString::from("")))
} }
// https://w3c.github.io/FileAPI/#dfn-isClosed
fn IsClosed(&self) -> bool {
self.is_closed.get()
}
// https://w3c.github.io/FileAPI/#dfn-close
fn Close(&self) {
// Step 1
if self.is_closed.get() {
return;
}
// Step 2
self.is_closed.set(true);
// Step 3
self.clean_up_file_resource();
}
} }
/// Get the normalized, MIME-parsable type string /// Get the normalized, MIME-parsable type string

View file

@ -375,20 +375,11 @@ impl FileReader {
if self.ready_state.get() == FileReaderReadyState::Loading { if self.ready_state.get() == FileReaderReadyState::Loading {
return Err(Error::InvalidState); return Err(Error::InvalidState);
} }
// Step 2 // Step 2
let global = self.global();
if blob.IsClosed() {
let exception = DOMException::new(&global, DOMErrorName::InvalidStateError);
self.error.set(Some(&exception));
self.dispatch_progress_event(atom!("error"), 0, None);
return Ok(());
}
// Step 3
self.change_ready_state(FileReaderReadyState::Loading); self.change_ready_state(FileReaderReadyState::Loading);
// Step 4 // Step 3
let blob_contents = Arc::new(blob.get_bytes().unwrap_or(vec![])); let blob_contents = Arc::new(blob.get_bytes().unwrap_or(vec![]));
let type_ = blob.Type(); let type_ = blob.Type();

View file

@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::cell::DOMRefCell; use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
use dom::bindings::codegen::Bindings::URLBinding::{self, URLMethods}; use dom::bindings::codegen::Bindings::URLBinding::{self, URLMethods};
use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::js::{MutNullableJS, Root};
@ -102,12 +101,6 @@ impl URL {
/// and should not be trusted. See issue https://github.com/servo/servo/issues/11722 /// and should not be trusted. See issue https://github.com/servo/servo/issues/11722
let origin = get_blob_origin(&global.get_url()); let origin = get_blob_origin(&global.get_url());
if blob.IsClosed() {
// Generate a dummy id
let id = Uuid::new_v4();
return DOMString::from(URL::unicode_serialization_blob_url(&origin, &id));
}
let id = blob.get_blob_url_id(); let id = blob.get_blob_url_id();
DOMString::from(URL::unicode_serialization_blob_url(&origin, &id)) DOMString::from(URL::unicode_serialization_blob_url(&origin, &id))
@ -116,13 +109,10 @@ impl URL {
// https://w3c.github.io/FileAPI/#dfn-revokeObjectURL // https://w3c.github.io/FileAPI/#dfn-revokeObjectURL
pub fn RevokeObjectURL(global: &GlobalScope, url: DOMString) { pub fn RevokeObjectURL(global: &GlobalScope, url: DOMString) {
/* /*
If the url refers to a Blob that has a readability state of CLOSED OR If the value provided for the url argument is not a Blob URL OR
if the value provided for the url argument is not a Blob URL, OR
if the value provided for the url argument does not have an entry in the Blob URL Store, if the value provided for the url argument does not have an entry in the Blob URL Store,
this method call does nothing. User agents may display a message on the error console. this method call does nothing. User agents may display a message on the error console.
NOTE: The first step is unnecessary, since closed blobs do not exist in the store
*/ */
let origin = get_blob_origin(&global.get_url()); let origin = get_blob_origin(&global.get_url());

View file

@ -11,21 +11,15 @@ interface Blob {
readonly attribute unsigned long long size; readonly attribute unsigned long long size;
readonly attribute DOMString type; readonly attribute DOMString type;
readonly attribute boolean isClosed;
// slice Blob into byte-ranged chunks // slice Blob into byte-ranged chunks
Blob slice([Clamp] optional long long start, Blob slice([Clamp] optional long long start,
[Clamp] optional long long end, [Clamp] optional long long end,
optional DOMString contentType); optional DOMString contentType);
void close();
}; };
dictionary BlobPropertyBag { dictionary BlobPropertyBag {
DOMString type = ""; DOMString type = "";
}; };
typedef (/*ArrayBuffer or ArrayBufferView or */Blob or DOMString) BlobPart; typedef (/*ArrayBuffer or ArrayBufferView or */Blob or DOMString) BlobPart;

View file

@ -1,5 +0,0 @@
[historical.html]
type: testharness
[Blob.close() should not be supported]
expected: FAIL