You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[css-shapes-1] Optional values shouldn't be serialized #8695
To serialize the functions, serialize as per their individual grammars, in the order the grammars are written in, avoiding calc() expressions where possible, avoiding calc() transformations, omitting components when possible without changing the meaning, joining space-separated tokens with a single space, and following each serialized comma with a single space.
This seems mostly fine, except there's a couple problems:
There's an example that says:
Omitting components means that some default values do not show up in the serialization. But since always uses the 2- or 4-value form, a default is not omitted.
which is nonsense, because omitting a default at <position> is required by the normative text above.
This example is then tested in WPT, which shows that we (unfortunately) have interop on the example rather than on the normative text. However, having special rules that go against our general serialization principles without good reason is an anti-pattern. We should be consistent and allow at <position> to be omitted from the serialization just like any other optional component.
The guidance about “avoiding calc() expressions where possible, avoiding calc() transformations” conflicts with our more generally-applicable rules about serializing <position> and calc() values, which distinguish specified-value and computed-value serializations in very particular ways.
Proposal:
Fix the examples and tests, and file implementation bugs, allowing at <position> to be omitted, consistent with our general serialization principles.
Remove guidance about calc() serialization, allowing the spec to defer to the more specific serialization rules in css-values-4.
I do not think the resolution for #2274 (always serialize with 2 or 4 values) was meant to be taken literally, but for the record (quoted from #368):
circle(), circle(at center), circle(at 50%), ... are all valid and means the same value, and my guess would have been to serialize them as circle(). I am not claiming that they should be serialized like this, but I just woud like to understand the current browser outputs.
@cdoublev (and others) take a look at the discussion in #2274 for some of the things that led us to decide to only serialize to 2- and 4-value forms.
Aside
It would be nice to clarify if a math function simplified to a numeric value representing a default value can be omitted, like in circle(at calc(50%)).
There seems to have interop on generally not omitting a math function representing a default value. But it is not always simple see #5642 (comment).
+1 to the proposal to omit the at <position>. This is especially necessary to motion path because offset-path doesn't use the standard default for at <position> if the component is omitted.
We definitely need to omit the at <position> when it was omitted by the author, for offset-path to work correctly, but we also need to preserve the at <position> even if it specifies the default value, for the same reason - circle(at center) works differently than circle() when used as an offset path, because the latter will use 'offset-position' for the default instead.
@tabatkins It's a bit weird to have a magic value by omission, I don't think we have many precedents for such thing? None come to mind right now but I haven't tried too hard...
Maybe there should be an at default keyword value to represent that magic state?
We do have some behaviors that can only be expressed by omission. I can't name them off the top of my head, but I know they exist because I've been annoyed by them in the past. I'd be fine with adding such a value, but that's a separate issue.
Activity
tabatkins commentedon Apr 6, 2023
+1 to both of these
cdoublev commentedon Apr 11, 2023
I do not think the resolution for #2274 (always serialize with 2 or 4 values) was meant to be taken literally, but for the record (quoted from #368):
Aside
It would be nice to clarify if a math function simplified to a numeric value representing a default value can be omitted, like in
circle(at calc(50%)).There seems to have interop on generally not omitting a math function representing a default value. But it is not always simple see #5642 (comment).
BorisChiou commentedon May 24, 2023
+1 to the proposal to omit the
at <position>. This is especially necessary to motion path becauseoffset-pathdoesn't use the standard default forat <position>if the component is omitted.tabatkins commentedon May 25, 2023
We definitely need to omit the
at <position>when it was omitted by the author, for offset-path to work correctly, but we also need to preserve theat <position>even if it specifies the default value, for the same reason -circle(at center)works differently thancircle()when used as an offset path, because the latter will use 'offset-position' for the default instead.emilio commentedon May 25, 2023
@tabatkins It's a bit weird to have a magic value by omission, I don't think we have many precedents for such thing? None come to mind right now but I haven't tried too hard...
Maybe there should be an
at defaultkeyword value to represent that magic state?tabatkins commentedon May 25, 2023
We do have some behaviors that can only be expressed by omission. I can't name them off the top of my head, but I know they exist because I've been annoyed by them in the past. I'd be fine with adding such a value, but that's a separate issue.
Change WPT test for offset-path parsing
Change WPT test for offset-path parsing
Change WPT test for offset-path parsing
Change WPT test for offset-path parsing
Change WPT test for offset-path parsing
17 remaining items
fantasai commentedon Dec 18, 2023
@emilio The expected serialization of
<position>is defined in https://drafts.csswg.org/css-values-4/#position-serialization[css-shapes-1] Targeted fix of shape serialization section, fix examp…
[css-shapes-1] Targeted fix of shape serialization section, fix examp…
Bug 1823475 - Convert position into length-percentage for basic shape…
Omit default circle/ellipse position except for offset-path
Bug 1834271 [wpt PR 40120] - Change WPT test for offset-path parsing,…
Bug 1823475 - Convert position into length-percentage for basic shape…
Bug 2030159 - Remove special serialization from specified shapes. r=b…
Bug 2030159 - Fix some WPTs that now match the spec and WebKit. r=bor…
Bug 2030159 - Remove special serialization from specified shapes. r=b…
Fix some WPTs that now match the spec and WebKit.
Fix some WPTs that now match the spec and WebKit.
Bug 2030159 - Remove special serialization from specified shapes. r=b…
Bug 2030159 - Fix some WPTs that now match the spec and WebKit. r=bor…