Bug 475066 - dragging a tab out of the browser window doesn't detach the tab (i.e. opens a window for that tab). r=enn.

This commit is contained in:
Asaf Romano 2009-04-16 03:33:15 +03:00
parent 52bfc6ae03
commit d0972ecf0b
3 changed files with 8 additions and 55 deletions

View File

@ -4938,24 +4938,6 @@ var contentAreaDNDObserver = {
var dragType = aXferData.flavour.contentType;
var dragData = aXferData.data;
if (dragType == TAB_DROP_TYPE) {
// If the tab was dragged from some other tab bar, its own dragend
// handler will take care of detaching the tab
if (dragData instanceof XULElement && dragData.localName == "tab" &&
dragData.ownerDocument.defaultView == window) {
// Detach only if the mouse pointer was released a little
// bit down in the content area (to be precise, by half the height
// of a tab)
if (aEvent.screenY > gBrowser.mPanelContainer.boxObject.screenY +
dragData.boxObject.height / 2) {
gBrowser.replaceTabWithWindow(dragData);
aEvent.dataTransfer.dropEffect = "move";
return;
}
}
aEvent.dataTransfer.dropEffect = "none";
return;
}
var url = transferUtils.retrieveURLFromData(dragData, dragType);

View File

@ -65,8 +65,6 @@
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="BrowserStartup()" onunload="BrowserShutdown()" onclose="return WindowIsClosing();"
ondragleave="gBrowser.browserWindowOnDragLeave(event);"
ondragenter="gBrowser.browserWindowOnDragEnter(event);"
title="&mainWindow.title;@PRE_RELEASE_SUFFIX@"
title_normal="&mainWindow.title;@PRE_RELEASE_SUFFIX@"
#ifdef XP_MACOSX

View File

@ -2261,25 +2261,20 @@
<body>
<![CDATA[
// Note: while this case is correctly handled here, this event
// isn't dispatched when the tab is moved within the tabstript,
// isn't dispatched when the tab is moved within the tabstrip,
// see bug 460801.
// * mozUserCancelled = the user pressed ESC to cancel the drag
// * Within our browser window, the detach-target is the content
// area. That case is handled by contentAreaDNDObserver.
// * The dragLeftWindow solution is suboptimal, a better solution
// is on bug 466379.
var dt = aEvent.dataTransfer;
if (dt.mozUserCancelled || !this._dragLeftWindow)
if (dt.mozUserCancelled || dt.dropEffect != "none")
return;
// The dropEffect == "none" scenarios:
// 1. No-op (no postion change) - "catched" by !dragLeftWindow
// 2. On the browser chrome (on element which don't handle
// text/plain or the tab type) - ditto.
// 2. Drop outside the browser window - the case that is handled
// here.
if (dt.dropEffect == "none") {
// Deatch happens only if the tab was dropped below the tabbar.
// That is applied even if it was dropped outside the browser
// window.
var bo = this.mTabContainer.mTabstrip.boxObject;
var tabbarEndScreenY = bo.screenY + bo.height;
if (aEvent.screenY > tabbarEndScreenY) {
var draggedTab = dt.mozGetDataAt(TAB_DROP_TYPE, 0);
this.replaceTabWithWindow(draggedTab);
}
@ -2288,28 +2283,6 @@
</body>
</method>
<method name="browserWindowOnDragEnter">
<parameter name="aEvent"/>
<body>
<![CDATA[
this._dragLeftWindow = false;
]]>
</body>
</method>
<method name="browserWindowOnDragLeave">
<parameter name="aEvent"/>
<body>
<![CDATA[
// If the clientX or clientY values are positive, the mouse is
// still dragged within our window. How would that happen? Either
// by the dragleave event that is dispatched right before the drop,
// or by a bubbled dragleave event
this._dragLeftWindow = aEvent.clientX < 0 || aEvent.clientY < 0;
]]>
</body>
</method>
<!-- Moves a tab to a new browser window, unless it's already the only tab
in the current window, in which case this will do nothing. -->
<method name="replaceTabWithWindow">