Closed Bug 458613 Opened 16 years ago Closed 16 years ago

event.relatedTarget is not set for dragexit/dragleave events?

Categories

(Core :: DOM: Copy & Paste and Drag & Drop, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: asaf, Assigned: enndeakin)

References

Details

Attachments

(2 files, 2 obsolete files)

While testing and hacking tabbbrowser, I figured that event.realatedTarget is never set for the dragexit/dragleave events.
Asaf, does this work for you?
Assignee: nobody → enndeakin
Status: NEW → ASSIGNED
Nope, relatedTarget is still set to null. Plus, and i don't know if that's related, effectAllowed for this event is unset.
Mano, do you have a testcase for relatedTarget?
I tested within the dragleave listener of tabbrowser. I don't have a standalone testcase, I could probably write one if that helps. Note that tabbrowser won't rely on this api after my patch lands (I'm using coordinates checks instead for some other reasons). This used to work previously though, assuuming someone tested that code path.
Martijn, what is this test checking? relatedTarget should only apply to dragleave and dragenter, and be null for all other drag events.
Attached file testcase
Sorry, I didn't know that. I was confused. I was thinking that dragend needed a relatedTarget to fix the bugs that bug 225680 caused. But apparently that can be done with dragleave too, perhaps, if I understand this code correctly: http://mxr.mozilla.org/mozilla-central/source/browser/base/content/tabbrowser.xml#2277
Attachment #350073 - Attachment is obsolete: true
The patch attached to this bug works fine for the testcase.
Comment on attachment 343418 [details] [diff] [review] check for drag events for relatedTarget and button properties OK, whether this fixes mano's issue or not, this is still a suitable patch for relatedTarget
Attachment #343418 - Flags: review?(Olli.Pettay)
Based on HTML 5 .relatedTarget should be null by default for drag events. Of course if relatedTarget is explicitly set using .initDragEvent, then .relatedTarget shouldn't be null. Btw, seems like we have some old version of initDragEvent(...), not the one HTML 5 specifies.
So as such the patch is ok, but ESM shouldn't set relatedTarget for drag events.
It seems that the spec changed very recently -- before drag events were just UIEvents so didn't have a relatedTarget. The relatedTarget should be updated for the dragenter/dragleave events to mirror the mouse ones (likely this is an oversight in the spec).
Neil, could you bring up this issue in whatwg?
Comment on attachment 343418 [details] [diff] [review] check for drag events for relatedTarget and button properties Anyway, I'd like to see the right kind of .initDragEvent()
Attachment #343418 - Flags: review?(Olli.Pettay) → review-
(In reply to comment #14) > (From update of attachment 343418 [details] [diff] [review]) > Anyway, I'd like to see the right kind of .initDragEvent() What does that have to do with this bug?
With initDragEvent scripts can set .relatedTarget to script generated events.
Attachment #343418 - Attachment is obsolete: true
Attachment #352216 - Flags: review?(Olli.Pettay)
Attachment #352216 - Flags: review?(Olli.Pettay) → review+
Comment on attachment 352216 [details] [diff] [review] something like this You could add some comment to those commented-out tests. (I know, not about this bug) Looks good, r=me. Please ask Hixie/WhatWG about .relatedTarget on system generated dnd events.
Comment on attachment 352216 [details] [diff] [review] something like this Is this actually missing a change to nsDOMClassInfo.cpp where DragEvents should be marked to be also MouseEvents?
(In reply to comment #19) > (From update of attachment 352216 [details] [diff] [review]) > Is this actually missing a change to nsDOMClassInfo.cpp where DragEvents should > be marked to be also MouseEvents? You asked that once before I think ;) DragEvent inherits from MouseEvent.
Attachment #352216 - Flags: superreview?(roc)
Attachment #352216 - Flags: superreview?(roc) → superreview+
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Flags: in-testsuite+
Depends on: 512347
testcase not working anymore on "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0", the relatedTarget is always null (but Chrome 60 now returns a valid relatedTarget)
i can see this is not working (always null) in 57.0.4 (64-bit) on mac OS X. Makes it impossible to see if the dragleave event is just for a nested child or the whole parent.
That issue is bug 1420590 which is to be fixed in Firefox 59.
ok awesome thanks! i've been looking into enter/leave counting such as explained in https://stackoverflow.com/questions/10253663/how-to-detect-the-dragleave-event-in-firefox-when-dragging-outside-the-window as a potential workaround in the meantime
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: