Fix rest of Issue 471: upon loading/setting the SVG, do a depth-first recalculateDimensions() on all nodes
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1380 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
9915407382
commit
8d4861d546
|
@ -1923,7 +1923,7 @@ function BatchCommand(text) {
|
|||
}
|
||||
|
||||
// if this element had no transforms, we are done
|
||||
if (tlist.numberOfItems == 0) {
|
||||
if (!tlist || tlist.numberOfItems == 0) {
|
||||
selected.removeAttribute("transform");
|
||||
return null;
|
||||
}
|
||||
|
@ -2001,6 +2001,8 @@ function BatchCommand(text) {
|
|||
m = svgroot.createSVGMatrix();
|
||||
|
||||
// temporarily strip off the rotate and save the old center
|
||||
var gangle = canvas.getRotationAngle(selected);
|
||||
if (gangle) {
|
||||
var a = gangle * Math.PI / 180;
|
||||
if ( Math.abs(a) > (1.0e-10) ) {
|
||||
var s = Math.sin(a)/(1 - Math.cos(a));
|
||||
|
@ -2019,7 +2021,7 @@ function BatchCommand(text) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
var tx = 0, ty = 0,
|
||||
operation = 0,
|
||||
N = tlist.numberOfItems;
|
||||
|
@ -2234,7 +2236,7 @@ function BatchCommand(text) {
|
|||
m = svgroot.createSVGMatrix(),
|
||||
// temporarily strip off the rotate and save the old center
|
||||
angle = canvas.getRotationAngle(selected);
|
||||
|
||||
if (angle) {
|
||||
var a = angle * Math.PI / 180;
|
||||
if ( Math.abs(a) > (1.0e-10) ) {
|
||||
var s = Math.sin(a)/(1 - Math.cos(a));
|
||||
|
@ -2253,6 +2255,7 @@ function BatchCommand(text) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2 = translate, 3 = scale, 4 = rotate, 1 = matrix imposition
|
||||
var operation = 0;
|
||||
|
@ -5555,6 +5558,20 @@ function BatchCommand(text) {
|
|||
canvas.fixOperaXML(svgcontent, newDoc.documentElement);
|
||||
}
|
||||
|
||||
// recalculate dimensions on the top-level children so that unnecessary transforms
|
||||
// are removed
|
||||
var deepdive = function(node) {
|
||||
if (node.nodeType == 1) {
|
||||
var children = node.children;
|
||||
var i = children.length;
|
||||
while (i--) { deepdive(children.item(i)); }
|
||||
try {
|
||||
recalculateDimensions(node);
|
||||
} catch(e) { console.log(e); }
|
||||
}
|
||||
}
|
||||
deepdive(svgcontent);
|
||||
|
||||
var content = $(svgcontent);
|
||||
|
||||
// determine proper size
|
||||
|
|
Loading…
Reference in New Issue