[csswg-drafts] [css-values-4] Resolve `<percentage>` representing `<number>` or `<angle>` at parse time (#9395)

cdoublev has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values-4] Resolve `<percentage>` representing `<number>` or `<angle>` at parse time ==
**Context**

There appears to be almost perfect browser interop and consistency between specs for serializing a `<percentage>` with a `<number>` as a component of a specified value:

  - in all color functions as any channel value
  - in `opacity`, `flood-opacity`, `shape-image-threshold`, as an `<alpha-value>`
  - in `transform` as an argument of the `<scale*()>` functions
  - in `scale`

The exception is in `filter` as an argument of some `<filter-function>`s, because [Filter Effects](https://drafts.fxtf.org/filter-effects-1/#serialization-of-filter-functions) does not require this.

---

**Problem 1**

In `scale`, which is defined with `[<number> | <percentage>]{1,3}`, the 3rd value must be omitted if it is `1`, and the 2nd value if it is *the same* as the 1st value.

However it is not clear whether `0% 0 100%` should serialize with `0%` or something else, because it is not clearly defined when `<percentage>` should be resolved.

Serializing `0` requires to resolve the 1st and 3rd values before trying to omit the 2nd value. The serialization is not "atomic".

**Problem 2**

[CSS Values](https://drafts.csswg.org/css-values-4/#simplify-a-calculation-tree) requires to try resolving a `<percentage>` in a math function (emphasize added):

  > If `root` is a percentage that will be resolved against another value, and there is enough information available to resolve it, do so, and express the resulting numeric value **in the appropriate canonical unit**.

However a `<number>` has no canonical unit. And `<angle>` is the only dimension that can be mapped from a `<percentage>` at parse time. The only context `<angle-percentage>` values appear is `<conic-gradient()>` and browsers do not resolve them, which seems rather complex and useless to me.

---

**Suggestions**

  1. either define explicitly to resolve `<percentage>` to `<number>` at parse time when there is enough information available (presumably in CSS Values), or status quo but provide clarifications/examples to serialize `scale` without optional values
  2. fix the above requirement to simplify a math function:

```diff
- If `root` is a percentage that will be resolved against another value, and there is enough information available to resolve it, do so, and express the resulting numeric value in the appropriate canonical unit.
+ If `root` is a percentage that will be resolved against another value, and there is enough information available to resolve it, do so, and express the resulting numeric value in the appropriate canonical unit when appropriate.
```

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9395 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 21 September 2023 13:39:28 UTC