[webkit-changes] [WebKit/WebKit] 8b1ebb: [macOS] Selection color does not honor custom app ...
Aditya Keerthi
noreply at github.com
Tue Mar 18 10:46:59 PDT 2025
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 8b1ebb351d75cb4d484bc9467cd9abe0026f6bb0
https://github.com/WebKit/WebKit/commit/8b1ebb351d75cb4d484bc9467cd9abe0026f6bb0
Author: Aditya Keerthi <akeerthi at apple.com>
Date: 2025-03-18 (Tue, 18 Mar 2025)
Changed paths:
M Source/WebCore/PAL/pal/spi/mac/NSColorSPI.h
M Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm
Log Message:
-----------
[macOS] Selection color does not honor custom app accent colors
https://bugs.webkit.org/show_bug.cgi?id=289912
rdar://146919866
Reviewed by Richard Robinson.
App accent color support in WebKit works by forwarding the effective accent
color from the UI process to the web process, and updating the effective accent
color in the web process using `-[NSApplication _setAccentColor:]`.
More specifically, the web process attempts to set its accent color using
`[NSApp _setAccentColor:]`. `NSApp` is a static variable that is only set after
`-[NSApplication sharedApplication]` has been called once.
It appears that `-[NSApplication sharedApplication]` is no longer getting
invoked anywhere before WebKit attempts to set the accent color in the web
process. Consequently, `NSApp` is `nil`, `[NSApp _setAccentColor:]` is a
no-op, and the web process never updates its accent color.
Fix by calling `-[NSApplication sharedApplication]` upon process initialization,
and a regression test. This solution was chosen over updating the call site, as
other use of `NSApp` would remain risky.
* Source/WebCore/PAL/pal/spi/mac/NSColorSPI.h:
* Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm:
(TestWebKitAPI::TEST(WebKit, AppAccentColorAffectsSystemColors)):
The regression test does not directly test selection color, as that is not easy
to capture. Instead, it checks the value of a CSS system color, which should
follow the accent color.
Additionally, the test creates an additional web view for the sole purpose of
detecting when the user accent color has been correctly set in the global domain.
App accent colors do not apply unless the user accent color is "multicolor".
This test still "fails" occasionally when the system's accent color is not
already set to "multicolor", due to the preference update being slow. Since the
default setting is "multicolor", and the test still passes 90% of the time when
the user has a custom value, the test exits early rather than failing if the
user accent color could not be updated in a reasonable time.
Canonical link: https://commits.webkit.org/292312@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list