Bug 1162775: Make contentAreaDropListener use dataTransfer.files to get the files dropped. r=smaug
authorDave Townsend <dtownsend@oxymoronical.com>
Mon, 11 May 2015 11:33:15 -0700
changeset 243955 34a03726e05906e3c3cdb6676148114b92a13b78
parent 243892 03fdeedb03af625617b576b10515761f574ebb92
child 243956 d5a378327e88b886d397a978e5cba2937578c9eb
push id28761
push usercbook@mozilla.com
push dateFri, 15 May 2015 14:50:10 +0000
treeherdermozilla-central@c0e709a5baca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1162775
milestone41.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 1162775: Make contentAreaDropListener use dataTransfer.files to get the files dropped. r=smaug
dom/base/contentAreaDropListener.js
--- a/dom/base/contentAreaDropListener.js
+++ b/dom/base/contentAreaDropListener.js
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/osfile.jsm");
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 // This component is used for handling dragover and drop of urls.
 //
 // It checks to see whether a drop of a url is allowed. For instance, a url
 // cannot be dropped if it is not a valid uri or the source of the drag cannot
@@ -37,23 +38,19 @@ ContentAreaDropListener.prototype =
         case "text/x-moz-url":
           return dt.getData(type).split("\n");
       }
     }
 
     // For shortcuts, we want to check for the file type last, so that the
     // url pointed to in one of the url types is found first before the file
     // type, which points to the actual file.
-    let file = dt.mozGetDataAt("application/x-moz-file", 0);
-    if (file instanceof Ci.nsIFile) {
-      let ioService = Cc["@mozilla.org/network/io-service;1"].
-                        getService(Ci.nsIIOService);
-      let fileHandler = ioService.getProtocolHandler("file")
-                                 .QueryInterface(Ci.nsIFileProtocolHandler);
-      return [fileHandler.getURLSpecFromFile(file), file.leafName];
+    let files = dt.files;
+    if (files && files.length) {
+      return [OS.Path.toFileURI(files[0].mozFullPath), files[0].name];
     }
 
     return [ ];
   },
 
   _validateURI: function(dataTransfer, uriString, disallowInherit)
   {
     if (!uriString)