WebKit Bugzilla
Attachment 371217 Details for
Bug 198484
: Upstream content mode support into open source from WebKitAdditions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Try to fix API tests on open source iOS
bug-198484-20190603150240.patch (text/plain), 75.61 KB, created by
Wenson Hsieh
on 2019-06-03 15:02:41 PDT
(
hide
)
Description:
Try to fix API tests on open source iOS
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2019-06-03 15:02:41 PDT
Size:
75.61 KB
patch
obsolete
>Subversion Revision: 246014 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 3c90c41e1c61c3f857652ed35d1320ff6e9d0071..48dba54a6b360045f30fb22580b6fcc402775d8c 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,16 @@ >+2019-06-03 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Upstream content mode support into open source from WebKitAdditions >+ https://bugs.webkit.org/show_bug.cgi?id=198484 >+ <rdar://problem/51355671> >+ >+ Reviewed by Andy Estes. >+ >+ * page/Quirks.cpp: >+ (WebCore::shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreasForHost): >+ (WebCore::shouldEmulateUndoRedoInHiddenEditableAreasForHost): >+ * page/SettingsBase.h: >+ > 2019-06-01 Andy Estes <aestes@apple.com> > > [Apple Pay] Every PaymentCoordinator client should explicitly decide whether they support unrestricted Apple Pay >diff --git a/Source/WebCore/PAL/ChangeLog b/Source/WebCore/PAL/ChangeLog >index e4a5974914581825cd1c5b444f4dc1da943d2938..2bbbc41cf1c04731c45a671a5d3b8c0c84309c16 100644 >--- a/Source/WebCore/PAL/ChangeLog >+++ b/Source/WebCore/PAL/ChangeLog >@@ -1,3 +1,15 @@ >+2019-06-03 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Upstream content mode support into open source from WebKitAdditions >+ https://bugs.webkit.org/show_bug.cgi?id=198484 >+ <rdar://problem/51355671> >+ >+ Reviewed by Andy Estes. >+ >+ Add some new constants to MobileGestaltSPI.h. >+ >+ * pal/spi/ios/MobileGestaltSPI.h: >+ > 2019-05-29 Don Olmstead <don.olmstead@sony.com> > > Remove ENABLE definitions from WebKit config files >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 0d9ca5ad48c2be6edd7a200a6aa61438f0eb433b..92162842e8ff7405336b64d8ea77c2f5ed51f22a 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,56 @@ >+2019-06-03 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Upstream content mode support into open source from WebKitAdditions >+ https://bugs.webkit.org/show_bug.cgi?id=198484 >+ <rdar://problem/51355671> >+ >+ Reviewed by Andy Estes. >+ >+ Move code for handling WKContentMode into open source. No change in behavior, for internal builds. >+ >+ * Shared/API/Cocoa/WebKit.apinotes: >+ * Shared/WebContentMode.h: Renamed from Source/WebKit/Shared/WebCompatibilityMode.h. >+ * Shared/WebPreferences.yaml: >+ * UIProcess/API/APINavigation.h: >+ (API::Navigation::setEffectiveContentMode): >+ (API::Navigation::effectiveContentMode const): >+ (API::Navigation::setEffectiveCompatibilityMode): Deleted. >+ (API::Navigation::effectiveCompatibilityMode const): Deleted. >+ * UIProcess/API/APINavigationClient.h: >+ (API::NavigationClient::shouldBypassContentModeSafeguards const): >+ (API::NavigationClient::shouldBypassCompatibilityModeSafeguards const): Deleted. >+ * UIProcess/API/APIWebsitePolicies.cpp: >+ (API::WebsitePolicies::copy const): >+ * UIProcess/API/APIWebsitePolicies.h: >+ * UIProcess/API/Cocoa/WKNavigation.h: >+ * UIProcess/API/Cocoa/WKNavigation.mm: >+ (-[WKNavigation effectiveContentMode]): >+ * UIProcess/API/Cocoa/WKWebpagePreferences.h: >+ * UIProcess/API/Cocoa/WKWebpagePreferences.mm: >+ (WebKit::contentMode): >+ (WebKit::webContentMode): >+ (-[WKWebpagePreferences _allowSiteSpecificQuirksToOverrideCompatibilityMode]): >+ (-[WKWebpagePreferences _setAllowSiteSpecificQuirksToOverrideCompatibilityMode:]): >+ (-[WKWebpagePreferences setPreferredContentMode:]): >+ (-[WKWebpagePreferences preferredContentMode]): >+ * UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h: >+ * UIProcess/Cocoa/NavigationState.h: >+ * UIProcess/Cocoa/NavigationState.mm: >+ (WebKit::NavigationState::NavigationClient::shouldBypassContentModeSafeguards const): >+ (WebKit::NavigationState::NavigationClient::shouldBypassCompatibilityModeSafeguards const): Deleted. >+ * UIProcess/WebPageProxy.cpp: >+ (WebKit::WebPageProxy::decidePolicyForNavigationAction): >+ (WebKit::WebPageProxy::effectiveContentModeAfterAdjustingPolicies): >+ (WebKit::WebPageProxy::effectiveCompatibilityModeAfterAdjustingPolicies): Deleted. >+ * UIProcess/WebPageProxy.h: >+ * UIProcess/ios/WebPageProxyIOS.mm: >+ (WebKit::desktopClassBrowsingSupported): >+ (WebKit::webViewSizeIsNarrow): >+ (WebKit::desktopClassBrowsingRecommendedForRequest): >+ (WebKit::desktopClassBrowsingRecommended): >+ (WebKit::WebPageProxy::effectiveContentModeAfterAdjustingPolicies): >+ * WebKit.xcodeproj/project.pbxproj: >+ > 2019-05-31 Megan Gardner <megan_gardner@apple.com> > > Ensure keyboard editing is up to date >diff --git a/Source/WebCore/PAL/pal/spi/ios/MobileGestaltSPI.h b/Source/WebCore/PAL/pal/spi/ios/MobileGestaltSPI.h >index 1c3fd624ecb795a91bda48d4bc2965f6e44a4f41..6d754b9e4e0fc386b2aa56ef43a58821d7f979b5 100644 >--- a/Source/WebCore/PAL/pal/spi/ios/MobileGestaltSPI.h >+++ b/Source/WebCore/PAL/pal/spi/ios/MobileGestaltSPI.h >@@ -38,6 +38,7 @@ > #else > > static const CFStringRef kMGQAppleInternalInstallCapability = CFSTR("apple-internal-install"); >+static const CFStringRef kMGQMainScreenClass = CFSTR("main-screen-class"); > static const CFStringRef kMGQMainScreenPitch = CFSTR("main-screen-pitch"); > static const CFStringRef kMGQMainScreenScale = CFSTR("main-screen-scale"); > static const CFStringRef kMGQiPadCapability = CFSTR("ipad"); >@@ -56,6 +57,12 @@ typedef enum { > MGDeviceClassWatch = 6, > } MGDeviceClass; > >+typedef enum { >+ MGScreenClassPad2 = 4, >+ MGScreenClassPad3 = 6, >+ MGScreenClassPad4 = 7, >+} MGScreenClass; >+ > #endif > > WTF_EXTERN_C_BEGIN >diff --git a/Source/WebCore/page/Quirks.cpp b/Source/WebCore/page/Quirks.cpp >index 2f571379447909e59c7a7327c11b4eefee25579b..4b9ed7584e5f92222a36a09f68c91aec65e6d268 100644 >--- a/Source/WebCore/page/Quirks.cpp >+++ b/Source/WebCore/page/Quirks.cpp >@@ -228,21 +228,25 @@ bool Quirks::isNeverRichlyEditableForTouchBar() const > return false; > } > >-#if USE(APPLE_INTERNAL_SDK) >-#import <WebKitAdditions/QuirksAdditions.cpp> >-#else >- >-static bool shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreasForHost(const StringView&) >+static bool shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreasForHost(const StringView& host) > { >+#if PLATFORM(IOS_FAMILY) >+ return equalLettersIgnoringASCIICase(host, "docs.google.com"); >+#else >+ UNUSED_PARAM(host); > return false; >+#endif > } > >-static bool shouldEmulateUndoRedoInHiddenEditableAreasForHost(const StringView&) >+static bool shouldEmulateUndoRedoInHiddenEditableAreasForHost(const StringView& host) > { >+#if PLATFORM(IOS_FAMILY) >+ return equalLettersIgnoringASCIICase(host, "docs.google.com"); >+#else >+ UNUSED_PARAM(host); > return false; >-} >- > #endif >+} > > bool Quirks::shouldDispatchSyntheticMouseEventsWhenModifyingSelection() const > { >diff --git a/Source/WebCore/page/SettingsBase.h b/Source/WebCore/page/SettingsBase.h >index 42622f132c7d0c278a9cc218da982fcb200edfca..4686cfaee4f5641ffe0b99f68f81ffe0fcdf83fa 100644 >--- a/Source/WebCore/page/SettingsBase.h >+++ b/Source/WebCore/page/SettingsBase.h >@@ -217,10 +217,6 @@ protected: > float m_multiLineTextMultiplierCoefficient { defaultMultiLineTextMultiplierCoefficient }; > float m_maxTextAutosizingScaleIncrease { defaultMaxTextAutosizingScaleIncrease }; > #endif >- >-#if USE(APPLE_INTERNAL_SDK) >-#include <WebKitAdditions/SettingsAdditions.h> >-#endif > }; > > } // namespace WebCore >diff --git a/Source/WebKit/Shared/API/Cocoa/WebKit.apinotes b/Source/WebKit/Shared/API/Cocoa/WebKit.apinotes >index 3efc93912e9228409ab6f21d804cd4d73e97e367..85ae8e72e95d8d561d6869d69e2d3bcd794d8b00 100644 >--- a/Source/WebKit/Shared/API/Cocoa/WebKit.apinotes >+++ b/Source/WebKit/Shared/API/Cocoa/WebKit.apinotes >@@ -200,6 +200,5 @@ Classes: > Tags: > - Name: WKErrorCode > NSErrorDomain: WKErrorDomain >-#if USE(APPLE_INTERNAL_SDK) >-#import <WebKitAdditions/WebKitAdditions.apinotes> >-#endif >+- Name: WKContentMode >+ SwiftName: WKWebpagePreferences.ContentMode >diff --git a/Source/WebKit/Shared/WebCompatibilityMode.h b/Source/WebKit/Shared/WebCompatibilityMode.h >deleted file mode 100644 >index cedf18f7b8eed2c02b2344fc1331d0edcf566c3b..0000000000000000000000000000000000000000 >--- a/Source/WebKit/Shared/WebCompatibilityMode.h >+++ /dev/null >@@ -1,38 +0,0 @@ >-/* >- * Copyright (C) 2019 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >- * THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#pragma once >- >-#include <wtf/Forward.h> >- >-namespace WebKit { >- >-enum class WebCompatibilityMode : uint8_t { >- Recommended, >- Legacy, >- Modern, >-}; >- >-} >diff --git a/Source/WebKit/Shared/WebContentMode.h b/Source/WebKit/Shared/WebContentMode.h >new file mode 100644 >index 0000000000000000000000000000000000000000..bc47c53764f834f1164f96cff870a3f8167c62f0 >--- /dev/null >+++ b/Source/WebKit/Shared/WebContentMode.h >@@ -0,0 +1,38 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/Forward.h> >+ >+namespace WebKit { >+ >+enum class WebContentMode : uint8_t { >+ Recommended, >+ Mobile, >+ Desktop >+}; >+ >+} >diff --git a/Source/WebKit/Shared/WebPreferences.yaml b/Source/WebKit/Shared/WebPreferences.yaml >index 72798c16dfb5377744395ee402b393fb29c43556..0142e01bc3dd04d2bfab0f4dff858f0c4889704e 100644 >--- a/Source/WebKit/Shared/WebPreferences.yaml >+++ b/Source/WebKit/Shared/WebPreferences.yaml >@@ -1070,14 +1070,6 @@ DisableScreenSizeOverride: > category: debug > condition: PLATFORM(IOS_FAMILY) > >-UseModernCompatibilityModeByDefault: >- type: bool >- defaultValue: false >- humanReadableName: "Use Modern Compatibility Mode" >- humanReadableDescription: "Use modern compatibility mode by default" >- webcoreBinding: none >- category: debug >- > SimpleLineLayoutDebugBordersEnabled: > type: bool > defaultValue: false >diff --git a/Source/WebKit/UIProcess/API/APINavigation.h b/Source/WebKit/UIProcess/API/APINavigation.h >index 92418f885f8b84b38b11f6cf67918f8c15123ec1..7285554d2dd5b024166e5c5a5550755540016f0e 100644 >--- a/Source/WebKit/UIProcess/API/APINavigation.h >+++ b/Source/WebKit/UIProcess/API/APINavigation.h >@@ -30,7 +30,7 @@ > #include "FrameInfoData.h" > #include "NavigationActionData.h" > #include "WebBackForwardListItem.h" >-#include "WebCompatibilityMode.h" >+#include "WebContentMode.h" > #include <WebCore/AdClickAttribution.h> > #include <WebCore/ProcessIdentifier.h> > #include <WebCore/ResourceRequest.h> >@@ -142,8 +142,8 @@ public: > void setDestinationFrameSecurityOrigin(const WebCore::SecurityOriginData& origin) { m_destinationFrameSecurityOrigin = origin; } > const WebCore::SecurityOriginData& destinationFrameSecurityOrigin() const { return m_destinationFrameSecurityOrigin; } > >- void setEffectiveCompatibilityMode(WebKit::WebCompatibilityMode compatibilityMode) { m_effectiveCompatibilityMode = compatibilityMode; } >- WebKit::WebCompatibilityMode effectiveCompatibilityMode() const { return m_effectiveCompatibilityMode; } >+ void setEffectiveContentMode(WebKit::WebContentMode mode) { m_effectiveContentMode = mode; } >+ WebKit::WebContentMode effectiveContentMode() const { return m_effectiveContentMode; } > > #if !LOG_DISABLED > const char* loggingString() const; >@@ -173,7 +173,7 @@ private: > WebKit::FrameInfoData m_originatingFrameInfo; > WebCore::SecurityOriginData m_destinationFrameSecurityOrigin; > bool m_userContentExtensionsEnabled { true }; >- WebKit::WebCompatibilityMode m_effectiveCompatibilityMode { WebKit::WebCompatibilityMode::Recommended }; >+ WebKit::WebContentMode m_effectiveContentMode { WebKit::WebContentMode::Recommended }; > }; > > } // namespace API >diff --git a/Source/WebKit/UIProcess/API/APINavigationClient.h b/Source/WebKit/UIProcess/API/APINavigationClient.h >index 021256ee96b76c5e5f1bfca7cfb5d058e92df792..196c37242bd2cea6ce8ee523493ad78790a444d0 100644 >--- a/Source/WebKit/UIProcess/API/APINavigationClient.h >+++ b/Source/WebKit/UIProcess/API/APINavigationClient.h >@@ -91,7 +91,7 @@ public: > virtual void renderingProgressDidChange(WebKit::WebPageProxy&, OptionSet<WebCore::LayoutMilestone>) { } > > virtual void didReceiveAuthenticationChallenge(WebKit::WebPageProxy&, WebKit::AuthenticationChallengeProxy& challenge) { challenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::PerformDefaultHandling); } >- virtual bool shouldBypassCompatibilityModeSafeguards() const { return false; } >+ virtual bool shouldBypassContentModeSafeguards() const { return false; } > > // FIXME: These function should not be part of this client. > virtual bool processDidTerminate(WebKit::WebPageProxy&, WebKit::ProcessTerminationReason) { return false; } >diff --git a/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp b/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp >index 4437dd5b73c9c31d67705623cefba1d36e4d0d31..c9994dbb2dcbe2b2857402df093fca6f6eddee65 100644 >--- a/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp >+++ b/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp >@@ -57,7 +57,7 @@ Ref<WebsitePolicies> WebsitePolicies::copy() const > policies->setCustomUserAgent(m_customUserAgent); > policies->setCustomJavaScriptUserAgentAsSiteSpecificQuirks(m_customJavaScriptUserAgentAsSiteSpecificQuirks); > policies->setCustomNavigatorPlatform(m_customNavigatorPlatform); >- policies->setPreferredCompatibilityMode(m_preferredCompatibilityMode); >+ policies->setPreferredContentMode(m_preferredContentMode); > policies->setMetaViewportPolicy(m_metaViewportPolicy); > policies->setMediaSourcePolicy(m_mediaSourcePolicy); > policies->setSimulatedMouseEventsDispatchPolicy(m_simulatedMouseEventsDispatchPolicy); >@@ -74,7 +74,7 @@ Ref<WebsitePolicies> WebsitePolicies::copy() const > for (auto& field : m_customHeaderFields) > customHeaderFields.uncheckedAppend(field); > policies->setCustomHeaderFields(WTFMove(customHeaderFields)); >- policies->setAllowSiteSpecificQuirksToOverrideCompatibilityMode(m_allowSiteSpecificQuirksToOverrideCompatibilityMode); >+ policies->setAllowSiteSpecificQuirksToOverrideContentMode(m_allowSiteSpecificQuirksToOverrideContentMode); > policies->setApplicationNameForUserAgentWithModernCompatibility(m_applicationNameForUserAgentWithModernCompatibility); > return policies; > } >diff --git a/Source/WebKit/UIProcess/API/APIWebsitePolicies.h b/Source/WebKit/UIProcess/API/APIWebsitePolicies.h >index b79fab0b194b0539229b99ddf0c7d9e1ec677dca..7ad5fe873ab0cc777470535ee67c37c5fed159ab 100644 >--- a/Source/WebKit/UIProcess/API/APIWebsitePolicies.h >+++ b/Source/WebKit/UIProcess/API/APIWebsitePolicies.h >@@ -26,7 +26,7 @@ > #pragma once > > #include "APIObject.h" >-#include "WebCompatibilityMode.h" >+#include "WebContentMode.h" > #include "WebsiteAutoplayPolicy.h" > #include "WebsiteAutoplayQuirk.h" > #include "WebsiteLegacyOverflowScrollingTouchPolicy.h" >@@ -93,8 +93,8 @@ public: > void setCustomNavigatorPlatform(const WTF::String& customNavigatorPlatform) { m_customNavigatorPlatform = customNavigatorPlatform; } > const WTF::String& customNavigatorPlatform() const { return m_customNavigatorPlatform; } > >- WebKit::WebCompatibilityMode preferredCompatibilityMode() const { return m_preferredCompatibilityMode; } >- void setPreferredCompatibilityMode(WebKit::WebCompatibilityMode mode) { m_preferredCompatibilityMode = mode; } >+ WebKit::WebContentMode preferredContentMode() const { return m_preferredContentMode; } >+ void setPreferredContentMode(WebKit::WebContentMode mode) { m_preferredContentMode = mode; } > > WebKit::WebsiteMetaViewportPolicy metaViewportPolicy() const { return m_metaViewportPolicy; } > void setMetaViewportPolicy(WebKit::WebsiteMetaViewportPolicy policy) { m_metaViewportPolicy = policy; } >@@ -108,8 +108,8 @@ public: > WebKit::WebsiteLegacyOverflowScrollingTouchPolicy legacyOverflowScrollingTouchPolicy() const { return m_legacyOverflowScrollingTouchPolicy; } > void setLegacyOverflowScrollingTouchPolicy(WebKit::WebsiteLegacyOverflowScrollingTouchPolicy policy) { m_legacyOverflowScrollingTouchPolicy = policy; } > >- bool allowSiteSpecificQuirksToOverrideCompatibilityMode() const { return m_allowSiteSpecificQuirksToOverrideCompatibilityMode; } >- void setAllowSiteSpecificQuirksToOverrideCompatibilityMode(bool value) { m_allowSiteSpecificQuirksToOverrideCompatibilityMode = value; } >+ bool allowSiteSpecificQuirksToOverrideContentMode() const { return m_allowSiteSpecificQuirksToOverrideContentMode; } >+ void setAllowSiteSpecificQuirksToOverrideContentMode(bool value) { m_allowSiteSpecificQuirksToOverrideContentMode = value; } > > WTF::String applicationNameForUserAgentWithModernCompatibility() const { return m_applicationNameForUserAgentWithModernCompatibility; } > void setApplicationNameForUserAgentWithModernCompatibility(const WTF::String& applicationName) { m_applicationNameForUserAgentWithModernCompatibility = applicationName; } >@@ -130,12 +130,12 @@ private: > WTF::String m_customUserAgent; > WTF::String m_customJavaScriptUserAgentAsSiteSpecificQuirks; > WTF::String m_customNavigatorPlatform; >- WebKit::WebCompatibilityMode m_preferredCompatibilityMode { WebKit::WebCompatibilityMode::Recommended }; >+ WebKit::WebContentMode m_preferredContentMode { WebKit::WebContentMode::Recommended }; > WebKit::WebsiteMetaViewportPolicy m_metaViewportPolicy { WebKit::WebsiteMetaViewportPolicy::Default }; > WebKit::WebsiteMediaSourcePolicy m_mediaSourcePolicy { WebKit::WebsiteMediaSourcePolicy::Default }; > WebKit::WebsiteSimulatedMouseEventsDispatchPolicy m_simulatedMouseEventsDispatchPolicy { WebKit::WebsiteSimulatedMouseEventsDispatchPolicy::Default }; > WebKit::WebsiteLegacyOverflowScrollingTouchPolicy m_legacyOverflowScrollingTouchPolicy { WebKit::WebsiteLegacyOverflowScrollingTouchPolicy::Default }; >- bool m_allowSiteSpecificQuirksToOverrideCompatibilityMode { false }; >+ bool m_allowSiteSpecificQuirksToOverrideContentMode { false }; > WTF::String m_applicationNameForUserAgentWithModernCompatibility; > }; > >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKNavigation.h b/Source/WebKit/UIProcess/API/Cocoa/WKNavigation.h >index e881dfc6a100c30fbd8ab0b9bd1915dcc9c5f6c7..c796c12de5dc3a7fb08d0e532560c86c74819b3d 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKNavigation.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKNavigation.h >@@ -36,8 +36,9 @@ > WK_CLASS_AVAILABLE(macos(10.10), ios(8.0)) > @interface WKNavigation : NSObject > >-#if USE(APPLE_INTERNAL_SDK) >-#import <WebKitAdditions/WKNavigationAdditions.h> >-#endif >+/*! The content mode used when loading this webpage. >+ @discussion The value is either WKContentModeMobile or WKContentModeDesktop. >+ */ >+@property (nonatomic, readonly) WKContentMode effectiveContentMode WK_API_AVAILABLE(ios(WK_IOS_TBA)); > > @end >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKNavigation.mm b/Source/WebKit/UIProcess/API/Cocoa/WKNavigation.mm >index 905309c9e8c2f6d682df33bd404d3da6cf07d9c6..77075bd664bb1b9157d803a4fbaeb138b73bf343 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKNavigation.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKNavigation.mm >@@ -45,9 +45,14 @@ - (NSURLRequest *)_request > return _navigation->originalRequest().nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody); > } > >-#if USE(APPLE_INTERNAL_SDK) >-#import <WebKitAdditions/WKNavigationAdditions.mm> >-#endif >+#if PLATFORM(IOS_FAMILY) >+ >+- (WKContentMode)effectiveContentMode >+{ >+ return WebKit::contentMode(_navigation->effectiveContentMode()); >+} >+ >+#endif // PLATFORM(IOS_FAMILY) > > #pragma mark WKObject protocol implementation > >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.h b/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.h >index 7e84ea0aa364c0b0a7a70d9b358eca70755d39fe..75279186803fc8ef8499d8e8eeab542dea8c0b1f 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.h >@@ -27,9 +27,21 @@ > > #import <Foundation/Foundation.h> > >-#if USE(APPLE_INTERNAL_SDK) >-#import <WebKitAdditions/WKWebpagePreferencesAdditionsBefore.h> >-#endif >+/*! @enum WKContentMode >+ @abstract A content mode represents the type of content to load, as well as >+ additional layout and rendering adaptations that are applied as a result of >+ loading the content >+ @constant WKContentModeRecommended The recommended content mode for the current platform >+ @constant WKContentModeMobile Represents content targeting mobile browsers >+ @constant WKContentModeDesktop Represents content targeting desktop browsers >+ @discussion WKContentModeRecommended behaves like WKContentModeMobile on iPhone and iPad mini >+ and WKContentModeDesktop on other iPad models as well as Mac. >+ */ >+typedef NS_ENUM(NSInteger, WKContentMode) { >+ WKContentModeRecommended, >+ WKContentModeMobile, >+ WKContentModeDesktop >+} WK_API_AVAILABLE(ios(WK_IOS_TBA)); > > /*! A WKWebpagePreferences object is a collection of properties that > determine the preferences to use when loading and rendering a page. >@@ -38,8 +50,11 @@ > WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)) > @interface WKWebpagePreferences : NSObject > >-#if USE(APPLE_INTERNAL_SDK) >-#import <WebKitAdditions/WKWebpagePreferencesAdditionsAfter.h> >-#endif >+/*! @abstract A WKContentMode indicating the content mode to prefer >+ when loading and rendering a webpage. >+ @discussion The default value is WKContentModeRecommended. The stated >+ preference is ignored on subframe navigation >+ */ >+@property (nonatomic) WKContentMode preferredContentMode WK_API_AVAILABLE(ios(WK_IOS_TBA)); > > @end >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm >index 4c99139621190f78e98fa43c5dc1b6e8cabb8d6b..8666be36130841f219205f28cb2cb0cdad65dd23 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm >@@ -29,14 +29,46 @@ > #import "APICustomHeaderFields.h" > #import "WKWebpagePreferencesInternal.h" > #import "WKWebsiteDataStoreInternal.h" >-#import "WebCompatibilityMode.h" >+#import "WebContentMode.h" > #import "_WKCustomHeaderFieldsInternal.h" > #import "_WKWebsitePoliciesInternal.h" > #import <wtf/RetainPtr.h> > >-#if USE(APPLE_INTERNAL_SDK) >-#import <WebKitAdditions/WKWebpagePreferencesAdditionsBefore.mm> >-#endif >+#if PLATFORM(IOS_FAMILY) >+ >+namespace WebKit { >+ >+WKContentMode contentMode(WebKit::WebContentMode contentMode) >+{ >+ switch (contentMode) { >+ case WebKit::WebContentMode::Recommended: >+ return WKContentModeRecommended; >+ case WebKit::WebContentMode::Mobile: >+ return WKContentModeMobile; >+ case WebKit::WebContentMode::Desktop: >+ return WKContentModeDesktop; >+ } >+ ASSERT_NOT_REACHED(); >+ return WKContentModeRecommended; >+} >+ >+WebKit::WebContentMode webContentMode(WKContentMode contentMode) >+{ >+ switch (contentMode) { >+ case WKContentModeRecommended: >+ return WebKit::WebContentMode::Recommended; >+ case WKContentModeMobile: >+ return WebKit::WebContentMode::Mobile; >+ case WKContentModeDesktop: >+ return WebKit::WebContentMode::Desktop; >+ } >+ ASSERT_NOT_REACHED(); >+ return WebKit::WebContentMode::Recommended; >+} >+ >+} // namespace WebKit >+ >+#endif // PLATFORM(IOS_FAMILY) > > @implementation WKWebpagePreferences > >@@ -276,12 +308,12 @@ - (NSString *)_customNavigatorPlatform > > - (BOOL)_allowSiteSpecificQuirksToOverrideCompatibilityMode > { >- return _websitePolicies->allowSiteSpecificQuirksToOverrideCompatibilityMode(); >+ return _websitePolicies->allowSiteSpecificQuirksToOverrideContentMode(); > } > > - (void)_setAllowSiteSpecificQuirksToOverrideCompatibilityMode:(BOOL)value > { >- _websitePolicies->setAllowSiteSpecificQuirksToOverrideCompatibilityMode(value); >+ _websitePolicies->setAllowSiteSpecificQuirksToOverrideContentMode(value); > } > > - (NSString *)_applicationNameForUserAgentWithModernCompatibility >@@ -299,8 +331,18 @@ - (API::Object&)_apiObject > return *_websitePolicies; > } > >-#if USE(APPLE_INTERNAL_SDK) >-#import <WebKitAdditions/WKWebpagePreferencesAdditionsAfter.mm> >-#endif >+#if PLATFORM(IOS_FAMILY) >+ >+- (void)setPreferredContentMode:(WKContentMode)contentMode >+{ >+ _websitePolicies->setPreferredContentMode(WebKit::webContentMode(contentMode)); >+} >+ >+- (WKContentMode)preferredContentMode >+{ >+ return WebKit::contentMode(_websitePolicies->preferredContentMode()); >+} >+ >+#endif // PLATFORM(IOS_FAMILY) > > @end >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h b/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h >index db611887c93dec157eb35a7090623c441366458d..b9e459c68af5fd8f62a8bcf613ebe42c85a9fb56 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h >@@ -36,8 +36,9 @@ template<> struct WrapperTraits<API::WebsitePolicies> { > using WrapperClass = WKWebpagePreferences; > }; > >-#if USE(APPLE_INTERNAL_SDK) >-#import <WebKitAdditions/WKWebpagePreferencesInternalAdditions.h> >+#if PLATFORM(IOS_FAMILY) >+WKContentMode contentMode(WebContentMode); >+WebContentMode webContentMode(WKContentMode); > #endif > > } >diff --git a/Source/WebKit/UIProcess/Cocoa/NavigationState.h b/Source/WebKit/UIProcess/Cocoa/NavigationState.h >index 7bae166b4cc4e792d32420eec3bdcd8f17e07325..091470fef035c8d4b84f44abefbf303c9e89c1b3 100644 >--- a/Source/WebKit/UIProcess/Cocoa/NavigationState.h >+++ b/Source/WebKit/UIProcess/Cocoa/NavigationState.h >@@ -109,7 +109,7 @@ private: > > void renderingProgressDidChange(WebPageProxy&, OptionSet<WebCore::LayoutMilestone>) override; > >- bool shouldBypassCompatibilityModeSafeguards() const final; >+ bool shouldBypassContentModeSafeguards() const final; > > void didReceiveAuthenticationChallenge(WebPageProxy&, AuthenticationChallengeProxy&) override; > bool processDidTerminate(WebPageProxy&, ProcessTerminationReason) override; >diff --git a/Source/WebKit/UIProcess/Cocoa/NavigationState.mm b/Source/WebKit/UIProcess/Cocoa/NavigationState.mm >index 526947f7243d5e8c14a5ab55cad9f4af9ff99218..a4ea6b731b043e035ed7133d5158ddbbd1b7a342 100644 >--- a/Source/WebKit/UIProcess/Cocoa/NavigationState.mm >+++ b/Source/WebKit/UIProcess/Cocoa/NavigationState.mm >@@ -939,7 +939,7 @@ void NavigationState::NavigationClient::renderingProgressDidChange(WebPageProxy& > [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView renderingProgressDidChange:renderingProgressEvents(layoutMilestones)]; > } > >-bool NavigationState::NavigationClient::shouldBypassCompatibilityModeSafeguards() const >+bool NavigationState::NavigationClient::shouldBypassContentModeSafeguards() const > { > return m_navigationState.m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionWithPreferencesDecisionHandler; > } >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index b6c05f14acc2ce41e3a0f1fb3dd4fb08107060a6..36754d6b49eb4e50218cc464d882722dc4184d47 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -4653,7 +4653,7 @@ void WebPageProxy::decidePolicyForNavigationAction(Ref<WebProcessProxy>&& proces > policies = defaultPolicies->copy(); > } > if (policies) >- navigation->setEffectiveCompatibilityMode(effectiveCompatibilityModeAfterAdjustingPolicies(*policies, navigation->currentRequest())); >+ navigation->setEffectiveContentMode(effectiveContentModeAfterAdjustingPolicies(*policies, navigation->currentRequest())); > } > receivedNavigationPolicyDecision(policyAction, navigation.get(), processSwapRequestedByClient, frame, policies.get(), WTFMove(sender)); > }; >@@ -9130,14 +9130,14 @@ void WebPageProxy::speechSynthesisResume(CompletionHandler<void()>&& completionH > } > #endif // ENABLE(SPEECH_SYNTHESIS) > >-#if !PLATFORM(IOS_FAMILY) || !USE(APPLE_INTERNAL_SDK) >+#if !PLATFORM(IOS_FAMILY) > >-WebCompatibilityMode WebPageProxy::effectiveCompatibilityModeAfterAdjustingPolicies(API::WebsitePolicies&, const WebCore::ResourceRequest&) >+WebContentMode WebPageProxy::effectiveContentModeAfterAdjustingPolicies(API::WebsitePolicies&, const WebCore::ResourceRequest&) > { >- return WebCompatibilityMode::Recommended; >+ return WebContentMode::Recommended; > } > >-#endif // !PLATFORM(IOS_FAMILY) || !USE(APPLE_INTERNAL_SDK) >+#endif // !PLATFORM(IOS_FAMILY) > > void WebPageProxy::addObserver(WebViewDidMoveToWindowObserver& observer) > { >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 6b4d34856c986d91b47052c75f51ba5987633b48..2cce37892effc741f2c5750a53143826342861c6 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -296,7 +296,7 @@ struct URLSchemeTaskParameters; > > enum class ProcessSwapRequestedByClient; > enum class UndoOrRedo : bool; >-enum class WebCompatibilityMode : uint8_t; >+enum class WebContentMode : uint8_t; > > #if USE(QUICK_LOOK) > class QuickLookDocumentData; >@@ -1647,7 +1647,7 @@ private: > void unableToImplementPolicy(uint64_t frameID, const WebCore::ResourceError&, const UserData&); > void beginSafeBrowsingCheck(const URL&, bool, WebFramePolicyListenerProxy&); > >- WebCompatibilityMode effectiveCompatibilityModeAfterAdjustingPolicies(API::WebsitePolicies&, const WebCore::ResourceRequest&); >+ WebContentMode effectiveContentModeAfterAdjustingPolicies(API::WebsitePolicies&, const WebCore::ResourceRequest&); > > void willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const Vector<std::pair<String, String>>& textFieldValues, uint64_t listenerID, const UserData&); > >diff --git a/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm b/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >index a3f82eabddae10dc42e4e775093a2a600b6fd233..3b46da2a60a763827a4c8a2a6e59554154b0626d 100644 >--- a/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >+++ b/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >@@ -63,6 +63,7 @@ > #import <WebCore/SharedBuffer.h> > #import <WebCore/UserAgent.h> > #import <WebCore/ValidationBubble.h> >+#import <pal/spi/ios/MobileGestaltSPI.h> > #import <wtf/text/TextStream.h> > > #if USE(QUICK_LOOK) >@@ -1261,9 +1262,145 @@ const String& WebPageProxy::paymentCoordinatorCTDataConnectionServiceType(const > > #endif > >-#if USE(APPLE_INTERNAL_SDK) >-#import <WebKitAdditions/WebPageProxyIOSAdditions.mm> >+static bool desktopClassBrowsingSupported() >+{ >+ static bool supportsDesktopClassBrowsing = false; >+ static dispatch_once_t onceToken; >+ dispatch_once(&onceToken, ^{ >+#if PLATFORM(IOSMAC) >+ supportsDesktopClassBrowsing = true; >+#else >+ supportsDesktopClassBrowsing = currentUserInterfaceIdiomIsPad(); > #endif >+ }); >+ return supportsDesktopClassBrowsing; >+} >+ >+#if !PLATFORM(IOSMAC) >+ >+static bool webViewSizeIsNarrow(WebCore::IntSize viewSize) >+{ >+ return !viewSize.isEmpty() && viewSize.width() <= 375; >+} >+ >+#endif // !PLATFORM(IOSMAC) >+ >+static bool desktopClassBrowsingRecommendedForRequest(const WebCore::ResourceRequest& request) >+{ >+ // FIXME: This should be additionally gated on site-specific quirks being enabled. However, site-specific quirks are already >+ // disabled by default in WKWebView, so we would need a new preference for controlling site-specific quirks that are on-by-default >+ // in all apps, but may be turned off via SPI (or via Web Inspector). See also: <rdar://problem/50035167>. >+ auto host = request.url().host(); >+ if (equalLettersIgnoringASCIICase(host, "tv.kakao.com") || host.endsWithIgnoringASCIICase(".tv.kakao.com")) >+ return false; >+ >+ if (equalLettersIgnoringASCIICase(host, "tving.com") || host.endsWithIgnoringASCIICase(".tving.com")) >+ return false; >+ >+ if (equalLettersIgnoringASCIICase(host, "live.iqiyi.com") || host.endsWithIgnoringASCIICase(".live.iqiyi.com")) >+ return false; >+ >+ if (equalLettersIgnoringASCIICase(host, "video.sina.com.cn") || host.endsWithIgnoringASCIICase(".video.sina.com.cn")) >+ return false; >+ >+ if (equalLettersIgnoringASCIICase(host, "huya.com") || host.endsWithIgnoringASCIICase(".huya.com")) >+ return false; >+ >+ if (equalLettersIgnoringASCIICase(host, "video.tudou.com") || host.endsWithIgnoringASCIICase(".video.tudou.com")) >+ return false; >+ >+ if (equalLettersIgnoringASCIICase(host, "cctv.com") || host.endsWithIgnoringASCIICase(".cctv.com")) >+ return false; >+ >+ if (equalLettersIgnoringASCIICase(host, "v.china.com.cn")) >+ return false; >+ >+ return true; >+} >+ >+enum class IgnoreAppCompatibilitySafeguards : bool { No, Yes }; >+static bool desktopClassBrowsingRecommended(const WebCore::ResourceRequest& request, WebCore::IntSize viewSize, IgnoreAppCompatibilitySafeguards ignoreSafeguards) >+{ >+ if (!desktopClassBrowsingRecommendedForRequest(request)) >+ return false; >+ >+#if !PLATFORM(IOSMAC) >+ if (webViewSizeIsNarrow(viewSize)) >+ return false; >+#endif >+ >+ static bool shouldRecommendDesktopClassBrowsing = false; >+ static dispatch_once_t onceToken; >+ dispatch_once(&onceToken, ^{ >+#if PLATFORM(IOSMAC) >+ UNUSED_PARAM(ignoreSafeguards); >+ shouldRecommendDesktopClassBrowsing = true; >+#else >+ // While desktop-class browsing is supported on all iPad models, it is not recommended for iPad mini. >+ auto screenClass = MGGetSInt32Answer(kMGQMainScreenClass, MGScreenClassPad2); >+ shouldRecommendDesktopClassBrowsing = screenClass != MGScreenClassPad3 && screenClass != MGScreenClassPad4 && desktopClassBrowsingSupported(); >+ if (ignoreSafeguards == IgnoreAppCompatibilitySafeguards::No && !linkedOnOrAfter(WebKit::SDKVersion::FirstWithModernCompabilityModeByDefault)) { >+ // Opt out apps that haven't yet built against the iOS 13 SDK to limit any incompatibilities as a result of enabling desktop-class browsing by default in >+ // WKWebView on appropriately-sized iPad models. >+ shouldRecommendDesktopClassBrowsing = false; >+ } >+#endif >+ }); >+ return shouldRecommendDesktopClassBrowsing; >+} >+ >+WebContentMode WebPageProxy::effectiveContentModeAfterAdjustingPolicies(API::WebsitePolicies& policies, const WebCore::ResourceRequest& request) >+{ >+ if (m_preferences->mediaSourceEnabled()) { >+ // FIXME: This is a compatibility hack to ensure that turning MSE on via the existing preference still enables MSE. >+ policies.setMediaSourcePolicy(WebsiteMediaSourcePolicy::Enable); >+ } >+ >+ auto viewSize = this->viewSize(); >+ bool useDesktopBrowsingMode; >+ switch (policies.preferredContentMode()) { >+ case WebContentMode::Recommended: { >+ auto ignoreSafeguards = m_navigationClient->shouldBypassContentModeSafeguards() ? IgnoreAppCompatibilitySafeguards::Yes : IgnoreAppCompatibilitySafeguards::No; >+ useDesktopBrowsingMode = desktopClassBrowsingRecommended(request, viewSize, ignoreSafeguards); >+ break; >+ } >+ case WebContentMode::Mobile: >+ useDesktopBrowsingMode = false; >+ break; >+ case WebContentMode::Desktop: >+ useDesktopBrowsingMode = !policies.allowSiteSpecificQuirksToOverrideContentMode() || desktopClassBrowsingRecommendedForRequest(request); >+ break; >+ default: >+ ASSERT_NOT_REACHED(); >+ useDesktopBrowsingMode = false; >+ break; >+ } >+ >+ if (!useDesktopBrowsingMode) >+ return WebContentMode::Mobile; >+ >+ if (policies.customUserAgent().isEmpty() && customUserAgent().isEmpty()) { >+ auto applicationName = policies.applicationNameForUserAgentWithModernCompatibility(); >+ if (applicationName.isEmpty()) >+ applicationName = applicationNameForUserAgent(); >+ policies.setCustomUserAgent(standardUserAgentWithApplicationName(applicationName, UserAgentType::Desktop)); >+ } >+ >+ if (policies.customNavigatorPlatform().isEmpty()) { >+ // FIXME: Grab this from WebCore instead of hard-coding it here. >+ policies.setCustomNavigatorPlatform("MacIntel"_s); >+ } >+ >+ if (desktopClassBrowsingSupported()) { >+ // Apply some additional desktop-class browsing behaviors on supported devices. >+ policies.setMetaViewportPolicy(WebsiteMetaViewportPolicy::Ignore); >+ policies.setMediaSourcePolicy(WebsiteMediaSourcePolicy::Enable); >+ policies.setSimulatedMouseEventsDispatchPolicy(WebsiteSimulatedMouseEventsDispatchPolicy::Allow); >+ policies.setLegacyOverflowScrollingTouchPolicy(WebsiteLegacyOverflowScrollingTouchPolicy::Disable); >+ } >+ >+ return WebContentMode::Desktop; >+} > > } // namespace WebKit > >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index 4850ca7f6422ea2c1dcbab2c3e941d03fac2a54b..bbd386811e40d1dc131179fcd276f73f669ab7eb 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -1657,7 +1657,7 @@ > F409BA181E6E64BC009DA28E /* WKDragDestinationAction.h in Headers */ = {isa = PBXBuildFile; fileRef = F409BA171E6E64B3009DA28E /* WKDragDestinationAction.h */; settings = {ATTRIBUTES = (Private, ); }; }; > F42D634122A0EFDF00D2FB3A /* WebAutocorrectionData.h in Headers */ = {isa = PBXBuildFile; fileRef = F42D633F22A0EFD300D2FB3A /* WebAutocorrectionData.h */; }; > F430E9422247335F005FE053 /* WebsiteMetaViewportPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = F430E941224732A9005FE053 /* WebsiteMetaViewportPolicy.h */; }; >- F430E94422473DFF005FE053 /* WebCompatibilityMode.h in Headers */ = {isa = PBXBuildFile; fileRef = F430E94322473DB8005FE053 /* WebCompatibilityMode.h */; }; >+ F430E94422473DFF005FE053 /* WebContentMode.h in Headers */ = {isa = PBXBuildFile; fileRef = F430E94322473DB8005FE053 /* WebContentMode.h */; }; > F438CD1C2241421400DE6DDA /* WKWebpagePreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD1B224140A600DE6DDA /* WKWebpagePreferences.h */; settings = {ATTRIBUTES = (Public, ); }; }; > F438CD1F22414D4000DE6DDA /* WKWebpagePreferencesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD1E22414D4000DE6DDA /* WKWebpagePreferencesInternal.h */; }; > F438CD212241F69500DE6DDA /* WKWebpagePreferencesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD202241F69500DE6DDA /* WKWebpagePreferencesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -4632,7 +4632,7 @@ > F42D633F22A0EFD300D2FB3A /* WebAutocorrectionData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAutocorrectionData.h; path = ios/WebAutocorrectionData.h; sourceTree = "<group>"; }; > F42D634022A0EFD300D2FB3A /* WebAutocorrectionData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebAutocorrectionData.mm; path = ios/WebAutocorrectionData.mm; sourceTree = "<group>"; }; > F430E941224732A9005FE053 /* WebsiteMetaViewportPolicy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebsiteMetaViewportPolicy.h; sourceTree = "<group>"; }; >- F430E94322473DB8005FE053 /* WebCompatibilityMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCompatibilityMode.h; sourceTree = "<group>"; }; >+ F430E94322473DB8005FE053 /* WebContentMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebContentMode.h; sourceTree = "<group>"; }; > F438CD1B224140A600DE6DDA /* WKWebpagePreferences.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebpagePreferences.h; sourceTree = "<group>"; }; > F438CD1D22414AD600DE6DDA /* WKWebpagePreferences.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebpagePreferences.mm; sourceTree = "<group>"; }; > F438CD1E22414D4000DE6DDA /* WKWebpagePreferencesInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebpagePreferencesInternal.h; sourceTree = "<group>"; }; >@@ -5213,7 +5213,6 @@ > 518D2CAB12D5153B003BB93B /* WebBackForwardListItem.cpp */, > 518D2CAC12D5153B003BB93B /* WebBackForwardListItem.h */, > BCF50726124329AA005955AE /* WebCertificateInfo.h */, >- F430E94322473DB8005FE053 /* WebCompatibilityMode.h */, > 7C4ABECE1AA8E9F00088AA37 /* WebCompiledContentRuleList.cpp */, > 7C4ABECF1AA8E9F00088AA37 /* WebCompiledContentRuleList.h */, > 7C4ABED21AA8FCB80088AA37 /* WebCompiledContentRuleListData.cpp */, >@@ -5223,6 +5222,7 @@ > 1A1FEC191627B3EF00700F6D /* WebConnection.messages.in */, > BC4A628D147312BE006C681A /* WebConnectionClient.cpp */, > BC4A628E147312BE006C681A /* WebConnectionClient.h */, >+ F430E94322473DB8005FE053 /* WebContentMode.h */, > 512935D51288D19400A4B695 /* WebContextMenuItem.cpp */, > 512935D61288D19400A4B695 /* WebContextMenuItem.h */, > 510FBB981288C95E00AFFDF4 /* WebContextMenuItemData.cpp */, >@@ -9614,13 +9614,13 @@ > 3F87B9BE158940190090FF62 /* WebColorChooser.h in Headers */, > 3F87B9C0158940D80090FF62 /* WebColorPicker.h in Headers */, > 728E86F11795188C0087879E /* WebColorPickerMac.h in Headers */, >- F430E94422473DFF005FE053 /* WebCompatibilityMode.h in Headers */, > 7C4ABED11AA8E9F00088AA37 /* WebCompiledContentRuleList.h in Headers */, > 7C4ABED51AA8FCB80088AA37 /* WebCompiledContentRuleListData.h in Headers */, > BC4A6290147312BE006C681A /* WebConnection.h in Headers */, > BC4A6292147312BE006C681A /* WebConnectionClient.h in Headers */, > 1A1FEC1D1627B45700700F6D /* WebConnectionMessages.h in Headers */, > BC4A62A814744EC7006C681A /* WebConnectionToWebProcess.h in Headers */, >+ F430E94422473DFF005FE053 /* WebContentMode.h in Headers */, > 31A505FA1680025500A930EB /* WebContextClient.h in Headers */, > BC09B8F9147460F7005F5625 /* WebContextConnectionClient.h in Headers */, > BCDE059B11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.h in Headers */, >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 288349033ceec728bdcd2b28d92272549e0c674c..f9ad42da2077229d5de317833c88f4be2bc0c201 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,31 @@ >+2019-06-03 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Upstream content mode support into open source from WebKitAdditions >+ https://bugs.webkit.org/show_bug.cgi?id=198484 >+ <rdar://problem/51355671> >+ >+ Reviewed by Andy Estes. >+ >+ * TestWebKitAPI/ios/PreferredCompatibilityMode.mm: >+ (-[ContentModeNavigationDelegate setDecidePolicyForNavigationActionWithPreferences:]): >+ (-[ContentModeNavigationDelegate decidePolicyForNavigationActionWithPreferences]): >+ (-[ContentModeNavigationDelegate webView:decidePolicyForNavigationAction:preferences:decisionHandler:]): >+ (+[WKWebpagePreferences preferencesWithContentMode:]): >+ (-[WKWebView navigatorUserAgent]): >+ (-[WKWebView navigatorPlatform]): >+ (-[WKWebView loadTestPageNamed:withPolicyDecisionHandler:]): >+ (-[WKWebView loadHTMLString:withPolicyDecisionHandler:]): >+ (-[WKWebView loadTestPageNamed:andExpectEffectiveContentMode:withPolicyDecisionHandler:]): >+ (-[NSString shouldContainStrings:]): >+ (IPhoneUserInterfaceSwizzler::IPhoneUserInterfaceSwizzler): >+ (IPhoneUserInterfaceSwizzler::phoneUserInterfaceIdiom): >+ (TestWebKitAPI::setUpWebViewForPreferredContentModeTestingWithoutNavigationDelegate): >+ (TestWebKitAPI::setUpWebViewForPreferredContentModeTesting): >+ (TestWebKitAPI::makeContentModeDecisionHandler): >+ (TestWebKitAPI::TEST): >+ * WebKitTestRunner/cocoa/TestControllerCocoa.mm: >+ (WTR::TestController::enableModernCompatibilityMode): >+ > 2019-05-31 Sihui Liu <sihui_liu@apple.com> > > TestWebKitAPI.WKWebView.LocalStorageProcessSuspends is flaky >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 961df7e3df397f1495812bebecfd10aebedd69dc..19666827b7a6eb87d5ff0cf4ec42f3614f99f5a1 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -937,7 +937,7 @@ > F4811E5921940BDE00A5E0FD /* WKWebViewEditActions.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4811E5821940B4400A5E0FD /* WKWebViewEditActions.mm */; }; > F4856CA31E649EA8009D7EE7 /* attachment-element.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4856CA21E6498A8009D7EE7 /* attachment-element.html */; }; > F486B1D01F67952300F34BDD /* DataTransfer-setDragImage.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F486B1CF1F6794FF00F34BDD /* DataTransfer-setDragImage.html */; }; >- F48D6C10224B377000E3E2FB /* PreferredCompatibilityMode.mm in Sources */ = {isa = PBXBuildFile; fileRef = F48D6C0F224B377000E3E2FB /* PreferredCompatibilityMode.mm */; }; >+ F48D6C10224B377000E3E2FB /* PreferredContentMode.mm in Sources */ = {isa = PBXBuildFile; fileRef = F48D6C0F224B377000E3E2FB /* PreferredContentMode.mm */; }; > F4A32EC41F05F3850047C544 /* dragstart-change-selection-offscreen.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4A32EC31F05F3780047C544 /* dragstart-change-selection-offscreen.html */; }; > F4A32ECB1F0643370047C544 /* contenteditable-in-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4A32ECA1F0642F40047C544 /* contenteditable-in-iframe.html */; }; > F4A9202F1FEE34E900F59590 /* apple-data-url.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4A9202E1FEE34C800F59590 /* apple-data-url.html */; }; >@@ -2343,7 +2343,7 @@ > F4811E5821940B4400A5E0FD /* WKWebViewEditActions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewEditActions.mm; sourceTree = "<group>"; }; > F4856CA21E6498A8009D7EE7 /* attachment-element.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "attachment-element.html"; sourceTree = "<group>"; }; > F486B1CF1F6794FF00F34BDD /* DataTransfer-setDragImage.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "DataTransfer-setDragImage.html"; sourceTree = "<group>"; }; >- F48D6C0F224B377000E3E2FB /* PreferredCompatibilityMode.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PreferredCompatibilityMode.mm; sourceTree = "<group>"; }; >+ F48D6C0F224B377000E3E2FB /* PreferredContentMode.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PreferredContentMode.mm; sourceTree = "<group>"; }; > F493247C1F44DF8D006F4336 /* UIKitSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIKitSPI.h; sourceTree = "<group>"; }; > F4A32EC31F05F3780047C544 /* dragstart-change-selection-offscreen.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "dragstart-change-selection-offscreen.html"; sourceTree = "<group>"; }; > F4A32ECA1F0642F40047C544 /* contenteditable-in-iframe.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "contenteditable-in-iframe.html"; sourceTree = "<group>"; }; >@@ -2787,7 +2787,7 @@ > F4CDAB3322489FE10057A2D9 /* IPadUserInterfaceSwizzler.h */, > 2E7765CC16C4D80A00BA2BB1 /* mainIOS.mm */, > 2D61EC3021B0B75C00A7D1CB /* PencilKitTestSPI.h */, >- F48D6C0F224B377000E3E2FB /* PreferredCompatibilityMode.mm */, >+ F48D6C0F224B377000E3E2FB /* PreferredContentMode.mm */, > F4517B652054C49500C26721 /* TestWKWebViewController.h */, > F4517B662054C49500C26721 /* TestWKWebViewController.mm */, > F493247C1F44DF8D006F4336 /* UIKitSPI.h */, >@@ -4348,7 +4348,7 @@ > 83BAEE8D1EF4625500DDE894 /* PluginLoadClientPolicies.mm in Sources */, > 7CCE7F261A411AF600447C4C /* Preferences.mm in Sources */, > CD227E44211A4D5D00D285AF /* PreferredAudioBufferSize.mm in Sources */, >- F48D6C10224B377000E3E2FB /* PreferredCompatibilityMode.mm in Sources */, >+ F48D6C10224B377000E3E2FB /* PreferredContentMode.mm in Sources */, > 7C1AF7951E8DCBAB002645B9 /* PrepareForMoveToWindow.mm in Sources */, > 7CCE7F0B1A411AE600447C4C /* PreventEmptyUserAgent.cpp in Sources */, > 7CCE7F2C1A411B1000447C4C /* PreventImageLoadWithAutoResizing.mm in Sources */, >diff --git a/Tools/TestWebKitAPI/ios/PreferredCompatibilityMode.mm b/Tools/TestWebKitAPI/ios/PreferredCompatibilityMode.mm >deleted file mode 100644 >index a8e573eb073dfda177dc04518df3d0edab6a01f8..0000000000000000000000000000000000000000 >--- a/Tools/TestWebKitAPI/ios/PreferredCompatibilityMode.mm >+++ /dev/null >@@ -1,30 +0,0 @@ >-/* >- * Copyright (C) 2019 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >- * THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#import "config.h" >- >-#if USE(APPLE_INTERNAL_SDK) >-#import <WebKitAdditions/PreferredCompatibilityModeAdditions.mm> >-#endif >diff --git a/Tools/TestWebKitAPI/ios/PreferredContentMode.mm b/Tools/TestWebKitAPI/ios/PreferredContentMode.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..e823940b334d6aa769d33404e8eac62ffaf317be >--- /dev/null >+++ b/Tools/TestWebKitAPI/ios/PreferredContentMode.mm >@@ -0,0 +1,435 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+ >+#if PLATFORM(IOS_FAMILY) >+ >+#import "IPadUserInterfaceSwizzler.h" >+#import "PlatformUtilities.h" >+#import "TestNavigationDelegate.h" >+#import "TestWKWebView.h" >+#import <WebKit/WKWebpagePreferences.h> >+#import <WebKit/WKWebpagePreferencesPrivate.h> >+#import <wtf/BlockPtr.h> >+#import <wtf/text/WTFString.h> >+ >+@interface ContentModeNavigationDelegate : TestNavigationDelegate >+@property (nonatomic, copy) void (^decidePolicyForNavigationActionWithPreferences)(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *)); >+@end >+ >+@implementation ContentModeNavigationDelegate { >+ BlockPtr<void(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *))> _decidePolicyForNavigationActionWithPreferences; >+} >+ >+- (void)setDecidePolicyForNavigationActionWithPreferences:(void (^)(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *)))decidePolicyForNavigationActionWithPreferences >+{ >+ _decidePolicyForNavigationActionWithPreferences = decidePolicyForNavigationActionWithPreferences; >+} >+ >+- (void (^)(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *)))decidePolicyForNavigationActionWithPreferences >+{ >+ return _decidePolicyForNavigationActionWithPreferences.get(); >+} >+ >+- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction preferences:(WKWebpagePreferences *)preferences decisionHandler:(void (^)(WKNavigationActionPolicy, WKWebpagePreferences *))decisionHandler >+{ >+ if (_decidePolicyForNavigationActionWithPreferences) >+ _decidePolicyForNavigationActionWithPreferences(navigationAction, preferences, decisionHandler); >+ else >+ decisionHandler(WKNavigationActionPolicyAllow, preferences); >+} >+ >+@end >+ >+@implementation WKWebpagePreferences (PreferredContentMode) >+ >++ (instancetype)preferencesWithContentMode:(WKContentMode)mode >+{ >+ auto preferences = adoptNS([[self alloc] init]); >+ [preferences setPreferredContentMode:mode]; >+ return preferences.autorelease(); >+} >+ >+@end >+ >+@implementation WKWebView (PreferredContentMode) >+ >+- (NSString *)navigatorUserAgent >+{ >+ return [self stringByEvaluatingJavaScript:@"navigator.userAgent"]; >+} >+ >+- (NSString *)navigatorPlatform >+{ >+ return [self stringByEvaluatingJavaScript:@"navigator.platform"]; >+} >+ >+- (void)loadTestPageNamed:(NSString *)pageName withPolicyDecisionHandler:(void (^)(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *)))decisionHandler >+{ >+ ContentModeNavigationDelegate *navigationDelegate = (ContentModeNavigationDelegate *)self.navigationDelegate; >+ navigationDelegate.decidePolicyForNavigationActionWithPreferences = decisionHandler; >+ [self loadTestPageNamed:pageName]; >+ [navigationDelegate waitForDidFinishNavigation]; >+} >+ >+- (void)loadHTMLString:(NSString *)htmlString withPolicyDecisionHandler:(void (^)(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *)))decisionHandler >+{ >+ ContentModeNavigationDelegate *navigationDelegate = (ContentModeNavigationDelegate *)self.navigationDelegate; >+ navigationDelegate.decidePolicyForNavigationActionWithPreferences = decisionHandler; >+ [self loadHTMLString:htmlString baseURL:nil]; >+ [navigationDelegate waitForDidFinishNavigation]; >+} >+ >+- (void)loadTestPageNamed:(NSString *)pageName andExpectEffectiveContentMode:(WKContentMode)expectedContentMode withPolicyDecisionHandler:(void (^)(WKNavigationAction *, WKWebpagePreferences *, void (^)(WKNavigationActionPolicy, WKWebpagePreferences *)))decisionHandler >+{ >+ ContentModeNavigationDelegate *navigationDelegate = (ContentModeNavigationDelegate *)self.navigationDelegate; >+ navigationDelegate.decidePolicyForNavigationActionWithPreferences = decisionHandler; >+ >+ auto didFailProvisionalNavigation = makeBlockPtr(navigationDelegate.didFailProvisionalNavigation); >+ navigationDelegate.didFailProvisionalNavigation = [expectedContentMode, didFailProvisionalNavigation] (WKWebView *webView, WKNavigation *navigation, NSError *error) { >+ EXPECT_EQ(expectedContentMode, navigation.effectiveContentMode); >+ if (didFailProvisionalNavigation) >+ didFailProvisionalNavigation(webView, navigation, error); >+ }; >+ >+ auto didStartProvisionalNavigation = makeBlockPtr(navigationDelegate.didStartProvisionalNavigation); >+ navigationDelegate.didStartProvisionalNavigation = [expectedContentMode, didStartProvisionalNavigation] (WKWebView *webView, WKNavigation *navigation) { >+ EXPECT_EQ(expectedContentMode, navigation.effectiveContentMode); >+ if (didStartProvisionalNavigation) >+ didStartProvisionalNavigation(webView, navigation); >+ }; >+ >+ auto didCommitNavigation = makeBlockPtr(navigationDelegate.didCommitNavigation); >+ navigationDelegate.didCommitNavigation = [expectedContentMode, didCommitNavigation] (WKWebView *webView, WKNavigation *navigation) { >+ EXPECT_EQ(expectedContentMode, navigation.effectiveContentMode); >+ if (didCommitNavigation) >+ didCommitNavigation(webView, navigation); >+ }; >+ >+ bool finishedNavigation = false; >+ auto didFinishNavigation = makeBlockPtr(navigationDelegate.didFinishNavigation); >+ navigationDelegate.didFinishNavigation = [expectedContentMode, didFinishNavigation, &finishedNavigation] (WKWebView *webView, WKNavigation *navigation) { >+ EXPECT_EQ(expectedContentMode, navigation.effectiveContentMode); >+ if (didFinishNavigation) >+ didFinishNavigation(webView, navigation); >+ finishedNavigation = true; >+ }; >+ >+ [self loadTestPageNamed:pageName]; >+ TestWebKitAPI::Util::run(&finishedNavigation); >+ >+ navigationDelegate.didFailProvisionalNavigation = didFailProvisionalNavigation.get(); >+ navigationDelegate.didStartProvisionalNavigation = didStartProvisionalNavigation.get(); >+ navigationDelegate.didCommitNavigation = didCommitNavigation.get(); >+ navigationDelegate.didFinishNavigation = didFinishNavigation.get(); >+} >+ >+@end >+ >+@implementation NSString (PreferredContentMode) >+ >+- (void)shouldContainStrings:(NSString *)firstString, ... >+{ >+ va_list args; >+ va_start(args, firstString); >+ for (NSString *string = firstString; string; string = va_arg(args, NSString *)) { >+ BOOL containsString = [self containsString:string]; >+ EXPECT_TRUE(containsString); >+ if (!containsString) >+ NSLog(@"Expected '%@' to contain '%@'", self, string); >+ } >+ va_end(args); >+} >+ >+@end >+ >+class IPhoneUserInterfaceSwizzler { >+public: >+ IPhoneUserInterfaceSwizzler() >+ : m_swizzler(UIDevice.class, @selector(userInterfaceIdiom), reinterpret_cast<IMP>(phoneUserInterfaceIdiom)) >+ { >+ } >+ >+private: >+ static UIUserInterfaceIdiom phoneUserInterfaceIdiom(id, SEL) >+ { >+ return UIUserInterfaceIdiomPhone; >+ } >+ >+ InstanceMethodSwizzler m_swizzler; >+}; >+ >+namespace TestWebKitAPI { >+ >+template <typename ViewClass> >+RetainPtr<ViewClass> setUpWebViewForPreferredContentModeTestingWithoutNavigationDelegate(Optional<WKContentMode> defaultContentMode = { }, const String& applicationNameForUserAgent = "TestWebKitAPI", CGSize size = CGSizeMake(1024, 768)) >+{ >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ if (defaultContentMode) >+ [configuration setDefaultWebpagePreferences:[WKWebpagePreferences preferencesWithContentMode:defaultContentMode.value()]]; >+ if (!!applicationNameForUserAgent) >+ [configuration setApplicationNameForUserAgent:applicationNameForUserAgent]; >+ auto webView = adoptNS([[ViewClass alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height) configuration:configuration.get()]); >+ EXPECT_TRUE([webView isKindOfClass:WKWebView.class]); >+ return webView; >+} >+ >+template <typename ViewClass> >+std::pair<RetainPtr<ViewClass>, RetainPtr<ContentModeNavigationDelegate>> setUpWebViewForPreferredContentModeTesting(Optional<WKContentMode> defaultContentMode = { }, const String& applicationNameForUserAgent = "TestWebKitAPI", CGSize size = CGSizeMake(1024, 768)) >+{ >+ auto webView = setUpWebViewForPreferredContentModeTestingWithoutNavigationDelegate<ViewClass>(defaultContentMode, applicationNameForUserAgent, size); >+ auto navigationDelegate = adoptNS([[ContentModeNavigationDelegate alloc] init]); >+ [webView setNavigationDelegate:navigationDelegate.get()]; >+ return { webView, navigationDelegate }; >+} >+ >+static auto makeContentModeDecisionHandler(WKContentMode mode) >+{ >+ return [mode] (WKNavigationAction *action, WKWebpagePreferences *, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) { >+ decisionHandler(WKNavigationActionPolicyAllow, [WKWebpagePreferences preferencesWithContentMode:mode]); >+ }; >+}; >+ >+TEST(PreferredContentMode, SetDefaultWebpagePreferences) >+{ >+ IPadUserInterfaceSwizzler iPadUserInterface; >+ >+ RetainPtr<WKWebView> webView; >+ RetainPtr<ContentModeNavigationDelegate> delegate; >+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>(); >+ [webView loadHTMLString:@"<pre>Foo</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) { >+ EXPECT_EQ(WKContentModeRecommended, defaultPreferences.preferredContentMode); >+ decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences); >+ }]; >+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil]; >+ EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]); >+ >+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>(WKContentModeDesktop); >+ [webView loadHTMLString:@"<pre>Bar</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) { >+ EXPECT_EQ(WKContentModeDesktop, defaultPreferences.preferredContentMode); >+ decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences); >+ }]; >+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil]; >+ EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]); >+ >+ [webView loadHTMLString:@"<pre>Baz</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) { >+ EXPECT_EQ(WKContentModeDesktop, defaultPreferences.preferredContentMode); >+ decisionHandler(WKNavigationActionPolicyAllow, [WKWebpagePreferences preferencesWithContentMode:WKContentModeMobile]); >+ }]; >+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (iP", @"TestWebKitAPI", nil]; >+ EXPECT_TRUE([[webView navigatorPlatform] containsString:@"iP"]); >+} >+ >+TEST(PreferredContentMode, DesktopModeWithoutNavigationDelegate) >+{ >+ IPadUserInterfaceSwizzler iPadUserInterface; >+ >+ auto webView = setUpWebViewForPreferredContentModeTestingWithoutNavigationDelegate<TestWKWebView>(WKContentModeDesktop, "TestWebKitAPI"); >+ [webView loadHTMLString:@"<body>Hello world</body>" baseURL:nil]; >+ >+ __block bool finished = false; >+ [webView performAfterLoading:^{ >+ finished = true; >+ }]; >+ Util::run(&finished); >+ >+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil]; >+ EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]); >+} >+ >+TEST(PreferredContentMode, DesktopModeOnPhone) >+{ >+ IPhoneUserInterfaceSwizzler iPhoneUserInterface; >+ >+ RetainPtr<WKWebView> webView; >+ RetainPtr<ContentModeNavigationDelegate> delegate; >+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>(); >+ [webView loadHTMLString:@"<pre>Foo</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) { >+ EXPECT_EQ(WKContentModeRecommended, defaultPreferences.preferredContentMode); >+ decisionHandler(WKNavigationActionPolicyAllow, [WKWebpagePreferences preferencesWithContentMode:WKContentModeDesktop]); >+ }]; >+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil]; >+ EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]); >+ EXPECT_EQ(980, [[webView objectByEvaluatingJavaScript:@"innerWidth"] intValue]); >+ >+ webView = setUpWebViewForPreferredContentModeTestingWithoutNavigationDelegate<WKWebView>(WKContentModeMobile); >+ [webView synchronouslyLoadHTMLString:@"<body>Hello world</body>"]; >+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (iP", @"TestWebKitAPI", nil]; >+ EXPECT_TRUE([[webView navigatorPlatform] containsString:@"iP"]); >+ EXPECT_EQ(980, [[webView objectByEvaluatingJavaScript:@"innerWidth"] intValue]); >+} >+ >+TEST(PreferredContentMode, DesktopModeTopLevelFrameSupercedesSubframe) >+{ >+ IPadUserInterfaceSwizzler iPadUserInterface; >+ >+ RetainPtr<WKWebView> webView; >+ RetainPtr<ContentModeNavigationDelegate> delegate; >+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>(); >+ >+ __block BOOL decidedPolicyForMainFrame = NO; >+ __block BOOL decidedPolicyForSubFrame = NO; >+ [webView loadHTMLString:@"<p>Foo bar</p><iframe src='data:text/html,<pre>Hello</pre>'></iframe>" withPolicyDecisionHandler:^(WKNavigationAction *action, WKWebpagePreferences *, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) { >+ WKContentMode contentMode; >+ if (action.targetFrame.mainFrame) { >+ decidedPolicyForMainFrame = YES; >+ contentMode = WKContentModeDesktop; >+ } else { >+ decidedPolicyForSubFrame = YES; >+ contentMode = WKContentModeMobile; >+ } >+ decisionHandler(WKNavigationActionPolicyAllow, [WKWebpagePreferences preferencesWithContentMode:contentMode]); >+ }]; >+ >+ EXPECT_TRUE(decidedPolicyForMainFrame); >+ EXPECT_TRUE(decidedPolicyForSubFrame); >+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil]; >+ EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]); >+} >+ >+TEST(PreferredContentMode, DesktopModeUsesNativeViewportByDefault) >+{ >+ IPadUserInterfaceSwizzler iPadUserInterface; >+ >+ RetainPtr<WKWebView> webView; >+ RetainPtr<ContentModeNavigationDelegate> delegate; >+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>(); >+ >+ [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeDesktop)]; >+ EXPECT_EQ(1024, [[webView objectByEvaluatingJavaScript:@"innerWidth"] intValue]); >+ >+ [webView loadTestPageNamed:@"simple2" withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeMobile)]; >+ EXPECT_EQ(980, [[webView objectByEvaluatingJavaScript:@"innerWidth"] intValue]); >+ >+ ((ContentModeNavigationDelegate *)[webView navigationDelegate]).decidePolicyForNavigationActionWithPreferences = makeContentModeDecisionHandler(WKContentModeDesktop); >+ [webView goBack]; >+ [delegate waitForDidFinishNavigation]; >+ EXPECT_EQ(1024, [[webView objectByEvaluatingJavaScript:@"innerWidth"] intValue]); >+} >+ >+TEST(PreferredContentMode, CustomUserAgentOverridesDesktopContentModeUserAgent) >+{ >+ IPadUserInterfaceSwizzler iPadUserInterface; >+ >+ RetainPtr<TestWKWebView> webView; >+ RetainPtr<ContentModeNavigationDelegate> delegate; >+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<TestWKWebView>(WKContentModeDesktop); >+ >+ NSString *customUserAgent = @"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"; >+ [webView setCustomUserAgent:customUserAgent]; >+ [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:nil]; >+ EXPECT_WK_STREQ(customUserAgent, [webView navigatorUserAgent]); >+ >+ [webView setCustomUserAgent:@""]; >+ [webView loadTestPageNamed:@"simple2" withPolicyDecisionHandler:nil]; >+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil]; >+} >+ >+TEST(PreferredContentMode, DoNotAllowChangingDefaultWebpagePreferencesInDelegateMethod) >+{ >+ IPadUserInterfaceSwizzler iPadUserInterface; >+ >+ RetainPtr<TestWKWebView> webView; >+ RetainPtr<ContentModeNavigationDelegate> delegate; >+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<TestWKWebView>(WKContentModeDesktop); >+ >+ [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) { >+ EXPECT_EQ(WKContentModeDesktop, defaultPreferences.preferredContentMode); >+ defaultPreferences.preferredContentMode = WKContentModeMobile; >+ decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences); >+ }]; >+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (iP", @"TestWebKitAPI", nil]; >+ >+ [webView loadTestPageNamed:@"simple2" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) { >+ EXPECT_EQ(WKContentModeDesktop, defaultPreferences.preferredContentMode); >+ decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences); >+ }]; >+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil]; >+} >+ >+TEST(PreferredContentMode, EffectiveContentModeOnIPad) >+{ >+ IPadUserInterfaceSwizzler iPadUserInterface; >+ >+ RetainPtr<TestWKWebView> webView; >+ RetainPtr<ContentModeNavigationDelegate> delegate; >+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>(); >+ >+ [webView loadTestPageNamed:@"simple" andExpectEffectiveContentMode:WKContentModeDesktop withPolicyDecisionHandler:nil]; >+ [webView loadTestPageNamed:@"simple2" andExpectEffectiveContentMode:WKContentModeDesktop withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeDesktop)]; >+ [webView loadTestPageNamed:@"simple3" andExpectEffectiveContentMode:WKContentModeMobile withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeMobile)]; >+} >+ >+TEST(PreferredContentMode, EffectiveContentModeOnPhone) >+{ >+ IPhoneUserInterfaceSwizzler iPhoneUserInterface; >+ >+ RetainPtr<TestWKWebView> webView; >+ RetainPtr<ContentModeNavigationDelegate> delegate; >+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>(); >+ >+ [webView loadTestPageNamed:@"simple" andExpectEffectiveContentMode:WKContentModeMobile withPolicyDecisionHandler:nil]; >+ [webView loadTestPageNamed:@"simple2" andExpectEffectiveContentMode:WKContentModeDesktop withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeDesktop)]; >+ [webView loadTestPageNamed:@"simple3" andExpectEffectiveContentMode:WKContentModeMobile withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeMobile)]; >+} >+ >+TEST(PreferredContentMode, RecommendedContentModeAtVariousViewWidths) >+{ >+ IPadUserInterfaceSwizzler iPadUserInterface; >+ >+ RetainPtr<TestWKWebView> webView; >+ RetainPtr<ContentModeNavigationDelegate> delegate; >+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>({ }, "TestWebKitAPI", CGSizeZero); >+ [webView loadTestPageNamed:@"simple" andExpectEffectiveContentMode:WKContentModeDesktop withPolicyDecisionHandler:nil]; >+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Macintosh", @"TestWebKitAPI", nil]; >+ >+ [webView setFrame:CGRectMake(0, 0, 320, 768)]; >+ [webView loadTestPageNamed:@"simple2" andExpectEffectiveContentMode:WKContentModeMobile withPolicyDecisionHandler:nil]; >+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (iP", @"TestWebKitAPI", nil]; >+ >+ [webView setFrame:CGRectMake(0, 0, 1024, 768)]; >+ [webView loadTestPageNamed:@"simple3" andExpectEffectiveContentMode:WKContentModeDesktop withPolicyDecisionHandler:nil]; >+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Macintosh", @"TestWebKitAPI", nil]; >+} >+ >+TEST(PreferredContentMode, ApplicationNameForDesktopUserAgent) >+{ >+ IPadUserInterfaceSwizzler iPadUserInterface; >+ >+ RetainPtr<TestWKWebView> webView; >+ RetainPtr<ContentModeNavigationDelegate> delegate; >+ std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>(); >+ [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) { >+ defaultPreferences._applicationNameForUserAgentWithModernCompatibility = @"DesktopBrowser"; >+ decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences); >+ }]; >+ [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Macintosh", @"DesktopBrowser", nil]; >+ EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]); >+} >+ >+} // namespace TestWebKitAPI >+ >+#endif // PLATFORM(IOS_FAMILY) >diff --git a/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm b/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm >index 4087735ba25bb853a2e6cff000f2e031abbcfa12..226df6a4ae6853a2e4aa94629491e7a809f754e3 100644 >--- a/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm >+++ b/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm >@@ -431,14 +431,13 @@ bool TestController::isDoingMediaCapture() const > return m_mainWebView->platformView()._mediaCaptureState != _WKMediaCaptureStateNone; > } > >-#if USE(APPLE_INTERNAL_SDK) >-#import <WebKitAdditions/TestControllerCocoaAdditions.mm> >-#else >- >-void TestController::enableModernCompatibilityMode(WKWebViewConfiguration *) >+void TestController::enableModernCompatibilityMode(WKWebViewConfiguration *configuration) > { >-} >- >+ auto webpagePreferences = adoptNS([[WKWebpagePreferences alloc] init]); >+#if PLATFORM(IOS_FAMILY) >+ [webpagePreferences setPreferredContentMode:WKContentModeDesktop]; > #endif >+ configuration.defaultWebpagePreferences = webpagePreferences.get(); >+} > > } // namespace WTR
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198484
:
371198
|
371203
|
371217
|
371231
|
371282
|
371286
|
371299
|
371406