Can display="none" elements be removed?

Bug #674992 reported by Walther
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Scour
Confirmed
Medium
Unassigned

Bug Description

The attached file was already ran through scour (0.25, default options).

If you notice, it is an svn which is full of display="none" elements. The actual image is merely two circles (one blurred) which draw a moon. I believe all the display=none elements are the hidden layers/objects from the original image.

Since these elements aren't meant to be displayed, can scour remove them? (notice how much invisible cruft the file contains...)

Revision history for this message
Walther (walther-md) wrote :
Revision history for this message
jazzynico (jazzynico) wrote :

It may not be a good idea to remove the elements by default. Since it could be a temporary state (later activated by a script), I'd rather add a boolean option (keep display=none elements).

Revision history for this message
Walther (walther-md) wrote :

I have no problems with that. I just would really like the ability to remove (in one way or another) disabled elements (specially when the file's meant to be used statically).

Changed in scour:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Louis Simard (louis-simard-deactivatedaccount) wrote :

After a little investigation in the SVG spec [1], it seems that display="none" affects an element and all of its children, with no way to override this on specific children, and the none'd element doesn't even appear in the render tree, so it couldn't even be changed by a script. However, visibility="hidden" adds the element and its children to the render tree anyway, and could be changed by a script to visibility="visible", so we shouldn't remove those.

Elements such as markers and patterns could be given as display="none", and a copy of them will appear in the render tree if referenced by xlink:href or <use>, so if a display="none" element is referenced elsewhere in the document, it MUST be preserved.

As for this moon, manually commenting out the display="none" elements in it and running Scour trunk on it as follows:

$ ./scour.py --enable-comment-stripping --renderer-workaround --enable-id-stripping --shorten-ids -i ~/temp/moon.svg -o ~/temp/moon.opt.svg

results in:

 Original file size: 54811 bytes; new file size: 1422 bytes (2.594%)

... and an identically-rendering file. Good catch. :)

[1] http://www.w3.org/TR/2002/CR-SVG11-20020430/painting.html#DisplayProperty

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.