⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 280726 in webkit


Ignore:
Timestamp:
Aug 6, 2021, 9:38:28 AM (5 years ago)
Author:
Peng Liu
Message:

[macOS] Clean up Feature Flags related code
https://bugs.webkit.org/show_bug.cgi?id=228803
<rdar://problem/81142982>

Reviewed by Tim Horton.

Source/WebKit:

On macOS, Safari Technology Preview or a local build WebKit/Safari will always
get the default preference values through the "Feature Flags" SPI. Unfortunately,
this approach won't work if the OS does not provide correct default preference values.

With this patch, we only get default preference values with the SPI for system
WebKit on macOS. For all other cases, we use hardcoded values. So that
WebKit will always get the correct default preference values.

This patch also fixes a few mistakes in two preferences: "webm_webaudio" and "vp8_decoder".

  • FeatureFlags/WebKit-appletvos.plist:
  • FeatureFlags/WebKit-ios.plist:
  • FeatureFlags/WebKit-macos.plist:
  • FeatureFlags/WebKit-watchos.plist:
  • Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm:

(WebKit::isFeatureFlagEnabled):

  • Shared/WebPreferencesDefaultValues.cpp:

(WebKit::isFeatureFlagEnabled):
(WebKit::defaultAsyncFrameAndOverflowScrollingEnabled):
(WebKit::defaultUseGPUProcessForCanvasRenderingEnabled):
(WebKit::defaultUseGPUProcessForDOMRenderingEnabled):
(WebKit::defaultUseGPUProcessForMediaEnabled):
(WebKit::defaultUseGPUProcessForWebGLEnabled):
(WebKit::defaultCaptureAudioInGPUProcessEnabled):
(WebKit::defaultCaptureVideoInGPUProcessEnabled):
(WebKit::defaultWebRTCCodecsInGPUProcess):
(WebKit::defaultIncrementalPDFEnabled):
(WebKit::defaultWebMFormatReaderEnabled):
(WebKit::defaultVP8DecoderEnabled):
(WebKit::defaultVP9DecoderEnabled):
(WebKit::defaultVP9SWDecoderEnabledOnBattery):
(WebKit::defaultWebMParserEnabled):
(WebKit::defaultWebMWebAudioEnabled):
(WebKit::defaultInAppBrowserPrivacy): Deleted.

  • Shared/WebPreferencesDefaultValues.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::creationParameters): Fix a typo.

Source/WebKitLegacy/mac:

On macOS, Safari Technology Preview or a local build WebKit/Safari will always
get the default preference values through the "Feature Flags" SPI. Unfortunately,
this approach won't work if the OS does not provide correct default preference values.

With this patch, we only get default preference values with the SPI for system
WebKit on macOS. For all other cases, we use hardcoded values. So that
WebKit will always get the correct default preference values.

This patch also fixes a few mistakes in two preferences: "webm_webaudio" and "vp8_decoder".

  • WebView/WebPreferencesDefaultValues.h:
  • WebView/WebPreferencesDefaultValues.mm:

(WebKit::isFeatureFlagEnabled):
(WebKit::defaultIncrementalPDFEnabled):
(WebKit::defaultWebXREnabled):
(WebKit::defaultWebMParserEnabled):
(WebKit::defaultWebMWebAudioEnabled):
(WebKit::defaultVP8DecoderEnabled):
(WebKit::defaultVP9DecoderEnabled):

LayoutTests:

Update a mac-bigsur specific test expectation file because the test is passing now.

  • platform/mac/imported/w3c/web-platform-tests/media-source/mediasource-addsourcebuffer-expected.txt: Removed.
  • platform/mac-bigsur/imported/w3c/web-platform-tests/media-source/mediasource-addsourcebuffer-expected.txt:
