Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 187dd258162fbd1c6ce6b4fbfaa7c3e7e9514468
https://github.com/WebKit/WebKit/commit/187dd258162fbd1c6ce6b4fbfaa7c3e7e9514468
Author: Kiet Ho <[email protected]>
Date: 2026-05-11 (Mon, 11 May 2026)
Changed paths:
A
LayoutTests/svg/custom/svg-image-dark-mode-prefers-color-scheme-repeat-loads-expected.html
A
LayoutTests/svg/custom/svg-image-dark-mode-prefers-color-scheme-repeat-loads.html
M Source/WebCore/loader/cache/CachedImage.cpp
Log Message:
-----------
prefers-color-scheme in SVG embedded using <img> or background-image is flaky
rdar://176413340
https://bugs.webkit.org/show_bug.cgi?id=314270
Reviewed by Said Abou-Hallawa.
When an SVG image, using @media (prefers-color-scheme), is embedded using <img
src> or
background-image, @media (prefers-color-scheme) evaluates to different results
between
reloads. This can be reproduced by reloading
LayoutTests/svg/custom/svg-image-dark-mode-initial.html
multiple times, and observing that the "<img> src" and "CSS background-image"
images
change between green and red between reloads.
303920@main implements @media (prefers-color-scheme) in SVG images by setting
the
appearance of the SVG's Page from system appearance. The flow to get the system
appearance
is SVGImage::dataChanged() -> ImageObserver::useSystemDarkAppearance()
(implemented by
CachedImageObserver::useSystemDarkAppearance()) ->
CachedImage::useSystemDarkAppearance() ->
calls CachedImageClient::useSystemDarkAppearance() on the first
CachedImageClient ->
RenderObject::CachedImageListener::useSystemDarkAppearance(). It's possible
that the first
CachedImageClient is not a RenderObject::CachedImageListener but something
else, in which its
useSystemDarkAppearance() is the default implementation in CachedImageClient
that returns false.
Fix this by having CachedImage::useSystemDarkAppearance() loop through all
clients, and
return true if any client->useSystemDarkAppearance() is true.
This was found when investigating
LayoutTests/svg/custom/svg-image-dark-mode-initial.html failing
in Site Isolation mode, so hopefully this will fix that too.
Test: svg/custom/svg-image-dark-mode-prefers-color-scheme-repeat-loads.html
*
LayoutTests/svg/custom/svg-image-dark-mode-prefers-color-scheme-repeat-loads-expected.html:
Added.
*
LayoutTests/svg/custom/svg-image-dark-mode-prefers-color-scheme-repeat-loads.html:
Added.
* Source/WebCore/loader/cache/CachedImage.cpp:
(WebCore::CachedImage::useSystemDarkAppearance const):
Canonical link: https://commits.webkit.org/313021@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications