Enable modern compatibility mode by default in WKWebView on some devices
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Apr 2019 03:54:10 +0000 (03:54 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Apr 2019 03:54:10 +0000 (03:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196883
<rdar://problem/49864527>

Reviewed by Tim Horton.

Source/WebCore:

Add a new helper function to determine whether an app is pre-installed on iOS, for the purposes of ensuring
compatibility with existing Apple apps that are not affected by linked-on-or-after. This involves all apps with
a bundle ID that begins with "com.apple.".

* platform/RuntimeApplicationChecks.h:
* platform/cocoa/RuntimeApplicationChecksCocoa.mm:
(WebCore::setApplicationBundleIdentifier):
(WebCore::applicationBundleStartsWith):
(WebCore::IOSApplication::isAppleApplication):

Source/WebKit:

Make some minor adjustments to new API.

* Shared/WebCompatibilityMode.h:

Rename WebCompatibilityMode::Default to WebCompatibilityMode::Recommended.

* Shared/WebPreferences.yaml:
* Shared/WebPreferencesDefaultValues.h:

Now that the role of the UseModernCompatibilityModeByDefault debug preference is limited to bypassing linked-on-
or-after and app bundle compatibility hacks, we no longer make this default to true in iOSMac.

* UIProcess/API/APIWebsitePolicies.h:
* UIProcess/API/Cocoa/WKNavigationDelegate.h:

Rename the withPreferences: label to just preferences:.

* UIProcess/API/Cocoa/WKWebViewConfiguration.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::setNavigationDelegate):
(WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
* UIProcess/Cocoa/VersionChecks.h:
* UIProcess/ios/WebPageProxyIOS.mm:

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

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/RuntimeApplicationChecks.h
Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebCompatibilityMode.h
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/Shared/WebPreferencesDefaultValues.h
Source/WebKit/UIProcess/API/APIWebsitePolicies.h
Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegate.h
Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.h
Source/WebKit/UIProcess/Cocoa/NavigationState.mm
Source/WebKit/UIProcess/Cocoa/VersionChecks.h
Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

index ad6357d..3f5ad65 100644 (file)
@@ -1,3 +1,21 @@
+2019-04-12  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Enable modern compatibility mode by default in WKWebView on some devices
+        https://bugs.webkit.org/show_bug.cgi?id=196883
+        <rdar://problem/49864527>
+
+        Reviewed by Tim Horton.
+
+        Add a new helper function to determine whether an app is pre-installed on iOS, for the purposes of ensuring
+        compatibility with existing Apple apps that are not affected by linked-on-or-after. This involves all apps with
+        a bundle ID that begins with "com.apple.".
+
+        * platform/RuntimeApplicationChecks.h:
+        * platform/cocoa/RuntimeApplicationChecksCocoa.mm:
+        (WebCore::setApplicationBundleIdentifier):
+        (WebCore::applicationBundleStartsWith):
+        (WebCore::IOSApplication::isAppleApplication):
+
 2019-04-12  Justin Fan  <justin_fan@apple.com>
 
         [Web GPU] Prevent narrowing conversions during Metal function calls on 32-bit platforms
index ba0d46f..f22b7c6 100644 (file)
@@ -91,6 +91,7 @@ WEBCORE_EXPORT bool isCardiogram();
 WEBCORE_EXPORT bool isNike();
 bool isMoviStarPlus();
 WEBCORE_EXPORT bool isFirefox();
+WEBCORE_EXPORT bool isAppleApplication();
 
 } // IOSApplication
 
index 60b2330..54238cd 100644 (file)
@@ -62,7 +62,7 @@ String applicationBundleIdentifier()
 void setApplicationBundleIdentifier(const String& bundleIdentifier)
 {
     ASSERT(RunLoop::isMain());
-    ASSERT_WITH_MESSAGE(!applicationBundleIdentifierOverrideWasQueried, "applicationBundleIsEqualTo() should not be called before setApplicationBundleIdentifier()");
+    ASSERT_WITH_MESSAGE(!applicationBundleIdentifierOverrideWasQueried, "applicationBundleIsEqualTo() and applicationBundleStartsWith() should not be called before setApplicationBundleIdentifier()");
     applicationBundleIdentifierOverride() = bundleIdentifier;
 }
 
@@ -191,6 +191,11 @@ bool MacApplication::isSolidStateNetworksDownloader()
 
 #if PLATFORM(IOS_FAMILY)
 
+static bool applicationBundleStartsWith(const String& bundleIdentifierPrefix)
+{
+    return applicationBundleIdentifier().startsWith(bundleIdentifierPrefix);
+}
+
 bool IOSApplication::isMobileMail()
 {
     static bool isMobileMail = applicationBundleIsEqualTo("com.apple.mobilemail"_s);
@@ -283,6 +288,12 @@ bool IOSApplication::isFirefox()
     return isFirefox;
 }
 
+bool IOSApplication::isAppleApplication()
+{
+    static bool isAppleApplication = applicationBundleStartsWith("com.apple."_s);
+    return isAppleApplication;
+}
+
 #endif
 
 } // namespace WebCore
index 641473e..cdfdb07 100644 (file)
@@ -1,3 +1,35 @@
+2019-04-12  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Enable modern compatibility mode by default in WKWebView on some devices
+        https://bugs.webkit.org/show_bug.cgi?id=196883
+        <rdar://problem/49864527>
+
+        Reviewed by Tim Horton.
+
+        Make some minor adjustments to new API.
+
+        * Shared/WebCompatibilityMode.h:
+
+        Rename WebCompatibilityMode::Default to WebCompatibilityMode::Recommended.
+
+        * Shared/WebPreferences.yaml:
+        * Shared/WebPreferencesDefaultValues.h:
+
+        Now that the role of the UseModernCompatibilityModeByDefault debug preference is limited to bypassing linked-on-
+        or-after and app bundle compatibility hacks, we no longer make this default to true in iOSMac.
+
+        * UIProcess/API/APIWebsitePolicies.h:
+        * UIProcess/API/Cocoa/WKNavigationDelegate.h:
+
+        Rename the withPreferences: label to just preferences:.
+
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::setNavigationDelegate):
+        (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
+        * UIProcess/Cocoa/VersionChecks.h:
+        * UIProcess/ios/WebPageProxyIOS.mm:
+
 2019-04-12  Brian Burg  <bburg@apple.com>
 
         WebDriver: fix typo in EnterFullscreen.js in error-handling code
index a8420ca..91b5bb1 100644 (file)
@@ -30,7 +30,7 @@
 namespace WebKit {
 
 enum class WebCompatibilityMode {
-    Default,
+    Recommended,
     Legacy,
     Modern,
 };
index 1c2fd76..e9ee671 100644 (file)
@@ -1060,7 +1060,7 @@ DisableScreenSizeOverride:
 
 UseModernCompatibilityModeByDefault:
   type: bool
-  defaultValue: USE_MODERN_COMPATIBILITY_MODE_BY_DEFAULT
+  defaultValue: false
   humanReadableName: "Use Modern Compatibility Mode"
   humanReadableDescription: "Use modern compatibility mode by default"
   webcoreBinding: none
index f380be9..a5bcbd4 100644 (file)
@@ -266,9 +266,3 @@ bool defaultCustomPasteboardDataEnabled();
 #else
 #define DEFAULT_APPLE_PAY_ENABLED false
 #endif
-
-#if PLATFORM(IOS_FAMILY) && !PLATFORM(IOSMAC)
-#define USE_MODERN_COMPATIBILITY_MODE_BY_DEFAULT false
-#else
-#define USE_MODERN_COMPATIBILITY_MODE_BY_DEFAULT true
-#endif
index 196e7e1..64b0779 100644 (file)
@@ -111,7 +111,7 @@ private:
     WTF::String m_customUserAgent;
     WTF::String m_customJavaScriptUserAgentAsSiteSpecificQuirks;
     WTF::String m_customNavigatorPlatform;
-    WebKit::WebCompatibilityMode m_preferredCompatibilityMode { WebKit::WebCompatibilityMode::Default };
+    WebKit::WebCompatibilityMode m_preferredCompatibilityMode { WebKit::WebCompatibilityMode::Recommended };
     WebKit::WebsiteMetaViewportPolicy m_metaViewportPolicy { WebKit::WebsiteMetaViewportPolicy::Default };
     WebKit::WebsiteMediaSourcePolicy m_mediaSourcePolicy { WebKit::WebsiteMediaSourcePolicy::Default };
     WebKit::WebsiteSimulatedMouseEventsDispatchPolicy m_simulatedMouseEventsDispatchPolicy { WebKit::WebsiteSimulatedMouseEventsDispatchPolicy::Default };
index e4b54e9..48d6351 100644 (file)
@@ -86,7 +86,7 @@ typedef NS_ENUM(NSInteger, WKNavigationResponsePolicy) {
  @discussion If you implement this method,
  -webView:decidePolicyForNavigationAction:decisionHandler: will not be called.
  */
-- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction withPreferences:(WKWebpagePreferences *)preferences decisionHandler:(void (^)(WKNavigationActionPolicy, WKWebpagePreferences *))decisionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction preferences:(WKWebpagePreferences *)preferences decisionHandler:(void (^)(WKNavigationActionPolicy, WKWebpagePreferences *))decisionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 /*! @abstract Decides whether to allow or cancel a navigation after its
  response is known.
index 42d24a9..88cc998 100644 (file)
@@ -132,7 +132,7 @@ WK_CLASS_AVAILABLE(macos(10.10), ios(8.0))
 
 /*! @abstract The set of default webpage preferences to use when loading and rendering content.
  @discussion These default webpage preferences are additionally passed to the navigation delegate
- in -webView:decidePolicyForNavigationAction:withPreferences:decisionHandler:.
+ in -webView:decidePolicyForNavigationAction:preferences:decisionHandler:.
  */
 @property (null_resettable, nonatomic, copy) WKWebpagePreferences *defaultWebpagePreferences WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
index b53ada5..6a705c5 100644 (file)
@@ -149,7 +149,7 @@ void NavigationState::setNavigationDelegate(id <WKNavigationDelegate> delegate)
     m_navigationDelegate = delegate;
 
     m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionDecisionHandler = [delegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)];
-    m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionWithPreferencesDecisionHandler = [delegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:withPreferences:decisionHandler:)];
+    m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionWithPreferencesDecisionHandler = [delegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:preferences:decisionHandler:)];
     m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionDecisionHandlerWebsitePolicies = [delegate respondsToSelector:@selector(_webView:decidePolicyForNavigationAction:decisionHandler:)];
     m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionUserInfoDecisionHandlerWebsitePolicies = [delegate respondsToSelector:@selector(_webView:decidePolicyForNavigationAction:userInfo:decisionHandler:)];
     m_navigationDelegateMethods.webViewDecidePolicyForNavigationResponseDecisionHandler = [delegate respondsToSelector:@selector(webView:decidePolicyForNavigationResponse:decisionHandler:)];
