Bug 42012 - Alpha value obtained by getComputedStyle is noticeably less than the actual value.
Summary: Alpha value obtained by getComputedStyle is noticeably less than the actual v...
Status: RESOLVED DUPLICATE of bug 91355
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-09 17:47 PDT by Ryosuke Niwa
Modified: 2012-07-15 20:39 PDT (History)
3 users (show)

See Also:


Attachments
demonstrates the bug (276 bytes, text/html)
2010-07-09 17:47 PDT, Ryosuke Niwa
no flags Details
demonstrates issue with getComputedStyle for opacity (651 bytes, text/html)
2010-12-13 01:44 PST, Daniel Wagner
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2010-07-09 17:47:51 PDT
Created attachment 61124 [details]
demonstrates the bug

When the background color is set to rgba(255, 255, 0.5), the computed style's background color indicates the actual alpha value to be 0.496094.  Firefox returns 0.5 correctly.  The bug is demonstrated in the attachment.
Comment 1 patrice 2010-09-09 17:04:03 PDT
Also, sometimes, assigning the generated rgba color append to generate a new value :

document.body.style.backgroundColor="rgba(0,0,0,0.3)";
"rgba(0,0,0,0.3)"
document.body.style.backgroundColor = document.body.style.backgroundColor;
"rgba(0, 0, 0, 0.296875)"
document.body.style.backgroundColor = document.body.style.backgroundColor;
"rgba(0, 0, 0, 0.292969)"
document.body.style.backgroundColor = document.body.style.backgroundColor;
"rgba(0, 0, 0, 0.292969)"
Comment 2 Daniel Wagner 2010-12-13 01:44:08 PST
Created attachment 76360 [details]
demonstrates issue with getComputedStyle for opacity

Similarly, if an element's opacity is set to 0.7, getComputedStyle returns 0.699999988079071.
Comment 3 Simon Fraser (smfr) 2010-12-13 10:37:47 PST
I think this is a divide-by-255 vs. 256 issue.
Comment 4 Simon Fraser (smfr) 2010-12-13 14:05:28 PST
Internally rgba(255, 255, 0, 0.5) is stored as 0x7fffff00 (ARGB), and 127/255 is 0.49803921568627.

(In reply to comment #2)
> Created an attachment (id=76360) [details]
> demonstrates issue with getComputedStyle for opacity
> 
> Similarly, if an element's opacity is set to 0.7, getComputedStyle returns 0.699999988079071.

This is just floating point rounding error.
Comment 5 Ryosuke Niwa 2012-07-15 20:39:54 PDT

*** This bug has been marked as a duplicate of bug 91355 ***