Open litherum opened 5 years ago
@litherum Could you provide a concrete proposal which features should/should not be supported? IIRC we agreed that var()
must be supported.
Sure.
Concept | Supported | Reason |
---|---|---|
var() |
✅ | Required for compatibility with OpenType palettes |
env() |
❌ | For now, because nothing would use it, but eventually we should probably add support because env() is a better fit for OpenType palettes than var() |
calc() |
❌ | Large implementation complexity |
Percentages | ❌ | They’re easy to implement, but I can’t think of a reason that a tool would ever want to emit one |
Relative Units | ❌ | Again, can’t think of a reason that a tool would ever want to emit one |
CSS global keywords (initial , inherit , unset , revert ) |
❌ | A tool knows what the style should be, so it can just write out the desired style without any of these keywords |
all Property |
❌ | Ditto |
Property / Attribute Inheritance | ✅ | Implementation burden isn’t high, and not having to emit the full style on every element can significantly decrease file size. Also, every existing OT-SVG glyph relies on this |
Did I forget anything?
@litherum attr()
is in an ED and more functions (all the math functions) are about to arrive. So a white list might be preferable over a black list. But taking the currently speced features as a starting point probably is a good thing. @AmeliaBR comments?
Going through Myles' list:
I agree that var()
and env()
are fairly equal from an implementation perspective. Might as well allow both. But no requirements that a renderer needs to provide any initial values, only that they can parse the function and apply the fallback.
calc()
is most useful in combination with relative or percentage units. If those are going to be banned, banning calc also makes sense, given the implementation complexity. Same for other math functions, which are most useful for dynamic graphical layouts, where you don't want to pre-calculate all the results.
For percentages, the implementation complexity evaporates if we require viewBox
on the root <svg>
(and continue to disallow nested SVG viewports). But, the authoring benefits evaporate, too: you can always directly convert the percentages to user units if you know the viewBox size.
Font-relative units aren't very useful inside a graphic if there is no text within it. But maybe we could still allow all units (and percentages) on the width
and height
attributes on the outer <svg>
, since they set the default size when the graphic is rendered. (E.g., it's common to set them to 1em for an icon.) Viewport-relative units in SVG are like percentages with extra complications, so I suppose they are reasonable to exclude, as well.
I don't see why there is any implementation complexity to supporting initial
and inherit
, to cancel inheritance in a normally inherited property or force inheritance in a normally uninherited one.
all
is more complex, but we've already prohibited it by saying we only support styling via presentation attributes; there is no all
attribute.
Full property inheritance is essential.
attr()
doesn't offer any benefits in SVG that only uses presentation attributes.
Other things to think of:
@AmeliaBR Good points! I am not opposed to special treatment of width and height on the root SVG element but we should clarify what they compute to for user agents that do not support text at all.
It seems that, for the most part, we are in agreement to @litherum ‘s list!
The SVG Working Group just discussed Which CSS concepts should be supported in presentation attributes?
, and agreed to the following:
RESOLUTION: SVG Native requires env()
We already agreed on supporting env()
and define that it behaves like var()
(or vice versa).
I hope we can make some more progress faster.
Can we get to a conclusion on relative values next? Concerns about not supporting relative values in SVG Native?
Next is percentage values: As @litherum said, in general not a big deal to support it. As @AmeliaBR said, we should require a viewBox
if we allow percentage values. With percentage values there might be a desire to support calc()
.
So can we get to a conclusion to not support percentage values @AmeliaBR @litherum ?
The SVG Working Group just discussed [svg-native] Which CSS concepts should be supported in presentation attributes?
, and agreed to the following:
RESOLUTION: SVG Native will not support relative units that are relative to either font metrics or the viewport.
RESOLUTION: SVG Native does not support percentage length values.
Forked from https://github.com/w3c/svgwg/issues/658:
We already agreed that parsing the presentation attributes needs to use a CSS lexer. How much further should we go?
var()
env()
calc()
unset
, etcComments should just work, and https://github.com/w3c/svgwg/issues/658 resolved that
var
will work.