Closed
Bug 899519
Opened 11 years ago
Closed 11 years ago
Use "description" instead of "mime type name" for filter name for accept attribute (input type=file)
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla26
People
(Reporter: arnaud.bienner, Assigned: arnaud.bienner)
Details
Attachments
(1 file, 1 obsolete file)
1.50 KB,
patch
|
mounir
:
review+
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
When working on bug 565274, I missed this attribute from nsIMIMEInfo.idl, which looks better in that case, as it's described as "human readable". So we should probably use this for the filter name which is shown to user, as mime type name is less meaningful.
Assignee | ||
Comment 1•11 years ago
|
||
Assignee | ||
Comment 2•11 years ago
|
||
Comment on attachment 783097 [details] [diff] [review] mime_type_description.patch The idea here is to use description instead of mime type name. E.g. this will shown "Adobe Acrobat Document" as the filter name instead of "application/pdf" currently; and "JPEG image" instead of "image/jpeg", which is really nicer IMO. In this patch, I fallback on mime type name if description is empty, but I don't think this might ever happen for a valid mime type: we drop bad mime types and mime types with no extension. So I don't think we will ever have a valid mime type with extension set but no description set. So maybe I should just always the description as the filter name. This will make the code simpler.
Assignee | ||
Comment 3•11 years ago
|
||
A simpler version, as described above. Maybe the comment is superfluous and we can just have "mimeInfo->GetDescription(filterName);" directly, as it might be self explanatory.
Attachment #783098 -
Flags: review?(mounir)
Comment 4•11 years ago
|
||
Comment on attachment 783097 [details] [diff] [review] mime_type_description.patch Review of attachment 783097 [details] [diff] [review]: ----------------------------------------------------------------- That sounds good to me but I would like bz to review this because there might be MIME things I am not aware of.
Attachment #783097 -
Flags: review?(mounir)
Attachment #783097 -
Flags: review?(bzbarsky)
Attachment #783097 -
Flags: review+
Comment 5•11 years ago
|
||
Comment on attachment 783098 [details] [diff] [review] mime_type_description2.patch I would tend to prefer the other patch to be safe but I hope Boris to have some insights about the behaviour of .description.
Attachment #783098 -
Flags: review?(mounir)
Comment 6•11 years ago
|
||
Comment on attachment 783097 [details] [diff] [review] mime_type_description.patch This looks fine. There is no guarantee of description ever being nonempty, so you need some fallback no matter what.
Attachment #783097 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Updated•11 years ago
|
Attachment #783098 -
Attachment is obsolete: true
Assignee | ||
Comment 8•11 years ago
|
||
Comment on attachment 783098 [details] [diff] [review] mime_type_description2.patch ># HG changeset patch ># User Arnaud Bienner <arnaud.bienner@gmail.com> ># Date 1375183429 -7200 ># Node ID 186deea69b5cc0827489bb6a3c829622838e7b4d ># Parent a3c421763fbd8849bb86a5522578a3b7447dc636 >Bug 899519 - Use "description" instead of "mime type name" for filter name for accept attribute (input type=file) > >diff --git a/content/html/content/src/HTMLInputElement.cpp b/content/html/content/src/HTMLInputElement.cpp >--- a/content/html/content/src/HTMLInputElement.cpp >+++ b/content/html/content/src/HTMLInputElement.cpp >@@ -6031,20 +6031,19 @@ HTMLInputElement::SetFilePickerFiltersFr > if (NS_FAILED(mimeService->GetFromTypeAndExtension( > NS_ConvertUTF16toUTF8(token), > EmptyCString(), // No extension > getter_AddRefs(mimeInfo))) || > !mimeInfo) { > continue; > } > >- // Get mime type name >- nsCString mimeTypeName; >- mimeInfo->GetType(mimeTypeName); >- CopyUTF8toUTF16(mimeTypeName, filterName); >+ // Use the description as the filter name, as it's "human readable" (as >+ // stated in the idl) >+ mimeInfo->GetDescription(filterName); > > // Get extension list > nsCOMPtr<nsIUTF8StringEnumerator> extensions; > mimeInfo->GetFileExtensions(getter_AddRefs(extensions)); > > bool hasMore; > while (NS_SUCCEEDED(extensions->HasMore(&hasMore)) && hasMore) { > nsCString extension;
Assignee | ||
Comment 9•11 years ago
|
||
Sorry, I forgot to update tje commit message when I provided the patch, and it looks like I can't modified it here. You can use the bug's title (i.e. "Bug 899519 - Use "description" instead of "mime type name" for filter name for accept attribute (input type=file)") for the check-in.
Comment 10•11 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/6367c753c7f9
Keywords: checkin-needed
Target Milestone: --- → mozilla25
Comment 11•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/6367c753c7f9
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•11 years ago
|
Target Milestone: mozilla25 → mozilla26
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•