Bug 62141

Summary: Incorrect rounding of color values during transitions
Product: WebKit Reporter: Boris Zbarsky <bzbarsky>
Component: CSSAssignee: Simon Fraser (smfr) <simon.fraser>
Status: RESOLVED FIXED    
Severity: Normal CC: cmarrin, simon.fraser
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Testcase
none
Better testcase
none
Patch mitz: review+

Boris Zbarsky
Reported 2011-06-06 13:11:53 PDT
Created attachment 96114 [details] Testcase BUILD: Current WebKit nightly (or current Chrome dev) STEPS TO REPRODUCE: 1) Load attached testcase. 2) Examine the sum of the "r" and "b" values in the printed rgb() triplets. EXPECTED RESULTS: Sum is always 255. ACTUAL RESULTS: Sum is 254 for most of them. ADDITIONAL NOTES: This is a regression from Safari 5. To see why the expected results are expected, note that at time t/5s in the range [0, 1] in the transition the computed color should be: rgb(255*(1-t), 0, 255*t); Now the color components will be rounded, but, for example, if 255*(1-t) is rounding to 254 then 255*t > 0.5. And therefore 255*t should be rounding to 1, not to 0. It looks like WebKit is just truncating the floating-point color values to get the interpolated color value instead of correctly rounding.
Attachments
Testcase (939 bytes, text/html)
2011-06-06 13:11 PDT, Boris Zbarsky
no flags
Better testcase (1.11 KB, text/html)
2011-06-06 20:28 PDT, Simon Fraser (smfr)
no flags
Patch (4.20 KB, patch)
2011-06-06 20:54 PDT, Simon Fraser (smfr)
mitz: review+
Simon Fraser (smfr)
Comment 1 2011-06-06 17:12:35 PDT
Color values are stored as unsigned bytes, so rounding is unsurprising.
Boris Zbarsky
Comment 2 2011-06-06 17:26:42 PDT
Rounding is unsurprising, but my point is that your rounding is wrong. You're rounding down instead of rounding to nearest.
Simon Fraser (smfr)
Comment 3 2011-06-06 20:28:06 PDT
Created attachment 96187 [details] Better testcase
Simon Fraser (smfr)
Comment 4 2011-06-06 20:54:03 PDT
Simon Fraser (smfr)
Comment 5 2011-06-06 21:13:08 PDT
Note You need to log in before you can comment on or make changes to this bug.