Bug 1345473 - Set tab as drag source. r=Gijs
In certain cases, such as dropping a tab's title on the URL bar when Compact
Themes are enabled, the tab dragging UX becomes frozen because it never receives
the expected `dragend` event.
In these situations, the event is lost because the source node we are dragging
becomes detached from the DOM, and so there is no path back to the handlers
waiting for the `dragend` event.
Here we set source node of the drag to the tab element, so that there's always
a stable node in place, and the `dragend` event can be delivered.
MozReview-Commit-ID: JVtEYNA7ImI
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -6640,16 +6640,20 @@
// We must not set text/x-moz-url or text/plain data here,
// otherwise trying to deatch the tab by dropping it on the desktop
// may result in an "internet shortcut"
dt.mozSetDataAt("text/x-moz-text-internal", browser.currentURI.spec, 0);
// Set the cursor to an arrow during tab drags.
dt.mozCursor = "default";
+ // Set the tab as the source of the drag, which ensures we have a stable
+ // node to deliver the `dragend` event. See bug 1345473.
+ dt.addElement(tab);
+
// Create a canvas to which we capture the current tab.
// Until canvas is HiDPI-aware (bug 780362), we need to scale the desired
// canvas size (in CSS pixels) to the window's backing resolution in order
// to get a full-resolution drag image for use on HiDPI displays.
let windowUtils = window.getInterface(Ci.nsIDOMWindowUtils);
let scale = windowUtils.screenPixelsPerCSSPixel / windowUtils.fullZoom;
let canvas = this._dndCanvas;
if (!canvas) {