<br><br><div class="gmail_quote">On Sat, Jan 23, 2010 at 2:30 AM, Ian Hickson <span dir="ltr"><<a href="mailto:ian@hixie.ch">ian@hixie.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On Mon, 17 Aug 2009, Jian Li wrote:<br>
><br>
> In order to download the attachment from an Internet mail application,<br>
> the user will have to click the attachment link and a "save" dialog will<br>
> pop up to let the user select the destination folder. This will normally<br>
> involves multiple clicks. Native application, like Outlook, can let the<br>
> user drag attachments directly into the destination place, i.e. desktop,<br>
> which is really convenient.<br>
><br>
> We propose adding a specific format string to the DataTransfer object:<br>
> "DownloadURL". The data associated with the "DownloadURL" format should<br>
> be parsed similar to the "URL" format. When the drag ends in another<br>
> application, the remote file described in the associated data URL should<br>
> be downloaded and provided to the target application.<br>
<br>
How would this be exposed to other apps? Is it possible in Windows to drop<br>
something and then have the application that received the drop wait for a<br>
download (which could take hours) to complete? How does that work?<br>
<br>
If we can rely on the download happening before the drag, then we could<br>
add something to the DataTransfer object to add File objects.<br>
<br></blockquote><div><br></div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><div>We cannot do the download before the drag because the drop target might not accept the drag or the user might press ESC to cancel the drag-and-drop. We do not want to do any unnecessary download before we know for sure that the user really wants it.</div>
<div><br></div><div>It could be possible that the target application could be blocked for long time if we do not provide the drag-and-drop information in a nice way. On Windows, we could provide a download file in two ways: file path or file stream. For the former way, a file has to be downloaded first before the target application can consume it and thus the target application will be blocked until the download completes. For the latter way, we use the file stream to transfer the data between the source application and the target application and thus the target application will not be blocked if it uses a background thread (this is what Windows Shell does). On MacOSX, a file stream is also used for such purpose.</div>
<div><br></div><div>However, we need to provide more metadata about the download when we call DataTransfer.setData("DownloadURL", ...). This is because on Windows we need to know about the file name and size when the drag is initiated. We can wait till we get the headers to extract the file name and size but this is blocking. Even more, if the http chunk mode is used, we cannot get the size from the headers. On MacOSX, we need to provide the mime type and file name. Could we consider adding mime type, file name and size information into the data value parameter of setData method? For example,</div>
</span><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">    dataTransfer.setData("DownloadURL", "text/plain:1000:<a href="http://example.com/download.txt" target="_blank" style="color: rgb(42, 93, 176); ">http://example.com/download.txt</a>");</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "></span> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<br>
On Fri, 4 Sep 2009, Jens Alfke wrote:<br>
> On Sep 3, 2009, at 6:05 PM, Francisco Tolmasky wrote:<br>
> ><br>
> > However, I think the addition of the deferred setData methods could be<br>
> > added today in a way that is completely backwards compatible with<br>
> > current implementations and would still be of great benefit.<br>
> > Specifically, my request for deferring the calling of toString on<br>
> > non-string objects as such:<br>
> ><br>
> > event.dataTransfer.setData("something", { toString: function() {<br>
> > return expensiveFunctionCall(); } });<br>
> ><br>
> > This would allow me to submit patches to Firefox and WebKit that would<br>
> > solve the current performance issues which are literally blocking my<br>
> > ability to switch from "fake" drag and drop to "native" drag and drop.<br>
> > At the same time, this should still work today in all browsers that<br>
> > implement setData because the object is coerced into a string<br>
> > immediately for you, thus not requiring immediate action on their part<br>
> > to change anything.<br>
><br>
> +1. A real drag-n-drop API has to support promised data.<br>
<br>
I agree with this in principle, but I think we should wait for DND to be<br>
properly implemented in current browsers before adding this.<br>
<br>
<br>
On Tue, 12 Jan 2010, Michael Davidson wrote:<br>
><br>
> The table in section 7.9.3 says that the DataTransfer object should be<br>
> empty for dragenter and dragover events.<br>
><br>
> Clearly this is not the case - the example in 7.9.1 shows that, at the<br>
> very least, the DataTransfer object needs to have a 'types' attribute so<br>
> that the drag handler can determine if it can accept the drag.<br>
<br>
I've tried to clarify what "empty" is supposed to mean here.<br>
<br>
<br>
> The issue that I'm having is that if the DataTransfer object says that<br>
> it has Files, I have no way to determine what type those files are. (In<br>
> this case, I only want to accept image files.) I understand that the<br>
> DataTransfer shouldn't have the content of the files for security<br>
> reasons, but it would be helpful if it did contain the file names and/or<br>
> MIME types.<br>
<br>
I could provide a second attribute with the types of the files, would that<br>
work? I suppose if we did this, we should remove the "Files" fake type.<br>
That might not be a bad idea in general, it's kind of a hack. I'm not sure<br>
how I feel about having multiple different ways of representing the data<br>
in a DataTransfer object... It would give a clean precedent for adding<br>
other features, though, like promises, which some people have requested.<br>
<br>
<br>
On Fri, 22 Jan 2010, Daniel Cheng wrote:<br>
><br>
> Two more questions about implementation details:<br>
><br>
> Cut/copy:<br>
> Does it make sense to fire a drag event at all? The spec says that drag<br>
> events should be fired at the source node every 350ms (presumably to allow<br>
> the source node to cancel a drag after it started), but a cut/copy takes<br>
> place "instantaneously".<br>
<br>
I've clarified the spec to say that the loop has to happen immediately and<br>
then only repeat every 350ms if it's still active.<br>
<br>
<br>
> If drag events should be fired during cut/copy, should the clipboard be<br>
> restored to its original state if the drag event is cancelled? It would<br>
> make sense, but might make implementations more complicated.<br>
<br>
The idea is for the cut/copy to be done exactly as if it was a drag to a<br>
hypothetical clipboard window, meaning everything happens in the "drop"<br>
part, so yes.<br>
<br>
<br>
> Paste:<br>
> It seems like there is no time a dragleave event would ever fire. A paste<br>
> essentially goes through the drag and drop loop once; the only possible<br>
> transition is for the current target element to go from null to non-null.<br>
<br>
The 'dragleave' event can fire during a paste if the drag is canceled.<br>
<font color="#888888"><br>
--<br>
Ian Hickson               U+1047E                )\._.,--....,'``.    fL<br>
<a href="http://ln.hixie.ch/" target="_blank">http://ln.hixie.ch/</a>       U+263A                /,   _.. \   _\  ;`._ ,.<br>
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'<br>
</font></blockquote></div><br>