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

Changeset 244239 in webkit


Ignore:
Timestamp:
Apr 12, 2019, 8:54:10 PM (7 years ago)
Author:
Wenson Hsieh
Message:

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:
Location:
trunk/Source
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r244235 r244239  
     12019-04-12  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Enable modern compatibility mode by default in WKWebView on some devices
     4        https://bugs.webkit.org/show_bug.cgi?id=196883
     5        <rdar://problem/49864527>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add a new helper function to determine whether an app is pre-installed on iOS, for the purposes of ensuring
     10        compatibility with existing Apple apps that are not affected by linked-on-or-after. This involves all apps with
     11        a bundle ID that begins with "com.apple.".
     12
     13        * platform/RuntimeApplicationChecks.h:
     14        * platform/cocoa/RuntimeApplicationChecksCocoa.mm:
     15        (WebCore::setApplicationBundleIdentifier):
     16        (WebCore::applicationBundleStartsWith):
     17        (WebCore::IOSApplication::isAppleApplication):
     18
    1192019-04-12  Justin Fan  <justin_fan@apple.com>
    220
  • trunk/Source/WebCore/platform/RuntimeApplicationChecks.h

    r239880 r244239  
    9292bool isMoviStarPlus();
    9393WEBCORE_EXPORT bool isFirefox();
     94WEBCORE_EXPORT bool isAppleApplication();
    9495
    9596} // IOSApplication
  • trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm

    r239880 r244239  
    6363{
    6464    ASSERT(RunLoop::isMain());
    65     ASSERT_WITH_MESSAGE(!applicationBundleIdentifierOverrideWasQueried, "applicationBundleIsEqualTo() should not be called before setApplicationBundleIdentifier()");
     65    ASSERT_WITH_MESSAGE(!applicationBundleIdentifierOverrideWasQueried, "applicationBundleIsEqualTo() and applicationBundleStartsWith() should not be called before setApplicationBundleIdentifier()");
    6666    applicationBundleIdentifierOverride() = bundleIdentifier;
    6767}
     
    191191
    192192#if PLATFORM(IOS_FAMILY)
     193
     194static bool applicationBundleStartsWith(const String& bundleIdentifierPrefix)
     195{
     196    return applicationBundleIdentifier().startsWith(bundleIdentifierPrefix);
     197}
    193198
    194199bool IOSApplication::isMobileMail()
     
    284289}
    285290
     291bool IOSApplication::isAppleApplication()
     292{
     293    static bool isAppleApplication = applicationBundleStartsWith("com.apple."_s);
     294    return isAppleApplication;
     295}
     296
    286297#endif
    287298
  • trunk/Source/WebKit/ChangeLog

    r244236 r244239  
     12019-04-12  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Enable modern compatibility mode by default in WKWebView on some devices
     4        https://bugs.webkit.org/show_bug.cgi?id=196883
     5        <rdar://problem/49864527>
     6
     7        Reviewed by Tim Horton.
     8
     9        Make some minor adjustments to new API.
     10
     11        * Shared/WebCompatibilityMode.h:
     12
     13        Rename WebCompatibilityMode::Default to WebCompatibilityMode::Recommended.
     14
     15        * Shared/WebPreferences.yaml:
     16        * Shared/WebPreferencesDefaultValues.h:
     17
     18        Now that the role of the UseModernCompatibilityModeByDefault debug preference is limited to bypassing linked-on-
     19        or-after and app bundle compatibility hacks, we no longer make this default to true in iOSMac.
     20
     21        * UIProcess/API/APIWebsitePolicies.h:
     22        * UIProcess/API/Cocoa/WKNavigationDelegate.h:
     23
     24        Rename the withPreferences: label to just preferences:.
     25
     26        * UIProcess/API/Cocoa/WKWebViewConfiguration.h:
     27        * UIProcess/Cocoa/NavigationState.mm:
     28        (WebKit::NavigationState::setNavigationDelegate):
     29        (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
     30        * UIProcess/Cocoa/VersionChecks.h:
     31        * UIProcess/ios/WebPageProxyIOS.mm:
     32
    1332019-04-12  Brian Burg  <bburg@apple.com>
    234
  • trunk/Source/WebKit/Shared/WebCompatibilityMode.h

    r243797 r244239  
    3131
    3232enum class WebCompatibilityMode {
    33     Default,
     33    Recommended,
    3434    Legacy,
    3535    Modern,
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r244228 r244239  
    10611061UseModernCompatibilityModeByDefault:
    10621062  type: bool
    1063   defaultValue: USE_MODERN_COMPATIBILITY_MODE_BY_DEFAULT
     1063  defaultValue: false
    10641064  humanReadableName: "Use Modern Compatibility Mode"
    10651065  humanReadableDescription: "Use modern compatibility mode by default"
  • trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h

    r244203 r244239  
    267267#define DEFAULT_APPLE_PAY_ENABLED false
    268268#endif
    269 
    270 #if PLATFORM(IOS_FAMILY) && !PLATFORM(IOSMAC)
    271 #define USE_MODERN_COMPATIBILITY_MODE_BY_DEFAULT false
    272 #else
    273 #define USE_MODERN_COMPATIBILITY_MODE_BY_DEFAULT true
    274 #endif
  • trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h

    r244218 r244239  
    112112    WTF::String m_customJavaScriptUserAgentAsSiteSpecificQuirks;
    113113    WTF::String m_customNavigatorPlatform;
    114     WebKit::WebCompatibilityMode m_preferredCompatibilityMode { WebKit::WebCompatibilityMode::Default };
     114    WebKit::WebCompatibilityMode m_preferredCompatibilityMode { WebKit::WebCompatibilityMode::Recommended };
    115115    WebKit::WebsiteMetaViewportPolicy m_metaViewportPolicy { WebKit::WebsiteMetaViewportPolicy::Default };
    116116    WebKit::WebsiteMediaSourcePolicy m_mediaSourcePolicy { WebKit::WebsiteMediaSourcePolicy::Default };
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegate.h

    r243787 r244239  
    8787 -webView:decidePolicyForNavigationAction:decisionHandler: will not be called.
    8888 */
    89 - (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));
     89- (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));
    9090
    9191/*! @abstract Decides whether to allow or cancel a navigation after its
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.h

    r243787 r244239  
    133133/*! @abstract The set of default webpage preferences to use when loading and rendering content.
    134134 @discussion These default webpage preferences are additionally passed to the navigation delegate
    135  in -webView:decidePolicyForNavigationAction:withPreferences:decisionHandler:.
     135 in -webView:decidePolicyForNavigationAction:preferences:decisionHandler:.
    136136 */
    137137@property (null_resettable, nonatomic, copy) WKWebpagePreferences *defaultWebpagePreferences WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm

    r244197 r244239  
    150150
    151151    m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionDecisionHandler = [delegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)];
    152     m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionWithPreferencesDecisionHandler = [delegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:withPreferences:decisionHandler:)];
     152    m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionWithPreferencesDecisionHandler = [delegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:preferences:decisionHandler:)];
    153153    m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionDecisionHandlerWebsitePolicies = [delegate respondsToSelector:@selector(_webView:decidePolicyForNavigationAction:decisionHandler:)];
    154154    m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionUserInfoDecisionHandlerWebsitePolicies = [delegate respondsToSelector:@selector(_webView:decidePolicyForNavigationAction:userInfo:decisionHandler:)];
     
    561561    auto selectorForCompletionHandlerChecker = ([&] () -> SEL {
    562562        if (delegateHasWebpagePreferences)
    563             return @selector(webView:decidePolicyForNavigationAction:withPreferences:decisionHandler:);
     563            return @selector(webView:decidePolicyForNavigationAction:preferences:decisionHandler:);
    564564        if (delegateHasWebsitePolicies)
    565565            return @selector(_webView:decidePolicyForNavigationAction:decisionHandler:);
     
    632632
    633633    if (delegateHasWebpagePreferences)
    634         [navigationDelegate webView:m_navigationState.m_webView decidePolicyForNavigationAction:wrapper(navigationAction) withPreferences:wrapper(defaultWebsitePolicies) decisionHandler:makeBlockPtr(WTFMove(decisionHandlerWithPreferencesOrPolicies)).get()];
     634        [navigationDelegate webView:m_navigationState.m_webView decidePolicyForNavigationAction:wrapper(navigationAction) preferences:wrapper(defaultWebsitePolicies) decisionHandler:makeBlockPtr(WTFMove(decisionHandlerWithPreferencesOrPolicies)).get()];
    635635    else if (delegateHasWebsitePolicies) {
    636636        auto decisionHandler = makeBlockPtr(WTFMove(decisionHandlerWithPreferencesOrPolicies));
  • trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h

    r244203 r244239  
    3636#define DYLD_IOS_VERSION_FIRST_WHERE_DOWNLOAD_ATTRIBUTE_DOES_NOT_OVERRIDE_NAVIGATION_DELEGATE 0
    3737#define DYLD_IOS_VERSION_FIRST_THAT_DECIDES_POLICY_BEFORE_LOADING_QUICK_LOOK_PREVIEW 0
     38#define DYLD_IOS_VERSION_FIRST_WITH_MODERN_COMPATIBILITY_MODE_BY_DEFAULT 0
    3839#define DYLD_MACOS_VERSION_FIRST_WITH_SNAPSHOT_AFTER_SCREEN_UPDATES 0
    3940#define DYLD_MACOS_VERSION_FIRST_WHERE_DOWNLOAD_ATTRIBUTE_DOES_NOT_OVERRIDE_NAVIGATION_DELEGATE 0
     
    7273    FirstThatDecidesPolicyBeforeLoadingQuickLookPreview = DYLD_IOS_VERSION_FIRST_THAT_DECIDES_POLICY_BEFORE_LOADING_QUICK_LOOK_PREVIEW,
    7374    FirstWithExceptionsForRelatedWebViewsUsingDifferentDataStores = DYLD_IOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES,
     75    FirstWithModernCompabilityModeByDefault = DYLD_IOS_VERSION_FIRST_WITH_MODERN_COMPATIBILITY_MODE_BY_DEFAULT,
    7476#elif PLATFORM(MAC)
    7577    FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r244151 r244239  
    5959#import <WebCore/NotImplemented.h>
    6060#import <WebCore/PlatformScreen.h>
     61#import <WebCore/RuntimeApplicationChecks.h>
    6162#import <WebCore/SharedBuffer.h>
    6263#import <WebCore/UserAgent.h>
Note: See TracChangeset for help on using the changeset viewer.