SvgImporter: Simplify creation of clip group.

No need to move group into place in DOM, since we're returning it instead of item.
This commit is contained in:
Jürg Lehni 2012-11-10 15:05:13 -08:00
parent 6475d61c89
commit af66bccb64

View file

@ -69,13 +69,9 @@ new function() {
|| value; || value;
} }
function clipItem(item, clip) { function createClipGroup(item, clip) {
var group = new Group(clip); clip.setClipMask(true);
// Make sure group stays in the same place in the DOM as item: return new Group(clip, item);
group.moveAbove(item);
group.addChild(item);
group.setClipped(true);
return group;
} }
// Define importer functions for various SVG node types // Define importer functions for various SVG node types
@ -386,7 +382,7 @@ new function() {
// http://www.w3.org/TR/SVG/masking.html#ClipPathProperty // http://www.w3.org/TR/SVG/masking.html#ClipPathProperty
case 'clip-path': case 'clip-path':
var clipPath = getDefinition(value).clone().flatten(); var clipPath = getDefinition(value).clone().flatten();
item = clipItem(item, clipPath); item = createClipGroup(item, clipPath);
break; break;
// http://www.w3.org/TR/SVG/types.html#DataTypeTransformList // http://www.w3.org/TR/SVG/types.html#DataTypeTransformList
case 'gradientTransform': case 'gradientTransform':
@ -439,7 +435,7 @@ new function() {
rectangle.setSize(size); rectangle.setSize(size);
rectangle.setPoint(0); rectangle.setPoint(0);
// TODO: the viewbox does not always need to be clipped // 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; break;
} }
} }