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

git-svn-id: svn://10.0.0.236/trunk@251900 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
gavin%gavinsharp.com 2008-05-28 19:04:30 +00:00
parent efe69d9e13
commit 0c687fc385

View File

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