Title: [265072] trunk/Source/WebKit
Revision
265072
Author
megan_gard...@apple.com
Date
2020-07-29 18:00:22 -0700 (Wed, 29 Jul 2020)

Log Message

Highlight color does not switch after being set it system preferences.
https://bugs.webkit.org/show_bug.cgi?id=214938
<rdar://problem/65270586>

Reviewed by Tim Horton.

After the changes to the sandbox and how defaults are being transferred to the web process
(https://trac.webkit.org/changeset/258064/webkit), the highlight color was not being updated
immediately. We need to send the proper notification after setting the defaults so that the
color cache is invalidated after it is actually set and we do not end up with a stale value.

* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::userHighlightColorPreferenceKey):
(WebKit::dispatchSimulatedNotificationsForPreferenceChange):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (265071 => 265072)


--- trunk/Source/WebKit/ChangeLog	2020-07-30 00:14:31 UTC (rev 265071)
+++ trunk/Source/WebKit/ChangeLog	2020-07-30 01:00:22 UTC (rev 265072)
@@ -1,3 +1,20 @@
+2020-07-29  Megan Gardner  <megan_gard...@apple.com>
+
+        Highlight color does not switch after being set it system preferences.
+        https://bugs.webkit.org/show_bug.cgi?id=214938
+        <rdar://problem/65270586>
+
+        Reviewed by Tim Horton.
+
+        After the changes to the sandbox and how defaults are being transferred to the web process
+        (https://trac.webkit.org/changeset/258064/webkit), the highlight color was not being updated 
+        immediately. We need to send the proper notification after setting the defaults so that the 
+        color cache is invalidated after it is actually set and we do not end up with a stale value.
+
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::userHighlightColorPreferenceKey):
+        (WebKit::dispatchSimulatedNotificationsForPreferenceChange):
+
 2020-07-29  Kate Cheney  <katherine_che...@apple.com>
 
         Migrate App-Bound Domains code from WebKit Additions

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (265071 => 265072)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-07-30 00:14:31 UTC (rev 265071)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-07-30 01:00:22 UTC (rev 265072)
@@ -922,6 +922,12 @@
     static NeverDestroyed<WTF::String> userAccentColorPreferenceKey(MAKE_STATIC_STRING_IMPL("AppleAccentColor"));
     return userAccentColorPreferenceKey;
 }
+
+static const WTF::String& userHighlightColorPreferenceKey()
+{
+    static NeverDestroyed<WTF::String> userHighlightColorPreferenceKey(MAKE_STATIC_STRING_IMPL("AppleHighlightColor"));
+    return userHighlightColorPreferenceKey;
+}
 #endif
 
 static void dispatchSimulatedNotificationsForPreferenceChange(const String& key)
@@ -930,8 +936,18 @@
     // Ordinarily, other parts of the system ensure that this notification is posted after this default is changed.
     // However, since we synchronize defaults to the Web Content process using a mechanism not known to the rest
     // of the system, we must re-post the notification in the Web Content process after updating the default.
-    if (key == userAccentColorPreferenceKey())
-        [[NSNotificationCenter defaultCenter] postNotificationName:@"kCUINotificationAquaColorVariantChanged" object:nil];
+    
+    if (key == userAccentColorPreferenceKey()) {
+        NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+        [notificationCenter postNotificationName:@"kCUINotificationAquaColorVariantChanged" object:nil];
+        [notificationCenter postNotificationName:@"NSSystemColorsWillChangeNotification" object:nil];
+        [notificationCenter postNotificationName:NSSystemColorsDidChangeNotification object:nil];
+    }
+    if (key == userHighlightColorPreferenceKey()) {
+        NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+        [notificationCenter postNotificationName:@"NSSystemColorsWillChangeNotification" object:nil];
+        [notificationCenter postNotificationName:NSSystemColorsDidChangeNotification object:nil];
+    }
 #endif
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to