Privatize File

This commit is contained in:
Tim Taubert 2014-10-12 13:27:00 +02:00
parent df60f8b2c5
commit ad6649d102
2 changed files with 9 additions and 4 deletions

View file

@ -12,10 +12,11 @@ use servo_util::str::DOMString;
#[jstraceable] #[jstraceable]
#[must_root] #[must_root]
#[privatize]
pub struct File { pub struct File {
pub blob: Blob, blob: Blob,
pub name: DOMString, name: DOMString,
pub type_: BlobType type_: BlobType
} }
impl File { impl File {
@ -34,6 +35,10 @@ impl File {
global, global,
FileBinding::Wrap) FileBinding::Wrap)
} }
pub fn name<'a>(&'a self) -> &'a DOMString {
&self.name
}
} }
impl<'a> FileMethods for JSRef<'a, File> { impl<'a> FileMethods for JSRef<'a, File> {

View file

@ -113,7 +113,7 @@ impl PrivateFormDataHelpers for FormData {
fn get_file_from_blob(&self, value: JSRef<Blob>, filename: Option<DOMString>) -> Temporary<File> { fn get_file_from_blob(&self, value: JSRef<Blob>, filename: Option<DOMString>) -> Temporary<File> {
let global = self.global.root(); let global = self.global.root();
let f: Option<JSRef<File>> = FileCast::to_ref(value); let f: Option<JSRef<File>> = FileCast::to_ref(value);
let name = filename.unwrap_or(f.map(|inner| inner.name.clone()).unwrap_or("blob".to_string())); let name = filename.unwrap_or(f.map(|inner| inner.name().clone()).unwrap_or("blob".to_string()));
File::new(&global.root_ref(), value, name) File::new(&global.root_ref(), value, name)
} }
} }