Changed getIntersectionList for minor performance improvement
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@478 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
5a62f3b209
commit
ecdcbf7d9b
|
@ -569,6 +569,8 @@ function SvgCanvas(c)
|
||||||
var undoStackPointer = 0;
|
var undoStackPointer = 0;
|
||||||
var undoStack = [];
|
var undoStack = [];
|
||||||
|
|
||||||
|
var curBBoxes = [];
|
||||||
|
|
||||||
// This method sends back an array or a NodeList full of elements that
|
// This method sends back an array or a NodeList full of elements that
|
||||||
// intersect the multi-select rubber-band-box.
|
// intersect the multi-select rubber-band-box.
|
||||||
//
|
//
|
||||||
|
@ -581,29 +583,38 @@ function SvgCanvas(c)
|
||||||
var getIntersectionList = function(rect) {
|
var getIntersectionList = function(rect) {
|
||||||
if (rubberBox == null) { return null; }
|
if (rubberBox == null) { return null; }
|
||||||
|
|
||||||
|
if(!curBBoxes.length) {
|
||||||
|
// Cache all bboxes
|
||||||
|
|
||||||
|
var nodes = svgroot.childNodes;
|
||||||
|
var i = svgroot.childNodes.length;
|
||||||
|
|
||||||
|
while (i--) {
|
||||||
|
// need to do this since the defs has no bbox and causes an exception
|
||||||
|
// to be thrown in Mozilla
|
||||||
|
try {
|
||||||
|
if (nodes[i].id != "selectorParentGroup" && canvas.getBBox(nodes[i])) {
|
||||||
|
curBBoxes.push({'elem':nodes[i], 'bbox':canvas.getBBox(nodes[i])});
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
// do nothing, this element did not have a bbox
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var resultList = null;
|
var resultList = null;
|
||||||
try {
|
try {
|
||||||
resultList = svgroot.getIntersectionList(rect, null);
|
resultList = svgroot.getIntersectionList(rect, null);
|
||||||
} catch(e) { }
|
} catch(e) { }
|
||||||
|
|
||||||
if (resultList == null || typeof(resultList.item) != "function")
|
if (resultList == null || typeof(resultList.item) != "function") {
|
||||||
{
|
|
||||||
resultList = [];
|
resultList = [];
|
||||||
|
|
||||||
var rubberBBox = rubberBox.getBBox();
|
var rubberBBox = rubberBox.getBBox();
|
||||||
var nodes = svgroot.childNodes;
|
var i = curBBoxes.length;
|
||||||
var i = svgroot.childNodes.length;
|
|
||||||
while (i--) {
|
while (i--) {
|
||||||
// need to do this since the defs has no bbox and causes an exception
|
if (Utils.rectsIntersect(rubberBBox, curBBoxes[i].bbox)) {
|
||||||
// to be thrown in Mozilla
|
resultList.push(curBBoxes[i].elem);
|
||||||
try {
|
|
||||||
if (nodes[i].id != "selectorParentGroup" &&
|
|
||||||
Utils.rectsIntersect(rubberBBox, canvas.getBBox(nodes[i])))
|
|
||||||
{
|
|
||||||
resultList.push(nodes[i]);
|
|
||||||
}
|
|
||||||
} catch(e) {
|
|
||||||
// do nothing, this element did not have a bbox
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1765,6 +1776,7 @@ function SvgCanvas(c)
|
||||||
case "multiselect":
|
case "multiselect":
|
||||||
if (rubberBox != null) {
|
if (rubberBox != null) {
|
||||||
rubberBox.setAttribute("display", "none");
|
rubberBox.setAttribute("display", "none");
|
||||||
|
curBBoxes = [];
|
||||||
}
|
}
|
||||||
current_mode = "select";
|
current_mode = "select";
|
||||||
case "select":
|
case "select":
|
||||||
|
|
Loading…
Reference in New Issue