Bug 1264236 - Implement DataTransfer.getFiles, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Sat, 09 Jul 2016 11:21:42 +0200
changeset 386004 ff117266d9de99e0bafa5cf147948cc8dc054949
parent 386003 942dac3830549a98809abca0d62aeb7599c51631
child 386005 a60cf1b7124aa067e96cdd751ac526008f96ff8a
push id22595
push userdmitchell@mozilla.com
push dateSat, 09 Jul 2016 22:01:26 +0000
reviewerssmaug
bugs1264236
milestone50.0a1
Bug 1264236 - Implement DataTransfer.getFiles, r=smaug
dom/events/DataTransfer.cpp
dom/events/DataTransfer.h
dom/webidl/DataTransfer.webidl
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -874,16 +874,23 @@ DataTransfer::GetFilesAndDirectories(Err
     return nullptr;
   }
 
   p->MaybeResolve(filesSeq);
 
   return p.forget();
 }
 
+already_AddRefed<Promise>
+DataTransfer::GetFiles(bool aRecursiveFlag, ErrorResult& aRv)
+{
+  // Currently we don't support directories.
+  return GetFilesAndDirectories(aRv);
+}
+
 void
 DataTransfer::AddElement(Element& aElement, ErrorResult& aRv)
 {
   if (mReadOnly) {
     aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
     return;
   }
 
--- a/dom/events/DataTransfer.h
+++ b/dom/events/DataTransfer.h
@@ -145,16 +145,19 @@ public:
 
   void ClearData(const mozilla::dom::Optional<nsAString>& aFormat,
                  mozilla::ErrorResult& aRv);
 
   FileList* GetFiles(mozilla::ErrorResult& aRv);
 
   already_AddRefed<Promise> GetFilesAndDirectories(ErrorResult& aRv);
 
+  already_AddRefed<Promise> GetFiles(bool aRecursiveFlag, ErrorResult& aRv);
+
+
   void AddElement(Element& aElement, mozilla::ErrorResult& aRv);
 
   uint32_t MozItemCount() const;
 
   void GetMozCursor(nsString& aCursor)
   {
     if (mCursorState) {
       aCursor.AssignLiteral("default");
--- a/dom/webidl/DataTransfer.webidl
+++ b/dom/webidl/DataTransfer.webidl
@@ -27,16 +27,19 @@ interface DataTransfer {
   void clearData(optional DOMString format);
   [Throws]
   readonly attribute FileList? files;
 };
 
 partial interface DataTransfer {
   [Throws, Pref="dom.input.dirpicker"]
   Promise<sequence<(File or Directory)>> getFilesAndDirectories();
+
+  [Throws, Pref="dom.input.dirpicker"]
+  Promise<sequence<File>>                getFiles(optional boolean recursiveFlag = false);
 };
 
 // Mozilla specific stuff
 partial interface DataTransfer {
   /*
    * Set the drag source. Usually you would not change this, but it will
    * affect which node the drag and dragend events are fired at. The
    * default target is the node that was dragged.