<?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>271627</bug_id>
          
          <creation_ts>2024-03-24 22:28:17 -0700</creation_ts>
          <short_desc>shorthand value for CSS gap is not kept as-is in serialized and computed values.</short_desc>
          <delta_ts>2024-03-28 12:24:01 -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>Safari 17</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>https://wpt.fyi/results/css/css-align/parsing/gap-computed.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>
          <dependson>271692</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Karl Dubost">karlcow</reporter>
          <assigned_to name="Karl Dubost">karlcow</assigned_to>
          <cc>ntim</cc>
    
    <cc>obrufau</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2023579</commentid>
    <comment_count>0</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-03-24 22:28:17 -0700</bug_when>
    <thetext>see http://wpt.live/css/css-align/parsing/gap-computed.html
    https://wpt.fyi/results/css/css-align/parsing/gap-computed.html

with 
  const target = document.getElementById(&apos;target&apos;);
  target.style[&apos;gap&apos;] = &apos;normal&apos;;
Then doing:
  target.style.cssText;
  target.style.getPropertyValue(&apos;gap&apos;);
  window.getComputedStyle(target).gap;


Safari:
cssText:          &quot;row-gap: normal; column-gap: normal;&quot;
getPropertyValue: &quot;normal&quot;
getComputedStyle: &quot;normal normal&quot;

Firefox:
cssText:          &quot;gap: normal;&quot;
getPropertyValue: &quot;normal&quot;
getComputedStyle: &quot;normal&quot;


Chrome:
cssText:          &quot;gap: normal;&quot;
getPropertyValue: &quot;normal&quot;
getComputedStyle: &quot;normal&quot;

  




In https://searchfox.org/wubkat/rev/de98fcee68c0bd94f16d6dfb9dac2ea106ee40d5/Source/WebCore/css/parser/CSSPropertyParser.cpp#2911-2921
    case CSSPropertyGap: {
        RefPtr rowGap = CSSPropertyParsing::consumeRowGap(m_range, m_context);
        RefPtr columnGap = CSSPropertyParsing::consumeColumnGap(m_range, m_context);
        if (!rowGap || !m_range.atEnd())
            return false;
        if (!columnGap)
            columnGap = rowGap;
        addProperty(CSSPropertyRowGap, CSSPropertyGap, rowGap.releaseNonNull(), important);
        addProperty(CSSPropertyColumnGap, CSSPropertyGap, columnGap.releaseNonNull(), important);
        return true;
    }


In https://searchfox.org/wubkat/rev/de98fcee68c0bd94f16d6dfb9dac2ea106ee40d5/Source/WebCore/css/ComputedStyleExtractor.cpp#3695-3696
    case CSSPropertyGap:
        return getCSSPropertyValuesForShorthandProperties(gapShorthand());



In https://searchfox.org/wubkat/rev/de98fcee68c0bd94f16d6dfb9dac2ea106ee40d5/Source/WebCore/css/ComputedStyleExtractor.cpp#4788-4794
Ref&lt;CSSValueList&gt; ComputedStyleExtractor::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand&amp; shorthand) const
{
    CSSValueListBuilder list;
    for (auto longhand : shorthand)
        list.append(propertyValue(longhand, UpdateLayout::No).releaseNonNull());
    return CSSValueList::createSpaceSeparated(WTFMove(list));
}


And [StylePropertyShorthandFunctions.cpp](https://searchfox.org/wubkat/source/__GENERATED__/WebCore/DerivedSources/StylePropertyShorthandFunctions.cpp#839-846)
StylePropertyShorthand gapShorthand()
{
    static const CSSPropertyID gapProperties[] = {
        CSSPropertyID::CSSPropertyRowGap,
        CSSPropertyID::CSSPropertyColumnGap,
    };
    return StylePropertyShorthand(CSSPropertyID::CSSPropertyGap, gapProperties);
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2023580</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-03-24 22:28:29 -0700</bug_when>
    <thetext>&lt;rdar://problem/125335787&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2023586</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Nguyen (:ntim)">ntim</who>
    <bug_when>2024-03-24 23:44:56 -0700</bug_when>
    <thetext>Fixing the cssText bit is just a matter of removing this line: https://searchfox.org/wubkat/rev/de98fcee68c0bd94f16d6dfb9dac2ea106ee40d5/Source/WebCore/css/StyleProperties.cpp#253

There are many ways to fix getComputedStyle, the easiest one being using ShorthandSerializer for the computed style by adding CSSPropertyGap here: https://searchfox.org/wubkat/rev/de98fcee68c0bd94f16d6dfb9dac2ea106ee40d5/Source/WebCore/css/CSSComputedStyleDeclaration.cpp#131-136</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2023592</commentid>
    <comment_count>3</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-03-25 00:35:27 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/26398</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2024520</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-03-28 12:23:59 -0700</bug_when>
    <thetext>Committed 276794@main (ab28ade5ffd5): &lt;https://commits.webkit.org/276794@main&gt;

Reviewed commits have been landed. Closing PR #26398 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>