Skip to content

Implement filter for file-type input's accept attribute - #11757

Merged
bors-servo merged 1 commit into
servo:masterfrom
izgzhen:file-acccept-mime-filter
Jun 20, 2016
Merged

bors-servo merged 1 commit into
servo:masterfrom
izgzhen:file-acccept-mime-filter

Conversation

@izgzhen

@izgzhen izgzhen commented Jun 16, 2016 •

Copy link
Copy Markdown
Contributor

Now the two sides are pasted together with the new version of mime_guess landed.

I tested this thing locally with stuff like this:

<input id="input_file" type="file" accept=".doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"></input>
<a onclick="open_file();">Click</a>

<script type="text/javascript">
    function open_file() {
        console.log("Open file");
        document.getElementById("input_file").click();
    }
</script>

Will WPT be able to handle this automatically?


Related to #11131


This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @KiChjang: components/net/Cargo.toml, components/net/filemanager_thread.rs, components/script/lib.rs, components/script/Cargo.toml, components/net_traits/filemanager_thread.rs, components/net_traits/filemanager_thread.rs, components/script/dom/htmlinputelement.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jun 16, 2016
@izgzhen

izgzhen commented Jun 16, 2016

Copy link
Copy Markdown
Contributor Author

cc @Manishearth

@Manishearth Manishearth assigned Manishearth and unassigned pcwalton Jun 16, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #11788) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jun 19, 2016
if let Some('.') = p.chars().nth(0) {
filter.push(FilterPattern(p[1..].to_string()));
} else {
if let Some(exts) = mime_guess::get_mime_extensions_str(p) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a better way of doing this by directly telling the OS the mime type. However, since it's not in the tfd api yet, we can just merge this for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I am a bit surprised that OS might have a concept like MIME (thinking only Web has that)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's a good point. I think you can tell the OS "image files only" though I'm not sure. You can investigate that later if you want.

@Manishearth

Copy link
Copy Markdown
Member

r=me post rebase

@KiChjang

Copy link
Copy Markdown
Contributor

@bors-servo r=Manishearth

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 74eb80d has been approved by Manishearth

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors. labels Jun 20, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 74eb80d with merge 33bda9c...

bors-servo pushed a commit that referenced this pull request Jun 20, 2016
Implement filter for file-type input's accept attribute

Now the two sides are pasted together with the new version of `mime_guess` landed.

I tested this thing locally with stuff like this:

```html
<input id="input_file" type="file" accept=".doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"></input>
<a onclick="open_file();">Click</a>

<script type="text/javascript">
    function open_file() {
        console.log("Open file");
        document.getElementById("input_file").click();
    }
</script>
```

Will WPT be able to handle this automatically?

---
<!-- 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 is related to #11131

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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/11757)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows

@bors-servo
bors-servo merged commit 74eb80d into servo:master Jun 20, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jun 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants