Bug 221096

Summary: [macOS] Observe color preference changes in the UI process
Product: WebKit Reporter: Per Arne Vollan <pvollan>
Component: WebKit Misc.Assignee: Per Arne Vollan <pvollan>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Per Arne Vollan
Reported 2021-01-28 13:09:34 PST
As a step towards blocking the distributed notifications daemon in the WebContent process, color preference changes should be observed in the UI process. The UI process should notify the WebContent process about color preference changes.
Attachments
Patch (7.46 KB, patch)
2021-01-28 13:22 PST, Per Arne Vollan
no flags
Radar WebKit Bug Importer
Comment 1 2021-01-28 13:11:02 PST
Per Arne Vollan
Comment 2 2021-01-28 13:22:38 PST
Brent Fulgham
Comment 3 2021-01-29 10:05:38 PST
Comment on attachment 418666 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=418666&action=review > Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:107 > +static CFStringRef AppleColorPreferencesChangedNotification = CFSTR("AppleColorPreferencesChangedNotification"); Should this be in one of our PAL SPI files? > Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:595 > + auto* pool = reinterpret_cast<WebProcessPool*>(observer); Could pool be null (perhaps during launch or shutdown)? Maybe this should be: if (auto* pool = ....) pool->sendToAllProcesses This might apply to the 'backlightLevelDidChangeCallback', too. > Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:1022 > + CFNotificationCenterPostNotification(CFNotificationCenterGetLocalCenter(), CFSTR("NSColorLocalPreferencesChangedNotification"), nullptr, nullptr, true); Should 'NSColorLocalPreferencesChangedNotification' be something we put in PAL SPI somewhere? Is this a real thing used elsewhere in the system?
Per Arne Vollan
Comment 4 2021-01-29 13:19:43 PST
(In reply to Brent Fulgham from comment #3) > Comment on attachment 418666 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=418666&action=review > > > Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:107 > > +static CFStringRef AppleColorPreferencesChangedNotification = CFSTR("AppleColorPreferencesChangedNotification"); > > Should this be in one of our PAL SPI files? > The constant has not been assigned an official name in the system. Even so, should we add this to an SPI file? > > Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:595 > > + auto* pool = reinterpret_cast<WebProcessPool*>(observer); > > Could pool be null (perhaps during launch or shutdown)? Maybe this should be: > if (auto* pool = ....) > pool->sendToAllProcesses > > This might apply to the 'backlightLevelDidChangeCallback', too. > That is a good point. In this particular case it seems pool cannot be null, since it is being initialized with 'this' in 'CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), this, colorPreferencesDidChangeCallback, AppleColorPreferencesChangedNotification, nullptr, CFNotificationSuspensionBehaviorCoalesce)'. > > Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:1022 > > + CFNotificationCenterPostNotification(CFNotificationCenterGetLocalCenter(), CFSTR("NSColorLocalPreferencesChangedNotification"), nullptr, nullptr, true); > > Should 'NSColorLocalPreferencesChangedNotification' be something we put in > PAL SPI somewhere? Is this a real thing used elsewhere in the system? It is used in the system, but it seems it has not been assigned an official name. Would you prefer it being added to an SPI file? Thanks for reviewing!
Brent Fulgham
Comment 5 2021-02-01 09:47:34 PST
Comment on attachment 418666 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=418666&action=review r=me >>> Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:107 >>> +static CFStringRef AppleColorPreferencesChangedNotification = CFSTR("AppleColorPreferencesChangedNotification"); >> >> Should this be in one of our PAL SPI files? > > The constant has not been assigned an official name in the system. Even so, should we add this to an SPI file? No, not if it's our own thing. >>> Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:595 >>> + auto* pool = reinterpret_cast<WebProcessPool*>(observer); >> >> Could pool be null (perhaps during launch or shutdown)? Maybe this should be: >> if (auto* pool = ....) >> pool->sendToAllProcesses >> >> This might apply to the 'backlightLevelDidChangeCallback', too. > > That is a good point. In this particular case it seems pool cannot be null, since it is being initialized with 'this' in 'CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), this, colorPreferencesDidChangeCallback, AppleColorPreferencesChangedNotification, nullptr, CFNotificationSuspensionBehaviorCoalesce)'. Makes sense.
Per Arne Vollan
Comment 6 2021-02-01 09:54:23 PST
Comment on attachment 418666 [details] Patch Thanks for reviewing!
EWS
Comment 7 2021-02-01 12:06:32 PST
Committed r272154: <https://trac.webkit.org/changeset/272154> All reviewed patches have been landed. Closing bug and clearing flags on attachment 418666 [details].
Note You need to log in before you can comment on or make changes to this bug.