diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2016-09-27 13:16:41 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2016-10-06 20:59:09 +0200 |
commit | fcb59d305742a18daa083352a9b6e9a45896c9f6 (patch) | |
tree | d1023c24bfb5827c49d4d4653a72541b66532b95 /components/script/dom/file.rs | |
parent | 093b189b4800909b17295b88aed762601f4b8482 (diff) | |
download | servo-fcb59d305742a18daa083352a9b6e9a45896c9f6.tar.gz servo-fcb59d305742a18daa083352a9b6e9a45896c9f6.zip |
Make reflect_dom_object take a &GlobalScope
Diffstat (limited to 'components/script/dom/file.rs')
-rw-r--r-- | components/script/dom/file.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/components/script/dom/file.rs b/components/script/dom/file.rs index 8b4abaaed80..6ee2f0c3771 100644 --- a/components/script/dom/file.rs +++ b/components/script/dom/file.rs @@ -7,10 +7,12 @@ use dom::bindings::codegen::Bindings::FileBinding::FileMethods; use dom::bindings::codegen::UnionTypes::BlobOrString; use dom::bindings::error::{Error, Fallible}; use dom::bindings::global::GlobalRef; +use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::blob::{Blob, BlobImpl, blob_parts_to_bytes}; +use dom::globalscope::GlobalScope; use dom::window::Window; use net_traits::filemanager_thread::SelectedFile; use time; @@ -41,7 +43,7 @@ impl File { } #[allow(unrooted_must_root)] - pub fn new(global: GlobalRef, blob_impl: BlobImpl, + pub fn new(global: &GlobalScope, blob_impl: BlobImpl, name: DOMString, modified: Option<i64>, typeString: &str) -> Root<File> { reflect_dom_object(box File::new_inherited(blob_impl, name, modified, typeString), global, @@ -52,9 +54,7 @@ impl File { pub fn new_from_selected(window: &Window, selected: SelectedFile) -> Root<File> { let name = DOMString::from(selected.filename.to_str().expect("File name encoding error")); - let global = GlobalRef::Window(window); - - File::new(global, BlobImpl::new_from_file(selected.id, selected.filename, selected.size), + File::new(window.upcast(), BlobImpl::new_from_file(selected.id, selected.filename, selected.size), name, Some(selected.modified as i64), &selected.type_string) } @@ -76,7 +76,11 @@ impl File { // NOTE: Following behaviour might be removed in future, // see https://github.com/w3c/FileAPI/issues/41 let replaced_filename = DOMString::from_string(filename.replace("/", ":")); - Ok(File::new(global, BlobImpl::new_from_bytes(bytes), replaced_filename, modified, typeString)) + Ok(File::new(global.as_global_scope(), + BlobImpl::new_from_bytes(bytes), + replaced_filename, + modified, + typeString)) } pub fn name(&self) -> &DOMString { |