fixed getRefElem and smoothControlPoints leaking variables

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2402 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Bruno Heridet 2013-02-15 23:05:23 +00:00
parent d5dca6b4a3
commit 7a36f90eb6
5 changed files with 65 additions and 81 deletions

View File

@ -356,7 +356,7 @@ svgedit.path.getSegSelector = function(seg, update) {
// //
// Returns: // Returns:
// Array of two "smoothed" point objects // Array of two "smoothed" point objects
svgedit.path.smoothControlPoints = this.smoothControlPoints = function(ct1, ct2, pt) { svgedit.path.smoothControlPoints = function(ct1, ct2, pt) {
// each point must not be the origin // each point must not be the origin
var x1 = ct1.x - pt.x, var x1 = ct1.x - pt.x,
y1 = ct1.y - pt.y, y1 = ct1.y - pt.y,

View File

@ -723,7 +723,7 @@
// Call when part of element is in process of changing, generally // Call when part of element is in process of changing, generally
// on mousemove actions like rotate, move, etc. // on mousemove actions like rotate, move, etc.
var elementTransition = function(window,elems) { var elementTransition = function(window, elems) {
var mode = svgCanvas.getMode(); var mode = svgCanvas.getMode();
var elem = elems[0]; var elem = elems[0];
@ -1728,7 +1728,7 @@
// Set up editor background functionality // Set up editor background functionality
// TODO add checkerboard as "pattern" // TODO add checkerboard as "pattern"
var color_blocks = ['#FFF','#888','#000']; // ,'url(data:image/gif;base64,R0lGODlhEAAQAIAAAP%2F%2F%2F9bW1iH5BAAAAAAALAAAAAAQABAAAAIfjG%2Bgq4jM3IFLJgpswNly%2FXkcBpIiVaInlLJr9FZWAQA7)']; var color_blocks = ['#FFF', '#888', '#000']; // ,'url(data:image/gif;base64,R0lGODlhEAAQAIAAAP%2F%2F%2F9bW1iH5BAAAAAAALAAAAAAQABAAAAIfjG%2Bgq4jM3IFLJgpswNly%2FXkcBpIiVaInlLJr9FZWAQA7)'];
var str = ''; var str = '';
$.each(color_blocks, function() { $.each(color_blocks, function() {
str += '<div class="color_block" style="background-color:' + this + ';"></div>'; str += '<div class="color_block" style="background-color:' + this + ';"></div>';
@ -1842,7 +1842,7 @@
var promptMoveLayerOnce = false; var promptMoveLayerOnce = false;
$('#selLayerNames').change(function(){ $('#selLayerNames').change(function(){
var destLayer = this.options[this.selectedIndex].value; var destLayer = this.options[this.selectedIndex].value;
var confirm_str = uiStrings.notification.QmoveElemsToLayer.replace('%s',destLayer); var confirmStr = uiStrings.notification.QmoveElemsToLayer.replace('%s', destLayer);
var moveToLayer = function(ok) { var moveToLayer = function(ok) {
if (!ok) return; if (!ok) return;
promptMoveLayerOnce = true; promptMoveLayerOnce = true;
@ -1854,7 +1854,7 @@
if (promptMoveLayerOnce) { if (promptMoveLayerOnce) {
moveToLayer(true); moveToLayer(true);
} else { } else {
$.confirm(confirm_str, moveToLayer); $.confirm(confirmStr, moveToLayer);
} }
} }
}); });

View File

@ -71,7 +71,6 @@ if (window.opera) {
obj[aname] = attr; obj[aname] = attr;
} }
return obj; return obj;
} else if (typeof key === "object") { } else if (typeof key === "object") {
// Setting attributes form object // Setting attributes form object
for (var v in key) { for (var v in key) {
@ -91,7 +90,6 @@ if (window.opera) {
} }
return this; return this;
}; };
}()); }());
// Class: SvgCanvas // Class: SvgCanvas
@ -345,7 +343,6 @@ canvas.undoMgr = new svgedit.history.UndoManager({
var elems = cmd.elements(); var elems = cmd.elements();
canvas.pathActions.clear(); canvas.pathActions.clear();
call("changed", elems); call("changed", elems);
var cmdType = cmd.type(); var cmdType = cmd.type();
var isApply = (eventType == EventTypes.AFTER_APPLY); var isApply = (eventType == EventTypes.AFTER_APPLY);
if (cmdType == MoveElementCommand.type()) { if (cmdType == MoveElementCommand.type()) {
@ -363,7 +360,6 @@ canvas.undoMgr = new svgedit.history.UndoManager({
} else { } else {
if (!isApply) restoreRefElems(cmd.elem); if (!isApply) restoreRefElems(cmd.elem);
} }
if (cmd.elem.tagName === 'use') { if (cmd.elem.tagName === 'use') {
setUseData(cmd.elem); setUseData(cmd.elem);
} }
@ -668,9 +664,7 @@ getStrokedBBox = this.getStrokedBBox = function(elems) {
svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(elem))) { svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(elem))) {
// Accurate way to get BBox of rotated element in Firefox: // Accurate way to get BBox of rotated element in Firefox:
// Put element in group and get its BBox // Put element in group and get its BBox
var good_bb = false; var good_bb = false;
// Get the BBox from the raw path for these elements // Get the BBox from the raw path for these elements
var elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon']; var elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon'];
if (elemNames.indexOf(elem.tagName) >= 0) { if (elemNames.indexOf(elem.tagName) >= 0) {
@ -1369,9 +1363,7 @@ var remapElement = this.remapElement = function(selected, changes, m) {
// ty - The translation's y value // ty - The translation's y value
var updateClipPath = function(attr, tx, ty) { var updateClipPath = function(attr, tx, ty) {
var path = getRefElem(attr).firstChild; var path = getRefElem(attr).firstChild;
var cp_xform = svgedit.transformlist.getTransformList(path); var cp_xform = svgedit.transformlist.getTransformList(path);
var newxlate = svgroot.createSVGTransform(); var newxlate = svgroot.createSVGTransform();
newxlate.setTranslate(tx, ty); newxlate.setTranslate(tx, ty);

View File

@ -316,8 +316,7 @@ svgedit.utilities.findDefs = function() {
var defs = svgElement.getElementsByTagNameNS(SVGNS, 'defs'); var defs = svgElement.getElementsByTagNameNS(SVGNS, 'defs');
if (defs.length > 0) { if (defs.length > 0) {
defs = defs[0]; defs = defs[0];
} } else {
else {
defs = svgElement.ownerDocument.createElementNS(SVGNS, 'defs'); defs = svgElement.ownerDocument.createElementNS(SVGNS, 'defs');
if (svgElement.firstChild) { if (svgElement.firstChild) {
// first child is a comment, so call nextSibling // first child is a comment, so call nextSibling
@ -386,7 +385,6 @@ svgedit.utilities.getPathBBox = function(path) {
} }
continue; continue;
} }
var b2ac = Math.pow(b,2) - 4 * c * a; var b2ac = Math.pow(b,2) - 4 * c * a;
if(b2ac < 0) continue; if(b2ac < 0) continue;
var t1 = (-b + Math.sqrt(b2ac))/(2 * a); var t1 = (-b + Math.sqrt(b2ac))/(2 * a);
@ -497,7 +495,6 @@ svgedit.utilities.getBBox = function(elem) {
if(elname === 'use') { if(elname === 'use') {
ret = groupBBFix(selected, true); ret = groupBBFix(selected, true);
} }
if(elname === 'use' || ( elname === 'foreignObject' && svgedit.browser.isWebkit() ) ) { if(elname === 'use' || ( elname === 'foreignObject' && svgedit.browser.isWebkit() ) ) {
if(!ret) ret = selected.getBBox(); if(!ret) ret = selected.getBBox();
// This is resolved in later versions of webkit, perhaps we should // This is resolved in later versions of webkit, perhaps we should
@ -528,7 +525,6 @@ svgedit.utilities.getBBox = function(elem) {
} }
} }
} }
if(ret) { if(ret) {
ret = svgedit.utilities.bboxToObj(ret); ret = svgedit.utilities.bboxToObj(ret);
} }
@ -566,7 +562,7 @@ svgedit.utilities.getRotationAngle = function(elem, to_rad) {
// //
// Parameters: // Parameters:
// attrVal - The attribute value as a string // attrVal - The attribute value as a string
svgedit.utilities.getRefElem = this.getRefElem = function(attrVal) { svgedit.utilities.getRefElem = function(attrVal) {
return svgedit.utilities.getElem(svgedit.utilities.getUrlFromAttr(attrVal).substr(1)); return svgedit.utilities.getElem(svgedit.utilities.getUrlFromAttr(attrVal).substr(1));
}; };
@ -622,9 +618,7 @@ svgedit.utilities.assignAttributes = function(node, attrs, suspendLength, unitCh
} else { } else {
svgedit.units.setUnitAttr(node, i, attrs[i]); svgedit.units.setUnitAttr(node, i, attrs[i]);
} }
} }
if (!svgedit.browser.isOpera()) svgroot_.unsuspendRedraw(handle); if (!svgedit.browser.isOpera()) svgroot_.unsuspendRedraw(handle);
}; };
@ -659,5 +653,4 @@ svgedit.utilities.cleanupElement = function(element) {
svgroot_.unsuspendRedraw(handle); svgroot_.unsuspendRedraw(handle);
}; };
})(); })();

View File

@ -225,17 +225,16 @@ svgedit.units.convertToNum = function(attr, val) {
if (wAttrs.indexOf(attr) >= 0) { if (wAttrs.indexOf(attr) >= 0) {
return num * width; return num * width;
} else if (hAttrs.indexOf(attr) >= 0) { }
if (hAttrs.indexOf(attr) >= 0) {
return num * height; return num * height;
} else { }
return num * Math.sqrt((width*width) + (height*height))/Math.sqrt(2); return num * Math.sqrt((width*width) + (height*height))/Math.sqrt(2);
} }
} else {
var unit = val.substr(-2); var unit = val.substr(-2);
var num = val.substr(0, val.length-2); var num = val.substr(0, val.length-2);
// Note that this multiplication turns the string into a number // Note that this multiplication turns the string into a number
return num * typeMap_[unit]; return num * typeMap_[unit];
}
}; };
// Function: svgedit.units.isValidUnit // Function: svgedit.units.isValidUnit