@@ -560,7 +560,7 @@ void NavigationState::NavigationClient::decidePolicyForNavigationAction(WebPageP
 
     auto selectorForCompletionHandlerChecker = ([&] () -> SEL {
         if (delegateHasWebpagePreferences)
-            return @selector(webView:decidePolicyForNavigationAction:withPreferences:decisionHandler:);
+            return @selector(webView:decidePolicyForNavigationAction:preferences:decisionHandler:);
         if (delegateHasWebsitePolicies)
             return @selector(_webView:decidePolicyForNavigationAction:decisionHandler:);
         return @selector(webView:decidePolicyForNavigationAction:decisionHandler:);
@@ -631,7 +631,7 @@ void NavigationState::NavigationClient::decidePolicyForNavigationAction(WebPageP
     };
 
     if (delegateHasWebpagePreferences)
-        [navigationDelegate webView:m_navigationState.m_webView decidePolicyForNavigationAction:wrapper(navigationAction) withPreferences:wrapper(defaultWebsitePolicies) decisionHandler:makeBlockPtr(WTFMove(decisionHandlerWithPreferencesOrPolicies)).get()];
+        [navigationDelegate webView:m_navigationState.m_webView decidePolicyForNavigationAction:wrapper(navigationAction) preferences:wrapper(defaultWebsitePolicies) decisionHandler:makeBlockPtr(WTFMove(decisionHandlerWithPreferencesOrPolicies)).get()];
     else if (delegateHasWebsitePolicies) {
         auto decisionHandler = makeBlockPtr(WTFMove(decisionHandlerWithPreferencesOrPolicies));
         if (m_navigationState.m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionUserInfoDecisionHandlerWebsitePolicies)
index 9003b14..dcd23db 100644 (file)
@@ -35,6 +35,7 @@
 #define DYLD_IOS_VERSION_FIRST_WITH_SNAPSHOT_AFTER_SCREEN_UPDATES 0
 #define DYLD_IOS_VERSION_FIRST_WHERE_DOWNLOAD_ATTRIBUTE_DOES_NOT_OVERRIDE_NAVIGATION_DELEGATE 0
 #define DYLD_IOS_VERSION_FIRST_THAT_DECIDES_POLICY_BEFORE_LOADING_QUICK_LOOK_PREVIEW 0
+#define DYLD_IOS_VERSION_FIRST_WITH_MODERN_COMPATIBILITY_MODE_BY_DEFAULT 0
 #define DYLD_MACOS_VERSION_FIRST_WITH_SNAPSHOT_AFTER_SCREEN_UPDATES 0
 #define DYLD_MACOS_VERSION_FIRST_WHERE_DOWNLOAD_ATTRIBUTE_DOES_NOT_OVERRIDE_NAVIGATION_DELEGATE 0
 #endif
@@ -71,6 +72,7 @@ enum class SDKVersion : uint32_t {
     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,
+    FirstWithModernCompabilityModeByDefault = DYLD_IOS_VERSION_FIRST_WITH_MODERN_COMPATIBILITY_MODE_BY_DEFAULT,
 #elif PLATFORM(MAC)
     FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
     FirstWithExceptionsForDuplicateCompletionHandlerCalls = DYLD_MACOSX_VERSION_10_13,
index 981c4ca..ff631a8 100644 (file)
@@ -58,6 +58,7 @@
 #import <WebCore/FrameView.h>
 #import <WebCore/NotImplemented.h>
 #import <WebCore/PlatformScreen.h>
+#import <WebCore/RuntimeApplicationChecks.h>
 #import <WebCore/SharedBuffer.h>
 #import <WebCore/UserAgent.h>
 #import <WebCore/ValidationBubble.h>