GNOME Bugzilla – Bug 614606
!important is not respected
Last modified: 2010-04-27 11:21:31 UTC
Created attachment 157709 [details] symbolic icon in eog and firefox Attached is a SVG file with some CSS information as CDATA. I would expect the colours to change based on that CSS. Instead, the icon stays gray.
Created attachment 157710 [details] symbolic svg file
This is the CDATA in question (line 21): <style type="text/css"> <![CDATA[rect,path { fill:#000000 !important; /* fill-opacity:1 !important; */ } .critical { fill: red !important; }]]> </style>
CDATA section does handle correctly. The problem is "!important" directive. librsvg seems to ignore "!important".
Created attachment 157730 [details] [review] Proposed patch The patch works only with libcroco. In case of without libcroco, CSS parser in librsvg has another issue that concatenated selectors do not work. So the style "rect,path { ...}" in the attachment svg is not applied.
(In reply to comment #4) > In case of without libcroco, CSS parser in librsvg has another issue that > concatenated selectors do not work. So the style "rect,path { ...}" in the > attachment svg is not applied. Filed a new bug for this issue. bug #614643.
The problem with this patch is that "important" is a free-form string. It could be called "foobar" and still have the same effect. The code needs to be more generic than that...
Yes, you are right. But I am afraid of regressions so I would prefer to write some test code before doing such modifications. Anyway test code might be useful I will write it some day.
*** Bug 379629 has been marked as a duplicate of this bug. ***
Created attachment 159492 [details] [review] Revised patch This patch does not include the fix in case of without libcroco. I will open a new bug when this patch is landed.
Works for the test icon provided, but as I mentioned, needs to work for any keyword used. Thanks for the fixes so far.
I can't understand what the "keyword" mean. Can you attach an example, please?
Never mind, I showed my lack of knowledge of CSS there. I thought !important was an arbitrary keyword, when it's not: http://www.w3.org/TR/CSS2/cascade.html#important-rules
I'm not actually so familiar with CSS too. ^o^ I have been reading those W3C documents in these days.
Comment on attachment 159492 [details] [review] Revised patch committed with a few additional test cases.
Thanks Bastien! Pushed. http://git.gnome.org/browse/librsvg/commit/?id=20dd6a3ae7fa5fcddfbcf3bcfc39d8783890135d