After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 592207 - Object cannot be rendered with more than 1 CSS {} rule
Object cannot be rendered with more than 1 CSS {} rule
Status: RESOLVED FIXED
Product: librsvg
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: librsvg maintainers
librsvg maintainers
Depends on:
Blocks:
 
 
Reported: 2009-08-18 12:39 UTC by Explorer09
Modified: 2010-04-14 07:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
testing image (331 bytes, image/png)
2009-08-18 12:39 UTC, Explorer09
  Details
Fix (1.66 KB, patch)
2010-04-11 05:29 UTC, Hiroyuki Ikezoe
committed Details | Review

Description Explorer09 2009-08-18 12:39:38 UTC
Created attachment 141060 [details]
testing image

This bug happens in a server with MediaWiki 1.13.3.
(http://worms2d.info/Image:Test.svg)

If a shape is to be applied with 2 or more CSS style rules. Librsvg will only
render one of them.

Example:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="100px" height="100px" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
  <style type="text/css"><![CDATA[
    rect { fill: #ff0000; }
    .class1 { stroke: #0000ff; }
  ]]></style>
  </defs>
  <rect x="20" y="20" width="50" height="50" class="class1"/>
</svg>

The square should have a red fill color and a blue outline.
But the actual result (see attachment) is that the fill color was black, the
default color.
Comment 1 Daniel Patterson 2010-01-28 16:26:00 UTC
I'm also seeing this, on a slightly more complex SVG file with external stylesheets:

map.svg:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="map.css" ?>
<?xml-stylesheet type="text/css" href="map-status.css" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
<svg version="1.1" baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1375" height="364" viewBox="0 0 1375 364">
    <g id="Banff_Trail">
      <path class="Banff_Trail" id="segment_62" fill="none" d="M 321.870242 165.909352 325.846668 167.245121 334.734233 167.314487 342.474152 171.208482 345.144807 172.452647 349.033835 173.050389 354.333170 171.711199 361.069587 169.730589 367.442812 169.963015 374.139924 169.935011 377.260932 169.209135 385.060687 167.290869 391.481025 165.797661"/>
      <path class="Banff_Trail" id="segment_1757" fill="none" d="M 391.481025 165.797661 397.827949 167.788766 401.086248 168.916652 405.860108 170.221523 408.104535 171.576143 411.233541 173.381001"/>
    </g>
</svg>

map.css:
#Banff_Trail path {
  stroke-width:8;
  stroke-linejoin:round;
  stroke-linecap:round;
}

map-status.css
#segment_62 { stroke: red; }
#segment_1757 { stroke: green; }

I expect the #segment_62 path to be drawn 8 pixels wide, rounded caps and red.  But I either get nothing at all (i.e. no stroke colour used), or the default line format, in red (1px wide), dependingon the order that the stylesheets are included.
Comment 2 Daniel Patterson 2010-01-28 18:03:01 UTC
After more research, the problem is with the CSS selector engine in librsvg/rsvg-styles.c.

The method "rsvg_parse_style_attrs" only implements a very simple CSS selector matcher.

A suggested fix would be to try to use libcroco's selector matching code instead, it's CSS2.1 compliant.  Unfortunately, it looks like that while libcroco is used for parsing the CSS (where it's available), the rules aren't stored in a way that libcroco's selector engine can use.

In some situations, there is an incomplete workaround that'll allow multiple CSS rules to be applied.

If you place dummy class name in the 'class' tag, then #id and tag rules will be applied on top of the class selectors.

Modifying the first example to be:

  <rect x="20" y="20" width="50" height="50" class="class1 dummy"/>

causes it to render properly.  This workaround is pretty fugly and very limited (but if RSVG is all you have and your problem is no more complex, then this might do the trick).
Comment 3 Hiroyuki Ikezoe 2010-04-11 05:29:22 UTC
Created attachment 158404 [details] [review]
Fix

CSS style applying order was something weird.
Comment 4 Hiroyuki Ikezoe 2010-04-11 05:30:42 UTC
Daniel, your issue seems to be the same as bug #338160.