From 7846230af9cfed06af0cf218ea1a10334204e7c4 Mon Sep 17 00:00:00 2001 From: Mark MacKay Date: Tue, 13 Nov 2012 10:37:24 +0000 Subject: [PATCH] Adding vectorEffect: non-scaling-stroke workaround to all of Webkit, since this bug has propagated to Safari 6 and Mobile Safari on iOS6 git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2154 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index db3d9648..9f252b02 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -2516,26 +2516,28 @@ var getMouseTarget = this.getMouseTarget = function(evt) { tlist.appendItem(svgroot.createSVGTransform()); if(svgedit.browser.supportsNonScalingStroke()) { - //Handle crash for newer Chrome: https://code.google.com/p/svg-edit/issues/detail?id=904 - //Chromium issue: https://code.google.com/p/chromium/issues/detail?id=114625 - // TODO: Remove this workaround (all isChrome blocks) once vendor fixes the issue - var isChrome = svgedit.browser.isChrome(); - if(isChrome) { + // Handle crash for newer Chrome and Safari 6 (Mobile and Desktop): + // https://code.google.com/p/svg-edit/issues/detail?id=904 + // Chromium issue: https://code.google.com/p/chromium/issues/detail?id=114625 + // TODO: Remove this workaround once vendor fixes the issue + var isWebkit = svgedit.browser.isWebkit(); + + if(isWebkit) { var delayedStroke = function(ele) { var _stroke = ele.getAttributeNS(null, 'stroke'); ele.removeAttributeNS(null, 'stroke'); //Re-apply stroke after delay. Anything higher than 1 seems to cause flicker - setTimeout(function() { ele.setAttributeNS(null, 'stroke', _stroke) }, 1); + setTimeout(function() { ele.setAttributeNS(null, 'stroke', _stroke) }, 0); } } mouse_target.style.vectorEffect = 'non-scaling-stroke'; - if(isChrome) delayedStroke(mouse_target); + if(isWebkit) delayedStroke(mouse_target); var all = mouse_target.getElementsByTagName('*'), len = all.length; for(var i = 0; i < len; i++) { all[i].style.vectorEffect = 'non-scaling-stroke'; - if(isChrome) delayedStroke(all[i]); + if(isWebkit) delayedStroke(all[i]); } } }