[BZ#748565] svg with clippath defined after use does not clip properly
Submitted by Thomas Caswell
Link to original bug (#748565)
Description
If the block containing a appears after any elements that use that clip path, they are not clipped. There seems to be nothing in the svg spec which requires that the object refereed to appears above what refers to it. The only place I could find anything about order mentioned was http://www.w3.org/TR/SVG/struct.html#DefsElement which only says that the is 'encouraged' to be a direct child of an ancestor of the node that refers to it.
A simple example of this is (from https://github.com/ipython/ipython/issues/8133#issuecomment-93051239):
<rect x="10" y="10" width="100" height="100"
clip-path="url(#myClip)"/>
<defs>
<clipPath id="myClip">
<circle cx="30" cy="30" r="20"/>
<circle cx="70" cy="70" r="20"/>
</clipPath>
</defs>
or basically anything emitted by matplotlib's svg backend.
This bug has been reported to ubuntu (https://bugs.launchpad.net/ubuntu/+source/librsvg/+bug/1207538) and matplotlib (https://github.com/matplotlib/matplotlib/issues/4341, https://github.com/matplotlib/matplotlib/issues/4179, https://github.com/matplotlib/matplotlib/issues/2277) but apparently never made it upstream.