WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
147932
Browser does not fall back to SVG attribute value when CSS style value is invalid or not supported
https://bugs.webkit.org/show_bug.cgi?id=147932
Summary
Browser does not fall back to SVG attribute value when CSS style value is inv...
Sara Soueidan
Reported
2015-08-12 01:44:06 PDT
An SVG element that has a fill color specified using both a fill attribute and a style attribute with fill property declaration, the browser needs to be able to fall back to the fill attribute value if the value in the style attribute is not valid. In this particular case, an SVG element is styled using CSS variables inside a style attribute. Since Safari does not support CSS variables yet, it is supposed to ignore the fill value in the style tag (using the variable) and fall back to the fill value in the fill attribute. Live example:
http://codepen.io/SaraSoueidan/pen/c30e270090b2460ba6e6833c611e5a76
The robots should all be colored and look alike in Safari, as they do in Chrome, for example. But instead, Safari falls back to all black colors (the user agent defaults) because it does not use the fill attribute fallback provided. More reference on this technique, how it works, and what's supposed to happen here:
http://tympanus.net/codrops/2015/07/16/styling-svg-use-content-css/
Attachments
Screenshot of what the demo should look like when CSS variables are not supported
(88.05 KB, image/png)
2015-08-12 01:46 PDT
,
Sara Soueidan
no flags
Details
Testcase
(129 bytes, image/svg+xml)
2015-11-24 05:12 PST
,
Antoine Quint
no flags
Details
Patch
(12.32 KB, patch)
2015-11-26 06:15 PST
,
Antoine Quint
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Sara Soueidan
Comment 1
2015-08-12 01:46:07 PDT
Created
attachment 258817
[details]
Screenshot of what the demo should look like when CSS variables are not supported This screenshot shows how the robots should look when CSS variables are not supported; i.e. if Safari does fall back appropriately. It currently shows all-black robots instead.
Dean Jackson
Comment 2
2015-08-12 18:00:13 PDT
<
rdar://problem/22261140
>
Antoine Quint
Comment 3
2015-11-24 05:12:46 PST
Created
attachment 266130
[details]
Testcase Simple test case showing that setting style="fill: whatever", which is invalid, means that the valid fill="green" attribute won't get picked up.
Antoine Quint
Comment 4
2015-11-24 06:17:11 PST
For some background on this, I think this is the relevant part of the SVG 1.1 specification:
http://www.w3.org/TR/SVG11/styling.html#UsingPresentationAttributes
In particular, this excerpt: "For user agents that support CSS, the presentation attributes must be translated to corresponding CSS style rules according to rules described in Precedence of non-CSS presentational hints ([CSS2], section 6.4.4), with the additional clarification that the presentation attributes are conceptually inserted into a new author style sheet which is the first in the author style sheet collection. The presentation attributes thus will participate in the CSS2 cascade as if they were replaced by corresponding CSS style rules placed at the start of the author style sheet with a specificity of zero. In general, this means that the presentation attributes have lower priority than other CSS style rules specified in author style sheets or ‘style’ attributes."
Antoine Quint
Comment 5
2015-11-24 08:28:26 PST
As far as I can understand so far, the MatchResult passed to StyleResolver::applyCascadedProperties has all the properties needed to make the right decision and fall back on a valid value. It doesn't use the valid property for reasons that aren't clear yet.
Antoine Quint
Comment 6
2015-11-24 08:46:05 PST
However, still in StyleResolver::applyCascadedProperties(), the cascaded properties don't have the expected values, so my guess is that something is going wrong when setting up the cascade in StyleResolver::applyMatchedProperties(): CascadedProperties cascade(direction, writingMode); cascade.addMatches(matchResult, false, 0, matchResult.matchedProperties().size() - 1, applyInheritedOnly); cascade.addMatches(matchResult, true, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); cascade.addMatches(matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); cascade.addMatches(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
Antoine Quint
Comment 7
2015-11-26 06:15:04 PST
Created
attachment 266184
[details]
Patch
Antoine Quint
Comment 8
2015-11-26 06:20:33 PST
Another fix I had in mind was to `return false` if `valueWithCalculation.value().id == CSSValueInvalid` was true in `CSSParser::parseSVGValue()`. This would mean that any value that is deemed invalid would be dropped. But since it was a much broader fix, I went for a more specialised fix for the case of SVGPaint values. I also wasn't entirely sure of the meaning of `CSSValueInvalid`, does it inform us with absolute certainty that the value is invalid, or only that with checks applied at this point that the value would likely be invalid?
WebKit Commit Bot
Comment 9
2015-11-29 14:03:29 PST
Comment on
attachment 266184
[details]
Patch Clearing flags on attachment: 266184 Committed
r192788
: <
http://trac.webkit.org/changeset/192788
>
WebKit Commit Bot
Comment 10
2015-11-29 14:03:33 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug