Clip can produce invalid svg (clip-path shouldn't contain a group)

Steps to reproduce:

  • Open Inkscape
  • Create two overlapping objects
  • Group the top one (with itself)
  • Select both and set Clip
  • Now the clip-path (see the defs) has a group in it.

What happened?

  • The clip-path (see the defs) has a group in it
  • The clipped object is not visible in firefox or resvg (qt-backend, cairo-backend) drawing.svg

What should have happened?

Group is disallowed or the group is copied into the clip-path then converted to a valid form (once there, if the clippath is kept after clipping, it should remain grouped)

https://www.w3.org/TR/SVG11/masking.html#EstablishingANewClippingPath

A ‘clipPath’ element can contain ‘path’ elements, ‘text’ elements, basic shapes (such as ‘circle’) or a ‘use’ element. If a ‘use’ element is a child of a ‘clipPath’ element, it must directly reference ‘path’, ‘text’ or basic shape elements. Indirect references are an error (see Error processing).

For SVG2, https://www.w3.org/TR/SVG/render.html#ClippingAndMasking which references https://www.w3.org/TR/css-masking-1/#elementdef-clippath, which says the same thing (see the description)

This disallows groups in clip-paths

Inkscape Version and Operating System:

  • Inkscape 1.1-dev (ce96f98111, 2020-04-08) Linux Mint 19.1