Diff
Modified: trunk/Source/WebKit/ChangeLog (290090 => 290091)
--- trunk/Source/WebKit/ChangeLog 2022-02-18 00:39:48 UTC (rev 290090)
+++ trunk/Source/WebKit/ChangeLog 2022-02-18 00:42:15 UTC (rev 290091)
@@ -1,3 +1,30 @@
+2022-02-17 Devin Rousso <[email protected]>
+
+ [MacCatalyst] improve support for resizing
+ https://bugs.webkit.org/show_bug.cgi?id=236745
+ <rdar://problem/86494393>
+
+ Reviewed by Tim Horton.
+
+ * UIProcess/API/Cocoa/WKWebViewInternal.h:
+ * UIProcess/API/ios/WKWebViewIOS.mm:
+ (-[WKWebView setFrame:]):
+ (-[WKWebView setBounds:]):
+ (-[WKWebView _acquireResizeAssertionForReason:]): Added.
+ Acquire a UIKit assertion whenever the `frame`/`bounds` of the `WKWebView` is changed that
+ is `invalidate` once the visible contect rect has been updated. UIKit can use this to know
+ both when WebKit is processing `WKWebView` resize changes and get notified once it's done.
+
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _doAfterNextVisibleContentRectUpdate:]): Added.
+ * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
+ * UIProcess/API/Cocoa/WKWebViewTesting.mm:
+ (-[WKWebView _doAfterNextVisibleContentRectUpdate:]): Deleted.
+ Allow this to be used outside of testing code (just like `-[WKWebView _doAfterNextPresentationUpdate:]`).
+
+ * Platform/spi/ios/UIKitSPI.h:
+
2022-02-17 Simon Fraser <[email protected]>
Move setting RemoteLayerBackingStore surfaces volatile into the GPU Process
Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (290090 => 290091)
--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2022-02-18 00:39:48 UTC (rev 290090)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2022-02-18 00:42:15 UTC (rev 290091)
@@ -1537,6 +1537,22 @@
#endif
+#if HAVE(MAC_CATALYST_LIVE_RESIZE)
+
+#if __has_include(<UIKit/_UIInvalidatable.h>)
+#include <UIKit/_UIInvalidatable.h>
+#else
+@protocol _UIInvalidatable <NSObject>
+- (void)_invalidate;
+@end
+#endif
+
+@interface UIWindowScene (Staging_86494115)
+- (id<_UIInvalidatable>)_holdLiveResizeSnapshotForReason:(NSString *)reason;
+@end
+
+#endif // HAVE(MAC_CATALYST_LIVE_RESIZE)
+
WTF_EXTERN_C_BEGIN
BOOL UIKeyboardEnabledInputModesAllowOneToManyShortcuts(void);
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (290090 => 290091)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2022-02-18 00:39:48 UTC (rev 290090)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2022-02-18 00:42:15 UTC (rev 290091)
@@ -3706,6 +3706,18 @@
[self _internalDoAfterNextPresentationUpdate:updateBlock withoutWaitingForPainting:YES withoutWaitingForAnimatedResize:NO];
}
+- (void)_doAfterNextVisibleContentRectUpdate:(void (^)(void))updateBlock
+{
+#if PLATFORM(IOS_FAMILY)
+ _visibleContentRectUpdateCallbacks.append(makeBlockPtr(updateBlock));
+ [self _scheduleVisibleContentRectUpdate];
+#else
+ RunLoop::main().dispatch([updateBlock = makeBlockPtr(updateBlock)] {
+ updateBlock();
+ });
+#endif
+}
+
- (WKDisplayCaptureSurfaces) _displayCaptureSurfaces
{
auto pageState = _page->reportedMediaState();
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h (290090 => 290091)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h 2022-02-18 00:39:48 UTC (rev 290090)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h 2022-02-18 00:42:15 UTC (rev 290091)
@@ -214,6 +214,10 @@
std::optional<WebKit::TransactionID> _firstTransactionIDAfterPageRestore;
double _scaleToRestore;
+#if HAVE(MAC_CATALYST_LIVE_RESIZE)
+ Vector<RetainPtr<id<_UIInvalidatable>>> _resizeAssertions;
+#endif
+
BOOL _allowsBackForwardNavigationGestures;
RetainPtr<UIView <WKWebViewContentProvider>> _customContentView;
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (290090 => 290091)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2022-02-18 00:39:48 UTC (rev 290090)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2022-02-18 00:42:15 UTC (rev 290091)
@@ -264,6 +264,8 @@
- (void)_doAfterNextPresentationUpdate:(void (^)(void))updateBlock WK_API_AVAILABLE(macos(10.12), ios(10.0));
- (void)_doAfterNextPresentationUpdateWithoutWaitingForPainting:(void (^)(void))updateBlock WK_API_AVAILABLE(macos(10.12.3), ios(10.3));
+- (void)_doAfterNextVisibleContentRectUpdate:(void (^)(void))updateBlock WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
- (void)_executeEditCommand:(NSString *)command argument:(NSString *)argument completion:(void (^)(BOOL))completion WK_API_AVAILABLE(macos(10.13.4), ios(11.3));
- (void)_isJITEnabled:(void(^)(BOOL))completionHandler WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h (290090 => 290091)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h 2022-02-18 00:39:48 UTC (rev 290090)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h 2022-02-18 00:42:15 UTC (rev 290091)
@@ -58,7 +58,6 @@
- (void)_requestActiveNowPlayingSessionInfo:(void(^)(BOOL, BOOL, NSString*, double, double, NSInteger))callback;
- (void)_doAfterNextPresentationUpdateWithoutWaitingForAnimatedResizeForTesting:(void (^)(void))updateBlock;
-- (void)_doAfterNextVisibleContentRectUpdate:(void (^)(void))updateBlock;
- (void)_disableBackForwardSnapshotVolatilityForTesting;
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm (290090 => 290091)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm 2022-02-18 00:39:48 UTC (rev 290090)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm 2022-02-18 00:42:15 UTC (rev 290091)
@@ -144,18 +144,6 @@
[self _internalDoAfterNextPresentationUpdate:updateBlock withoutWaitingForPainting:NO withoutWaitingForAnimatedResize:YES];
}
-- (void)_doAfterNextVisibleContentRectUpdate:(void (^)(void))updateBlock
-{
-#if PLATFORM(IOS_FAMILY)
- _visibleContentRectUpdateCallbacks.append(makeBlockPtr(updateBlock));
- [self _scheduleVisibleContentRectUpdate];
-#else
- RunLoop::main().dispatch([updateBlock = makeBlockPtr(updateBlock)] {
- updateBlock();
- });
-#endif
-}
-
- (void)_disableBackForwardSnapshotVolatilityForTesting
{
WebKit::ViewSnapshotStore::singleton().setDisableSnapshotVolatilityForTesting(true);
Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (290090 => 290091)
--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2022-02-18 00:39:48 UTC (rev 290090)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2022-02-18 00:42:15 UTC (rev 290091)
@@ -119,8 +119,13 @@
CGRect oldFrame = self.frame;
[super setFrame:frame];
- if (!CGSizeEqualToSize(oldFrame.size, frame.size))
+ if (!CGSizeEqualToSize(oldFrame.size, frame.size)) {
[self _frameOrBoundsChanged];
+
+#if HAVE(MAC_CATALYST_LIVE_RESIZE)
+ [self _acquireResizeAssertionForReason:@"-[WKWebView setFrame:]"];
+#endif
+ }
}
- (void)setBounds:(CGRect)bounds
@@ -129,8 +134,13 @@
[super setBounds:bounds];
[_customContentFixedOverlayView setFrame:self.bounds];
- if (!CGSizeEqualToSize(oldBounds.size, bounds.size))
+ if (!CGSizeEqualToSize(oldBounds.size, bounds.size)) {
[self _frameOrBoundsChanged];
+
+#if HAVE(MAC_CATALYST_LIVE_RESIZE)
+ [self _acquireResizeAssertionForReason:@"-[WKWebView setBounds:]"];
+#endif
+ }
}
- (void)layoutSubviews
@@ -1987,6 +1997,30 @@
[self _scheduleVisibleContentRectUpdate];
}
+#if HAVE(MAC_CATALYST_LIVE_RESIZE)
+
+- (void)_acquireResizeAssertionForReason:(NSString *)reason
+{
+ UIWindowScene *windowScene = self.window.windowScene;
+ if (!windowScene)
+ return;
+
+ if (_resizeAssertions.isEmpty()) {
+ [self _doAfterNextVisibleContentRectUpdate:makeBlockPtr([weakSelf = WeakObjCPtr<WKWebView>(self)] {
+ auto strongSelf = weakSelf.get();
+ if (!strongSelf)
+ return;
+
+ for (auto resizeAssertion : std::exchange(strongSelf->_resizeAssertions, { }))
+ [resizeAssertion _invalidate];
+ }).get()];
+ }
+
+ _resizeAssertions.append(adoptNS([windowScene _holdLiveResizeSnapshotForReason:reason]));
+}
+
+#endif // HAVE(MAC_CATALYST_LIVE_RESIZE)
+
// Unobscured content rect where the user can interact. When the keyboard is up, this should be the area above or below the keyboard, wherever there is enough space.
- (CGRect)_contentRectForUserInteraction
{