On Fri, Feb 26, 2010 at 10:56 AM, Dmitry Titov <span dir="ltr"><<a href="mailto:dimich@google.com" target="_blank">dimich@google.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="gmail_quote"><div>On Mon, Feb 22, 2010 at 6:06 PM, Daniel Cheng <span dir="ltr"><<a href="mailto:dcheng@google.com" target="_blank">dcheng@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div>Several questions about the proposal:</div>How does DataTransferItems interact with the original DataTransfer object? I'm assuming changes in one should be reflected in the other. If that's the case, what should happen if I do this:<div>





dataTransfer.items.add(fileData);</div><div>dataTransfer.getData(mimeTypeForFile);</div></blockquote><div><br></div></div><div>Unless there is a specific reason to think different, there is only one set of items backing DataTransfer object - today the files and 'other items' are represented separtely, the proposed items list is simply a merged version of the same. In your example you should be able to getData.</div>

</div></blockquote><div><br></div><div>Does that mean getData() can return types besides DOMString?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div><div><div>How come there's no DataTransferItems.get(type) method?</div></div></div></div>



</div></blockquote><div><br></div></div><div>There can be multiple items of that type (dragging several image files). Would it return another items list? What is the use case for this? Also, some items may have empty type (a file with unknown extension).</div>

</div></blockquote><div><br></div><div>I think files have always been a special case and should continue to be handled that way. I don't think there's any platform pasteboard that supports multiple items of one non-file type, so it'd make the most sense to make it a 1:1 mapping from types to data.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div><div><div><div>DataTransferItem provides richer metadata than is available through the native drag-and-drop interface on most platforms. When dragging data from a non-DOM application, how do you extrapolate the metadata to fill in the type/binary fields?</div>


</div></div></div></div></blockquote><div><br></div></div><div>'type' can be inferred in many cases from file extension, native clipboard format or other means. It can be done w/o content sniffing and disk IO.</div>

</div></blockquote><div><br></div><div>Should there be some sort of standard list of mappings that all UAs should support wherever possible? What happens if the UA doesn't have a mapping for a type?</div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div>
<br></div><div>I understand 'binary' as indicator of whether or not the item can be read as a text string. I'm not sure why item.kind == "string" is not the same. If the intent is to also cover some files that can be read as string and as Blob, then it might be buggy because the only way to establish if the file can be converted into JS string is to actually read the bytes and try to convert to Unicode. There can be invalid character sequences or the encoding info may be missing.</div>


<div><br></div><div>Perhaps we should remove 'binary' and assume that items that item.kind == "string" can use getTextData(callback) to pull the string.</div><div><br></div><div>On a separate note, I think items.add(dataTransferItem) is not useful w/o a way to create a new DataTransferItem separately from the DataTransferItems list.</div>

<div><div></div><div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div><div>


<div><br></div><div><font color="#888888">Daniel</font><div><div></div><div><br><br><div class="gmail_quote">On Mon, Feb 22, 2010 at 3:51 PM, Ian Hickson <span dir="ltr"><<a href="mailto:ian@hixie.ch" target="_blank">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">

<div>On Thu, 4 Feb 2010, Ian Hickson wrote:<br>
> On Sat, 23 Jan 2010, Eduard Pascual wrote:<br>
> ><br>
> > Would it be possible to provide a list of "drag items" (to call them<br>
> > somehow) instead of, or in addition to, the current info provided by<br>
> > the DataTransfer object?<br>
><br>
> That's a pretty good idea. I think we should probably do this when we<br>
> add more types to the DataTransfer object.<br>
<br>
</div>Some engineers at Google discussed this a bit and came up with the<br>
following proposal:<br>
<br>
   dataTransfer.items = DataTransferItems<br>
<br>
    DataTransferItems.length<br>
                     .getItem(n) = DataTransferItem<br>
                     .add(stringData, type)<br>
                     .add(blobData)<br>
                     .add(fileData)<br>
                     .add(dataTransferItem)<br>
                     .clear()<br>
<br>
    DataTransferItem.kind = 'string', 'file', 'blob', ...<br>
                    .type = MIME type<br>
                    .binary = boolean<br>
                    .getTextData(function callback (data)) - throws if binary is true<br>
                    .getBlob() - returns File or Blob<br>
<br>
When we add promises later, this can easily be extended to support that as<br>
well (basically, just by adding a new add() method for the promise case).<br>
<br>
I've put this into the comment in the spec, but haven't specced it. If any<br>
browser vendors want to try implementing this or something like it, any<br>
reports of implementation experience would be very useful. Please prefix<br>
the "items" attribute with some unique string like "webkitItems" or<br>
"geckoItems" so that it doesn't clash with the spec when we do add<br>
something like this!<br>
<br>
Cheers,<br>
<div><div></div><div>--<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>
</div></div></blockquote></div><br></div></div></div></div></div></div></div>
</blockquote></div></div></div><br>
</blockquote></div><br>