Bug 1202964 - Use the correct nsIFilePicker API for directory picking in HTMLInputElement::nsFilePickerShownCallback::Done. r=baku
authorJonathan Watt <jwatt@jwatt.org>
Tue, 18 Aug 2015 10:30:19 +0100
changeset 294141 b91ede451160f0507b73404ab5061f5ebb0f742f
parent 294140 786caad5b4cfe1a375a512493454d2444fa9dd74
child 294142 06bb0c1766f1f7daed068836f1cb95ba45aac59a
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1202964
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1202964 - Use the correct nsIFilePicker API for directory picking in HTMLInputElement::nsFilePickerShownCallback::Done. r=baku
dom/html/HTMLInputElement.cpp
widget/nsBaseFilePicker.cpp
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -373,18 +373,17 @@ HTMLInputElement::nsFilePickerShownCallb
     return NS_OK;
   }
 
   int16_t mode;
   mFilePicker->GetMode(&mode);
 
   // Collect new selected filenames
   nsTArray<nsRefPtr<File>> newFiles;
-  if (mode == static_cast<int16_t>(nsIFilePicker::modeOpenMultiple) ||
-      mode == static_cast<int16_t>(nsIFilePicker::modeGetFolder)) {
+  if (mode == static_cast<int16_t>(nsIFilePicker::modeOpenMultiple)) {
     nsCOMPtr<nsISimpleEnumerator> iter;
     nsresult rv = mFilePicker->GetDomfiles(getter_AddRefs(iter));
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (!iter) {
       return NS_OK;
     }
 
@@ -396,17 +395,18 @@ HTMLInputElement::nsFilePickerShownCallb
       nsCOMPtr<nsIDOMBlob> domBlob = do_QueryInterface(tmp);
       MOZ_ASSERT(domBlob,
                  "Null file object from FilePicker's file enumerator?");
       if (domBlob) {
         newFiles.AppendElement(static_cast<File*>(domBlob.get()));
       }
     }
   } else {
-    MOZ_ASSERT(mode == static_cast<int16_t>(nsIFilePicker::modeOpen));
+    MOZ_ASSERT(mode == static_cast<int16_t>(nsIFilePicker::modeOpen) ||
+               mode == static_cast<int16_t>(nsIFilePicker::modeGetFolder));
     nsCOMPtr<nsISupports> tmp;
     nsresult rv = mFilePicker->GetDomfile(getter_AddRefs(tmp));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(tmp);
     if (blob) {
       nsRefPtr<File> file = static_cast<Blob*>(blob.get())->ToFile();
       newFiles.AppendElement(file);
--- a/widget/nsBaseFilePicker.cpp
+++ b/widget/nsBaseFilePicker.cpp
@@ -343,18 +343,19 @@ nsBaseFilePicker::GetDomfile(nsISupports
   nsresult rv = GetFile(getter_AddRefs(localFile));
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!localFile) {
     *aDomfile = nullptr;
     return NS_OK;
   }
 
-  nsCOMPtr<nsIDOMBlob> domFile = File::CreateFromFile(mParent, localFile);
-  domFile.forget(aDomfile);
+  nsRefPtr<File> domFile = File::CreateFromFile(mParent, localFile);
+  domFile->Impl()->SetIsDirectory(mMode == nsIFilePicker::modeGetFolder);
+  nsCOMPtr<nsIDOMBlob>(domFile).forget(aDomfile);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBaseFilePicker::GetDomfiles(nsISimpleEnumerator** aDomfiles)
 {
   nsCOMPtr<nsISimpleEnumerator> iter;
   nsresult rv = GetFiles(getter_AddRefs(iter));