From 7674ea35642dee132456cd55cee5000b2de9650a Mon Sep 17 00:00:00 2001 From: Alexis Deveria Date: Tue, 28 Sep 2010 20:21:22 +0000 Subject: [PATCH] Fixed gradient import bug for webkit browsers git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1765 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 619fac14..26ab977b 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -8119,7 +8119,15 @@ var uniquifyElems = this.uniquifyElems = function(g) { // Function convertGradients // Converts gradients from userSpaceOnUse to objectBoundingBox var convertGradients = this.convertGradients = function(elem) { - $(elem).find('linearGradient, radialGradient').each(function() { + var elems = $(elem).find('linearGradient, radialGradient'); + if(!elems.length && isWebkit) { + // Bug in webkit prevents regular *Gradient selector search + elems = $(elem).find('*').filter(function() { + return (this.tagName.indexOf('Gradient') !== -1); + }); + } + + elems.each(function() { var grad = this; if($(grad).attr('gradientUnits') === 'userSpaceOnUse') { // TODO: Support more than one element with this ref by duplicating parent grad @@ -8240,6 +8248,7 @@ var convertToGroup = this.convertToGroup = function(elem) { } batchCmd.addSubCommand(new InsertElementCommand(g)); } + convertGradients(g); // recalculate dimensions on the top-level children so that unnecessary transforms