Fix Bug 604000: Correctly remove overflow attributes on marker, pattern, svg

This commit is contained in:
Jeff Schiller 2010-07-11 11:18:26 -07:00
parent b661e479ea
commit c17c689ae4
7 changed files with 69 additions and 4 deletions

View file

@ -1,5 +1,16 @@
Thanks to the following contributors to scour:
* Louis Simard
Bugs Fixed:
- https://bugs.launchpad.net/scour/+bug/583758
- https://bugs.launchpad.net/scour/+bug/583458
- https://bugs.launchpad.net/scour/+bug/594930
- https://bugs.launchpad.net/scour/+bug/576958
New features:
- https://bugs.launchpad.net/scour/+bug/428069 Remove metadata option.
- https://bugs.launchpad.net/scour/+bug/582619 Feature implementations: --quiet, --enable-comment-stripping.
- Add options --shorten-ids, --renderer-workaround.
* Doug Schepers (W3C SVG WG)
- function to embed rasters as base64 data: URLs
- report file size reduction

View file

@ -20,6 +20,12 @@
<li>Fix <a href="https://bugs.launchpad.net/scour/+bug/577940">Bug 577940</a> to include stroke-dasharray into list of style properties turned into XML attributes.</li>
<li>Fix <a href="https://bugs.launchpad.net/scour/+bug/562784">Bug 562784</a>, typo in Inkscape description</li>
<li>Fix <a href="https://bugs.launchpad.net/scour/+bug/603988">Bug 603988</a>, do not commonize attributes if the element is referenced elsewhere.</li>
<li>Fix <a href="https://bugs.launchpad.net/scour/+bug/604000">Bug 604000</a>, correctly remove default overflow attributes.</li>
<li>Fix <a href="https://bugs.launchpad.net/scour/+bug/583758">Bug 583758</a>, added a bit to the Inkscape help text saying that groups aren't collapsed if IDs are also not stripped.</li>
<li>Fix <a href="https://bugs.launchpad.net/scour/+bug/583458">Bug 583458</a>, another typo in the Inkscape help tab.</li>
<li>Fix <a href="https://bugs.launchpad.net/scour/+bug/594930">Bug 594930</a>, In a &lt;switch&gt;, require one level of &lt;g&gt; if there was a &lt;g&gt; in the file already. Otherwise, only the first subelement of the &lt;g&gt; is chosen and rendered.</li>
<li>Fix <a href="https://bugs.launchpad.net/scour/+bug/576958">Bug 576958</a>, "Viewbox option doesn't work when units are set", when renderer workarounds are disabled.</li>
<li>Added many options: --remove-metadata, --quiet, --enable-comment-stripping, --shorten-ids, --renderer-workaround.</li>
</ul>
</section>

View file

@ -4,6 +4,7 @@
# Scour
#
# Copyright 2010 Jeff Schiller
# Copyright 2010 Louis Simard
#
# This file is part of Scour, http://www.codedread.com/scour/
#
@ -1328,12 +1329,24 @@ def repairStyle(node, options):
del styleMap['display']
num += 1
# overflow: visible or overflow specified on element other than svg, marker, pattern
if styleMap.has_key('overflow') :
if styleMap['overflow'] == 'visible' or node.nodeName in ['svg','marker','pattern']:
# overflow specified on element other than svg, marker, pattern
if not node.nodeName in ['svg','marker','pattern']:
del styleMap['overflow']
num += 1
# it is a marker, pattern or svg
# as long as this node is not the document <svg>, then only
# remove overflow='hidden'. See
# http://www.w3.org/TR/2010/WD-SVG11-20100622/masking.html#OverflowProperty
elif node != node.ownerDocument.documentElement:
if styleMap['overflow'] == 'hidden':
del styleMap['overflow']
num += 1
# else if outer svg has a overflow="visible", we can remove it
elif styleMap['overflow'] == 'visible':
del styleMap['overflow']
num += 1
# marker: none
if styleMap.has_key('marker') :
if styleMap['marker'] == 'none':

View file

@ -3,7 +3,7 @@
# SVG transformation list parser
#
# Copyright 2010
# Copyright 2010 Louis Simard
#
# This file is part of Scour, http://www.codedread.com/scour/
#

View file

@ -4,6 +4,7 @@
# Test Harness for Scour
#
# Copyright 2010 Jeff Schiller
# Copyright 2010 Louis Simard
#
# This file is part of Scour, http://www.codedread.com/scour/
#
@ -1102,6 +1103,19 @@ class DoNotCommonizeAttributesOnReferencedElements(unittest.TestCase):
doc = scour.scourXmlFile('unittests/commonized-referenced-elements.svg')
self.assertEquals(doc.getElementsByTagName('circle')[0].getAttribute('fill'), '#0f0')
class DoNotRemoveOverflowVisibleOnMarker(unittest.TestCase):
def runTest(self):
doc = scour.scourXmlFile('unittests/overflow-marker.svg')
self.assertEquals(doc.getElementsByTagName('marker')[0].getAttribute('overflow'), 'visible')
self.assertEquals(doc.getElementsByTagName('marker')[1].getAttribute('overflow'), '')
class MarkerOnSvgElements(unittest.TestCase):
def runTest(self):
doc = scour.scourXmlFile('unittests/overflow-svg.svg')
self.assertEquals(doc.getElementsByTagName('svg')[0].getAttribute('overflow'), '')
self.assertEquals(doc.getElementsByTagName('svg')[1].getAttribute('overflow'), '')
self.assertEquals(doc.getElementsByTagName('svg')[2].getAttribute('overflow'), 'visible')
# TODO: write tests for --enable-viewboxing
# TODO; write a test for embedding rasters
# TODO: write a test for --disable-embed-rasters

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<marker id="m1" style="overflow:visible">
<rect width="200" height="100"/>
</marker>
<marker id="m2" style="overflow:hidden">
<rect width="200" height="100"/>
</marker>
</defs>
<line x2="100" y2="100" style="marker-start:url(#m1);marker-end:url(#m2)" stroke="#000" />
</svg>

After

Width:  |  Height:  |  Size: 438 B

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="overflow:visible">
<svg style="overflow:hidden">
<line x2="100" y2="100" stroke="#000" />
</svg>
<svg style="overflow:visible">
<line x2="100" y2="100" stroke="#000" />
</svg>
</svg>

After

Width:  |  Height:  |  Size: 344 B