This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 26024 - Drag and drop <img> should give the rendered image's URL
Summary: Drag and drop <img> should give the rendered image's URL
Status: RESOLVED MOVED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: Other All
: P3 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard: picture
Keywords:
Depends on: picture
Blocks:
  Show dependency treegraph
 
Reported: 2014-06-09 21:37 UTC by contributor
Modified: 2019-03-29 22:21 UTC (History)
5 users (show)

See Also:


Attachments

Description contributor 2014-06-09 21:37:54 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html
Multipage: http://www.whatwg.org/C#the-draggable-attribute
Complete: http://www.whatwg.org/c#the-draggable-attribute
Referrer: http://www.whatwg.org/specs/web-apps/current-work/multipage/

Comment:
Make <picture> draggable by default
See http://picture.responsiveimages.org/#dnd
https://github.com/ResponsiveImagesCG/picture-element/issues/198

Posted from: 2a00:801:e0:30:f151:a389:93c6:526d by simonp@opera.com
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36 OPR/22.0.1471.40 (Edition Next)
Comment 1 Ian 'Hixie' Hickson 2014-06-09 22:59:07 UTC
What does that mean? Isn't it the <img> that gets rendered?

Please be specific about the changes you want...
Comment 2 Simon Pieters 2014-06-09 23:29:12 UTC
Yes, but when you drag the image you want the <picture> and <source>s to come along as well.

change:

[[
Otherwise, the element's draggable content attribute has the state auto. If the element is an img element, an object element that represents an image, or an a element with an href content attribute, the draggable IDL attribute must return true; otherwise, the draggable IDL attribute must return false.
]]

to

[[
Otherwise, the element's draggable content attribute has the state auto. If the element is an img element that does not have a picture parent element, a picture element, an object element that represents an image, or an a element with an href content attribute, the draggable IDL attribute must return true; otherwise, the draggable IDL attribute must return false.
]]
Comment 3 Ian 'Hixie' Hickson 2014-06-10 16:44:32 UTC
Uh, that won't do anything useful. Nothing will end up in the drag data store, for example. You sure that's what you want?
Comment 4 Simon Pieters 2014-06-11 07:45:30 UTC
Hmm, nope! Let's see.

[[
setDragImage
]]

This seems fine without changes.

[[
If the list of dragged nodes is not empty, then extract the microdata from those nodes into a JSON form, and add one item to the drag data store item list, with its properties set as follows:
...
If the node is an img element with a src attribute
Add to urls the result of resolving the element's src content attribute relative to the element.
]]

Is this intentionally using <img src> as opposed to the last selected source? In either case, I want to tweak this for <picture> so that it uses the first <img> child's src or currentSrc (I think the latter is probably more useful).

[[
drag data store bitmap
]]

This should be populated with the <picture> element's first <img> child's image data, but I don't really follow where the spec does this for <img> right now.
Comment 5 Ian 'Hixie' Hickson 2014-06-11 19:40:00 UTC
If we're just trying to make it possible to drag a bitmap out of the page, why isn't it ok to just rely on the user dragging the actual rendered <img> element? I don't really understand what problem we're fixing here.

(That algorithm ignoring srcset="" was just an oversight, I agree that we should use the rendered image's URL and data if there is one.)
Comment 6 Simon Pieters 2014-06-12 07:34:20 UTC
That would be OK if you're dragging to a different application or so, but I think it's bad if you want to move elements around within the page and just appendChild the dragged element in the dropzone. That would leave the <picture> behind, which results in an invalid document and breaks the association between the <img> and the <picture>.

I would also like to be able to drag <picture> around within contenteditable. I'm not sure if changing the drag and drop API also changes behavior for contenteditable though, I don't know if and where dragging in contenteditable is defined.
Comment 7 Ian 'Hixie' Hickson 2014-06-12 16:55:51 UTC
The DND API doesn't support the dragging of an element being mediated by author script.

For contentEditable it works only because the UA is mediating it and it includes secret stuff in the dataTransfer object to represent the element itself.

(This is exactly the kind of nonsense that multielement designs lead to, by the way. I'm really unhappy that you're leaking details all over the rest of the spec.)
Comment 8 Simon Pieters 2014-06-16 12:58:09 UTC
You're right. This is probably more trouble than it solves. I've reverted the change in the picture spec. It's reasonably easy for authors to check the parent of the dragged element.

Let's just fix which URL is exposed. You can use "the img element's _current request_'s _current URL_" for that.
Comment 9 Ian 'Hixie' Hickson 2014-06-18 21:22:37 UTC
Will do.
Comment 10 Anne 2015-09-16 11:44:12 UTC
Simon, we cannot change this as that would expose a URL that would otherwise be hidden. Any other ideas?
Comment 11 Simon Pieters 2015-09-17 19:37:03 UTC
No, this wouldn't expose redirects.
Comment 12 Domenic Denicola 2019-03-29 22:21:56 UTC
https://github.com/whatwg/html/issues/4493