- From: Oriol Brufau via GitHub <sysbot+gh@w3.org>
- Date: Mon, 11 Dec 2023 18:51:39 +0000
- To: public-css-archive@w3.org
Loirooriol has just created a new issue for https://github.com/w3c/csswg-drafts: == [css-values] Sort calculation children suring simplification, not serialization == In floating-point numbers, addition is not associative, so recording the operands can change the result. Currently, the spec invokes [sort a calculation’s children](https://drafts.csswg.org/css-values/#sort-a-calculations-children) from [serialize a calculation tree](https://drafts.csswg.org/css-values/#serialize-a-calculation-tree). This implies that we don't have round-tripping. For example: ```html <!DOCTYPE html> <style>div { font-size: 1px; line-height: 1px; background: currentcolor content-box; border: dashed; height: 100px; }</style> <div style="width: calc(100px + 1e30em + -1e30lh); color: #f0f"></div> <div style="width: calc(1e30em + -1e30lh + 100px); color: #0ff"></div> ``` In Blink: ![](https://github.com/w3c/csswg-drafts/assets/7477678/519e4e14-6740-4c6c-a2aa-7ace0fc9c0f4) If I serialize the `width`s, I get `calc(100px + 1e+30em + -1e+30lh)` and `calc(1e+30em + -1e+30lh + 100px)`. So Blink is not sorting, otherwise the former would be like the later. But if Blink sorted as per the spec, then the former wouldn't round-trip! Gecko serializes both as `calc(1e30em - 1e30lh + 100px)`, but it's fine since both behave the same. I suspect the reordiring happens during [simplification](https://drafts.csswg.org/css-values/#calc-simplification), which seems more reasonable. Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9696 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Monday, 11 December 2023 18:51:41 UTC