mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 377624 - "Implement the accept attribute for the form and file upload controls form "image/*"" [r=enndeakin,roc]
This commit is contained in:
parent
0b2b6d6828
commit
869533b09b
@ -372,8 +372,18 @@ nsFileControlFrame::MouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
// Set filter "All Files"
|
||||
filePicker->AppendFilters(nsIFilePicker::filterAll);
|
||||
// We want to get the file filter from the accept attribute and we add the
|
||||
// |filterAll| filter to be sure the user has a valid fallback.
|
||||
PRUint32 filter = mFrame->GetFileFilterFromAccept();
|
||||
filePicker->AppendFilters(filter | nsIFilePicker::filterAll);
|
||||
|
||||
// If the accept attribute asks for a filter, it has to be the default one.
|
||||
if (filter) {
|
||||
// We have two filters: |filterAll| and another one. |filterAll| is
|
||||
// always the first one (index=0) so we can assume the one we want to be
|
||||
// the default is at index 1.
|
||||
filePicker->SetFilterIndex(1);
|
||||
}
|
||||
|
||||
// Set default directry and filename
|
||||
nsAutoString defaultName;
|
||||
@ -851,6 +861,18 @@ NS_IMETHODIMP nsFileControlFrame::GetAccessible(nsIAccessible** aAccessible)
|
||||
}
|
||||
#endif
|
||||
|
||||
PRInt32
|
||||
nsFileControlFrame::GetFileFilterFromAccept() const
|
||||
{
|
||||
nsAutoString accept;
|
||||
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accept, accept);
|
||||
|
||||
if (accept.EqualsLiteral("image/*")) {
|
||||
return nsIFilePicker::filterImages;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
////////////////////////////////////////////////////////////
|
||||
// Mouse listener implementation
|
||||
|
||||
|
@ -103,6 +103,19 @@ public:
|
||||
// which directory was last used on a site-by-site basis
|
||||
static void InitUploadLastDir();
|
||||
static void DestroyUploadLastDir();
|
||||
|
||||
/**
|
||||
* This methods return the file filter mask requested by the HTML5 accept
|
||||
* attribute. If the accept attribute isn't present or the value isn't valid,
|
||||
* the returned value will be 0.
|
||||
*
|
||||
* See:
|
||||
* http://dev.w3.org/html5/spec/forms.html#attr-input-accept
|
||||
*
|
||||
* @return the file picker filter mask or 0 if there is no filter.
|
||||
*/
|
||||
PRInt32 GetFileFilterFromAccept() const;
|
||||
|
||||
protected:
|
||||
class MouseListener;
|
||||
friend class MouseListener;
|
||||
|
@ -1,6 +1,6 @@
|
||||
allFilter=*
|
||||
htmlFilter=*.html; *.htm; *.shtml; *.xhtml
|
||||
textFilter=*.txt; *.text
|
||||
imageFilter=*.jpg; *.jpeg; *.gif; *.png; *.bmp; *.ico
|
||||
imageFilter=*.jpe; *.jpg; *.jpeg; *.gif; *.png; *.bmp; *.ico; *.svg; *.svgz; *.tif; *.tiff; *.ai; *.drw; *.pct; *.psp; *.xcf; *.psd; *.raw
|
||||
xmlFilter=*.xml
|
||||
xulFilter=*.xul
|
||||
|
@ -59,7 +59,11 @@ interface nsIFilePicker : nsISupports
|
||||
const long filterAll = 0x01; // *.*
|
||||
const long filterHTML = 0x02; // *.html; *.htm
|
||||
const long filterText = 0x04; // *.txt
|
||||
const long filterImages = 0x08; // *.png; *.gif; *.jpg; *.jpeg
|
||||
const long filterImages = 0x08; // *.jpe; *.jpg; *.jpeg; *.gif;
|
||||
// *.png; *.bmp; *.ico; *.svg;
|
||||
// *.svgz; *.tif; *.tiff; *.ai;
|
||||
// *.drw; *.pct; *.psp; *.xcf;
|
||||
// *.psd; *.raw
|
||||
const long filterXML = 0x10; // *.xml
|
||||
const long filterXUL = 0x20; // *.xul
|
||||
const long filterApps = 0x40; // Applications (per-platform implementation)
|
||||
|
Loading…
Reference in New Issue
Block a user