Bug 434749: [RTL] Drag&Drop bookmarks in Firefox 3 not usable, patch by Asaf Romano <mano@mozilla.com>, r=mconnor, a=shaver

This commit is contained in:
gavin@gavinsharp.com 2008-05-28 12:04:30 -07:00
parent b1f1aa6313
commit 3fc67fca04

View File

@ -762,6 +762,10 @@
if (!PlacesUtils.nodeIsFolder(result.root))
return null;
var isRTL = document.defaultView
.getComputedStyle(this._self.parentNode, "")
.direction == "rtl";
var dropPoint = { ip: null, beforeIndex: null, folderNode: null };
// Loop through all the nodes to see which one this should
// get dropped in/next to
@ -770,9 +774,11 @@
if (PlacesUtils.nodeIsFolder(xulNode.node) &&
!PlacesUtils.nodeIsReadOnly(xulNode.node)) {
// This is a folder. If the mouse is in the left 25% of the
// node, drop to the left of the folder. If it's in the middle
// 50%, drop into the folder. If it's past that, drop to the right.
if (event.clientX < xulNode.boxObject.x + (xulNode.boxObject.width * 0.25)) {
// node (or 25% of the right, in RTL UI), drop before the folder.
// If it's in the middle 50%, drop into the folder. If it's past
// that, drop after.
if ((isRTL && event.clientX > xulNode.boxObject.x + (xulNode.boxObject.width * 0.75)) ||
(!isRTL && event.clientX < xulNode.boxObject.x + (xulNode.boxObject.width * 0.25))) {
// Drop to the left of this folder.
dropPoint.ip =
new InsertionPoint(PlacesUtils.getConcreteItemId(result.root),
@ -780,7 +786,8 @@
dropPoint.beforeIndex = i;
return dropPoint;
}
else if (event.clientX < xulNode.boxObject.x + (xulNode.boxObject.width * 0.75)) {
else if ((isRTL && event.clientX > xulNode.boxObject.x + (xulNode.boxObject.width * 0.25)) ||
(!isRTL && event.clientX < xulNode.boxObject.x + (xulNode.boxObject.width * 0.75))) {
// Drop inside this folder.
dropPoint.ip =
new InsertionPoint(PlacesUtils.getConcreteItemId(xulNode.node),
@ -791,10 +798,12 @@
}
}
else {
// This is a non-folder node. If the mouse is left of the middle,
// drop to the left of the folder. If it's right, drop to the right.
if (event.clientX < xulNode.boxObject.x + (xulNode.boxObject.width / 2)) {
// Drop to the left of this bookmark.
// This is a non-folder node. If the mouse is left (or right, in
// RTL UI) of the middle, drop before the folder. Otehrwise,
// we'll drop after
if ((isRTL && event.clientX > xulNode.boxObject.x + (xulNode.boxObject.width / 2)) ||
(!isRTL && event.clientX < xulNode.boxObject.x + (xulNode.boxObject.width / 2))) {
// Drop before this bookmark.
dropPoint.ip =
new InsertionPoint(PlacesUtils.getConcreteItemId(result.root),
i, -1);
@ -803,7 +812,7 @@
}
}
}
// Should drop to the right of the last node.
// Should drop after the last node.
dropPoint.ip =
new InsertionPoint(PlacesUtils.getConcreteItemId(result.root),
-1, 1);
@ -893,12 +902,19 @@
}
else {
halfInd = Math.floor(halfInd);
if (dropPoint.beforeIndex == -1 || !this._self.childNodes.length)
ind.style.marginRight = '0px';
else
ind.style.marginRight = (this._self.childNodes[this._self.childNodes.length - 1].boxObject.x +
this._self.childNodes[this._self.childNodes.length - 1].boxObject.width) -
(this._self.childNodes[dropPoint.beforeIndex].boxObject.x) - halfInd + 'px';
if (this._self.childNodes.length == 0)
ind.style.marginRight = this._self.boxObject.width + 'px';
else if (dropPoint.beforeIndex == -1) {
ind.style.marginRight = this._self.boxObject.width -
(this._self.childNodes[this._self.childNodes.length - 1].boxObject.x +
halfInd) +'px';
}
else {
ind.style.marginRight = this._self.boxObject.width -
(this._self.childNodes[dropPoint.beforeIndex].boxObject.x +
this._self.childNodes[dropPoint.beforeIndex].boxObject.width -
this._self.boxObject.x + halfInd) + 'px';
}
}
// Clear out old folder information
this._clearOverFolder();