Changeset 287364 in webkit


Ignore:
Timestamp:
Dec 22, 2021, 10:48:55 AM (4 years ago)
Author:
Simon Fraser
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:
Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r287360 r287364  
     12021-12-22  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Preferences that read from NSUserDefaults need to be initialied from platformInitializeStore()
     4        https://bugs.webkit.org/show_bug.cgi?id=234488
     5
     6        Reviewed by Sam Weinig.
     7
     8        Having the default value for a preference read from NSUserDefaults can cause issues
     9        if the UIProcess and WebProcess values don't match. Instead, have platformInitializeStore()
     10        explicitly add values for these keys; this is done for scrollAnimatorEnabledKey.
     11
     12        * Scripts/Preferences/WebPreferences.yaml:
     13
    1142021-12-22  J Pascoe  <j_pascoe@apple.com>
    215
  • trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml

    r287228 r287364  
    18941894      default: false
    18951895    WebKit:
    1896       "PLATFORM(MAC)": WebKit::defaultScrollAnimatorEnabled()
     1896      # PLATFORM(MAC) initializes the value in initializeProcessStateDependentPreferences
    18971897      "PLATFORM(GTK) || PLATFORM(WPE)": true
    18981898      default: false
  • trunk/Source/WebKit/ChangeLog

    r287358 r287364  
     12021-12-22  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Preferences that read from NSUserDefaults need to be initialied from platformInitializeStore()
     4        https://bugs.webkit.org/show_bug.cgi?id=234488
     5
     6        Reviewed by Sam Weinig.
     7
     8        Having the default value for a preference read from NSUserDefaults can cause issues
     9        if the UIProcess and WebProcess values don't match. Instead, have platformInitializeStore()
     10        explicitly add values for these keys; this is done for scrollAnimatorEnabledKey.
     11
     12        * UIProcess/Cocoa/WebPreferencesCocoa.mm:
     13        (WebKit::WebPreferences::initializePlatformDependentPreferences):
     14        (WebKit::WebPreferences::platformInitializeStore):
     15        * UIProcess/WebPreferences.cpp:
     16        (WebKit::WebPreferences::initializePlatformDependentPreferences):
     17        * UIProcess/WebPreferences.h:
     18
    1192021-12-22  Commit Queue  <commit-queue@webkit.org>
    220
  • trunk/Source/WebKit/UIProcess/Cocoa/WebPreferencesCocoa.mm

    r268012 r287364  
    141141}
    142142
     143void WebPreferences::initializeProcessStateDependentPreferences()
     144{
     145#if ENABLE(MEDIA_STREAM)
     146    // NOTE: This is set here, and does not set the default using the 'defaultValue' mechanism, because the
     147    // 'defaultValue' must be the same in both the UIProcess and WebProcess, which may not be true for audio
     148    // and video capture state as the WebProcess is not entitled to use the camera or microphone by default.
     149    // If other preferences need to dynamically set the initial value based on host app state, we should extended
     150    // the declarative format rather than adding more special cases here.
     151    m_store.setBoolValueForKey(WebPreferencesKey::mediaDevicesEnabledKey(), UserMediaPermissionRequestManagerProxy::permittedToCaptureAudio() || UserMediaPermissionRequestManagerProxy::permittedToCaptureVideo());
     152#endif
     153
     154#if PLATFORM(MAC)
     155    m_store.setBoolValueForKey(WebPreferencesKey::scrollAnimatorEnabledKey(), [[NSUserDefaults standardUserDefaults] boolForKey:@"NSScrollAnimationEnabled"]);
     156#endif
     157}
     158
    143159void WebPreferences::platformInitializeStore()
    144160{
    145161    @autoreleasepool {
    146 #if ENABLE(MEDIA_STREAM)
    147         // NOTE: This is set here, and does not setting the default using the 'defaultValue' mechanism, because the
    148         // 'defaultValue' must be the same in both the UIProcess and WebProcess, which may not be true for audio
    149         // and video capture state as the WebProcess is not entitled to use the camera or microphone by default.
    150         // If other preferences need to dynamically set the initial value based on host app state, we should extended
    151         // the declarative format rather than adding more special cases here.
    152         m_store.setBoolValueForKey(WebPreferencesKey::mediaDevicesEnabledKey(), UserMediaPermissionRequestManagerProxy::permittedToCaptureAudio() || UserMediaPermissionRequestManagerProxy::permittedToCaptureVideo());
    153 #endif
     162        initializeProcessStateDependentPreferences();
    154163
    155164#define INITIALIZE_DEBUG_PREFERENCE_FROM_NSUSERDEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue, HumanReadableName, HumanReadableDescription) \
  • trunk/Source/WebKit/UIProcess/WebPreferences.cpp

    r271287 r287364  
    229229
    230230#if !PLATFORM(COCOA)
     231void WebPreferences::initializeProcessStateDependentPreferences()
     232{
     233}
     234
    231235void WebPreferences::platformUpdateStringValueForKey(const String&, const String&)
    232236{
  • trunk/Source/WebKit/UIProcess/WebPreferences.h

    r276880 r287364  
    9090private:
    9191    void platformInitializeStore();
     92    void initializeProcessStateDependentPreferences();
    9293
    9394    void update();
Note: See TracChangeset for help on using the changeset viewer.