[csswg-drafts] [css-values-4] Specify that calculation trees explicitly work in double precision (#4551)

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

== [css-values-4] Specify that calculation trees explicitly work in double precision ==
In [this twitter thread by @starsandrobots](https://twitter.com/starsandrobots/status/1199757377286754309), a CSS hack is shared that, in Chrome, causes values to snap to multiples of 1024px. This is because Chrome evaluates calc()s in  f64 precision, and the hack uses very large values that overflow the safe-integer range of a double by several bits.

In general CSS precision is intentionally unspecified (tho not *explicitly* unspecified; I should fix that...), to allow impls freedom to use their desired size of LayoutUnit, pack values into optimized structs, etc., so numeric precision/width can vary across impls and across properties in a single impl. But it seems likely that, within a calc(), impls will use a single consistent precision (since otherwise it would require multiple separate implementations of calculation trees and all the math functions for each numeric type).

Currently this precision also varies across impls (the hack doesn't work in Firefox, since they use f32s in calculation trees), but it seems likely that we can standardize this value across impls, and as people get used to using more complex calc()s, it's likely they'll come to depend on particular precisions, accidentally or purposefully. Since the Typed OM exposes numbers in f64s (JS's native numeric type), I think we should specify that calculation trees do their work in that precision too.

Thoughts? @emilio @heycam @domenic @smfr @bfgeek @xiaochengh 

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

Received on Monday, 2 December 2019 03:25:56 UTC