Auto merge of #11931 - izgzhen:fix-html-input-element, r=Manishearth

Fix file-type input element

A simple fix to put `inputElem.files` online

---
<!-- 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

<!-- Either: -->
- [x] There are tests for these changes

<!-- 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/11931)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-06-30 01:20:11 -05:00 committed by GitHub
commit 8052f5b80d
8 changed files with 15 additions and 182 deletions

View file

@ -302,6 +302,14 @@ impl HTMLInputElementMethods for HTMLInputElement {
self.form_owner()
}
// https://html.spec.whatwg.org/multipage/#dom-input-files
fn GetFiles(&self) -> Option<Root<FileList>> {
match self.filelist.get() {
Some(ref fl) => Some(fl.clone()),
None => None,
}
}
// https://html.spec.whatwg.org/multipage/#dom-input-defaultchecked
make_bool_getter!(DefaultChecked, "checked");
@ -796,6 +804,12 @@ impl VirtualMethods for HTMLInputElement {
el.set_read_write_state(false);
}
if new_type == InputType::InputFile {
let window = window_from_node(self);
let filelist = FileList::new(window.r(), vec![]);
self.filelist.set(Some(&filelist));
}
let new_value_mode = self.value_mode();
match (&old_value_mode, old_idl_value.is_empty(), new_value_mode) {

View file

@ -13,7 +13,7 @@ interface HTMLInputElement : HTMLElement {
attribute DOMString dirName;
attribute boolean disabled;
readonly attribute HTMLFormElement? form;
//readonly attribute FileList? files;
readonly attribute FileList? files;
attribute DOMString formAction;
attribute DOMString formEnctype;
attribute DOMString formMethod;