w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.44k stars 657 forks source link

[cssom][css-values] Serialization of <number-percentage>? #1546

Open birtles opened 7 years ago

birtles commented 7 years ago

This is possibly more of a Chrome bug than a spec issue but I thought I'd check: how should brightness(0.5) and brightness(50%) be serialized. As-is?

Given this fiddle in Firefox and Edge the two values are serialized as-is, but in Chrome both become brightness(0.5). Servo, I believe, does the same as Chrome here so I want to check that Chrome is in fact wrong before changing Servo.

AmeliaBR commented 7 years ago

It would definitely be preferable if equivalent declarations serialized to the same value.

Furthermore, serializing to number is probably slightly preferable to percentages, as they are easier to use in JS.

But to make this a general rule (and not just something specific to filter) would require that <number-percentage> only be used when numbers and percentages are directly equivalent. Which I think was the agreement from the discussion of calc(), but I'm not sure.

upsuper commented 7 years ago

Serialization is really a matter of CSSOM spec, I believe.

In the serialization section of CSSOM, there is no individual rule for <number-percentage>, and from CSS Values spec, <number-percentage> is really just [ <number> | <percentage> ] so I would suggest we should just serialize it as [ <number> | <percentage> ], which means they should be serialized as-is in this case.

tabatkins commented 7 years ago

Underspecified. I'd prefer they serialize to the same thing too, tho.

ewilligers commented 5 years ago

WPTs show current browsers serializing specified values as supplied by the author, and serializing getComputedStyle() results using numbers.

fantasai commented 1 year ago

They are not generally compatible, so their specified values should be serialized as-is. As for the computed value serialization, that should depend on what the Computed Value is defined to be. It's up to the property/function to define that e.g. <percentage> values compute to equivalent <number>s or vice versa.

Retagging against Filters.