Location:
trunk
Files:
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r280721 r280726  
     12021-08-06  Peng Liu  <peng.liu6@apple.com>
     2
     3        [macOS] Clean up Feature Flags related code
     4        https://bugs.webkit.org/show_bug.cgi?id=228803
     5        <rdar://problem/81142982>
     6
     7        Reviewed by Tim Horton.
     8
     9        Update a mac-bigsur specific test expectation file because the test is passing now.
     10
     11        * platform/mac/imported/w3c/web-platform-tests/media-source/mediasource-addsourcebuffer-expected.txt: Removed.
     12        * platform/mac-bigsur/imported/w3c/web-platform-tests/media-source/mediasource-addsourcebuffer-expected.txt:
     13
    1142021-08-06  Antti Koivisto  <antti@apple.com>
    215
  • trunk/LayoutTests/platform/mac-bigsur/imported/w3c/web-platform-tests/media-source/mediasource-addsourcebuffer-expected.txt

    r270720 r280726  
    44PASS Test addSourceBuffer() with null
    55PASS Test addSourceBuffer() with unsupported type
    6 FAIL Test addSourceBuffer() with Vorbis and VP8 assert_true: video/webm;codecs="vp8,vorbis" is supported expected true got false
    7 FAIL Test addSourceBuffer() with Vorbis and VP8 in separate SourceBuffers assert_true: audio/webm;codecs="vorbis" is supported expected true got false
     6PASS Test addSourceBuffer() with Vorbis and VP8
     7PASS Test addSourceBuffer() with Vorbis and VP8 in separate SourceBuffers
    88PASS Test addSourceBuffer() video only
    99PASS Test addSourceBuffer() audio only
  • trunk/Source/WebKit/ChangeLog

    r280723 r280726  
     12021-08-06  Peng Liu  <peng.liu6@apple.com>
     2
     3        [macOS] Clean up Feature Flags related code
     4        https://bugs.webkit.org/show_bug.cgi?id=228803
     5        <rdar://problem/81142982>
     6
     7        Reviewed by Tim Horton.
     8
     9        On macOS, Safari Technology Preview or a local build WebKit/Safari will always
     10        get the default preference values through the "Feature Flags" SPI. Unfortunately,
     11        this approach won't work if the OS does not provide correct default preference values.
     12
     13        With this patch, we only get default preference values with the SPI for system
     14        WebKit on macOS. For all other cases, we use hardcoded values. So that
     15        WebKit will always get the correct default preference values.
     16
     17        This patch also fixes a few mistakes in two preferences: "webm_webaudio" and "vp8_decoder".
     18
     19        * FeatureFlags/WebKit-appletvos.plist:
     20        * FeatureFlags/WebKit-ios.plist:
     21        * FeatureFlags/WebKit-macos.plist:
     22        * FeatureFlags/WebKit-watchos.plist:
     23
     24        * Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm:
     25        (WebKit::isFeatureFlagEnabled):
     26        * Shared/WebPreferencesDefaultValues.cpp:
     27        (WebKit::isFeatureFlagEnabled):
     28        (WebKit::defaultAsyncFrameAndOverflowScrollingEnabled):
     29        (WebKit::defaultUseGPUProcessForCanvasRenderingEnabled):
     30        (WebKit::defaultUseGPUProcessForDOMRenderingEnabled):
     31        (WebKit::defaultUseGPUProcessForMediaEnabled):
     32        (WebKit::defaultUseGPUProcessForWebGLEnabled):
     33        (WebKit::defaultCaptureAudioInGPUProcessEnabled):
     34        (WebKit::defaultCaptureVideoInGPUProcessEnabled):
     35        (WebKit::defaultWebRTCCodecsInGPUProcess):
     36        (WebKit::defaultIncrementalPDFEnabled):
     37        (WebKit::defaultWebMFormatReaderEnabled):
     38        (WebKit::defaultVP8DecoderEnabled):
     39        (WebKit::defaultVP9DecoderEnabled):
     40        (WebKit::defaultVP9SWDecoderEnabledOnBattery):
     41        (WebKit::defaultWebMParserEnabled):
     42        (WebKit::defaultWebMWebAudioEnabled):
     43        (WebKit::defaultInAppBrowserPrivacy): Deleted.
     44        * Shared/WebPreferencesDefaultValues.h:
     45
     46        * UIProcess/WebPageProxy.cpp:
     47        (WebKit::WebPageProxy::creationParameters): Fix a typo.
     48
    1492021-08-06  Jer Noble  <jer.noble@apple.com>
    250
  • trunk/Source/WebKit/FeatureFlags/WebKit-appletvos.plist

    r280467 r280726  
    6868                <true/>
    6969        </dict>
     70        <key>vp8_decoder</key>
     71        <dict>
     72                <key>Enabled</key>
     73                <true/>
     74        </dict>
    7075        <key>WebXR</key>
    7176        <dict>
     
    8388                <true/>
    8489        </dict>
    85         <key>webm_webaudio</key>
    86         <dict>
    87                 <key>Enabled</key>
    88                 <true/>
    89         </dict>
    9090        <key>RB_full_manage_WK_jetsam</key>
    9191        <dict>
  • trunk/Source/WebKit/FeatureFlags/WebKit-ios.plist

    r280467 r280726  
    6868                <true/>
    6969        </dict>
     70        <key>vp8_decoder</key>
     71        <dict>
     72                <key>Enabled</key>
     73                <true/>
     74        </dict>
    7075        <key>WebXR</key>
    7176        <dict>
     
    8388                <true/>
    8489        </dict>
    85         <key>webm_webaudio</key>
    86         <dict>
    87                 <key>Enabled</key>
    88                 <true/>
    89         </dict>
    9090        <key>RB_full_manage_WK_jetsam</key>
    9191        <dict>
  • trunk/Source/WebKit/FeatureFlags/WebKit-macos.plist

    r280467 r280726  
    6868                <true/>
    6969        </dict>
     70        <key>vp8_decoder</key>
     71        <dict>
     72                <key>Enabled</key>
     73                <true/>
     74        </dict>
    7075        <key>WebXR</key>
    7176        <dict>
     
    8691        <dict>
    8792                <key>Enabled</key>
    88                 <true/>
     93                <false/>
    8994        </dict>
    9095        <key>RB_full_manage_WK_jetsam</key>
  • trunk/Source/WebKit/FeatureFlags/WebKit-watchos.plist

    r280467 r280726  
    6868                <true/>
    6969        </dict>
     70        <key>vp8_decoder</key>
     71        <dict>
     72                <key>Enabled</key>
     73                <true/>
     74        </dict>
    7075        <key>WebXR</key>
    7176        <dict>
     
    8388                <true/>
    8489        </dict>
    85         <key>webm_webaudio</key>
    86         <dict>
    87                 <key>Enabled</key>
    88                 <true/>
    89         </dict>
    9090        <key>RB_full_manage_WK_jetsam</key>
    9191        <dict>
  • trunk/Source/WebKit/Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm

    r280433 r280726  
    2727#import "WebPreferencesDefaultValues.h"
    2828
    29 #if PLATFORM(COCOA) && HAVE(SYSTEM_FEATURE_FLAGS)
     29#if PLATFORM(COCOA)
    3030
    3131#import <Foundation/NSBundle.h>
     
    3939
    4040// Because of <rdar://problem/60608008>, WebKit has to parse the feature flags plist file
    41 bool isFeatureFlagEnabled(const String& featureName)
     41bool isFeatureFlagEnabled(const String& featureName, bool defaultValue)
    4242{
    43     static bool isWebKitBundleFromStagedFramework = [] {
    44         NSBundle *webkit2Bundle = [NSBundle bundleForClass:NSClassFromString(@"WKWebView")];
    45         return [webkit2Bundle.bundlePath hasPrefix:@"/Library/Apple/System/Library/StagedFrameworks/Safari/"];
     43#if HAVE(SYSTEM_FEATURE_FLAGS)
     44
     45#if PLATFORM(MAC)
     46    static bool isSystemWebKit = [] {
     47        NSBundle *bundle = [NSBundle bundleForClass:NSClassFromString(@"WKWebView")];
     48        return [bundle.bundlePath hasPrefix:@"/System/"];
    4649    }();
    4750
    48     if (!isWebKitBundleFromStagedFramework)
    49         return _os_feature_enabled_impl("WebKit", (const char*)featureName.utf8().data());
    50 
    51     static NeverDestroyed<RetainPtr<NSDictionary>> dictionary = [NSDictionary dictionaryWithContentsOfFile:@"/Library/Apple/System/Library/FeatureFlags/Domain/WebKit.plist"];
    52 
    53     if (![[dictionary.get() objectForKey:featureName] objectForKey:@"Enabled"])
     51    if (isSystemWebKit)
    5452        return _os_feature_enabled_impl("WebKit", (const char*)featureName.characters8());
    5553
    56     return [[[dictionary.get() objectForKey:featureName] objectForKey:@"Enabled"] isKindOfClass:[NSNumber class]] && [[[dictionary.get() objectForKey:featureName] objectForKey:@"Enabled"] boolValue];
     54    return defaultValue;
     55#else
     56    UNUSED_PARAM(defaultValue);
     57    return _os_feature_enabled_impl("WebKit", (const char*)featureName.characters8());
     58#endif // PLATFORM(MAC)
     59
     60#else
     61
     62    UNUSED_PARAM(featureName);
     63    return defaultValue;
     64
     65#endif // HAVE(SYSTEM_FEATURE_FLAGS)
    5766}
    5867
  • trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp

    r280467 r280726  
    4242namespace WebKit {
    4343
     44#if !PLATFORM(COCOA)
     45bool isFeatureFlagEnabled(const String&, bool defaultValue)
     46{
     47    return defaultValue;
     48}
     49#endif
     50
    4451#if PLATFORM(IOS_FAMILY)
    4552
     
    109116#endif
    110117
    111 #if HAVE(SYSTEM_FEATURE_FLAGS)
    112     return isFeatureFlagEnabled("async_frame_and_overflow_scrolling");
    113 #endif
    114 
    115 #if PLATFORM(MAC)
    116     return true;
    117 #endif
    118 
    119     return false;
     118#if PLATFORM(MAC)
     119    bool defaultValue = true;
     120#else
     121    bool defaultValue = false;
     122#endif
     123
     124    return isFeatureFlagEnabled("async_frame_and_overflow_scrolling", defaultValue);
    120125}
    121126
     
    151156{
    152157#if ENABLE(GPU_PROCESS_BY_DEFAULT)
    153 #if HAVE(SYSTEM_FEATURE_FLAGS)
    154     return isFeatureFlagEnabled("gpu_process_canvas_rendering");
    155 #else
    156     return true;
    157 #endif // HAVE(SYSTEM_FEATURE_FLAGS)
    158 #else
     158    bool defaultValue = true;
     159#else
     160    bool defaultValue = false;
     161#endif
     162
     163    return isFeatureFlagEnabled("gpu_process_canvas_rendering", defaultValue);
     164}
     165
     166bool defaultUseGPUProcessForDOMRenderingEnabled()
     167{
     168    return isFeatureFlagEnabled("gpu_process_dom_rendering", false);
     169}
     170
     171bool defaultUseGPUProcessForMediaEnabled()
     172{
     173#if ENABLE(GPU_PROCESS_BY_DEFAULT)
     174    bool defaultValue = true;
     175#else
     176    bool defaultValue = false;
     177#endif
     178
     179    return isFeatureFlagEnabled("gpu_process_media", defaultValue);
     180}
     181
     182bool defaultUseGPUProcessForWebGLEnabled()
     183{
     184    return isFeatureFlagEnabled("gpu_process_webgl", false);
     185}
     186
     187#endif // ENABLE(GPU_PROCESS)
     188
     189#if ENABLE(MEDIA_STREAM)
     190
     191bool defaultCaptureAudioInGPUProcessEnabled()
     192{
     193#if ENABLE(GPU_PROCESS_BY_DEFAULT)
     194    bool defaultValue = true;
     195#else
     196    bool defaultValue = false;
     197#endif
     198
     199#if PLATFORM(MAC)
     200    return isFeatureFlagEnabled("gpu_process_webrtc", defaultValue);
     201#elif PLATFORM(IOS_FAMILY)
     202    return isFeatureFlagEnabled("gpu_process_media", defaultValue);
     203#else
     204    return defaultValue;
     205#endif
     206}
     207
     208bool defaultCaptureAudioInUIProcessEnabled()
     209{
     210#if PLATFORM(MAC)
     211    return !defaultCaptureAudioInGPUProcessEnabled();
     212#endif
     213
    159214    return false;
    160 #endif
    161 }
    162 
    163 bool defaultUseGPUProcessForDOMRenderingEnabled()
    164 {
    165 #if ENABLE(GPU_PROCESS_BY_DEFAULT)
    166 #if HAVE(SYSTEM_FEATURE_FLAGS)
    167     return isFeatureFlagEnabled("gpu_process_dom_rendering");
    168 #else
    169     return false;
    170 #endif // HAVE(SYSTEM_FEATURE_FLAGS)
    171 #else
    172     return false;
    173 #endif
    174 }
    175 
    176 bool defaultUseGPUProcessForMediaEnabled()
    177 {
    178 #if ENABLE(GPU_PROCESS_BY_DEFAULT)
    179 #if HAVE(SYSTEM_FEATURE_FLAGS)
    180     return isFeatureFlagEnabled("gpu_process_media");
    181 #else
    182     return true;
    183 #endif // HAVE(SYSTEM_FEATURE_FLAGS)
    184 #else
    185     return false;
    186 #endif
    187 }
    188 
    189 bool defaultUseGPUProcessForWebGLEnabled()
    190 {
    191 #if HAVE(SYSTEM_FEATURE_FLAGS)
    192     return isFeatureFlagEnabled("gpu_process_webgl");
    193 #endif
    194 
    195     return false;
    196 }
    197 
    198 #endif // ENABLE(GPU_PROCESS)
    199 
    200 #if ENABLE(MEDIA_STREAM)
    201 
    202 bool defaultCaptureAudioInGPUProcessEnabled()
    203 {
    204 #if ENABLE(GPU_PROCESS_BY_DEFAULT)
    205 
    206 #if HAVE(SYSTEM_FEATURE_FLAGS)
    207 #if PLATFORM(MAC)
    208     return isFeatureFlagEnabled("gpu_process_webrtc");
    209 #elif PLATFORM(IOS_FAMILY)
    210     return isFeatureFlagEnabled("gpu_process_media");
    211 #endif
    212 #else
    213     return true;
    214 #endif // HAVE(SYSTEM_FEATURE_FLAGS)
    215 
    216 #else
    217     return false;
    218 #endif
    219 }
    220 
    221 bool defaultCaptureAudioInUIProcessEnabled()
    222 {
    223 #if PLATFORM(MAC)
    224     return !defaultCaptureAudioInGPUProcessEnabled();
    225 #endif
    226 
    227     return false;
    228215}
    229216
     
    231218{
    232219#if ENABLE(GPU_PROCESS_BY_DEFAULT)
    233 #if HAVE(SYSTEM_FEATURE_FLAGS)
    234     return isFeatureFlagEnabled("gpu_process_webrtc");
    235 #else
    236     return true;
    237 #endif // HAVE(SYSTEM_FEATURE_FLAGS)
    238 #else
    239     return false;
    240 #endif
     220    bool defaultValue = true;
     221#else
     222    bool defaultValue = false;
     223#endif
     224
     225    return isFeatureFlagEnabled("gpu_process_webrtc", defaultValue);
    241226}
    242227
     
    248233{
    249234#if ENABLE(GPU_PROCESS_BY_DEFAULT)
    250 #if HAVE(SYSTEM_FEATURE_FLAGS)
    251     return isFeatureFlagEnabled("gpu_process_webrtc");
    252 #else
    253     return true;
    254 #endif // HAVE(SYSTEM_FEATURE_FLAGS)
    255 #else
    256     return false;
    257 #endif
     235    bool defaultValue = true;
     236#else
     237    bool defaultValue = false;
     238#endif
     239
     240    return isFeatureFlagEnabled("gpu_process_webrtc", defaultValue);
    258241}
    259242
    260243#endif // ENABLE(WEB_RTC)
    261 
    262 bool defaultInAppBrowserPrivacy()
    263 {
    264 #if HAVE(SYSTEM_FEATURE_FLAGS)
    265     return isFeatureFlagEnabled("InAppBrowserPrivacy");
    266 #endif
    267 
    268     return false;
    269 }
    270244
    271245#if HAVE(INCREMENTAL_PDF_APIS)
    272246bool defaultIncrementalPDFEnabled()
    273247{
    274 #if HAVE(SYSTEM_FEATURE_FLAGS)
    275     return isFeatureFlagEnabled("incremental_pdf");
    276 #endif
    277 
    278 #if PLATFORM(MAC)
     248#if PLATFORM(MAC)
     249    bool defaultValue = true;
     250#else
     251    bool defaultValue = false;
     252#endif
     253
     254    return isFeatureFlagEnabled("incremental_pdf", defaultValue);
     255}
     256#endif
     257
     258#if ENABLE(WEBXR)
     259
     260bool defaultWebXREnabled()
     261{
     262#if HAVE(WEBXR_INTERNALS)
    279263    return true;
    280264#else
     
    282266#endif
    283267}
    284 #endif
    285 
    286 #if ENABLE(WEBXR)
    287 
    288 bool defaultWebXREnabled()
    289 {
    290 #if HAVE(WEBXR_INTERNALS)
    291     return true;
    292 #else
    293     return false;
    294 #endif
    295 }
    296268
    297269#endif // ENABLE(WEBXR)
     
    301273bool defaultWebMFormatReaderEnabled()
    302274{
    303 #if HAVE(SYSTEM_FEATURE_FLAGS)
    304     return isFeatureFlagEnabled("webm_format_reader");
    305 #endif
    306 
    307 #if PLATFORM(MAC)
    308     return true;
    309 #else
    310     return false;
    311 #endif
     275#if PLATFORM(MAC)
     276    bool defaultValue = true;
     277#else
     278    bool defaultValue = false;
     279#endif
     280
     281    return isFeatureFlagEnabled("webm_format_reader", defaultValue);
    312282}
    313283
     
    318288bool defaultVP8DecoderEnabled()
    319289{
    320 #if HAVE(SYSTEM_FEATURE_FLAGS)
    321     return isFeatureFlagEnabled("vp8_decoder");
    322 #endif
    323 
    324     return false;
     290    return isFeatureFlagEnabled("vp8_decoder", true);
    325291}
    326292
    327293bool defaultVP9DecoderEnabled()
    328294{
    329 #if HAVE(SYSTEM_FEATURE_FLAGS)
    330     return isFeatureFlagEnabled("vp9_decoder");
    331 #endif
    332 
    333     return true;
     295    return isFeatureFlagEnabled("vp9_decoder", true);
    334296}
    335297
    336298bool defaultVP9SWDecoderEnabledOnBattery()
    337299{
    338 #if HAVE(SYSTEM_FEATURE_FLAGS)
    339     return isFeatureFlagEnabled("sw_vp9_decoder_on_battery");
    340 #endif
    341 
    342     return false;
     300    return isFeatureFlagEnabled("sw_vp9_decoder_on_battery", false);
    343301}
    344302#endif // ENABLE(VP9)
     
    348306bool defaultWebMParserEnabled()
    349307{
    350 #if HAVE(SYSTEM_FEATURE_FLAGS)
    351     return isFeatureFlagEnabled("webm_parser");
    352 #endif
    353 
    354     return true;
     308    return isFeatureFlagEnabled("webm_parser", true);
    355309}
    356310
    357311bool defaultWebMWebAudioEnabled()
    358312{
    359 #if HAVE(SYSTEM_FEATURE_FLAGS)
    360     return isFeatureFlagEnabled("webm_webaudio");
    361 #endif
    362 
    363     return false;
     313    return isFeatureFlagEnabled("webm_webaudio", false);
    364314}
    365315
  • trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h

    r280467 r280726  
    3636namespace WebKit {
    3737
    38 #if HAVE(SYSTEM_FEATURE_FLAGS)
    39 bool isFeatureFlagEnabled(const String&);
    40 #endif
     38bool isFeatureFlagEnabled(const String&, bool defaultValue = false);
    4139
    4240#if PLATFORM(IOS_FAMILY)
     
    8684#endif
    8785
    88 bool defaultInAppBrowserPrivacy();
    89 
    9086#if HAVE(INCREMENTAL_PDF_APIS)
    9187bool defaultIncrementalPDFEnabled();
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r280374 r280726  
    82408240#if ENABLE(VP9) && PLATFORM(COCOA)
    82418241    // FIXME: This is also being passed over the to WebProcess via the PreferencesStore.
    8242     parameters.shouldEnableVP8Decoder = preferences().vp9DecoderEnabled();
     8242    parameters.shouldEnableVP8Decoder = preferences().vp8DecoderEnabled();
    82438243    // FIXME: This is also being passed over the to WebProcess via the PreferencesStore.
    82448244    parameters.shouldEnableVP9SWDecoder = preferences().vp9DecoderEnabled() && (!WebCore::systemHasBattery() || preferences().vp9SWDecoderEnabledOnBattery());
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r280718 r280726  
     12021-08-06  Peng Liu  <peng.liu6@apple.com>
     2
     3        [macOS] Clean up Feature Flags related code
     4        https://bugs.webkit.org/show_bug.cgi?id=228803
     5        <rdar://problem/81142982>
     6
     7        Reviewed by Tim Horton.
     8
     9        On macOS, Safari Technology Preview or a local build WebKit/Safari will always
     10        get the default preference values through the "Feature Flags" SPI. Unfortunately,
     11        this approach won't work if the OS does not provide correct default preference values.
     12
     13        With this patch, we only get default preference values with the SPI for system
     14        WebKit on macOS. For all other cases, we use hardcoded values. So that
     15        WebKit will always get the correct default preference values.
     16
     17        This patch also fixes a few mistakes in two preferences: "webm_webaudio" and "vp8_decoder".
     18
     19        * WebView/WebPreferencesDefaultValues.h:
     20        * WebView/WebPreferencesDefaultValues.mm:
     21        (WebKit::isFeatureFlagEnabled):
     22        (WebKit::defaultIncrementalPDFEnabled):
     23        (WebKit::defaultWebXREnabled):
     24        (WebKit::defaultWebMParserEnabled):
     25        (WebKit::defaultWebMWebAudioEnabled):
     26        (WebKit::defaultVP8DecoderEnabled):
     27        (WebKit::defaultVP9DecoderEnabled):
     28
    1292021-08-05  Cameron McCormack  <heycam@apple.com>
    230
  • trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.h

    r280467 r280726  
    3636namespace WebKit {
    3737
    38 #if PLATFORM(COCOA) && HAVE(SYSTEM_FEATURE_FLAGS)
    39 bool isFeatureFlagEnabled(const String&);
     38#if PLATFORM(COCOA)
     39bool isFeatureFlagEnabled(const String&, bool defaultValue = false);
    4040#endif
    4141
  • trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm

    r280467 r280726  
    4343namespace WebKit {
    4444
    45 #if PLATFORM(COCOA) && HAVE(SYSTEM_FEATURE_FLAGS)
     45#if PLATFORM(COCOA)
    4646
    4747// Because of <rdar://problem/60608008>, WebKit has to parse the feature flags plist file
    48 bool isFeatureFlagEnabled(const String& featureName)
    49 {
    50     BOOL isWebKitBundleFromStagedFramework = [[[NSBundle mainBundle] bundlePath] hasPrefix:@"/Library/Apple/System/Library/StagedFrameworks/WebKit"];
    51 
    52     if (!isWebKitBundleFromStagedFramework)
    53         return _os_feature_enabled_impl("WebKit", (const char*)featureName.utf8().data());
    54 
    55     static NeverDestroyed<RetainPtr<NSDictionary>> dictionary = [NSDictionary dictionaryWithContentsOfFile:@"/Library/Apple/System/Library/FeatureFlags/Domain/WebKit.plist"];
    56 
    57     if (![[dictionary.get() objectForKey:featureName] objectForKey:@"Enabled"])
     48bool isFeatureFlagEnabled(const String& featureName, bool defaultValue)
     49{
     50#if HAVE(SYSTEM_FEATURE_FLAGS)
     51
     52#if PLATFORM(MAC)
     53    static bool isSystemWebKit = [] {
     54        NSBundle *bundle = [NSBundle bundleForClass:NSClassFromString(@"WebView")];
     55        return [bundle.bundlePath hasPrefix:@"/System/"];
     56    }();
     57
     58    if (isSystemWebKit)
    5859        return _os_feature_enabled_impl("WebKit", (const char*)featureName.characters8());
    5960
    60     return [[[dictionary.get() objectForKey:featureName] objectForKey:@"Enabled"] isKindOfClass:[NSNumber class]] && [[[dictionary.get() objectForKey:featureName] objectForKey:@"Enabled"] boolValue];
     61    return defaultValue;
     62#else
     63    UNUSED_PARAM(defaultValue);
     64    return _os_feature_enabled_impl("WebKit", (const char*)featureName.characters8());
     65#endif // PLATFORM(MAC)
     66
     67#else
     68
     69    UNUSED_PARAM(featureName);
     70    return defaultValue;
     71
     72#endif // HAVE(SYSTEM_FEATURE_FLAGS)
    6173}
    6274
     
    6779bool defaultIncrementalPDFEnabled()
    6880{
    69 #if HAVE(SYSTEM_FEATURE_FLAGS)
    70     return isFeatureFlagEnabled("incremental_pdf");
    71 #endif
    72 
    73     return false;
     81    return isFeatureFlagEnabled("incremental_pdf", false);
    7482}
    7583
     
    8088bool defaultWebXREnabled()
    8189{
    82 #if HAVE(SYSTEM_FEATURE_FLAGS)
    83     return isFeatureFlagEnabled("WebXR");
    84 #endif
    85 
    86     return false;
     90    return isFeatureFlagEnabled("WebXR", false);
    8791}
    8892
     
    279283bool defaultWebMParserEnabled()
    280284{
    281 #if HAVE(SYSTEM_FEATURE_FLAGS)
    282     return isFeatureFlagEnabled("webm_parser");
    283 #endif
    284 
    285     return true;
     285    return isFeatureFlagEnabled("webm_parser", true);
    286286}
    287287
    288288bool defaultWebMWebAudioEnabled()
    289289{
    290 #if HAVE(SYSTEM_FEATURE_FLAGS)
    291     return isFeatureFlagEnabled("webm_webaudio");
    292 #endif
    293 
    294     return false;
     290    return isFeatureFlagEnabled("webm_webaudio", false);
    295291}
    296292
     
    301297bool defaultVP8DecoderEnabled()
    302298{
    303 #if HAVE(SYSTEM_FEATURE_FLAGS)
    304     return isFeatureFlagEnabled("vp8_decoder");
    305 #endif
    306 
    307     return false;
     299    return isFeatureFlagEnabled("vp8_decoder", true);
    308300}
    309301
    310302bool defaultVP9DecoderEnabled()
    311303{
    312 #if HAVE(SYSTEM_FEATURE_FLAGS)
    313     return isFeatureFlagEnabled("vp9_decoder");
    314 #endif
    315 
    316     return true;
     304    return isFeatureFlagEnabled("vp9_decoder", true);
    317305}
    318306
Note: See TracChangeset for help on using the changeset viewer.