aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-06-14 07:27:47 -0500
committerGitHub <noreply@github.com>2016-06-14 07:27:47 -0500
commit0cfae3a3e756c5719b5ab58dde9d0eacc7f197be (patch)
tree824e2eb5e7163e97ea768732cdc190c81643ec61 /components/script/dom
parentebf412a2aa2415d3921c95ad6413a6ee2896f270 (diff)
parent256c7e894ee5eba8c35502acff3fa0328833f560 (diff)
downloadservo-0cfae3a3e756c5719b5ab58dde9d0eacc7f197be.tar.gz
servo-0cfae3a3e756c5719b5ab58dde9d0eacc7f197be.zip
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 -->
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/htmlinputelement.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs
index 4c164f2c819..561ccc647f2 100644
--- a/components/script/dom/htmlinputelement.rs
+++ b/components/script/dom/htmlinputelement.rs
@@ -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![]
+}
+