Changeset 244203 in webkit


Ignore:
Timestamp:
Apr 11, 2019 4:43:10 PM (5 years ago)
Author:
Chris Dumez
Message:

Unable to run system Safari with trunk WebKit
https://bugs.webkit.org/show_bug.cgi?id=196777
<rdar://problem/49784574>

Reviewed by Alex Christensen.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _initializeWithConfiguration:]):
Add a linkedOnAfter check so that throwing exceptions when related web views use a different
data store only happens for apps rebuilt using recent SDK.

  • UIProcess/Cocoa/VersionChecks.h:
  • UIProcess/Cocoa/VersionChecks.mm:

(WebKit::linkedOnOrAfter):

  • By default, linkedOnOrAfter assumed Safari / MobileSafari is always linked-on-after. To satisfy my use cases, I introduced a new AssumeSafariIsAlwaysLinkedOnAfter parameter so that this behavior can be controlled by the caller.
  • In the header, DYLD_IOS_VERSION_* / DYLD_MACOS_VERSION_* constants are 0 when building with the non-internal SDK. As a result, the check instead linkedOnOrAfter() would cause us to always return true, which was wrong. I therefore updated the check inside linkedOnOrAfter() to special-case the 0 value for sdkVersion.
Location:
trunk/Source/WebKit
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r244202 r244203  
     12019-04-11  Chris Dumez  <cdumez@apple.com>
     2
     3        Unable to run system Safari with trunk WebKit
     4        https://bugs.webkit.org/show_bug.cgi?id=196777
     5        <rdar://problem/49784574>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * UIProcess/API/Cocoa/WKWebView.mm:
     10        (-[WKWebView _initializeWithConfiguration:]):
     11        Add a linkedOnAfter check so that throwing exceptions when related web views use a different
     12        data store only happens for apps rebuilt using recent SDK.
     13
     14        * UIProcess/Cocoa/VersionChecks.h:
     15        * UIProcess/Cocoa/VersionChecks.mm:
     16        (WebKit::linkedOnOrAfter):
     17        - By default, linkedOnOrAfter assumed Safari / MobileSafari is always linked-on-after. To satisfy my
     18          use cases, I introduced a new AssumeSafariIsAlwaysLinkedOnAfter parameter so that this behavior can
     19          be controlled by the caller.
     20        - In the header, DYLD_IOS_VERSION_* / DYLD_MACOS_VERSION_* constants are 0 when building with the
     21          non-internal SDK. As a result, the check instead linkedOnOrAfter() would cause us to always return
     22          true, which was wrong. I therefore updated the check inside linkedOnOrAfter() to special-case the
     23          0 value for sdkVersion.
     24
    1252019-04-11  Zalan Bujtas  <zalan@apple.com>
    226
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r244202 r244203  
    1515DeviceOrientationPermissionAPIEnabled:
    1616  type: bool
    17   defaultValue: defaultDeviceOrientationPermissionAPIEnabled()
     17  defaultValue: false
    1818  condition: ENABLE(DEVICE_ORIENTATION)
    1919  webcoreName: deviceOrientationPermissionAPIEnabled
    20   humanReadableName: "Permission API for device orientation / motion access."
    21   humanReadableDescription: "DeviceOrientationEvent.requestPermission() / DeviceMotionEvent.requestPermission()"
    22   category: experimental
    2320
    2421JavaScriptEnabled:
  • trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp

    r242664 r244203  
    4545}
    4646
    47 bool defaultDeviceOrientationPermissionAPIEnabled()
    48 {
    49 #if PLATFORM(IOS) && ENABLE(DEVICE_ORIENTATION)
    50     return linkedOnOrAfter(WebKit::SDKVersion::FirstWithDeviceOrientationAndMotionPermissionAPI);
    51 #else
    52     return false;
    53 #endif
    54 }
    55 
    5647bool defaultCustomPasteboardDataEnabled()
    5748{
  • trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h

    r244140 r244203  
    232232
    233233bool defaultPassiveTouchListenersAsDefaultOnDocument();
    234 bool defaultDeviceOrientationPermissionAPIEnabled();
    235234bool defaultCustomPasteboardDataEnabled();
    236235
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r244170 r244203  
    553553        if (processPool && processPool != relatedWebViewProcessPool)
    554554            [NSException raise:NSInvalidArgumentException format:@"Related web view %@ has process pool %@ but configuration specifies a different process pool %@", relatedWebView, relatedWebViewProcessPool, configuration.processPool];
    555         if ([relatedWebView->_configuration websiteDataStore] != [_configuration websiteDataStore])
     555        if ([relatedWebView->_configuration websiteDataStore] != [_configuration websiteDataStore] && linkedOnOrAfter(WebKit::SDKVersion::FirstWithExceptionsForRelatedWebViewsUsingDifferentDataStores, WebKit::AssumeSafariIsAlwaysLinkedOnAfter::No))
    556556            [NSException raise:NSInvalidArgumentException format:@"Related web view %@ has data store %@ but configuration specifies a different data store %@", relatedWebView, [relatedWebView->_configuration websiteDataStore], [_configuration websiteDataStore]];
    557557
     
    629629    pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::allowSettingAnyXHRHeaderFromFileURLsKey(), WebKit::WebPreferencesStore::Value(shouldAllowSettingAnyXHRHeaderFromFileURLs()));
    630630    pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::shouldDecidePolicyBeforeLoadingQuickLookPreviewKey(), WebKit::WebPreferencesStore::Value(!![_configuration _shouldDecidePolicyBeforeLoadingQuickLookPreview]));
     631#if ENABLE(DEVICE_ORIENTATION)
     632    pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::deviceOrientationPermissionAPIEnabledKey(), WebKit::WebPreferencesStore::Value(linkedOnOrAfter(WebKit::SDKVersion::FirstWithDeviceOrientationAndMotionPermissionAPI)));
     633#endif
    631634#if USE(SYSTEM_PREVIEW)
    632635    pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::systemPreviewEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _systemPreviewEnabled]));
  • trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h

    r244170 r244203  
    4040#endif
    4141
     42#ifndef DYLD_IOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES
     43#define DYLD_IOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES 0
     44#endif
     45#ifndef DYLD_MACOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES
     46#define DYLD_MACOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES 0
     47#endif
     48
    4249#ifndef DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API
    4350#define DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API 0
     
    6471    FirstWithDeviceOrientationAndMotionPermissionAPI = DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API,
    6572    FirstThatDecidesPolicyBeforeLoadingQuickLookPreview = DYLD_IOS_VERSION_FIRST_THAT_DECIDES_POLICY_BEFORE_LOADING_QUICK_LOOK_PREVIEW,
     73    FirstWithExceptionsForRelatedWebViewsUsingDifferentDataStores = DYLD_IOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES,
    6674#elif PLATFORM(MAC)
    6775    FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
     
    7280    FirstWithSnapshotAfterScreenUpdates = DYLD_MACOS_VERSION_FIRST_WITH_SNAPSHOT_AFTER_SCREEN_UPDATES,
    7381    FirstWhereDownloadAttributeDoesNotOverrideNavigationDelegate = DYLD_MACOS_VERSION_FIRST_WHERE_DOWNLOAD_ATTRIBUTE_DOES_NOT_OVERRIDE_NAVIGATION_DELEGATE,
     82    FirstWithExceptionsForRelatedWebViewsUsingDifferentDataStores = DYLD_MACOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES,
    7483#endif
    7584};
    7685
    77 bool linkedOnOrAfter(SDKVersion);
     86enum class AssumeSafariIsAlwaysLinkedOnAfter : bool { No, Yes };
     87bool linkedOnOrAfter(SDKVersion, AssumeSafariIsAlwaysLinkedOnAfter = AssumeSafariIsAlwaysLinkedOnAfter::Yes);
    7888
    7989}
  • trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.mm

    r244170 r244203  
    3535static NSString * const WebKitLinkedOnOrAfterEverythingKey = @"WebKitLinkedOnOrAfterEverything";
    3636
    37 bool linkedOnOrAfter(SDKVersion sdkVersion)
     37bool linkedOnOrAfter(SDKVersion sdkVersion, AssumeSafariIsAlwaysLinkedOnAfter assumeSafariIsAlwaysLinkedOnAfter)
    3838{
    39      static bool linkedOnOrAfterEverything;
    40      static std::once_flag once;
    41      std::call_once(once, [] {
    42         bool isSafari = false;
     39    static bool linkedOnOrAfterEverything = false;
     40    static bool isSafari = false;
     41    static std::once_flag once;
     42    std::call_once(once, [] {
    4343#if PLATFORM(IOS_FAMILY)
    4444        if (WebCore::IOSApplication::isMobileSafari())
     
    4949#endif
    5050
    51         if (isSafari || [[NSUserDefaults standardUserDefaults] boolForKey:WebKitLinkedOnOrAfterEverythingKey])
     51        if ([[NSUserDefaults standardUserDefaults] boolForKey:WebKitLinkedOnOrAfterEverythingKey])
    5252            linkedOnOrAfterEverything = true;
    5353    });
    5454
    55     return linkedOnOrAfterEverything ? true : dyld_get_program_sdk_version() >= static_cast<uint32_t>(sdkVersion);
     55    if (UNLIKELY(linkedOnOrAfterEverything))
     56        return true;
     57
     58    if (isSafari && assumeSafariIsAlwaysLinkedOnAfter == AssumeSafariIsAlwaysLinkedOnAfter::Yes)
     59        return true;
     60
     61    auto sdkVersionAsInteger = static_cast<uint32_t>(sdkVersion);
     62    return sdkVersionAsInteger && dyld_get_program_sdk_version() >= sdkVersionAsInteger;
    5663}
    5764
Note: See TracChangeset for help on using the changeset viewer.