Title: [287364] trunk/Source
Revision
287364
Author
[email protected]
Date
2021-12-22 10:48:55 -0800 (Wed, 22 Dec 2021)

Log Message

Preferences that read from NSUserDefaults need to be initialied from platformInitializeStore()
https://bugs.webkit.org/show_bug.cgi?id=234488

Reviewed by Sam Weinig.

Having the default value for a preference read from NSUserDefaults can cause issues
if the UIProcess and WebProcess values don't match. Instead, have platformInitializeStore()
explicitly add values for these keys; this is done for scrollAnimatorEnabledKey.

Source/WebKit:

* UIProcess/Cocoa/WebPreferencesCocoa.mm:
(WebKit::WebPreferences::initializePlatformDependentPreferences):
(WebKit::WebPreferences::platformInitializeStore):
* UIProcess/WebPreferences.cpp:
(WebKit::WebPreferences::initializePlatformDependentPreferences):
* UIProcess/WebPreferences.h:

Source/WTF:

* Scripts/Preferences/WebPreferences.yaml:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (287363 => 287364)


--- trunk/Source/WTF/ChangeLog	2021-12-22 18:35:41 UTC (rev 287363)
+++ trunk/Source/WTF/ChangeLog	2021-12-22 18:48:55 UTC (rev 287364)
@@ -1,3 +1,16 @@
+2021-12-22  Simon Fraser  <[email protected]>
+
+        Preferences that read from NSUserDefaults need to be initialied from platformInitializeStore()
+        https://bugs.webkit.org/show_bug.cgi?id=234488
+
+        Reviewed by Sam Weinig.
+
+        Having the default value for a preference read from NSUserDefaults can cause issues
+        if the UIProcess and WebProcess values don't match. Instead, have platformInitializeStore()
+        explicitly add values for these keys; this is done for scrollAnimatorEnabledKey.
+
+        * Scripts/Preferences/WebPreferences.yaml:
+
 2021-12-22  J Pascoe  <[email protected]>
 
         [WebAuthn] Set Web Authentication experimental feature flag as default true

Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml (287363 => 287364)


--- trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml	2021-12-22 18:35:41 UTC (rev 287363)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml	2021-12-22 18:48:55 UTC (rev 287364)
@@ -1893,7 +1893,7 @@
       "PLATFORM(GTK) || PLATFORM(WPE)": true
       default: false
     WebKit:
-      "PLATFORM(MAC)": WebKit::defaultScrollAnimatorEnabled()
+      # PLATFORM(MAC) initializes the value in initializeProcessStateDependentPreferences
       "PLATFORM(GTK) || PLATFORM(WPE)": true
       default: false
     WebCore:

Modified: trunk/Source/WebKit/ChangeLog (287363 => 287364)


--- trunk/Source/WebKit/ChangeLog	2021-12-22 18:35:41 UTC (rev 287363)
+++ trunk/Source/WebKit/ChangeLog	2021-12-22 18:48:55 UTC (rev 287364)
@@ -1,3 +1,21 @@
+2021-12-22  Simon Fraser  <[email protected]>
+
+        Preferences that read from NSUserDefaults need to be initialied from platformInitializeStore()
+        https://bugs.webkit.org/show_bug.cgi?id=234488
+
+        Reviewed by Sam Weinig.
+
+        Having the default value for a preference read from NSUserDefaults can cause issues
+        if the UIProcess and WebProcess values don't match. Instead, have platformInitializeStore()
+        explicitly add values for these keys; this is done for scrollAnimatorEnabledKey.
+
+        * UIProcess/Cocoa/WebPreferencesCocoa.mm:
+        (WebKit::WebPreferences::initializePlatformDependentPreferences):
+        (WebKit::WebPreferences::platformInitializeStore):
+        * UIProcess/WebPreferences.cpp:
+        (WebKit::WebPreferences::initializePlatformDependentPreferences):
+        * UIProcess/WebPreferences.h:
+
 2021-12-22  Commit Queue  <[email protected]>
 
         Unreviewed, reverting r285087.

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPreferencesCocoa.mm (287363 => 287364)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebPreferencesCocoa.mm	2021-12-22 18:35:41 UTC (rev 287363)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPreferencesCocoa.mm	2021-12-22 18:48:55 UTC (rev 287364)
@@ -140,18 +140,27 @@
     store.setUInt32ValueForKey(key, [object unsignedIntegerValue]);
 }
 
