<?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>161002</bug_id>
          
          <creation_ts>2016-08-19 11:09:07 -0700</creation_ts>
          <short_desc>Nested calculations using intermediate CSS Custom Properties don&apos;t work</short_desc>
          <delta_ts>2016-12-29 08:51:12 -0800</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>Safari Technology Preview</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.11</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=166493</see_also>
          <bug_file_loc>http://codepen.io/anon/pen/bZJaVO</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sergio Gomes">sgomes</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>hyatt</cc>
    
    <cc>oliverjash</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>singhthing</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1221400</commentid>
    <comment_count>0</comment_count>
    <who name="Sergio Gomes">sgomes</who>
    <bug_when>2016-08-19 11:09:07 -0700</bug_when>
    <thetext>As per example 9 in section 2.2 (Resolving Dependency Cycles) of the spec (https://drafts.csswg.org/css-variables/), it should be possible to have nested calculations:

one   { --foo: 10px; }
two   { --bar: calc(var(--foo) + 10px); }
three { --foo: calc(var(--bar) + 10px); }

This doesn&apos;t seem to work in Safari 9.1.2 or Safari Technology Preview.

Furthermore, it is stated: &quot;Custom properties are left almost entirely unevaluated, except that they allow and evaluate the var() function in their value.&quot;
This implies that it should be possible to declare the intermediate calculations without calc() as well, as the value returned by var() would just be substituted into the new definition.

I have prepared a demo illustrating both ways of nesting calculations; one using calc() for the intermediate steps (as per the example above), and one using calc() for the final step only: http://codepen.io/anon/pen/bZJaVO
The expected result is that the third div in both groups is 30px wide.

Steps to reproduce:
1 - Load http://codepen.io/anon/pen/bZJaVO
2 - Observe third div in each group

Expected results: third div should be 30px wide.

Actual results: third div is 10px wide in Safari 9.1.2; third div fits to screen width in Safari Technology Preview.

Other browsers: The demo produces the expected result in both Chrome 53 and Firefox 48.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1221653</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2016-08-20 10:42:04 -0700</bug_when>
    <thetext>&lt;rdar://problem/27936993&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1262832</commentid>
    <comment_count>2</comment_count>
    <who name="Oliver Joseph Ash">oliverjash</who>
    <bug_when>2016-12-27 12:15:58 -0800</bug_when>
    <thetext>I think the specific problem here is Safari doesn&apos;t like nested calcs: https://bugs.webkit.org/show_bug.cgi?id=166493</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1262846</commentid>
    <comment_count>3</comment_count>
    <who name="Talwinder Singh">singhthing</who>
    <bug_when>2016-12-27 13:42:21 -0800</bug_when>
    <thetext>@Oliver
There are two separate issues that are outlined. The nested calc issue as you mentioned. But also the fact that declaring a computed value (using arthimatic operations) for a variable is valid even without wrapping it inside a calc. This is also working in FF and Chrome but not in Safari.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1263040</commentid>
    <comment_count>4</comment_count>
    <who name="Sergio Gomes">sgomes</who>
    <bug_when>2016-12-29 06:06:03 -0800</bug_when>
    <thetext>As an update, this issue appears to be resolved in Safari Tech Preview Release 20! Fingers crossed it will make it into a stable release soon.

Marking the issue as resolved for now, but I&apos;ll keep an eye out to make sure there aren&apos;t any regressions in new TP releases.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1263055</commentid>
    <comment_count>5</comment_count>
    <who name="Oliver Joseph Ash">oliverjash</who>
    <bug_when>2016-12-29 08:45:58 -0800</bug_when>
    <thetext>(In reply to comment #4)
&gt; As an update, this issue appears to be resolved in Safari Tech Preview
&gt; Release 20! Fingers crossed it will make it into a stable release soon.
&gt; 
&gt; Marking the issue as resolved for now, but I&apos;ll keep an eye out to make sure
&gt; there aren&apos;t any regressions in new TP releases.

Does this also mean this bug is fixed? https://bugs.webkit.org/show_bug.cgi?id=166493</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1263056</commentid>
    <comment_count>6</comment_count>
    <who name="Sergio Gomes">sgomes</who>
    <bug_when>2016-12-29 08:51:12 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; (In reply to comment #4)
&gt; &gt; As an update, this issue appears to be resolved in Safari Tech Preview
&gt; &gt; Release 20! Fingers crossed it will make it into a stable release soon.
&gt; &gt; 
&gt; &gt; Marking the issue as resolved for now, but I&apos;ll keep an eye out to make sure
&gt; &gt; there aren&apos;t any regressions in new TP releases.
&gt; 
&gt; Does this also mean this bug is fixed?
&gt; https://bugs.webkit.org/show_bug.cgi?id=166493

Yes, it appears to be. I&apos;ll add a note to it.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>