Bug 251196

Summary: image-set() should serialize in authored order
Product: WebKit Reporter: Karl Dubost <karlcow>
Component: CSSAssignee: Ryan Reno <rreno>
Status: RESOLVED FIXED    
Severity: Normal CC: rreno, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: BrowserCompat, InRadar, WPTImpact
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
URL: https://wpt.fyi/results/css/css-images/image-set/image-set-computed.sub.html?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2023-webcompat
See Also: https://github.com/web-platform-tests/wpt/pull/38709

Karl Dubost
Reported 2023-01-25 23:22:33 PST
Go to http://wpt.live/css/css-images/image-set/image-set-computed.sub.html Two tests are failing. expected: "image-set(url(\"http://wpt.live/example.png\") 63.5dppx, url(\"http://wpt.live/example.png\") 2dppx)" actual: "image-set(url(\"http://wpt.live/example.png\") 2dppx, url(\"http://wpt.live/example.png\") 63.5dppx)" expected: "image-set(url(\"http://wpt.live/example.png\") 2dppx, linear-gradient(rgb(0, 0, 0), rgb(255, 255, 255)) 1dppx)" actual: "image-set(linear-gradient(rgb(0, 0, 0), rgb(255, 255, 255)) 1dppx, url(\"http://wpt.live/example.png\") 2dppx)" The order of the rules have been swapped.
Attachments
Radar WebKit Bug Importer
Comment 1 2023-01-25 23:23:25 PST
Ryan Reno
Comment 2 2023-02-06 17:41:58 PST
I wonder if the output is the sorted list of images after the engine calculated the preferred image order.
Ryan Reno
Comment 3 2023-02-07 07:35:49 PST
Yes that's almost it. If I remove this sort the tests have the serialized arguments to image-set in the expected order: https://github.com/WebKit/WebKit/blob/6055ee6392589ea77765c0a3d4d8b8898a6534ff/Source/WebCore/css/CSSImageSetValue.cpp#L82 When we're constructing the style from the CSSImageSetValue object we sort the images by resolution so we can more quickly search for an appropriate resolution later when we need to pick one of the images. When we serialize the computed style we may no longer have the arguments in the order the author wrote them. So it's not in "engine preferred order" but in ascending resolution order.
Ryan Reno
Comment 4 2023-02-07 08:11:26 PST
When we implement support for type() (https://bugs.webkit.org/show_bug.cgi?id=225185) we will need to filter the set of images on supported MIME type. One thing that could be done to fix this bug is store the image-set as written by the author in the StyleImageSet object. On construction that object could then create a second list of sorted-by-resolution and filtered-by-MIME-type images that it uses in the algorithm to determine which image to use.
Ryan Reno
Comment 5 2023-02-24 23:25:16 PST
Ryan Reno
Comment 6 2023-02-24 23:52:28 PST
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/38709
EWS
Comment 7 2023-03-01 10:29:09 PST
Committed 261015@main (2fff06ab22a9): <https://commits.webkit.org/261015@main> Reviewed commits have been landed. Closing PR #10680 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.