More work on Issue 382: Get rid of most updates of selectedBBoxes array

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1122 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Jeff Schiller 2009-12-29 14:26:04 +00:00
parent 3b991ed9bb
commit 9015f80156
1 changed files with 32 additions and 17 deletions

View File

@ -568,7 +568,6 @@ function BatchCommand(text) {
this.selectorMap[elem.id].locked = true;
return this.selectorMap[elem.id];
}
for (var i = 0; i < N; ++i) {
if (this.selectors[i] && !this.selectors[i].locked) {
this.selectors[i].locked = true;
@ -2047,7 +2046,7 @@ function BatchCommand(text) {
if (elem == null) break;
selectorManager.releaseSelector(elem);
selectedElements[i] = null;
selectedBBoxes[i] = null;
if (i==0) selectedBBoxes[i] = null;
}
}
call("selected", selectedElements);
@ -2081,7 +2080,9 @@ function BatchCommand(text) {
// if it's not already there, add it
if (selectedElements.indexOf(elem) == -1) {
selectedElements[j] = elem;
selectedBBoxes[j++] = this.getBBox(elem);
// only the first selectedBBoxes element is ever used in the codebase these days
if (j == 0) selectedBBoxes[j] = this.getBBox(elem);
j++;
var sel = selectorManager.requestSelector(elem);
if (selectedElements.length > 1) {
@ -2136,8 +2137,9 @@ function BatchCommand(text) {
if (elem) {
// keep the item
if (elemsToRemove.indexOf(elem) == -1) {
newSelectedBBoxes[j] = selectedBBoxes[i];
newSelectedItems[j++] = elem;
newSelectedItems[j] = elem;
if (j==0) newSelectedBBoxes[j] = selectedBBoxes[i];
j++;
}
else { // remove the item and its selector
selectorManager.releaseSelector(elem);
@ -2736,9 +2738,11 @@ function BatchCommand(text) {
for (var i = 0; i < len; ++i) {
var selected = selectedElements[i];
if (selected == null) break;
if (i==0) {
var box = canvas.getBBox(selected);
selectedBBoxes[i].x = box.x + dx;
selectedBBoxes[i].y = box.y + dy;
}
// update the dummy transform in our transform list
// to be a translate
@ -2780,7 +2784,7 @@ function BatchCommand(text) {
// - if newList contains selected, do nothing
// - if newList doesn't contain selected, remove it from selected
// - for any newList that was not in selectedElements, add it to selected
var elemsToRemove = [];
var elemsToRemove = [], elemsToAdd = [];
var newList = getIntersectionList();
var len = selectedElements.length;
for (var i = 0; i < len; ++i) {
@ -2792,10 +2796,15 @@ function BatchCommand(text) {
newList[ind] = null;
}
}
len = newList.length;
for (i = 0; i < len; ++i) { if (newList[i]) elemsToAdd.push(newList[i]); }
if (elemsToRemove.length > 0)
canvas.removeFromSelection(elemsToRemove);
canvas.addToSelection(newList);
if (elemsToAdd.length > 0)
canvas.addToSelection(elemsToAdd);
//*/
break;
case "resize":
@ -5769,6 +5778,7 @@ function BatchCommand(text) {
elem.setAttributeNS(xlinkns, "href", newValue);
}
else elem.setAttribute(attr, newValue);
if (i==0)
selectedBBoxes[i] = this.getBBox(elem);
// Use the Firefox quickClone hack for text elements with gradients or
// where other text attributes are changed.
@ -6077,6 +6087,7 @@ function BatchCommand(text) {
while (i--) {
var selected = selectedElements[i];
if (selected != null) {
if (i==0)
selectedBBoxes[i] = this.getBBox(selected);
var xform = svgroot.createSVGTransform();
@ -6084,12 +6095,16 @@ function BatchCommand(text) {
// dx and dy could be arrays
if (dx.constructor == Array) {
if (i==0) {
selectedBBoxes[i].x += dx[i];
selectedBBoxes[i].y += dy[i];
}
xform.setTranslate(dx[i],dy[i]);
} else {
if (i==0) {
selectedBBoxes[i].x += dx;
selectedBBoxes[i].y += dy;
}
xform.setTranslate(dx,dy);
}