mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Remove global field from Blob
This commit is contained in:
parent
4d8d6bf7ff
commit
5e3bbdcafb
2 changed files with 8 additions and 12 deletions
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::BlobBinding;
|
use dom::bindings::codegen::Bindings::BlobBinding;
|
||||||
use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
|
use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::{GlobalField, GlobalRef};
|
use dom::bindings::global::{GlobalRef, global_root_from_reflector};
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::js::Root;
|
||||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||||
use dom::bindings::trace::JSTraceable;
|
use dom::bindings::trace::JSTraceable;
|
||||||
|
@ -76,7 +76,6 @@ pub struct Blob {
|
||||||
#[ignore_heap_size_of = "No clear owner"]
|
#[ignore_heap_size_of = "No clear owner"]
|
||||||
data: DataSlice,
|
data: DataSlice,
|
||||||
typeString: String,
|
typeString: String,
|
||||||
global: GlobalField,
|
|
||||||
isClosed_: Cell<bool>,
|
isClosed_: Cell<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,8 +86,7 @@ fn is_ascii_printable(string: &str) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Blob {
|
impl Blob {
|
||||||
pub fn new_inherited(global: GlobalRef,
|
pub fn new_inherited(bytes: Arc<Vec<u8>>,
|
||||||
bytes: Arc<Vec<u8>>,
|
|
||||||
bytes_start: Option<i64>,
|
bytes_start: Option<i64>,
|
||||||
bytes_end: Option<i64>,
|
bytes_end: Option<i64>,
|
||||||
typeString: &str) -> Blob {
|
typeString: &str) -> Blob {
|
||||||
|
@ -96,13 +94,12 @@ impl Blob {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
data: DataSlice::new(bytes, bytes_start, bytes_end),
|
data: DataSlice::new(bytes, bytes_start, bytes_end),
|
||||||
typeString: typeString.to_owned(),
|
typeString: typeString.to_owned(),
|
||||||
global: GlobalField::from_rooted(&global),
|
|
||||||
isClosed_: Cell::new(false),
|
isClosed_: Cell::new(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef, bytes: Vec<u8>, typeString: &str) -> Root<Blob> {
|
pub fn new(global: GlobalRef, bytes: Vec<u8>, typeString: &str) -> Root<Blob> {
|
||||||
let boxed_blob = box Blob::new_inherited(global, Arc::new(bytes), None, None, typeString);
|
let boxed_blob = box Blob::new_inherited(Arc::new(bytes), None, None, typeString);
|
||||||
reflect_dom_object(boxed_blob, global, BlobBinding::Wrap)
|
reflect_dom_object(boxed_blob, global, BlobBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +109,7 @@ impl Blob {
|
||||||
bytes_end: Option<i64>,
|
bytes_end: Option<i64>,
|
||||||
typeString: &str) -> Root<Blob> {
|
typeString: &str) -> Root<Blob> {
|
||||||
|
|
||||||
let boxed_blob = box Blob::new_inherited(global, bytes, bytes_start, bytes_end, typeString);
|
let boxed_blob = box Blob::new_inherited(bytes, bytes_start, bytes_end, typeString);
|
||||||
reflect_dom_object(boxed_blob, global, BlobBinding::Wrap)
|
reflect_dom_object(boxed_blob, global, BlobBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +168,7 @@ impl BlobMethods for Blob {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let global = self.global.root();
|
let global = global_root_from_reflector(self);
|
||||||
let bytes = self.data.bytes.clone();
|
let bytes = self.data.bytes.clone();
|
||||||
Blob::new_sliced(global.r(), bytes, start, end, &relativeContentType)
|
Blob::new_sliced(global.r(), bytes, start, end, &relativeContentType)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,10 @@ pub struct File {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl File {
|
impl File {
|
||||||
fn new_inherited(global: GlobalRef,
|
fn new_inherited(_file_bits: &Blob, name: DOMString) -> File {
|
||||||
_file_bits: &Blob, name: DOMString) -> File {
|
|
||||||
File {
|
File {
|
||||||
//TODO: get type from the underlying filesystem instead of "".to_string()
|
//TODO: get type from the underlying filesystem instead of "".to_string()
|
||||||
blob: Blob::new_inherited(global, Arc::new(Vec::new()), None, None, ""),
|
blob: Blob::new_inherited(Arc::new(Vec::new()), None, None, ""),
|
||||||
name: name,
|
name: name,
|
||||||
}
|
}
|
||||||
// XXXManishearth Once Blob is able to store data
|
// XXXManishearth Once Blob is able to store data
|
||||||
|
@ -30,7 +29,7 @@ impl File {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: GlobalRef, file_bits: &Blob, name: DOMString) -> Root<File> {
|
pub fn new(global: GlobalRef, file_bits: &Blob, name: DOMString) -> Root<File> {
|
||||||
reflect_dom_object(box File::new_inherited(global, file_bits, name),
|
reflect_dom_object(box File::new_inherited(file_bits, name),
|
||||||
global,
|
global,
|
||||||
FileBinding::Wrap)
|
FileBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue