<?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>216144</bug_id>
          
          <creation_ts>2020-09-03 14:40:28 -0700</creation_ts>
          <short_desc>[css-grid] Wrong &apos;auto&apos; track size for a grid item with a specified &apos;width:max-content&apos;</short_desc>
          <delta_ts>2025-04-22 15:05:38 -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>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.chromium.org/p/chromium/issues/detail?id=818401</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=289961</see_also>
          <bug_file_loc>http://wpt.live/css/css-grid/grid-items/grid-intrinsic-maximums.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar, WPTImpact</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Oriol Brufau">obrufau</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>bramus</cc>
    
    <cc>gwhitworth</cc>
    
    <cc>jfernandez</cc>
    
    <cc>rego</cc>
    
    <cc>sgill26</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1685441</commentid>
    <comment_count>0</comment_count>
      <attachid>407914</attachid>
    <who name="Oriol Brufau">obrufau</who>
    <bug_when>2020-09-03 14:40:28 -0700</bug_when>
    <thetext>Created attachment 407914
testcase

Originally filed by Mats Palmgren for Chromium (https://bugs.chromium.org/p/chromium/issues/detail?id=818401)

**What steps will reproduce the problem?**
(1) load the attached testcase

**What is the expected result?**
In the two tests labelled &quot;max-content&quot;, the grid container&apos;s width and its computed &apos;grid-template-columns&apos; value should be 40px, because that&apos;s the grid item&apos;s max-content size.

**What happens instead?**
The grid item overflows the grid container in the two tests labelled &quot;max-content&quot;.

The relevant spec section:
https://drafts.csswg.org/css-grid/#algo-single-span-items
&quot;For auto minimums:
If the track has an auto min track sizing function and the grid container is being sized under a min/max-content constraint, set the track’s base size to the maximum of its items’ min/max-content contributions, respectively.

Otherwise, set its base size to the maximum of its items’ min-size contributions. The min-size contribution of an item is the outer size that would result from assuming the item’s min-width or min-height value (whichever matches the relevant axis) as its specified size if its specified size (width or height, whichever matches the relevant axis) is auto, or else the item’s min-content contribution.&quot;

When sized under a min/max-content constraint, the base size is the item&apos;s min/max-content contributions, respectively.  The item has an explicit &apos;width&apos; that is &apos;max-content&apos;, thus it&apos;s min-content contribution is 40px and its max-content contribution is also 40px.
Thus the column size is 40px which makes the container&apos;s width 40px in both cases, thus the intrinsic width of the container is 40px.

Under &quot;no constraint&quot;, the 2nd paragraph applies, and the &apos;min-size contribution&apos; is &quot;the item’s min-content contribution&quot; (since its &apos;width&apos; is not &apos;auto&apos;).
Again, the result is 40px.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1687540</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-09-10 14:41:17 -0700</bug_when>
    <thetext>&lt;rdar://problem/68665611&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1893408</commentid>
    <comment_count>2</comment_count>
    <who name="Greg Whitworth">gwhitworth</who>
    <bug_when>2022-08-23 19:52:36 -0700</bug_when>
    <thetext>This has bitten me as well as can be seen in this scenario: 
(1) Open https://codepen.io/gregwhitworth/pen/BarERQv

Chromium and Firefox render as expected</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2112488</commentid>
    <comment_count>3</comment_count>
    <who name="">miteshgulecha</who>
    <bug_when>2025-04-22 15:05:38 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/44385</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>407914</attachid>
            <date>2020-09-03 14:40:28 -0700</date>
            <delta_ts>2020-09-03 14:40:28 -0700</delta_ts>
            <desc>testcase</desc>
            <filename>Chrome-bug-max-content.html</filename>
            <type>text/html</type>
            <size>1772</size>
            <attacher name="Oriol Brufau">obrufau</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjwhLS0KICAgICBBbnkgY29weXJpZ2h0IGlzIGRlZGljYXRlZCB0byB0
aGUgUHVibGljIERvbWFpbi4KICAgICBodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9wdWJsaWNk
b21haW4vemVyby8xLjAvCi0tPgo8aHRtbD48aGVhZD4KICA8bWV0YSBjaGFyc2V0PSJ1dGYtOCI+
CiAgPHRpdGxlPjwvdGl0bGU+CiAgPHN0eWxlIHR5cGU9InRleHQvY3NzIj4KCi5ncmlkIHsKICBk
aXNwbGF5OiBpbmxpbmUtZ3JpZDsKICBncmlkLXRlbXBsYXRlLWNvbHVtbnM6IG1pbm1heChhdXRv
LCAxNXB4KTsKICBhbGlnbi1pdGVtczogc3RhcnQ7CiAganVzdGlmeS1pdGVtczogc3RhcnQ7CiAg
Ym9yZGVyOiBkb3R0ZWQ7CiAgbWFyZ2luLWJvdHRvbTogNHB4Owp9CgoudDIgeyBncmlkLXRlbXBs
YXRlLWNvbHVtbnM6IG1pbm1heChhdXRvLCAzMHB4KTsgfQoKc3BhbiB7CiAgYmFja2dyb3VuZDog
Z3JleTsKfQoKLm1pbi1jb250ZW50IHsKICB3aWR0aDogLW1vei1taW4tY29udGVudDsKICB3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