- Revision
- 293564
- Author
- wenson_hs...@apple.com
- Date
- 2022-04-27 22:01:24 -0700 (Wed, 27 Apr 2022)
Log Message
[iOS] Add a mechanism to override desktop-class browsing state in multitasking mode
https://bugs.webkit.org/show_bug.cgi?id=239801
rdar://89786146
Reviewed by Tim Horton.
Keep the recommended desktop-class browsing state stable as the width of the web view changes, while
multitasking mode is active.
* UIProcess/API/ios/WKWebViewIOS.h:
* UIProcess/PageClient.h:
(WebKit::PageClient::isInMultitaskingMode const):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::isInMultitaskingMode const):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::isDesktopClassBrowsingRecommended const):
Turn the static helper function `desktopClassBrowsingRecommended` into a private method instead, so that we
don't need to pass in all the information we need from the WebPageProxy when determining whether we should
default to desktop-class browsing. This also allows us to make a slight adjustment here to avoid recommending
mobile content when the window is narrower than 375 points in multitasking mode.
(WebKit::WebPageProxy::effectiveContentModeAfterAdjustingPolicies):
(WebKit::desktopClassBrowsingRecommended): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (293563 => 293564)
--- trunk/Source/WebKit/ChangeLog 2022-04-28 04:50:39 UTC (rev 293563)
+++ trunk/Source/WebKit/ChangeLog 2022-04-28 05:01:24 UTC (rev 293564)
@@ -1,3 +1,32 @@
+2022-04-27 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [iOS] Add a mechanism to override desktop-class browsing state in multitasking mode
+ https://bugs.webkit.org/show_bug.cgi?id=239801
+ rdar://89786146
+
+ Reviewed by Tim Horton.
+
+ Keep the recommended desktop-class browsing state stable as the width of the web view changes, while
+ multitasking mode is active.
+
+ * UIProcess/API/ios/WKWebViewIOS.h:
+ * UIProcess/PageClient.h:
+ (WebKit::PageClient::isInMultitaskingMode const):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/PageClientImplIOS.h:
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::isInMultitaskingMode const):
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::isDesktopClassBrowsingRecommended const):
+
+ Turn the static helper function `desktopClassBrowsingRecommended` into a private method instead, so that we
+ don't need to pass in all the information we need from the WebPageProxy when determining whether we should
+ default to desktop-class browsing. This also allows us to make a slight adjustment here to avoid recommending
+ mobile content when the window is narrower than 375 points in multitasking mode.
+
+ (WebKit::WebPageProxy::effectiveContentModeAfterAdjustingPolicies):
+ (WebKit::desktopClassBrowsingRecommended): Deleted.
+
2022-04-27 Simon Fraser <simon.fra...@apple.com>
Avoid sending a flush IPC to the GPU process when destroying a RemoteImageBuffer
Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h (293563 => 293564)
--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h 2022-04-28 04:50:39 UTC (rev 293563)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h 2022-04-28 05:01:24 UTC (rev 293564)
@@ -170,6 +170,10 @@
@property (nonatomic, readonly, getter=_isRetainingActiveFocusedState) BOOL _retainingActiveFocusedState;
@property (nonatomic, readonly) int32_t _deviceOrientation;
+#if HAVE(MULTITASKING_MODE)
+@property (nonatomic, readonly) BOOL _isInMultitaskingMode;
+#endif
+
@end
_WKTapHandlingResult wkTapHandlingResult(WebKit::TapHandlingResult);
Modified: trunk/Source/WebKit/UIProcess/PageClient.h (293563 => 293564)
--- trunk/Source/WebKit/UIProcess/PageClient.h 2022-04-28 04:50:39 UTC (rev 293563)
+++ trunk/Source/WebKit/UIProcess/PageClient.h 2022-04-28 05:01:24 UTC (rev 293564)
@@ -554,6 +554,8 @@
virtual WebCore::DataOwnerType dataOwnerForPasteboard(PasteboardAccessIntent) const { return WebCore::DataOwnerType::Undefined; }
#endif
+ virtual bool isInMultitaskingMode() const { return false; }
+
#if ENABLE(IMAGE_ANALYSIS)
virtual void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&& completion) { completion({ }); }
virtual void computeHasVisualSearchResults(const URL&, ShareableBitmap&, CompletionHandler<void(bool)>&& completion) { completion(false); }
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (293563 => 293564)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2022-04-28 04:50:39 UTC (rev 293563)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2022-04-28 05:01:24 UTC (rev 293564)
@@ -2425,6 +2425,7 @@
void updateStringForFind(const String&);
bool isValidPerformActionOnElementAuthorizationToken(const String& authorizationToken) const;
+ bool isDesktopClassBrowsingRecommended(const WebCore::ResourceRequest&) const;
#endif
void focusedFrameChanged(const std::optional<WebCore::FrameIdentifier>&);
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (293563 => 293564)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2022-04-28 04:50:39 UTC (rev 293563)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2022-04-28 05:01:24 UTC (rev 293564)
@@ -310,6 +310,8 @@
void beginElementFullscreenVideoExtraction(const ShareableBitmap::Handle&, WebCore::FloatRect) final;
void cancelElementFullscreenVideoExtraction() final;
+ bool isInMultitaskingMode() const final;
+
WeakObjCPtr<WKContentView> m_contentView;
RetainPtr<WKEditorUndoTarget> m_undoTarget;
};
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (293563 => 293564)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2022-04-28 04:50:39 UTC (rev 293563)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2022-04-28 05:01:24 UTC (rev 293564)
@@ -1069,6 +1069,15 @@
[m_contentView cancelElementFullscreenVideoExtraction];
}
+bool PageClientImpl::isInMultitaskingMode() const
+{
+#if HAVE(MULTITASKING_MODE)
+ return [m_webView _isInMultitaskingMode];
+#else
+ return false;
+#endif
+}
+
} // namespace WebKit
#endif // PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (293563 => 293564)
--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2022-04-28 04:50:39 UTC (rev 293563)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2022-04-28 05:01:24 UTC (rev 293564)
@@ -1387,8 +1387,7 @@
return RecommendDesktopClassBrowsingForRequest::Auto;
}
-enum class IgnoreAppCompatibilitySafeguards : bool { No, Yes };
-static bool desktopClassBrowsingRecommended(const WebCore::ResourceRequest& request, WebCore::IntSize viewSize, IgnoreAppCompatibilitySafeguards ignoreSafeguards)
+bool WebPageProxy::isDesktopClassBrowsingRecommended(const WebCore::ResourceRequest& request) const
{
auto desktopClassBrowsingRecommendation = desktopClassBrowsingRecommendedForRequest(request);
if (desktopClassBrowsingRecommendation == RecommendDesktopClassBrowsingForRequest::Yes)
@@ -1398,7 +1397,7 @@
return false;
#if !PLATFORM(MACCATALYST)
- if (webViewSizeIsNarrow(viewSize))
+ if (!pageClient().isInMultitaskingMode() && webViewSizeIsNarrow(viewSize()))
return false;
#endif
@@ -1412,7 +1411,7 @@
auto screenClass = MGGetSInt32Answer(kMGQMainScreenClass, MGScreenClassPad2);
shouldRecommendDesktopClassBrowsing = screenClass != MGScreenClassPad3 && screenClass != MGScreenClassPad4 && desktopClassBrowsingSupported();
#endif
- if (ignoreSafeguards == IgnoreAppCompatibilitySafeguards::No && !linkedOnOrAfterSDKWithBehavior(SDKAlignedBehavior::ModernCompabilityModeByDefault)) {
+ if (!m_navigationClient->shouldBypassContentModeSafeguards() && !linkedOnOrAfterSDKWithBehavior(SDKAlignedBehavior::ModernCompabilityModeByDefault)) {
// 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;
@@ -1428,12 +1427,10 @@
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);
+ useDesktopBrowsingMode = isDesktopClassBrowsingRecommended(request);
break;
}
case WebContentMode::Mobile: