Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jun 20, 2016

Conversation

@izgzhen
Copy link
Contributor

izgzhen commented Jun 16, 2016

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

highfive commented Jun 16, 2016

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
@izgzhen
Copy link
Contributor Author

izgzhen commented Jun 16, 2016

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

bors-servo commented Jun 19, 2016

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

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) {

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jun 20, 2016

Member

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.

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jun 20, 2016

Author Contributor

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

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jun 20, 2016

Member

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
Member

Manishearth commented Jun 20, 2016

r=me post rebase

@izgzhen izgzhen force-pushed the izgzhen:file-acccept-mime-filter branch from 2c8c953 to 74eb80d Jun 20, 2016
@KiChjang
Copy link
Member

KiChjang commented Jun 20, 2016

@bors-servo r=Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Jun 20, 2016

📌 Commit 74eb80d has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Jun 20, 2016

Testing commit 74eb80d with merge 33bda9c...

bors-servo added 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
Contributor

bors-servo commented Jun 20, 2016

@bors-servo bors-servo merged commit 74eb80d into servo:master Jun 20, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.