aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/file.rs
diff options
context:
space:
mode:
authorZhen Zhang <izgzhen@gmail.com>2016-05-17 18:10:07 +0800
committerZhen Zhang <izgzhen@gmail.com>2016-05-23 15:35:46 +0800
commitdd590d088b036e06dd5775237e04ac45de3b1488 (patch)
tree741d109fece881f31cca5848868186aa3863b1e6 /components/script/dom/file.rs
parent983612751ba6a031d7a22e53bc2baabe64739f1b (diff)
downloadservo-dd590d088b036e06dd5775237e04ac45de3b1488.tar.gz
servo-dd590d088b036e06dd5775237e04ac45de3b1488.zip
Implement file-type functionalities in htmlinputelement and related
Changes include: - Implement file selection and other DOM behaviours in htmlinputelement - Integrate IpcSender<FileManagerThreadMsg> into ResourceThreads - Improve filemanager_thread, including adding type_string field to SelectedFile - Improve interfaces in FileList/File/Blob to accommodate the above changes
Diffstat (limited to 'components/script/dom/file.rs')
-rw-r--r--components/script/dom/file.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/components/script/dom/file.rs b/components/script/dom/file.rs
index 9667182671a..4ece71a5ce3 100644
--- a/components/script/dom/file.rs
+++ b/components/script/dom/file.rs
@@ -10,6 +10,8 @@ use dom::bindings::global::GlobalRef;
use dom::bindings::js::Root;
use dom::bindings::reflector::reflect_dom_object;
use dom::blob::{Blob, DataSlice, blob_parts_to_bytes};
+use dom::window::Window;
+use net_traits::filemanager_thread::SelectedFile;
use std::sync::Arc;
use time;
use util::str::DOMString;
@@ -45,6 +47,19 @@ impl File {
FileBinding::Wrap)
}
+ // Construct from selected file message from file manager thread
+ pub fn new_from_selected(window: &Window, selected: SelectedFile) -> Root<File> {
+ let name = DOMString::from(selected.filename.to_str().expect("File name encoding error"));
+
+ // FIXME: fix this after PR #11221 is landed
+ let id = selected.id;
+ let slice = DataSlice::empty();
+
+ let global = GlobalRef::Window(window);
+
+ File::new(global, slice, name, Some(selected.modified as i64), "")
+ }
+
// https://w3c.github.io/FileAPI/#file-constructor
pub fn Constructor(global: GlobalRef,
fileBits: Vec<BlobOrString>,
@@ -64,7 +79,6 @@ impl File {
pub fn name(&self) -> &DOMString {
&self.name
}
-
}
impl FileMethods for File {