Bug 1345473 - Set tab as drag source. r=Gijs draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Mon, 13 Mar 2017 16:43:30 -0500
changeset 497818 3c7edc4ce445814a4b04fad63202a857976dae37
parent 495323 800ba54a4bd52628833c4db005ddd182586666c4
child 548996 b24c202ce7a07a04853d63a433d0873fdfceaa44
push id49017
push userbmo:jryans@gmail.com
push dateMon, 13 Mar 2017 21:55:13 +0000
reviewersGijs
bugs1345473
milestone55.0a1
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
browser/base/content/tabbrowser.xml
--- 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) {