<?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>261552</bug_id>
          
          <creation_ts>2023-09-14 02:28:52 -0700</creation_ts>
          <short_desc>getComputedStyle(elt).backgroundBlendMode returns only the first property of a list (background-blend-mode)</short_desc>
          <delta_ts>2023-10-12 19:45:41 -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>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=263051</see_also>
          <bug_file_loc>http://wpt.live/css/compositing/parsing/background-blend-mode-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>263104</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Karl Dubost">karlcow</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>emilio</cc>
    
    <cc>heycam</cc>
    
    <cc>koivisto</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1977465</commentid>
    <comment_count>0</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-09-14 02:28:52 -0700</bug_when>
    <thetext>see http://wpt.live/css/compositing/parsing/background-blend-mode-computed.html

when &quot;normal, luminosity&quot; is specified it returns only &quot;normal&quot;
while the &quot;normal, luminosity&quot; values are considered supported.

Firefox passes the test.
http://wpt.fyi/css/compositing/parsing/background-blend-mode-computed.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1978930</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-09-21 02:29:13 -0700</bug_when>
    <thetext>&lt;rdar://problem/115832043&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984236</commentid>
    <comment_count>2</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-10-11 00:38:31 -0700</bug_when>
    <thetext>https://searchfox.org/wubkat/rev/e21786e1635702a6ca7c1e30290f32e8a97fec23/Source/WebCore/css/ComputedStyleExtractor.cpp#4101-4109

    case CSSPropertyBackgroundBlendMode: {
        auto&amp; layers = style.backgroundLayers();
        if (!layers.next())
            return createConvertingToCSSValueID(layers.blendMode());
        CSSValueListBuilder list;
        for (auto* currLayer = &amp;layers; currLayer; currLayer = currLayer-&gt;next())
            list.append(createConvertingToCSSValueID(currLayer-&gt;blendMode()));
        return CSSValueList::createSpaceSeparated(WTFMove(list));
    }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984238</commentid>
    <comment_count>3</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-10-11 00:55:50 -0700</bug_when>
    <thetext>I do not have much knowledge on this code, but the `getComputedStyle()` seems to take into account a list of values `CSSValueList::createSpaceSeparated(WTFMove(list));`. 

So maybe this is related to the computation of `auto&amp; layers = style.backgroundLayers();`

Probably Antti is a better person for understanding what is the source of the issue.
Once understood Maybe it will be easy to fix.

oh wait, is it because it should be comma instead of space.

`CSSValueList::createCommaSeparated(WTFMove(list));`.
instead of:
`CSSValueList::createSpaceSeparated(WTFMove(list));`.


```
&gt; target.style.backgroundBlendMode
&lt; &quot;screen, overlay&quot;
&gt; getComputedStyle(target)[&apos;background-blend-mode&apos;]
&lt; &quot;screen&quot;
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984241</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-10-11 01:18:05 -0700</bug_when>
    <thetext>That&apos;s not it. 

* Not because of layers
* Not because of Comma vs Space</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984242</commentid>
    <comment_count>5</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-10-11 01:33:53 -0700</bug_when>
    <thetext>Maybe layers, only 1?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984392</commentid>
    <comment_count>6</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2023-10-11 14:10:06 -0700</bug_when>
    <thetext>I think it is because it should be createCommaSeparated(). See the similar code for case CSSPropertyBackgroundImage:</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984411</commentid>
    <comment_count>7</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-10-11 14:54:45 -0700</bug_when>
    <thetext>yes, I quickly tried to replace by createCommaSeparated, but it didn&apos;t fix it. 

So I added different WTFLogAlways() at a couple of places.
It never goes in that part part of the code with CSSValueList::createCommaSeparated(WTFMove(list))

So there must be something else too. 

I will try again to make double sure.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984466</commentid>
    <comment_count>8</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-10-11 17:04:58 -0700</bug_when>
    <thetext>Simon, 
I tried again by just changing to make sure. And it&apos;s not only the createCommaSeparated/createSpaceSeparated

diff --git a/Source/WebCore/css/ComputedStyleExtractor.cpp b/Source/WebCore/css/ComputedStyleExtractor.cpp
index b3c66f42e0f0..0b652382f480 100644
--- a/Source/WebCore/css/ComputedStyleExtractor.cpp
+++ b/Source/WebCore/css/ComputedStyleExtractor.cpp
@@ -4099,13 +4099,19 @@ RefPtr&lt;CSSValue&gt; ComputedStyleExtractor::valueForPropertyInStyle(const RenderSty
         return createConvertingToCSSValueID(style.isolation());
 #endif
     case CSSPropertyBackgroundBlendMode: {
+        WTFLogAlways(&quot;Inside CSSPropertyBackgroundBlendMode&quot;);
         auto&amp; layers = style.backgroundLayers();
-        if (!layers.next())
+        if (!layers.next()) {
+            WTFLogAlways(&quot;Early return createConvertingToCSSValueID(layers.blendMode())&quot;);
             return createConvertingToCSSValueID(layers.blendMode());
+        }
         CSSValueListBuilder list;
         for (auto* currLayer = &amp;layers; currLayer; currLayer = currLayer-&gt;next())
             list.append(createConvertingToCSSValueID(currLayer-&gt;blendMode()));
-        return CSSValueList::createSpaceSeparated(WTFMove(list));
+        // we want a comma separated list,
+        // but are we reaching this line of code?
+        WTFLogAlways(&quot;final return CSSValueList::createCommaSeparated(WTFMove(list))&quot;);
+        return CSSValueList::createCommaSeparated(WTFMove(list));
     }
     case CSSPropertyBackground:
         return getBackgroundShorthandValue();


and loading:
http://wpt.live/css/compositing/parsing/background-blend-mode-computed.html

it never goes to the last return for the list of values.


% run-minibrowser debug       
Starting MiniBrowser with DYLD_FRAMEWORK_PATH set to point to built WebKit in /Users/karlcow/code/OpenSource/WebKitBuild/Debug.
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())
Inside CSSPropertyBackgroundBlendMode
Early return createConvertingToCSSValueID(layers.blendMode())</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984473</commentid>
    <comment_count>9</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2023-10-11 17:21:09 -0700</bug_when>
    <thetext>This depends on whether the background-image property has &gt; 1 image, since, in webkit, that determines the length of the FillLayers list.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984493</commentid>
    <comment_count>10</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-10-11 18:14:01 -0700</bug_when>
    <thetext>So in Bug 263051, the createCommaSeparated() list is being fixed.

But that doesn&apos;t solve this issue as explained in the comments above. 

There could be a test bug, but it&apos;s not totally sure either. 
http://wpt.live/css/compositing/parsing/background-blend-mode-computed.html

Simon is saying:

&gt; there should be a FillLayer per background value; the length of the list is determined by background-image/mask-image


but we should double check the spec first to see how this is supposed to work. 
https://drafts.fxtf.org/compositing-1/#background-blend-mode

&gt; Defines the blending mode of each background layer.
&gt; 
&gt; Each background layer must blend with the element’s background layer 
&gt; that is below it and the element’s background color. Background layers 
&gt; must not blend with the content that is behind the element, instead 
&gt; they must act as if they are rendered into an isolated group.

and


&gt; The background-blend-mode list must be applied in the same order 
&gt; as background-image [CSS3BG]. This means that the first element 
&gt; in the list will apply to the layer that is on top. If a property 
&gt; doesn’t have enough comma-separated values to match the number 
&gt; of layers, the UA must calculate its used value by repeating the 
&gt; list of values until there are enough.


The layering seems to be defined in 
https://drafts.csswg.org/css-backgrounds-3/#layering

It says:

&gt; Each of the images is sized, positioned, and tiled according 
&gt; to the corresponding value in the other background properties. 

Then 

&gt; The lists are matched up from the first value: excess values 
&gt; at the end are not used. 

Then 

&gt; If a property doesn’t have enough comma-separated values 
&gt; to match the number of layers, the UA must calculate its used value 
&gt; by repeating the list of values until there are enough.


I need to read this carefully again. 

The example in this section 

background-image: url(flower.png), url(ball.png), url(grass.png);
background-position: center center, 20% 80%, top left, bottom right;
background-origin: border-box, content-box;
background-repeat: no-repeat;

has exactly the same effect as this set with the extra position dropped and the missing values for background-origin and background-repeat filled in (emphasized for clarity):

background-image: url(flower.png), url(ball.png), url(grass.png);
background-position: center center, 20% 80%, top left;
background-origin: border-box, content-box, border-box;
background-repeat: no-repeat, no-repeat, no-repeat;


And we can see that for background-position where there is 4 values list with an extra &quot;bottom right&quot;, it drops it to make it a 3 values list.

So from this I would say the test as currently defined on WPT is wrong and probably the implementation of Gecko too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984507</commentid>
    <comment_count>11</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-10-11 19:41:57 -0700</bug_when>
    <thetext>Note tests will be fixed/extended in 
https://github.com/web-platform-tests/wpt/issues/42496</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984531</commentid>
    <comment_count>12</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-10-11 22:47:36 -0700</bug_when>
    <thetext>I opened a bug on Mozilla bugzilla too. 
https://bugzilla.mozilla.org/show_bug.cgi?id=1858591</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984551</commentid>
    <comment_count>13</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-10-12 00:35:39 -0700</bug_when>
    <thetext>I was too hasty here. 

See the discussions on the tests fix!
https://github.com/web-platform-tests/wpt/issues/42496#issuecomment-1759017241

The latest discussions in the CSS WG
https://github.com/w3c/csswg-drafts/issues/7164#issuecomment-1201340918

led fantasai to clarify the way this is working
https://drafts.csswg.org/css-values-4/#linked-properties


Specifically this sentence:

&gt; The computed values of the coordinating list properties are not affected by such truncation or repetition.

which means getComputedStyle() should return the same list than what was specified. 

(even if the used values have been truncated or repeated.)

So there is something which needs to be fixed in WebKit (and Blink).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984560</commentid>
    <comment_count>14</comment_count>
      <attachid>468185</attachid>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-10-12 01:09:31 -0700</bug_when>
    <thetext>Created attachment 468185
testcase

it has a bigger impact than just backgroundBlendMode.
We might want to rename this bug. 

getComputedStyle(elt).* should return the specified values for coordinating list properties.

.test {
    background-image: url(foo.ping);
    background-blend-mode: normal, luminosity;
    background-position: 0px 0px, 10px 10px;
}

let test = document.querySelector(&apos;.test&apos;);
window.getComputedStyle(test).backgroundBlendMode;
window.getComputedStyle(test).backgroundPosition;

should return (like Gecko)

normal, luminosity
0px 0px, 10px 10px

currently WebKit and Blink return

normal
0px 0px</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984800</commentid>
    <comment_count>15</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-10-12 19:45:41 -0700</bug_when>
    <thetext>Created Bug 263104</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>468185</attachid>
            <date>2023-10-12 01:09:31 -0700</date>
            <delta_ts>2023-10-12 01:09:31 -0700</delta_ts>
            <desc>testcase</desc>
            <filename>computed-background-linked-list-values.html</filename>
            <type>text/html</type>
            <size>1136</size>
            <attacher name="Karl Dubost">karlcow</attacher>
            
              <data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QoJ3Jlc3VsdCcpLnRleHRDb250ZW50ID0gJ2dldENTKCku
YmFja2dyb3VuZEJsZW5kTW9kZTogJyArIGNvbXB1dGVkU3R5bGUxICsgJ1xuJwogICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAnZ2V0Q1Mo
KS5iYWNrZ3JvdW5kUG9zaXRpb246ICcgKyBjb21wdXRlZFN0eWxlMjsKICAgICAgICB9LCBmYWxz
ZSk7CiAgICA8L3NjcmlwdD4KPC9oZWFkPgo8Ym9keT4KICAgIDxkaXYgY2xhc3M9ImJveCI+CiAg
ICA8L2Rpdj4KICAgIDxwcmUgaWQ9InJlc3VsdCI+PC9wcmU+CjwvYm9keT4KPC9odG1sPgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>