- Revision
- 220286
- Author
- [email protected]
- Date
- 2017-08-04 12:50:23 -0700 (Fri, 04 Aug 2017)
Log Message
viewport-fit changes during animated resize can cause layout size to get stuck
https://bugs.webkit.org/show_bug.cgi?id=175169
<rdar://problem/33684697>
Reviewed by Simon Fraser.
If we get a commit that changes viewport-fit state while an animated
resize is underway, and that change causes the client to push a new
minimumLayoutSizeOverride, the new size will be lost forever, and we
will get stuck laying out at the wrong size.
This is because we unconditionally apply avoidsUnsafeArea for every commit,
while most other changes that come in from a commit are ignored if we're
inside animated resize. To fix, also ignore avoidsUnsafeArea changes during
animated resize, by moving the code that keeps track of it into WKWebView
like all of the rest, and read it out of the commit in didCommitLayerTree
*after* the animated-resize early-return.
Also, fix the associated layout tests by adding a missing assignment
in _computedContentInset, which was broken in r220138.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
(-[WKWebView _setHasCustomContentView:loadedMIMEType:]):
(-[WKWebView _processDidExit]):
(-[WKWebView _didCommitLayerTree:]):
(-[WKWebView _setAvoidsUnsafeArea:]):
(-[WKWebView _safeAreaShouldAffectObscuredInsets]):
(-[WKWebView _didChangeAvoidsUnsafeArea:]): Deleted.
* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resetState):
(WebKit::WebPageProxy::setAvoidsUnsafeArea): Deleted.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::avoidsUnsafeArea const): Deleted.
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::didChangeAvoidsUnsafeArea): Deleted.
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::didCommitLayerTree):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (220285 => 220286)
--- trunk/Source/WebKit/ChangeLog 2017-08-04 19:44:04 UTC (rev 220285)
+++ trunk/Source/WebKit/ChangeLog 2017-08-04 19:50:23 UTC (rev 220286)
@@ -1,3 +1,47 @@
+2017-08-04 Tim Horton <[email protected]>
+
+ viewport-fit changes during animated resize can cause layout size to get stuck
+ https://bugs.webkit.org/show_bug.cgi?id=175169
+ <rdar://problem/33684697>
+
+ Reviewed by Simon Fraser.
+
+ If we get a commit that changes viewport-fit state while an animated
+ resize is underway, and that change causes the client to push a new
+ minimumLayoutSizeOverride, the new size will be lost forever, and we
+ will get stuck laying out at the wrong size.
+
+ This is because we unconditionally apply avoidsUnsafeArea for every commit,
+ while most other changes that come in from a commit are ignored if we're
+ inside animated resize. To fix, also ignore avoidsUnsafeArea changes during
+ animated resize, by moving the code that keeps track of it into WKWebView
+ like all of the rest, and read it out of the commit in didCommitLayerTree
+ *after* the animated-resize early-return.
+
+ Also, fix the associated layout tests by adding a missing assignment
+ in _computedContentInset, which was broken in r220138.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _initializeWithConfiguration:]):
+ (-[WKWebView _setHasCustomContentView:loadedMIMEType:]):
+ (-[WKWebView _processDidExit]):
+ (-[WKWebView _didCommitLayerTree:]):
+ (-[WKWebView _setAvoidsUnsafeArea:]):
+ (-[WKWebView _safeAreaShouldAffectObscuredInsets]):
+ (-[WKWebView _didChangeAvoidsUnsafeArea:]): Deleted.
+ * UIProcess/API/Cocoa/WKWebViewInternal.h:
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::resetState):
+ (WebKit::WebPageProxy::setAvoidsUnsafeArea): Deleted.
+ * UIProcess/WebPageProxy.h:
+ (WebKit::WebPageProxy::avoidsUnsafeArea const): Deleted.
+ * UIProcess/ios/PageClientImplIOS.h:
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::didChangeAvoidsUnsafeArea): Deleted.
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::didCommitLayerTree):
+
2017-08-04 Matt Lewis <[email protected]>
Unreviewed, rolling out r220271.
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (220285 => 220286)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2017-08-04 19:44:04 UTC (rev 220285)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2017-08-04 19:50:23 UTC (rev 220286)
@@ -246,6 +246,7 @@
UIEdgeInsets _unobscuredSafeAreaInsets;
BOOL _haveSetUnobscuredSafeAreaInsets;
+ BOOL _avoidsUnsafeArea;
UIRectEdge _obscuredInsetEdgesAffectedBySafeArea;
UIInterfaceOrientation _interfaceOrientationOverride;
@@ -523,6 +524,7 @@
[_scrollView setInternalDelegate:self];
[_scrollView setBouncesZoom:YES];
+ _avoidsUnsafeArea = YES;
[self _updateScrollViewInsetAdjustmentBehavior];
[self addSubview:_scrollView.get()];
@@ -1268,7 +1270,7 @@
_scrollViewBackgroundColor = WebCore::Color();
[_scrollView setContentOffset:[self _adjustedContentOffset:CGPointZero]];
- [self _didChangeAvoidsUnsafeArea:NO];
+ [self _setAvoidsUnsafeArea:NO];
} else if (_customContentView) {
[_customContentView removeFromSuperview];
_customContentView = nullptr;
@@ -1282,8 +1284,6 @@
[_customContentFixedOverlayView setFrame:self.bounds];
[self addSubview:_customContentFixedOverlayView.get()];
-
- [self _didChangeAvoidsUnsafeArea:_page->avoidsUnsafeArea()];
}
if (self.isFirstResponder) {
@@ -1407,7 +1407,7 @@
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
if (self._safeAreaShouldAffectObscuredInsets)
- UIEdgeInsetsAdd(insets, [_scrollView _systemContentInset], self._effectiveObscuredInsetEdgesAffectedBySafeArea);
+ insets = UIEdgeInsetsAdd(insets, [_scrollView _systemContentInset], self._effectiveObscuredInsetEdgesAffectedBySafeArea);
#endif
return insets;
@@ -1461,6 +1461,8 @@
_firstPaintAfterCommitLoadTransactionID = 0;
_firstTransactionIDAfterPageRestore = 0;
_resizeAnimationTransformTransactionID = std::nullopt;
+
+ _avoidsUnsafeArea = YES;
}
- (void)_didCommitLoadForMainFrame
@@ -1559,6 +1561,7 @@
[_contentView _setDoubleTapGesturesEnabled:self._allowsDoubleTapGestures];
[self _updateScrollViewBackground];
+ [self _setAvoidsUnsafeArea:layerTreeTransaction.avoidsUnsafeArea()];
if (_gestureController)
_gestureController->setRenderTreeSize(layerTreeTransaction.renderTreeSize());
@@ -2717,8 +2720,13 @@
#endif
}
-- (void)_didChangeAvoidsUnsafeArea:(BOOL)avoidsUnsafeArea
+- (void)_setAvoidsUnsafeArea:(BOOL)avoidsUnsafeArea
{
+ if (_avoidsUnsafeArea == avoidsUnsafeArea)
+ return;
+
+ _avoidsUnsafeArea = avoidsUnsafeArea;
+
[self _updateScrollViewInsetAdjustmentBehavior];
[self _scheduleVisibleContentRectUpdate];
@@ -4672,9 +4680,7 @@
{
if (![self usesStandardContentView])
return NO;
- if (!_page)
- return YES;
- return _page->avoidsUnsafeArea();
+ return _avoidsUnsafeArea;
}
- (void)_setInterfaceOrientationOverride:(UIInterfaceOrientation)interfaceOrientation
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h (220285 => 220286)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h 2017-08-04 19:44:04 UTC (rev 220285)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h 2017-08-04 19:50:23 UTC (rev 220286)
@@ -119,8 +119,6 @@
- (void)_showPasswordViewWithDocumentName:(NSString *)documentName passwordHandler:(void (^)(NSString *))passwordHandler;
- (void)_hidePasswordView;
-- (void)_didChangeAvoidsUnsafeArea:(BOOL)avoidsUnsafeArea;
-
- (void)_addShortcut:(id)sender;
- (void)_arrowKey:(id)sender;
- (void)_define:(id)sender;
Modified: trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h (220285 => 220286)
--- trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h 2017-08-04 19:44:04 UTC (rev 220285)
+++ trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h 2017-08-04 19:50:23 UTC (rev 220286)
@@ -146,8 +146,6 @@
WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override { return WebCore::UserInterfaceLayoutDirection::LTR; }
- void didChangeAvoidsUnsafeArea(bool) override { }
-
JSGlobalContextRef _javascript_GlobalContext() override;
// Members of PageClientImpl class
Modified: trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h (220285 => 220286)
--- trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h 2017-08-04 19:44:04 UTC (rev 220285)
+++ trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h 2017-08-04 19:50:23 UTC (rev 220286)
@@ -117,8 +117,6 @@
WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
- void didChangeAvoidsUnsafeArea(bool) override { }
-
JSGlobalContextRef _javascript_GlobalContext() override;
WKWPE::View& m_view;
Modified: trunk/Source/WebKit/UIProcess/PageClient.h (220285 => 220286)
--- trunk/Source/WebKit/UIProcess/PageClient.h 2017-08-04 19:44:04 UTC (rev 220285)
+++ trunk/Source/WebKit/UIProcess/PageClient.h 2017-08-04 19:50:23 UTC (rev 220286)
@@ -384,8 +384,6 @@
virtual void didChangeDataInteractionCaretRect(const WebCore::IntRect& previousCaretRect, const WebCore::IntRect& caretRect) = 0;
#endif
- virtual void didChangeAvoidsUnsafeArea(bool avoidsUnsafeArea) = 0;
-
#if PLATFORM(GTK) || PLATFORM(WPE)
virtual JSGlobalContextRef _javascript_GlobalContext() { return nullptr; }
#endif
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (220285 => 220286)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2017-08-04 19:44:04 UTC (rev 220285)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2017-08-04 19:50:23 UTC (rev 220286)
@@ -5514,8 +5514,6 @@
#if ENABLE(POINTER_LOCK)
requestPointerUnlock();
#endif
-
- m_avoidsUnsafeArea = true;
}
void WebPageProxy::resetStateAfterProcessExited()
@@ -6950,14 +6948,4 @@
iterator->value->stopTask(*this, taskIdentifier);
}
-void WebPageProxy::setAvoidsUnsafeArea(bool avoidsUnsafeArea)
-{
- if (m_avoidsUnsafeArea == avoidsUnsafeArea)
- return;
-
- m_avoidsUnsafeArea = avoidsUnsafeArea;
-
- m_pageClient.didChangeAvoidsUnsafeArea(avoidsUnsafeArea);
-}
-
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (220285 => 220286)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2017-08-04 19:44:04 UTC (rev 220285)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2017-08-04 19:50:23 UTC (rev 220286)
@@ -1201,9 +1201,6 @@
void createSandboxExtensionsIfNeeded(const Vector<String>& files, SandboxExtension::Handle& fileReadHandle, SandboxExtension::HandleArray& fileUploadHandles);
#endif
- void setAvoidsUnsafeArea(bool);
- bool avoidsUnsafeArea() const { return m_avoidsUnsafeArea; }
-
private:
WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, Ref<API::PageConfiguration>&&);
void platformInitialize();
@@ -2000,8 +1997,6 @@
bool m_isUsingHighPerformanceWebGL { false };
- bool m_avoidsUnsafeArea { true };
-
WeakPtrFactory<WebPageProxy> m_weakPtrFactory;
HashMap<String, Ref<WebURLSchemeHandler>> m_urlSchemeHandlersByScheme;
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (220285 => 220286)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2017-08-04 19:44:04 UTC (rev 220285)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2017-08-04 19:50:23 UTC (rev 220286)
@@ -199,8 +199,6 @@
void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) override;
- void didChangeAvoidsUnsafeArea(bool avoidsUnsafeArea) override;
-
#if USE(QUICK_LOOK)
void requestPasswordForQuickLookDocument(const String& fileName, WTF::Function<void(const String&)>&&) override;
#endif
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (220285 => 220286)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2017-08-04 19:44:04 UTC (rev 220285)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2017-08-04 19:50:23 UTC (rev 220286)
@@ -826,11 +826,6 @@
}
#endif
-void PageClientImpl::didChangeAvoidsUnsafeArea(bool avoidsUnsafeArea)
-{
- [m_webView _didChangeAvoidsUnsafeArea:avoidsUnsafeArea];
-}
-
} // namespace WebKit
#endif // PLATFORM(IOS)
Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (220285 => 220286)
--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2017-08-04 19:44:04 UTC (rev 220285)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2017-08-04 19:50:23 UTC (rev 220286)
@@ -372,7 +372,6 @@
void WebPageProxy::didCommitLayerTree(const WebKit::RemoteLayerTreeTransaction& layerTreeTransaction)
{
m_pageExtendedBackgroundColor = layerTreeTransaction.pageExtendedBackgroundColor();
- setAvoidsUnsafeArea(layerTreeTransaction.avoidsUnsafeArea());
if (!m_hasReceivedLayerTreeTransactionAfterDidCommitLoad) {
if (layerTreeTransaction.transactionID() >= m_firstLayerTreeTransactionIdAfterDidCommitLoad) {
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImpl.h (220285 => 220286)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImpl.h 2017-08-04 19:44:04 UTC (rev 220285)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImpl.h 2017-08-04 19:50:23 UTC (rev 220286)
@@ -253,8 +253,6 @@
void didRestoreScrollPosition() override;
bool windowIsFrontWindowUnderMouse(const NativeWebMouseEvent&) override;
-
- void didChangeAvoidsUnsafeArea(bool avoidsUnsafeArea) override { }
};
} // namespace WebKit