<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>93445</bug_id>
          
          <creation_ts>2012-08-08 00:20:49 -0700</creation_ts>
          <short_desc>getComputedStyle for `opacity` loses precision</short_desc>
          <delta_ts>2012-08-08 14:27:02 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc>javascript: var el = document.body; void(el.style.opacity = &apos;0.95&apos;); alert([el.style.opacity, getComputedStyle(el).opacity]);</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="dhtmlkitchen@gmail.com">dhtmlkitchen</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>simon.fraser</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>690009</commentid>
    <comment_count>0</comment_count>
    <who name="dhtmlkitchen@gmail.com">dhtmlkitchen</who>
    <bug_when>2012-08-08 00:20:49 -0700</bug_when>
    <thetext>Reading `opacity` back from `getComputedStyle` results in a value that is not the value specified.

var el = document.body;
el.style.opacity = &apos;0.95&apos;; // Specified value.
el.style.opacity;// Specified value returned.
&quot;0.95&quot; 
getComputedStyle(el).opacity; // Not the specified value.
&quot;0.949999988079071&quot; 

With getComputedStyle(el).opacity, an internal number of the opacity is returned. Is it that &apos;9.5&apos; sets the opacity as a (lossy) binary number, which, when returned, is converted to a string? 

Css3 spec says that the value returned must be &quot;The same as the specified value after clipping the &lt;alphavalue&gt; to the range [0.0,1.0].&quot; 

Since the value returned (&quot;0.949999988079071&quot;) is not the specified value (&quot;9.5&quot;), then this is a violation of a spec. 

http://www.w3.org/TR/css3-color/#transparency

| Computed value: 	The same as the specified value 
| after clipping the &lt;alphavalue&gt; to the range [0.0,1.0]. 

Version 5.1.1 (6534.51.22)

&quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>690484</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2012-08-08 10:36:41 -0700</bug_when>
    <thetext>&gt; Is it that &apos;9.5&apos; sets the opacity as a (lossy) binary number, which, when returned, is converted to a string?

Yes. As such, this really is the specified value, and no specs have been violated.

But perhaps there is something to do here that would swipe this under the carpet (like switching from float to double?), or something else I&apos;m unaware of. So, keeping the bug open for experts to consider.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>690554</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2012-08-08 11:34:11 -0700</bug_when>
    <thetext>I think some floating point rounding is acceptable, so I don&apos;t think this is a bug. &lt;http://dev.w3.org/csswg/css3-values/#numeric-types&gt; says &quot;UAs should support reasonably useful ranges and precisions&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>690728</commentid>
    <comment_count>3</comment_count>
    <who name="dhtmlkitchen@gmail.com">dhtmlkitchen</who>
    <bug_when>2012-08-08 14:22:55 -0700</bug_when>
    <thetext>So 9.5., specified value, is out of reasonably useful?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>690737</commentid>
    <comment_count>4</comment_count>
    <who name="dhtmlkitchen@gmail.com">dhtmlkitchen</who>
    <bug_when>2012-08-08 14:27:02 -0700</bug_when>
    <thetext>Correction: &quot;.95&quot;, not &quot;9.5&quot;.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>