<?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>265276</bug_id>
          
          <creation_ts>2023-11-23 02:17:22 -0800</creation_ts>
          <short_desc>Support CSS math functions on flexible lengths</short_desc>
          <delta_ts>2025-01-24 00:12:07 -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>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></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="Roman Komarov">kizmarh</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>karlcow</cc>
    
    <cc>ntim</cc>
    
    <cc>sam</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1994500</commentid>
    <comment_count>0</comment_count>
    <who name="Roman Komarov">kizmarh</who>
    <bug_when>2023-11-23 02:17:22 -0800</bug_when>
    <thetext>To reproduce, go to https://codepen.io/kizu/pen/RwvyyOg or try using `calc(1fr)` in `grid-template-columns`.

The `calc(1fr)` is treated as invalid, but it should be valid, as per specs (see it for the `&lt;flex&gt;` type):

https://drafts.csswg.org/css-values-4/#calc-type-checking

and as clarified by the spec editors: 

https://github.com/w3c/csswg-drafts/issues/6989

&gt; Definitely a bug; `fr` units should be math&apos;able just fine. That note is, indeed, just observing that `fr` is not a `&lt;length&gt;` so `calc(1px + 1fr)` is invalid, but `calc(1fr / 3)` should be just fine.

Curiously, no other browser did fix this yet. Chromium has a bug open from 2019: https://bugs.chromium.org/p/chromium/issues/detail?id=993136&amp;q=calc%20fr&amp;can=2 and I did not find one for Firefox, so I did open it: https://bugzilla.mozilla.org/show_bug.cgi?id=1866236</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1994522</commentid>
    <comment_count>1</comment_count>
    <who name="Roman Komarov">kizmarh</who>
    <bug_when>2023-11-23 04:54:47 -0800</bug_when>
    <thetext>I did open a PR adding WPT tests for this: https://github.com/web-platform-tests/wpt/pull/43322</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1995840</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-11-30 02:18:14 -0800</bug_when>
    <thetext>&lt;rdar://problem/118975697&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2088985</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Nguyen (:ntim)">ntim</who>
    <bug_when>2025-01-22 07:49:05 -0800</bug_when>
    <thetext>Sam, is this easy to do with the calc() rewrite you did?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2089395</commentid>
    <comment_count>4</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2025-01-23 17:08:15 -0800</bug_when>
    <thetext>I can&apos;t speak to why the initial codepen doesn&apos;t seem to work as the text in the codepen suggests it should (its not 50%) but calc() and fr units is fully supported. (I just don&apos;t understand the grid syntax at all so don&apos;t know if its correct.

The WPT test added for this, https://wpt.fyi/results/css/css-grid/grid-definition/grid-support-flexible-lengths-001.html?label=experimental&amp;label=master&amp;aligned, seems to be passing in Safari.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2089460</commentid>
    <comment_count>5</comment_count>
    <who name="Roman Komarov">kizmarh</who>
    <bug_when>2025-01-24 00:12:07 -0800</bug_when>
    <thetext>The current WPT tests do not cover the case I mentioned — my wpt PR with the tests for this is still unmerged: https://github.com/web-platform-tests/wpt/pull/43322</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>