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 <martijn.martijn@gmail.com> r=gavin

This commit is contained in:
asqueella@gmail.com 2007-08-21 22:02:40 -07:00
Родитель 10e21476f5
Коммит bc97475ae6
1 изменённых файлов: 112 добавлений и 113 удалений

Просмотреть файл

@ -1759,128 +1759,127 @@
<parameter name="aDragSession"/> <parameter name="aDragSession"/>
<body> <body>
<![CDATA[ <![CDATA[
if (aDragSession.sourceNode) { var tabStrip = this.mTabContainer.mTabstrip;
var tabStrip = this.mTabContainer.mTabstrip;
// autoscroll the tab strip if we drag over the scroll // autoscroll the tab strip if we drag over the scroll
// buttons, even if we aren't dragging a tab, but then // buttons, even if we aren't dragging a tab, but then
// return to avoid drawing the drop indicator // return to avoid drawing the drop indicator
var pixelsToScroll = 0; var pixelsToScroll = 0;
var targetAnonid = aEvent.originalTarget.getAttribute("anonid"); var targetAnonid = aEvent.originalTarget.getAttribute("anonid");
if (targetAnonid == "scrollbutton-up") { if (targetAnonid == "scrollbutton-up") {
pixelsToScroll = tabStrip.scrollIncrement * -1; pixelsToScroll = tabStrip.scrollIncrement * -1;
tabStrip.scrollByPixels(pixelsToScroll); tabStrip.scrollByPixels(pixelsToScroll);
} }
else if (targetAnonid == "scrollbutton-down" || else if (targetAnonid == "scrollbutton-down" ||
(targetAnonid == "alltabs-button" && (targetAnonid == "alltabs-button" &&
this.mTabContainer.getAttribute("overflow") == "true")) { this.mTabContainer.getAttribute("overflow") == "true")) {
pixelsToScroll = tabStrip.scrollIncrement; pixelsToScroll = tabStrip.scrollIncrement;
tabStrip.scrollByPixels(pixelsToScroll); tabStrip.scrollByPixels(pixelsToScroll);
} }
var isTabDrag = (aDragSession.sourceNode.parentNode == this.mTabContainer); var isTabDrag = (aDragSession.sourceNode &&
if (!isTabDrag && aEvent.target.localName == "tab") { aDragSession.sourceNode.parentNode == this.mTabContainer);
if (!this.mDragTime) if (!isTabDrag && aEvent.target.localName == "tab") {
this.mDragTime = Date.now(); if (!this.mDragTime)
if (Date.now() >= this.mDragTime + this.mDragOverDelay) this.mDragTime = Date.now();
this.mTabContainer.selectedItem = aEvent.target; if (Date.now() >= this.mDragTime + this.mDragOverDelay)
return; this.mTabContainer.selectedItem = aEvent.target;
} return;
}
var newIndex = this.getNewIndex(aEvent); var newIndex = this.getNewIndex(aEvent);
var ib = this.mTabDropIndicatorBar; var ib = this.mTabDropIndicatorBar;
var ind = ib.firstChild; var ind = ib.firstChild;
ib.setAttribute('dragging', ib.setAttribute('dragging',
aDragSession.canDrop ? 'true' : 'false'); aDragSession.canDrop ? 'true' : 'false');
var tabStripBoxObject = tabStrip.scrollBoxObject; var tabStripBoxObject = tabStrip.scrollBoxObject;
var halfIndWidth = Math.floor((ind.boxObject.width + 1) / 2); var halfIndWidth = Math.floor((ind.boxObject.width + 1) / 2);
if (window.getComputedStyle(this.parentNode, null) if (window.getComputedStyle(this.parentNode, null)
.direction == "ltr") { .direction == "ltr") {
var newMarginLeft; var newMarginLeft;
var minMarginLeft = tabStripBoxObject.x - halfIndWidth - var minMarginLeft = tabStripBoxObject.x - halfIndWidth -
ib.boxObject.x; ib.boxObject.x;
// make sure we don't place the tab drop indicator past the // make sure we don't place the tab drop indicator past the
// edge, or the containing box will flex and stretch // edge, or the containing box will flex and stretch
// the tab drop indicator bar, which will flex the url bar. // the tab drop indicator bar, which will flex the url bar.
// XXX todo // XXX todo
// just use first value if you can figure out how to get // 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 to crop instead of flex and stretch
// the tab drop indicator bar. // the tab drop indicator bar.
var maxMarginLeft = Math.min( var maxMarginLeft = Math.min(
(minMarginLeft + tabStripBoxObject.width), (minMarginLeft + tabStripBoxObject.width),
(ib.boxObject.x + ib.boxObject.width - ind.boxObject.width)); (ib.boxObject.x + ib.boxObject.width - ind.boxObject.width));
// if we are scrolling, put the drop indicator at the edge // if we are scrolling, put the drop indicator at the edge
// so that it doesn't jump while scrolling // so that it doesn't jump while scrolling
if (pixelsToScroll > 0) if (pixelsToScroll > 0)
newMarginLeft = maxMarginLeft; newMarginLeft = maxMarginLeft;
else if (pixelsToScroll < 0) else if (pixelsToScroll < 0)
newMarginLeft = minMarginLeft; newMarginLeft = minMarginLeft;
else { else {
if (newIndex == this.mTabs.length) { if (newIndex == this.mTabs.length) {
newMarginLeft = this.mTabs[newIndex-1].boxObject.screenX + newMarginLeft = this.mTabs[newIndex-1].boxObject.screenX +
this.mTabs[newIndex-1].boxObject.width - this.mTabs[newIndex-1].boxObject.width -
this.boxObject.screenX - halfIndWidth; 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';
} else { } else {
var newMarginRight; newMarginLeft = this.mTabs[newIndex].boxObject.screenX -
var minMarginRight = tabStripBoxObject.x - halfIndWidth - this.boxObject.screenX - 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';
} }
// 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';
} }
]]> ]]>
</body> </body>