-void WebPreferences::platformInitializeStore()
+void WebPreferences::initializeProcessStateDependentPreferences()
 {
-    @autoreleasepool {
 #if ENABLE(MEDIA_STREAM)
-        // NOTE: This is set here, and does not setting the default using the 'defaultValue' mechanism, because the
-        // 'defaultValue' must be the same in both the UIProcess and WebProcess, which may not be true for audio
-        // and video capture state as the WebProcess is not entitled to use the camera or microphone by default.
-        // If other preferences need to dynamically set the initial value based on host app state, we should extended
-        // the declarative format rather than adding more special cases here.
-        m_store.setBoolValueForKey(WebPreferencesKey::mediaDevicesEnabledKey(), UserMediaPermissionRequestManagerProxy::permittedToCaptureAudio() || UserMediaPermissionRequestManagerProxy::permittedToCaptureVideo());
+    // NOTE: This is set here, and does not set the default using the 'defaultValue' mechanism, because the
+    // 'defaultValue' must be the same in both the UIProcess and WebProcess, which may not be true for audio
+    // and video capture state as the WebProcess is not entitled to use the camera or microphone by default.
+    // If other preferences need to dynamically set the initial value based on host app state, we should extended
+    // the declarative format rather than adding more special cases here.
+    m_store.setBoolValueForKey(WebPreferencesKey::mediaDevicesEnabledKey(), UserMediaPermissionRequestManagerProxy::permittedToCaptureAudio() || UserMediaPermissionRequestManagerProxy::permittedToCaptureVideo());
 #endif
 
+#if PLATFORM(MAC)
+    m_store.setBoolValueForKey(WebPreferencesKey::scrollAnimatorEnabledKey(), [[NSUserDefaults standardUserDefaults] boolForKey:@"NSScrollAnimationEnabled"]);
+#endif
+}
+
+void WebPreferences::platformInitializeStore()
+{
+    @autoreleasepool {
+        initializeProcessStateDependentPreferences();
+
 #define INITIALIZE_DEBUG_PREFERENCE_FROM_NSUSERDEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue, HumanReadableName, HumanReadableDescription) \
         setDebug##TypeName##ValueIfInUserDefaults(m_identifier, m_keyPrefix, m_globalDebugKeyPrefix, WebPreferencesKey::KeyLower##Key(), m_store);
 

Modified: trunk/Source/WebKit/UIProcess/WebPreferences.cpp (287363 => 287364)


--- trunk/Source/WebKit/UIProcess/WebPreferences.cpp	2021-12-22 18:35:41 UTC (rev 287363)
+++ trunk/Source/WebKit/UIProcess/WebPreferences.cpp	2021-12-22 18:48:55 UTC (rev 287364)
@@ -228,6 +228,10 @@
 #endif
 
 #if !PLATFORM(COCOA)
+void WebPreferences::initializeProcessStateDependentPreferences()
+{
+}
+
 void WebPreferences::platformUpdateStringValueForKey(const String&, const String&)
 {
     notImplemented();

Modified: trunk/Source/WebKit/UIProcess/WebPreferences.h (287363 => 287364)


--- trunk/Source/WebKit/UIProcess/WebPreferences.h	2021-12-22 18:35:41 UTC (rev 287363)
+++ trunk/Source/WebKit/UIProcess/WebPreferences.h	2021-12-22 18:48:55 UTC (rev 287364)
@@ -89,6 +89,7 @@
 
 private:
     void platformInitializeStore();
+    void initializeProcessStateDependentPreferences();
 
     void update();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to