Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: ae31aa9f4098d28ea997a4f9e04e585e637be6cb
https://github.com/WebKit/WebKit/commit/ae31aa9f4098d28ea997a4f9e04e585e637be6cb
Author: Kiet Ho <[email protected]>
Date: 2025-07-15 (Tue, 15 Jul 2025)
Changed paths:
A LayoutTests/fast/media/mq-inverted-colors-ua-style-on-to-off-expected.html
A LayoutTests/fast/media/mq-inverted-colors-ua-style-on-to-off.html
M LayoutTests/platform/gtk/TestExpectations
M Source/WebCore/style/StyleScope.cpp
Log Message:
-----------
Dynamic media queries in user-agent shadow DOM stylesheet don't get updated
when accessibility settings change
rdar://142851714
https://bugs.webkit.org/show_bug.cgi?id=294905
Reviewed by Simon Fraser.
Two events occur when an accessibilty setting changes (like toggling "Smart
invert"):
1. Web process got an IPC message that ScreenProperties has changed.
(WebKit::WebProcess::setScreenProperties). This calls
WebKit::WebPage::screenPropertiesDidChange ->
Page::screenPropertiesDidChange ->
Page::setNeedsRecalcStyleInAllFrames ->
Scope::didChangeStyleSheetEnvironment -> calls
Scope::scheduleUpdate on document scope and non-user-agent shadow root scopes.
Scope::scheduleUpdate clears out the resolver so they could be rebuilt with
the new ScreenProperties on the next update. Crucially, resolvers of user-agent
shadow root scopes don't get cleared. So it's possible that the resolver of the
document scope is cleared, but not resolvers of user-agent shadow root scopes.
(1)
2. Web process got an IPC message that accessibility settings has changed
(Page::accessibilitySettingsDidChange). This calls
Scope::evaluateMediaQueriesForAccessibilitySettingsChange() ->
Scope::evaluateMediaQueries() to re-evaluate dynamic media queries in the
document.
To do that, it calls Scope::collectResolverScopes() to collect resolvers for
re-evaluation. The method assumes that if the document scope doesn't have a
resolver, then the scopes of shadow roots in the document also won't have a
resolver. This is wrong because of (1)
The effect: When an accessibility setting changes, dynamic media queries in the
document are re-evaluated, except for media queries in user-agent shadow-DOM
trees.
This breaks "Smart invert", since this uses @media (inverted-colors) in
user-agent stylesheet (see Source/WebCore/css/html.css and
Source/WebCore/Modules/modern-media-controls/controls/media-controls.css)
* LayoutTests/fast/media/mq-inverted-colors-ua-style-on-to-off-expected.html:
Added.
* LayoutTests/fast/media/mq-inverted-colors-ua-style-on-to-off.html: Added.
* LayoutTests/platform/gtk/TestExpectations:
- New test is failing on GTK, adding expectation for it.
* Source/WebCore/style/StyleScope.cpp:
(WebCore::Style::Scope::collectResolverScopes):
- Collect resolvers of shadow root scopes, even when the document scope
resolver doesn't exist.
(WebCore::Style::Scope::didChangeStyleSheetEnvironment):
- Call Scope::scheduleUpdate on all shadow root scopes, including user-agent
shadow roots.
Canonical link: https://commits.webkit.org/297386@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes