From af66bccb64e481af8e0291eb4ed10304763f6721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 10 Nov 2012 15:05:13 -0800 Subject: [PATCH] SvgImporter: Simplify creation of clip group. No need to move group into place in DOM, since we're returning it instead of item. --- src/svg/SvgImport.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/svg/SvgImport.js b/src/svg/SvgImport.js index dd399a12..15612062 100644 --- a/src/svg/SvgImport.js +++ b/src/svg/SvgImport.js @@ -69,13 +69,9 @@ new function() { || value; } - function clipItem(item, clip) { - var group = new Group(clip); - // Make sure group stays in the same place in the DOM as item: - group.moveAbove(item); - group.addChild(item); - group.setClipped(true); - return group; + function createClipGroup(item, clip) { + clip.setClipMask(true); + return new Group(clip, item); } // Define importer functions for various SVG node types @@ -386,7 +382,7 @@ new function() { // http://www.w3.org/TR/SVG/masking.html#ClipPathProperty case 'clip-path': var clipPath = getDefinition(value).clone().flatten(); - item = clipItem(item, clipPath); + item = createClipGroup(item, clipPath); break; // http://www.w3.org/TR/SVG/types.html#DataTypeTransformList case 'gradientTransform': @@ -439,7 +435,7 @@ new function() { rectangle.setSize(size); rectangle.setPoint(0); // TODO: the viewbox does not always need to be clipped - item = clipItem(item, new Path.Rectangle(rectangle)); + item = createClipGroup(item, new Path.Rectangle(rectangle)); break; } }