<?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>245105</bug_id>
          
          <creation_ts>2022-09-12 16:58:57 -0700</creation_ts>
          <short_desc>CSS properties set to &apos;initial&apos; don&apos;t roundtrip from CSSOM correctly</short_desc>
          <delta_ts>2022-09-26 19:33:42 -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 Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>185953</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=245104</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ahmad Saleem">ahmad.saleem792</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>bfulgham</cc>
    
    <cc>karlcow</cc>
    
    <cc>obrufau</cc>
    
    <cc>rniwa</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>1898074</commentid>
    <comment_count>0</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-09-12 16:58:57 -0700</bug_when>
    <thetext>Hi Team,

I was going through Chrome MonoRail and came across another test case, where Webkit is different from other browsers:

Link - https://jsbin.com/lezefopa/1/edit?html,console,output

Chrome Bug - https://bugs.chromium.org/p/chromium/issues/detail?id=358273

____

*** Safari 16 on macOS 12.6 ***

.foo { } 

*** Safari Technology Preview 153 ***

.foo { }

*** Chrome Canary 107 ***

.foo { background: initial; border: initial; padding: initial; position: initial; opacity: initial; }

*** Firefox Nightly 106 ***

.foo { background: initial; border: initial; padding: initial; position: initial; opacity: initial; } 


______

I think matching with other browsers would be great.

If it is duplicate, please mark this as such. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1899685</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-09-19 16:59:18 -0700</bug_when>
    <thetext>&lt;rdar://problem/100147342&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1900344</commentid>
    <comment_count>2</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2022-09-22 04:43:29 -0700</bug_when>
    <thetext>  &lt;style&gt;
    .foo {
      background: initial;
      border: initial;
      padding: initial;
      position: initial;
      opacity: initial;
    }    
  &lt;/style&gt;

with 

document.querySelector(&apos;style&apos;).sheet.cssRules[0].cssText


&gt; The cssText attribute must return a serialization of the CSS rule. On setting the cssText attribute must do nothing.

https://drafts.csswg.org/cssom/#serialize-a-css-rule

if I comment out this part 

git diff
diff --git a/Source/WebCore/css/StyleProperties.cpp b/Source/WebCore/css/StyleProperties.cpp
index 1768f465451d..769da676ae45 100644
--- a/Source/WebCore/css/StyleProperties.cpp
+++ b/Source/WebCore/css/StyleProperties.cpp
@@ -1750,8 +1750,8 @@ StringBuilder StyleProperties::asTextInternal() const
         } else
             value = property.value()-&gt;cssText();
 
-        if (propertyID != CSSPropertyCustom &amp;&amp; value == &quot;initial&quot;_s &amp;&amp; !CSSProperty::isInheritedProperty(propertyID))
-            continue;
+        // if (propertyID != CSSPropertyCustom &amp;&amp; value == &quot;initial&quot;_s &amp;&amp; !CSSProperty::isInheritedProperty(propertyID))
+        //     continue;
 
         if (numDecls++)
             result.append(&apos; &apos;);


I get for the test result:


.foo { background-image: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; border: initial; padding: initial; position: initial; opacity: initial; }

which almost fixes it except for background shorthand which gets expanded.
(that might break other things.) 

Maybe it needs a function similar to 
https://searchfox.org/wubkat/rev/abe3878de54ffed9a6eb6de74e246bee9739e209/Source/WebCore/css/StyleProperties.cpp#1135-1157</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1900346</commentid>
    <comment_count>3</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2022-09-22 04:59:52 -0700</bug_when>
    <thetext>ah there&apos;s also a different behavior for background with regards to shorthands.

.foo {
      background: green;
    }

and

document.querySelector(&apos;style&apos;).sheet.cssRules[0].cssText


will return: 

in chrome
.foo { background: green; } 

in firefox
.foo { background: green; } 

but in safari
.foo { background-color: green; }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1900350</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2022-09-22 05:28:52 -0700</bug_when>
    <thetext>The modification in comment #2 would fix:
http://wpt.live/css/cssom/shorthand-serialization.html

but is breaking the third test.
http://wpt.live/css/cssom/border-shorthand-serialization.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1900627</commentid>
    <comment_count>5</comment_count>
    <who name="Oriol Brufau">obrufau</who>
    <bug_when>2022-09-23 06:55:32 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 185953 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>