mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
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
This commit is contained in:
parent
983612751b
commit
dd590d088b
10 changed files with 155 additions and 30 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue