Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.

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:


Canonical link: https://commits.webkit.org/211147@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244239 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
whsieh committed Apr 13, 2019
1 parent 53c4d9d commit 2806981
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 15 deletions.
18 changes: 18 additions & 0 deletions Source/WebCore/ChangeLog
@@ -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
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/platform/RuntimeApplicationChecks.h
Expand Up @@ -91,6 +91,7 @@ WEBCORE_EXPORT bool isCardiogram();
WEBCORE_EXPORT bool isNike();
bool isMoviStarPlus();
WEBCORE_EXPORT bool isFirefox();
WEBCORE_EXPORT bool isAppleApplication();

} // IOSApplication

Expand Down
13 changes: 12 additions & 1 deletion Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm
Expand Up @@ -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;
}

Expand Down Expand Up @@ -191,6 +191,11 @@ static bool applicationBundleIsEqualTo(const String& bundleIdentifierString)

#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);
Expand Down Expand Up @@ -283,6 +288,12 @@ static bool applicationBundleIsEqualTo(const String& bundleIdentifierString)
return isFirefox;
}

bool IOSApplication::isAppleApplication()
{
static bool isAppleApplication = applicationBundleStartsWith("com.apple."_s);
return isAppleApplication;
}

#endif

} // namespace WebCore
Expand Down
32 changes: 32 additions & 0 deletions Source/WebKit/ChangeLog
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/Shared/WebCompatibilityMode.h
Expand Up @@ -30,7 +30,7 @@
namespace WebKit {

enum class WebCompatibilityMode {
Default,
Recommended,
Legacy,
Modern,
};
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/Shared/WebPreferences.yaml
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions Source/WebKit/Shared/WebPreferencesDefaultValues.h
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/API/APIWebsitePolicies.h
Expand Up @@ -111,7 +111,7 @@ class WebsitePolicies final : public API::ObjectImpl<API::Object::Type::WebsiteP
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 };
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegate.h
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.h
Expand Up @@ -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));

Expand Down
6 changes: 3 additions & 3 deletions Source/WebKit/UIProcess/Cocoa/NavigationState.mm
Expand Up @@ -149,7 +149,7 @@
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:)];
Expand Down Expand Up @@ -560,7 +560,7 @@ static void tryInterceptNavigation(Ref<API::NavigationAction>&& navigationAction

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:);
Expand Down Expand Up @@ -631,7 +631,7 @@ static void tryInterceptNavigation(Ref<API::NavigationAction>&& navigationAction
};

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)
Expand Down
2 changes: 2 additions & 0 deletions Source/WebKit/UIProcess/Cocoa/VersionChecks.h
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
Expand Up @@ -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>
Expand Down

0 comments on commit 2806981

Please sign in to comment.