Bug 251196
Summary: | image-set() should serialize in authored order | ||
---|---|---|---|
Product: | WebKit | Reporter: | Karl Dubost <karlcow> |
Component: | CSS | Assignee: | 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
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/104683422>
Ryan Reno
I wonder if the output is the sorted list of images after the engine calculated the preferred image order.
Ryan Reno
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
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
Pull request: https://github.com/WebKit/WebKit/pull/10680
Ryan Reno
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/38709
EWS
Committed 261015@main (2fff06ab22a9): <https://commits.webkit.org/261015@main>
Reviewed commits have been landed. Closing PR #10680 and removing active labels.