Title: [219594] trunk
Revision
219594
Author
timothy_hor...@apple.com
Date
2017-07-17 18:45:59 -0700 (Mon, 17 Jul 2017)

Log Message

Page using safe area constant properties jumps to correct layout after resize
https://bugs.webkit.org/show_bug.cgi?id=174598
<rdar://problem/33364275>

Reviewed by Simon Fraser.

Source/WebKit:

Test: fast/events/ios/rotation/safe-area-insets-during-safari-type-rotation.html

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _beginAnimatedResizeWithUpdates:]):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::dynamicViewportSizeUpdate):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::dynamicViewportSizeUpdate):
Plumb unobscured safe area insets through in the dynamicViewportSizeUpdate,
like we do in VisibleContentRectUpdate (once again sad that these aren't
more similar), so that it will be correct in the during-rotation snapshot,
instead of only becoming correct in the first visible content rect update
post-rotation.

LayoutTests:

* fast/events/ios/rotation/safe-area-insets-during-safari-type-rotation-expected.txt: Added.
* fast/events/ios/rotation/safe-area-insets-during-safari-type-rotation.html: Added.
Add a test making sure that dynamic-viewport-update-based rotation
updates safe area insets when needed.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (219593 => 219594)


--- trunk/LayoutTests/ChangeLog	2017-07-18 01:12:18 UTC (rev 219593)
+++ trunk/LayoutTests/ChangeLog	2017-07-18 01:45:59 UTC (rev 219594)
@@ -1,3 +1,16 @@
+2017-07-17  Timothy Horton  <timothy_hor...@apple.com>
+
+        Page using safe area constant properties jumps to correct layout after resize
+        https://bugs.webkit.org/show_bug.cgi?id=174598
+        <rdar://problem/33364275>
+
+        Reviewed by Simon Fraser.
+
+        * fast/events/ios/rotation/safe-area-insets-during-safari-type-rotation-expected.txt: Added.
+        * fast/events/ios/rotation/safe-area-insets-during-safari-type-rotation.html: Added.
+        Add a test making sure that dynamic-viewport-update-based rotation
+        updates safe area insets when needed.
+
 2017-07-17  Matt Lewis  <jlew...@apple.com>
         
         Fixed test expectations after r219518.

Added: trunk/LayoutTests/fast/events/ios/rotation/safe-area-insets-during-safari-type-rotation-expected.txt (0 => 219594)


--- trunk/LayoutTests/fast/events/ios/rotation/safe-area-insets-during-safari-type-rotation-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/rotation/safe-area-insets-during-safari-type-rotation-expected.txt	2017-07-18 01:45:59 UTC (rev 219594)
@@ -0,0 +1,15 @@
+Before rotation
+layoutViewport: 0, 0 - 320 x 548
+visualViewport: 0, 0 - 320 x 548
+client rect of fixed object:0, 0 - 320 x 548
+
+In resize event handler:
+layoutViewport: 0, 0 - 568 x 320
+visualViewport: 0, 0 - 568 x 320
+client rect of fixed object:100, 50 - 443 x 195
+
+After rotation
+layoutViewport: 0, 0 - 568 x 320
+visualViewport: 0, 0 - 568 x 320
+client rect of fixed object:100, 50 - 443 x 195
+

Added: trunk/LayoutTests/fast/events/ios/rotation/safe-area-insets-during-safari-type-rotation.html (0 => 219594)


--- trunk/LayoutTests/fast/events/ios/rotation/safe-area-insets-during-safari-type-rotation.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/ios/rotation/safe-area-insets-during-safari-type-rotation.html	2017-07-18 01:45:59 UTC (rev 219594)
@@ -0,0 +1,52 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+    <meta name="viewport" content="initial-scale=1, viewport-fit=cover">
+    <style>
+        body {
+            height: 2000px;
+        }
+
+        #extent {
+            position: fixed;
+            border: 10px solid rgba(0, 0, 128, 0.5);
+            left: constant(safe-area-inset-left);
+            top: constant(safe-area-inset-top);
+            right: constant(safe-area-inset-right);
+            bottom: constant(safe-area-inset-bottom);
+        }
+    </style>
+    <script src=""
+    <script src=""
+    <script>
+        if (window.internals) {
+            internals.settings.setConstantPropertiesEnabled(true);
+            internals.settings.setViewportFitEnabled(true);
+        }
+
+        function getRotationUIScript()
+        {
+            return `
+            (function() {
+                uiController.setSafeAreaInsets(50, 25, 75, 100);
+                uiController.simulateRotationLikeSafari('landscape-right', function() {
+                    uiController.uiScriptComplete();
+                });
+            })();`
+        }
+        
+        window.addEventListener('resize', function() {
+            accumulateLog('');
+            accumulateLog('In resize event handler:');
+            logFixedAndViewports();
+        }, false);
+
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+    <div id="extent"></div>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebKit/ChangeLog (219593 => 219594)


