Bug 30341

Summary: Make float decimal formatting of CSS values consistent
Product: WebKit Reporter: Evan Martin <evan>
Component: Tools / TestsAssignee: Evan Martin <evan>
Status: NEW ---    
Severity: Normal CC: achristensen, ahmad.saleem792, ap, bfulgham, ian, krit, simon.fraser, zalan
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Page for testing float handling none

Description Evan Martin 2009-10-13 14:42:02 PDT
When JS reads a float value from CSS, it gets it back as a string.
As the following console session shows, we format long floats to six digits.
This should be checked against other browsers, unified, and spec'd.

> document.foobar = 1/9;
0.1111111111111111
> document.foobar
0.1111111111111111
> var x = document.getElementById('header')
undefined
> x
<div id=​"header">​
> x.style.opacity = 1/9;
0.1111111111111111
> x.style.opacity
0.111111
Comment 1 Evan Martin 2009-10-13 14:46:05 PDT
Another related question is what the upper bound on CSS values are.  E.g., can I set foobar.style.left = 100000000000000000000000px?
Comment 2 Evan Martin 2009-12-20 07:18:38 PST
Created attachment 45276 [details]
Page for testing float handling
Comment 3 Evan Martin 2009-12-20 07:21:02 PST
+simon, in case he's curious

The attachment tries to summarize some corner cases that browsers might have.
Next I need to run this on various browsers and see if there's any pattern they might agree on.  (I only have a Linux box at the moment, but when I'm back at work I can test IE, Safari, and Opera.)
Comment 4 Simon Fraser (smfr) 2009-12-21 07:47:10 PST
I can take this to the CSS Working group.
Comment 5 Evan Martin 2010-01-07 11:24:37 PST
By the way, I realized that this attachment is probably confusing things a bit because we might be doing a float -> string conversion to print out the result in the table.  That's probably using another printf()-like call that will introduce exponential notation etc. that may not be part of the code this is intending to test.
Comment 6 Ahmad Saleem 2022-09-02 14:58:36 PDT
I notice that there are changes in the Safari Technology Preview 152 and other browsers (Chrome Canary 107 and Firefox Nightly 107) despite Webkit adopting CSS Parser. All browsers differ from each other in few cases.

Just wanted to highlight. Thanks!