[csswg-drafts] [css-values] Calc serialization of subtractions

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

== [css-values] Calc serialization of subtractions ==
In #1731 we decided to serialize percentages before dimensioned values.

Existing browsers have varied behavior when there are two negatives in a computed value: Safari uses `-20px - 10%`. Blink previously used `-20px + -10%` and now uses `-10% + -20px`. Legacy Firefox code uses `-20px - 10%` and more recent (Servo) code uses `-10% - 20px`. Edge often reduces a `<length-percentage>` to a `<length>`.


A single subtraction often occur in the context of `<position>`, e.g. `right 200px bottom 200px`.

Should `calc(100% - 200px)` serialize as-is, or should this be `calc(100% + -200px)`?

Various WPTs expect the former, but a literal reading of the [spec](https://drafts.csswg.org/css-values/#math-function-serialize-a-summation) requires the latter:
> Serialize all the terms, then join them into a single string, with " + " between each term.

If the former is preferred, we might want to add a sentence:
> Replace any resulting " + -" with " - ".

This would leave a specified value like `calc(100% + max(-10%, -200px))` unchanged.

The spec could also use an example or text showing how to simplify/serialize a specified value like `calc(100% - max(10%, 200px))` 


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

Received on Monday, 19 November 2018 21:37:56 UTC