From bc97475ae6a37563907d3e279624501e956fc72b Mon Sep 17 00:00:00 2001 From: "asqueella@gmail.com" Date: Tue, 21 Aug 2007 22:02:40 -0700 Subject: [PATCH] Bug 356819 - drag&drop to a background tab that's scrolled off the tabstrip not functional if the drag source is another application p=Martijn Wargers r=gavin --- browser/base/content/tabbrowser.xml | 225 ++++++++++++++-------------- 1 file changed, 112 insertions(+), 113 deletions(-) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 77b49126533..958f1739885 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -1759,128 +1759,127 @@ = this.mDragTime + this.mDragOverDelay) - this.mTabContainer.selectedItem = aEvent.target; - return; - } + var isTabDrag = (aDragSession.sourceNode && + aDragSession.sourceNode.parentNode == this.mTabContainer); + if (!isTabDrag && aEvent.target.localName == "tab") { + if (!this.mDragTime) + this.mDragTime = Date.now(); + if (Date.now() >= this.mDragTime + this.mDragOverDelay) + this.mTabContainer.selectedItem = aEvent.target; + return; + } - var newIndex = this.getNewIndex(aEvent); + var newIndex = this.getNewIndex(aEvent); - var ib = this.mTabDropIndicatorBar; - var ind = ib.firstChild; - ib.setAttribute('dragging', - aDragSession.canDrop ? 'true' : 'false'); + var ib = this.mTabDropIndicatorBar; + var ind = ib.firstChild; + ib.setAttribute('dragging', + aDragSession.canDrop ? 'true' : 'false'); - var tabStripBoxObject = tabStrip.scrollBoxObject; - var halfIndWidth = Math.floor((ind.boxObject.width + 1) / 2); - if (window.getComputedStyle(this.parentNode, null) - .direction == "ltr") { - var newMarginLeft; - var minMarginLeft = tabStripBoxObject.x - halfIndWidth - - ib.boxObject.x; - // make sure we don't place the tab drop indicator past the - // edge, or the containing box will flex and stretch - // the tab drop indicator bar, which will flex the url bar. - // XXX todo - // just use first value if you can figure out how to get - // the tab drop indicator to crop instead of flex and stretch - // the tab drop indicator bar. - var maxMarginLeft = Math.min( - (minMarginLeft + tabStripBoxObject.width), - (ib.boxObject.x + ib.boxObject.width - ind.boxObject.width)); + var tabStripBoxObject = tabStrip.scrollBoxObject; + var halfIndWidth = Math.floor((ind.boxObject.width + 1) / 2); + if (window.getComputedStyle(this.parentNode, null) + .direction == "ltr") { + var newMarginLeft; + var minMarginLeft = tabStripBoxObject.x - halfIndWidth - + ib.boxObject.x; + // make sure we don't place the tab drop indicator past the + // edge, or the containing box will flex and stretch + // the tab drop indicator bar, which will flex the url bar. + // XXX todo + // just use first value if you can figure out how to get + // the tab drop indicator to crop instead of flex and stretch + // the tab drop indicator bar. + var maxMarginLeft = Math.min( + (minMarginLeft + tabStripBoxObject.width), + (ib.boxObject.x + ib.boxObject.width - ind.boxObject.width)); - // if we are scrolling, put the drop indicator at the edge - // so that it doesn't jump while scrolling - if (pixelsToScroll > 0) - newMarginLeft = maxMarginLeft; - else if (pixelsToScroll < 0) - newMarginLeft = minMarginLeft; - else { - if (newIndex == this.mTabs.length) { - newMarginLeft = this.mTabs[newIndex-1].boxObject.screenX + - this.mTabs[newIndex-1].boxObject.width - - this.boxObject.screenX - halfIndWidth; - } else { - newMarginLeft = this.mTabs[newIndex].boxObject.screenX - - this.boxObject.screenX - halfIndWidth; - } - - // ensure we never place the drop indicator beyond - // our limits - if (newMarginLeft < minMarginLeft) - newMarginLeft = minMarginLeft; - else if (newMarginLeft > maxMarginLeft) - newMarginLeft = maxMarginLeft; - } - ind.style.marginLeft = newMarginLeft + 'px'; + // if we are scrolling, put the drop indicator at the edge + // so that it doesn't jump while scrolling + if (pixelsToScroll > 0) + newMarginLeft = maxMarginLeft; + else if (pixelsToScroll < 0) + newMarginLeft = minMarginLeft; + else { + if (newIndex == this.mTabs.length) { + newMarginLeft = this.mTabs[newIndex-1].boxObject.screenX + + this.mTabs[newIndex-1].boxObject.width - + this.boxObject.screenX - halfIndWidth; } else { - var newMarginRight; - var minMarginRight = tabStripBoxObject.x - halfIndWidth - - ib.boxObject.x; - // make sure we don't place the tab drop indicator past the - // edge, or the containing box will flex and stretch - // the tab drop indicator bar, which will flex the url bar. - // XXX todo - // just use first value if you can figure out how to get - // the tab drop indicator to crop instead of flex and stretch - // the tab drop indicator bar. - var maxMarginRight = Math.min( - (minMarginRight + tabStripBoxObject.width), - (ib.boxObject.x + ib.boxObject.width - ind.boxObject.width)); - - // if we are scrolling, put the drop indicator at the edge - // so that it doesn't jump while scrolling - if (pixelsToScroll > 0) - newMarginRight = maxMarginRight; - else if (pixelsToScroll < 0) - newMarginRight = minMarginRight; - else { - if (newIndex == this.mTabs.length) { - newMarginRight = this.boxObject.width + - this.boxObject.screenX - - this.mTabs[newIndex-1].boxObject.screenX - - halfIndWidth; - } else { - newMarginRight = this.boxObject.width + - this.boxObject.screenX - - this.mTabs[newIndex].boxObject.screenX - - this.mTabs[newIndex].boxObject.width - - halfIndWidth; - } - - // ensure we never place the drop indicator beyond - // our limits - if (newMarginRight < minMarginRight) - newMarginRight = minMarginRight; - else if (newMarginRight > maxMarginRight) - newMarginRight = maxMarginRight; - } - ind.style.marginRight = newMarginRight + 'px'; + newMarginLeft = this.mTabs[newIndex].boxObject.screenX - + this.boxObject.screenX - halfIndWidth; } + + // ensure we never place the drop indicator beyond + // our limits + if (newMarginLeft < minMarginLeft) + newMarginLeft = minMarginLeft; + else if (newMarginLeft > maxMarginLeft) + newMarginLeft = maxMarginLeft; + } + ind.style.marginLeft = newMarginLeft + 'px'; + } else { + var newMarginRight; + var minMarginRight = tabStripBoxObject.x - halfIndWidth - + ib.boxObject.x; + // make sure we don't place the tab drop indicator past the + // edge, or the containing box will flex and stretch + // the tab drop indicator bar, which will flex the url bar. + // XXX todo + // just use first value if you can figure out how to get + // the tab drop indicator to crop instead of flex and stretch + // the tab drop indicator bar. + var maxMarginRight = Math.min( + (minMarginRight + tabStripBoxObject.width), + (ib.boxObject.x + ib.boxObject.width - ind.boxObject.width)); + + // if we are scrolling, put the drop indicator at the edge + // so that it doesn't jump while scrolling + if (pixelsToScroll > 0) + newMarginRight = maxMarginRight; + else if (pixelsToScroll < 0) + newMarginRight = minMarginRight; + else { + if (newIndex == this.mTabs.length) { + newMarginRight = this.boxObject.width + + this.boxObject.screenX - + this.mTabs[newIndex-1].boxObject.screenX - + halfIndWidth; + } else { + newMarginRight = this.boxObject.width + + this.boxObject.screenX - + this.mTabs[newIndex].boxObject.screenX - + this.mTabs[newIndex].boxObject.width - + halfIndWidth; + } + + // ensure we never place the drop indicator beyond + // our limits + if (newMarginRight < minMarginRight) + newMarginRight = minMarginRight; + else if (newMarginRight > maxMarginRight) + newMarginRight = maxMarginRight; + } + ind.style.marginRight = newMarginRight + 'px'; } ]]>