--- trunk/Source/WebKit/ChangeLog	2017-07-18 01:12:18 UTC (rev 219593)
+++ trunk/Source/WebKit/ChangeLog	2017-07-18 01:45:59 UTC (rev 219594)
@@ -1,3 +1,28 @@
+2017-07-17  Timothy Horton  <timothy_hor...@apple.com>
+
+        Page using safe area constant properties jumps to correct layout after resize
+        https://bugs.webkit.org/show_bug.cgi?id=174598
+        <rdar://problem/33364275>
+
+        Reviewed by Simon Fraser.
+
+        Test: fast/events/ios/rotation/safe-area-insets-during-safari-type-rotation.html
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _beginAnimatedResizeWithUpdates:]):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::dynamicViewportSizeUpdate):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::dynamicViewportSizeUpdate):
+        Plumb unobscured safe area insets through in the dynamicViewportSizeUpdate,
+        like we do in VisibleContentRectUpdate (once again sad that these aren't
+        more similar), so that it will be correct in the during-rotation snapshot,
+        instead of only becoming correct in the first visible content rect update
+        post-rotation.
+
 2017-07-17  Chris Dumez  <cdu...@apple.com>
 
         UserMediaPermissionRequestManagerProxy should not use WebCore::Timer

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (219593 => 219594)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2017-07-18 01:12:18 UTC (rev 219593)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2017-07-18 01:45:59 UTC (rev 219594)
@@ -4859,7 +4859,10 @@
     CGRect visibleRectInContentCoordinates = [self convertRect:newBounds toView:_contentView.get()];
     CGRect unobscuredRectInContentCoordinates = [self convertRect:futureUnobscuredRectInSelfCoordinates toView:_contentView.get()];
 
-    _page->dynamicViewportSizeUpdate(newMinimumLayoutSize, newMaximumUnobscuredSize, visibleRectInContentCoordinates, unobscuredRectInContentCoordinates, futureUnobscuredRectInSelfCoordinates, targetScale, newOrientation);
+    UIEdgeInsets unobscuredSafeAreaInsets = [self _computedUnobscuredSafeAreaInset];
+    WebCore::FloatBoxExtent unobscuredSafeAreaInsetsExtent(unobscuredSafeAreaInsets.top, unobscuredSafeAreaInsets.right, unobscuredSafeAreaInsets.bottom, unobscuredSafeAreaInsets.left);
+
+    _page->dynamicViewportSizeUpdate(newMinimumLayoutSize, newMaximumUnobscuredSize, visibleRectInContentCoordinates, unobscuredRectInContentCoordinates, futureUnobscuredRectInSelfCoordinates, unobscuredSafeAreaInsetsExtent, targetScale, newOrientation);
     if (WebKit::DrawingAreaProxy* drawingArea = _page->drawingArea())
         drawingArea->setSize(WebCore::IntSize(newBounds.size), WebCore::IntSize(), WebCore::IntSize());
 }

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (219593 => 219594)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2017-07-18 01:12:18 UTC (rev 219593)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2017-07-18 01:45:59 UTC (rev 219594)
@@ -499,7 +499,7 @@
     void overflowScrollWillStartScroll();
     void overflowScrollDidEndScroll();
 
-    void dynamicViewportSizeUpdate(const WebCore::FloatSize& minimumLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, double targetScale, int32_t deviceOrientation);
+    void dynamicViewportSizeUpdate(const WebCore::FloatSize& minimumLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation);
     void synchronizeDynamicViewportUpdate();
 
     void setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize&);

Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (219593 => 219594)


--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2017-07-18 01:12:18 UTC (rev 219593)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2017-07-18 01:45:59 UTC (rev 219594)
@@ -287,7 +287,7 @@
     m_pageClient.overflowScrollDidEndScroll();
 }
 
