mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #11717 - izgzhen:filepicker, r=Manishearth
Add filepicker Add file picker based on tinyfiledialog to the file manager implementation. Changes: - [x] Add the picker invocation code - [x] Rewrite unit test to accommodate the change - [x] Patch up `htmlinputelement` to make things work <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes are related to #11131. <!-- Either: --> - [x] There are tests for these changes OR <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11717) <!-- Reviewable:end -->
This commit is contained in:
commit
0cfae3a3e7
5 changed files with 135 additions and 46 deletions
|
@ -33,7 +33,7 @@ use dom::validation::Validatable;
|
|||
use dom::virtualmethods::VirtualMethods;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::IpcSend;
|
||||
use net_traits::filemanager_thread::FileManagerThreadMsg;
|
||||
use net_traits::filemanager_thread::{FileManagerThreadMsg, FilterPattern};
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::Cell;
|
||||
|
@ -993,7 +993,7 @@ impl Activatable for HTMLInputElement {
|
|||
// https://html.spec.whatwg.org/multipage/#reset-button-state-%28type=reset%29:activation-behaviour-2
|
||||
// https://html.spec.whatwg.org/multipage/#checkbox-state-%28type=checkbox%29:activation-behaviour-2
|
||||
// https://html.spec.whatwg.org/multipage/#radio-button-state-%28type=radio%29:activation-behaviour-2
|
||||
InputType::InputSubmit | InputType::InputReset
|
||||
InputType::InputSubmit | InputType::InputReset | InputType::InputFile
|
||||
| InputType::InputCheckbox | InputType::InputRadio => self.is_mutable(),
|
||||
_ => false
|
||||
}
|
||||
|
@ -1140,9 +1140,11 @@ impl Activatable for HTMLInputElement {
|
|||
let mut files: Vec<Root<File>> = vec![];
|
||||
let mut error = None;
|
||||
|
||||
let filter = filter_from_accept(self.Accept());
|
||||
|
||||
if self.Multiple() {
|
||||
let (chan, recv) = ipc::channel().expect("Error initializing channel");
|
||||
let msg = FileManagerThreadMsg::SelectFiles(chan);
|
||||
let msg = FileManagerThreadMsg::SelectFiles(filter, chan);
|
||||
let _ = filemanager.send(msg).unwrap();
|
||||
|
||||
match recv.recv().expect("IpcSender side error") {
|
||||
|
@ -1155,7 +1157,7 @@ impl Activatable for HTMLInputElement {
|
|||
};
|
||||
} else {
|
||||
let (chan, recv) = ipc::channel().expect("Error initializing channel");
|
||||
let msg = FileManagerThreadMsg::SelectFile(chan);
|
||||
let msg = FileManagerThreadMsg::SelectFile(filter, chan);
|
||||
let _ = filemanager.send(msg).unwrap();
|
||||
|
||||
match recv.recv().expect("IpcSender side error") {
|
||||
|
@ -1228,3 +1230,10 @@ impl Activatable for HTMLInputElement {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn filter_from_accept(_s: DOMString) -> Vec<FilterPattern> {
|
||||
/// TODO: it means not pattern restriction now
|
||||
/// Blocked by https://github.com/cybergeek94/mime_guess/issues/19
|
||||
vec![]
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue