Unable to run system Safari with trunk WebKit
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Apr 2019 23:43:10 +0000 (23:43 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Apr 2019 23:43:10 +0000 (23:43 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244203 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/Shared/WebPreferencesDefaultValues.cpp
Source/WebKit/Shared/WebPreferencesDefaultValues.h
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/Cocoa/VersionChecks.h
Source/WebKit/UIProcess/Cocoa/VersionChecks.mm

index 4b4aab1..91c3986 100644 (file)
@@ -1,3 +1,27 @@
+2019-04-11  Chris Dumez  <cdumez@apple.com>
+
+        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.
+
 2019-04-11  Zalan Bujtas  <zalan@apple.com>
 
         Add @page margin support
index 8ff2ca0..3b52721 100644 (file)
@@ -14,12 +14,9 @@ DeviceOrientationEventEnabled:
 
 DeviceOrientationPermissionAPIEnabled:
   type: bool
-  defaultValue: defaultDeviceOrientationPermissionAPIEnabled()
+  defaultValue: false
   condition: ENABLE(DEVICE_ORIENTATION)
   webcoreName: deviceOrientationPermissionAPIEnabled
-  humanReadableName: "Permission API for device orientation / motion access."
-  humanReadableDescription: "DeviceOrientationEvent.requestPermission() / DeviceMotionEvent.requestPermission()"
-  category: experimental
 
 JavaScriptEnabled:
   type: bool
index cbf7d09..fa18251 100644 (file)
@@ -44,15 +44,6 @@ bool defaultPassiveTouchListenersAsDefaultOnDocument()
 #endif
 }
 
-bool defaultDeviceOrientationPermissionAPIEnabled()
-{
-#if PLATFORM(IOS) && ENABLE(DEVICE_ORIENTATION)
-    return linkedOnOrAfter(WebKit::SDKVersion::FirstWithDeviceOrientationAndMotionPermissionAPI);
-#else
-    return false;
-#endif
-}
-
 bool defaultCustomPasteboardDataEnabled()
 {
 #if PLATFORM(IOSMAC)
index a6d145d..f380be9 100644 (file)
 #endif
 
 bool defaultPassiveTouchListenersAsDefaultOnDocument();
-bool defaultDeviceOrientationPermissionAPIEnabled();
 bool defaultCustomPasteboardDataEnabled();
 
 #if PLATFORM(MAC)
index 2545f0e..2591dbe 100644 (file)
@@ -552,7 +552,7 @@ static void validate(WKWebViewConfiguration *configuration)
         WKProcessPool *relatedWebViewProcessPool = [relatedWebView->_configuration processPool];
         if (processPool && processPool != relatedWebViewProcessPool)
             [NSException raise:NSInvalidArgumentException format:@"Related web view %@ has process pool %@ but configuration specifies a different process pool %@", relatedWebView, relatedWebViewProcessPool, configuration.processPool];
-        if ([relatedWebView->_configuration websiteDataStore] != [_configuration websiteDataStore])
+        if ([relatedWebView->_configuration websiteDataStore] != [_configuration websiteDataStore] && linkedOnOrAfter(WebKit::SDKVersion::FirstWithExceptionsForRelatedWebViewsUsingDifferentDataStores, WebKit::AssumeSafariIsAlwaysLinkedOnAfter::No))
             [NSException raise:NSInvalidArgumentException format:@"Related web view %@ has data store %@ but configuration specifies a different data store %@", relatedWebView, [relatedWebView->_configuration websiteDataStore], [_configuration websiteDataStore]];
 
         [_configuration setProcessPool:relatedWebViewProcessPool];
@@ -628,6 +628,9 @@ static void validate(WKWebViewConfiguration *configuration)
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::systemLayoutDirectionKey(), WebKit::WebPreferencesStore::Value(static_cast<uint32_t>(WebCore::TextDirection::LTR)));
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::allowSettingAnyXHRHeaderFromFileURLsKey(), WebKit::WebPreferencesStore::Value(shouldAllowSettingAnyXHRHeaderFromFileURLs()));
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::shouldDecidePolicyBeforeLoadingQuickLookPreviewKey(), WebKit::WebPreferencesStore::Value(!![_configuration _shouldDecidePolicyBeforeLoadingQuickLookPreview]));
+#if ENABLE(DEVICE_ORIENTATION)
+    pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::deviceOrientationPermissionAPIEnabledKey(), WebKit::WebPreferencesStore::Value(linkedOnOrAfter(WebKit::SDKVersion::FirstWithDeviceOrientationAndMotionPermissionAPI)));
+#endif
 #if USE(SYSTEM_PREVIEW)
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::systemPreviewEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _systemPreviewEnabled]));
 #endif
index f4d4281..9003b14 100644 (file)
 #define DYLD_MACOS_VERSION_FIRST_WHERE_DOWNLOAD_ATTRIBUTE_DOES_NOT_OVERRIDE_NAVIGATION_DELEGATE 0
 #endif
 
+#ifndef DYLD_IOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES
+#define DYLD_IOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES 0
+#endif
+#ifndef DYLD_MACOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES
+#define DYLD_MACOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES 0
+#endif
+
 #ifndef DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API
 #define DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API 0
 #endif
@@ -63,6 +70,7 @@ enum class SDKVersion : uint32_t {
     FirstWhereDownloadAttributeDoesNotOverrideNavigationDelegate = DYLD_IOS_VERSION_FIRST_WHERE_DOWNLOAD_ATTRIBUTE_DOES_NOT_OVERRIDE_NAVIGATION_DELEGATE,
     FirstWithDeviceOrientationAndMotionPermissionAPI = DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API,
     FirstThatDecidesPolicyBeforeLoadingQuickLookPreview = DYLD_IOS_VERSION_FIRST_THAT_DECIDES_POLICY_BEFORE_LOADING_QUICK_LOOK_PREVIEW,
+    FirstWithExceptionsForRelatedWebViewsUsingDifferentDataStores = DYLD_IOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES,
 #elif PLATFORM(MAC)
     FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
     FirstWithExceptionsForDuplicateCompletionHandlerCalls = DYLD_MACOSX_VERSION_10_13,
@@ -71,9 +79,11 @@ enum class SDKVersion : uint32_t {
     FirstWithMainThreadReleaseAssertionInWebPageProxy = DYLD_MACOSX_VERSION_10_14,
     FirstWithSnapshotAfterScreenUpdates = DYLD_MACOS_VERSION_FIRST_WITH_SNAPSHOT_AFTER_SCREEN_UPDATES,
     FirstWhereDownloadAttributeDoesNotOverrideNavigationDelegate = DYLD_MACOS_VERSION_FIRST_WHERE_DOWNLOAD_ATTRIBUTE_DOES_NOT_OVERRIDE_NAVIGATION_DELEGATE,
+    FirstWithExceptionsForRelatedWebViewsUsingDifferentDataStores = DYLD_MACOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES,
 #endif
 };
 
-bool linkedOnOrAfter(SDKVersion);
+enum class AssumeSafariIsAlwaysLinkedOnAfter : bool { No, Yes };
+bool linkedOnOrAfter(SDKVersion, AssumeSafariIsAlwaysLinkedOnAfter = AssumeSafariIsAlwaysLinkedOnAfter::Yes);
 
 }
index 48e6bd8..0dd6537 100644 (file)
@@ -34,12 +34,12 @@ namespace WebKit {
 
 static NSString * const WebKitLinkedOnOrAfterEverythingKey = @"WebKitLinkedOnOrAfterEverything";
 
-bool linkedOnOrAfter(SDKVersion sdkVersion)
+bool linkedOnOrAfter(SDKVersion sdkVersion, AssumeSafariIsAlwaysLinkedOnAfter assumeSafariIsAlwaysLinkedOnAfter)
 {
-     static bool linkedOnOrAfterEverything;
-     static std::once_flag once;
-     std::call_once(once, [] {
-        bool isSafari = false;
+    static bool linkedOnOrAfterEverything = false;
+    static bool isSafari = false;
+    static std::once_flag once;
+    std::call_once(once, [] {
 #if PLATFORM(IOS_FAMILY)
         if (WebCore::IOSApplication::isMobileSafari())
             isSafari = true;
@@ -48,11 +48,18 @@ bool linkedOnOrAfter(SDKVersion sdkVersion)
             isSafari = true;
 #endif
 
-        if (isSafari || [[NSUserDefaults standardUserDefaults] boolForKey:WebKitLinkedOnOrAfterEverythingKey])
+        if ([[NSUserDefaults standardUserDefaults] boolForKey:WebKitLinkedOnOrAfterEverythingKey])
             linkedOnOrAfterEverything = true;
     });
 
-    return linkedOnOrAfterEverything ? true : dyld_get_program_sdk_version() >= static_cast<uint32_t>(sdkVersion);
+    if (UNLIKELY(linkedOnOrAfterEverything))
+        return true;
+
+    if (isSafari && assumeSafariIsAlwaysLinkedOnAfter == AssumeSafariIsAlwaysLinkedOnAfter::Yes)
+        return true;
+
+    auto sdkVersionAsInteger = static_cast<uint32_t>(sdkVersion);
+    return sdkVersionAsInteger && dyld_get_program_sdk_version() >= sdkVersionAsInteger;
 }
 
 }