-void WebPageProxy::dynamicViewportSizeUpdate(const FloatSize& minimumLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const FloatRect& targetUnobscuredRectInScrollViewCoordinates,  double targetScale, int32_t deviceOrientation)
+void WebPageProxy::dynamicViewportSizeUpdate(const FloatSize& minimumLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation)
 {
     if (!isValid())
         return;
@@ -296,7 +296,7 @@
 
     m_dynamicViewportSizeUpdateWaitingForTarget = true;
     m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = true;
-    m_process->send(Messages::WebPage::DynamicViewportSizeUpdate(minimumLayoutSize, maximumUnobscuredSize, targetExposedContentRect, targetUnobscuredRect, targetUnobscuredRectInScrollViewCoordinates, targetScale, deviceOrientation, ++m_currentDynamicViewportSizeUpdateID), m_pageID);
+    m_process->send(Messages::WebPage::DynamicViewportSizeUpdate(minimumLayoutSize, maximumUnobscuredSize, targetExposedContentRect, targetUnobscuredRect, targetUnobscuredRectInScrollViewCoordinates, unobscuredSafeAreaInsets, targetScale, deviceOrientation, ++m_currentDynamicViewportSizeUpdateID), m_pageID);
 }
 
 void WebPageProxy::synchronizeDynamicViewportUpdate()

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (219593 => 219594)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2017-07-18 01:12:18 UTC (rev 219593)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2017-07-18 01:45:59 UTC (rev 219594)
@@ -825,7 +825,7 @@
     void setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize&);
     void setMaximumUnobscuredSize(const WebCore::FloatSize&);
     void setDeviceOrientation(int32_t);
-    void dynamicViewportSizeUpdate(const WebCore::FloatSize& minimumLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, double scale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID);
+    void dynamicViewportSizeUpdate(const WebCore::FloatSize& minimumLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& targetUnobscuredSafeAreaInsets, double scale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID);
     void synchronizeDynamicViewportUpdate(double& newTargetScale, WebCore::FloatPoint& newScrollPosition, uint64_t& nextValidLayerTreeTransactionID);
     std::optional<float> scaleFromUIProcess(const VisibleContentRectUpdateInfo&) const;
     void updateVisibleContentRects(const VisibleContentRectUpdateInfo&, MonotonicTime oldestTimestamp);

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (219593 => 219594)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2017-07-18 01:12:18 UTC (rev 219593)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2017-07-18 01:45:59 UTC (rev 219594)
@@ -43,7 +43,7 @@
     SetViewportConfigurationMinimumLayoutSize(WebCore::FloatSize size)
     SetMaximumUnobscuredSize(WebCore::FloatSize size)
     SetDeviceOrientation(int32_t deviceOrientation)
-    DynamicViewportSizeUpdate(WebCore::FloatSize minimumLayoutSize, WebCore::FloatSize maximumUnobscuredSize, WebCore::FloatRect targetExposedContentRect, WebCore::FloatRect targetUnobscuredRect, WebCore::FloatRect targetUnobscuredRectInScrollViewCoordinates, double scale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID)
+    DynamicViewportSizeUpdate(WebCore::FloatSize minimumLayoutSize, WebCore::FloatSize maximumUnobscuredSize, WebCore::FloatRect targetExposedContentRect, WebCore::FloatRect targetUnobscuredRect, WebCore::FloatRect targetUnobscuredRectInScrollViewCoordinates, WebCore::BoxExtent<float> targetUnobscuredSafeAreaInsets, double scale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID)
     SynchronizeDynamicViewportUpdate() -> (double newTargetScale, WebCore::FloatPoint newScrollPosition, uint64_t nextValidLayerTreeTransactionID)
 
     HandleTap(WebCore::IntPoint point, uint64_t lastLayerTreeTransactionId)

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (219593 => 219594)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2017-07-18 01:12:18 UTC (rev 219593)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2017-07-18 01:45:59 UTC (rev 219594)
@@ -2856,7 +2856,7 @@
     }
 }
 
-void WebPage::dynamicViewportSizeUpdate(const FloatSize& minimumLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, double targetScale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID)
+void WebPage::dynamicViewportSizeUpdate(const FloatSize& minimumLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& targetUnobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID)
 {
     SetForScope<bool> dynamicSizeUpdateGuard(m_inDynamicSizeUpdate, true);
     // FIXME: this does not handle the cases where the content would change the content size or scroll position from _javascript_.
@@ -2900,6 +2900,7 @@
         resetTextAutosizing();
 
     setMaximumUnobscuredSize(maximumUnobscuredSize);
+    m_page->setUnobscuredSafeAreaInsets(targetUnobscuredSafeAreaInsets);
 
     frameView.updateLayoutAndStyleIfNeededRecursive();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to