Title: [211541] trunk
Revision
211541
Author
simon.fra...@apple.com
Date
2017-02-01 17:12:53 -0800 (Wed, 01 Feb 2017)

Log Message

[iOS WK2] With visual viewports, a fixed bottom bar can be clipped out when the keyboard is visible
https://bugs.webkit.org/show_bug.cgi?id=167710
rdar://problem/30100286

Reviewed by Wenson Hsieh.
Source/WebCore:

Add a bit of logging to show when RLC decides to not composite a fixed element which
is out of bounds.

Test: fast/visual-viewport/ios/bottom-bar-with-keyboard.html

* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::requiresCompositingForPosition):

Source/WebKit2:

The unobscuredRectInContentCoordinates passed to -didUpdateVisibleRect:... could project outside
of the bounds of the document, which is OK when rubber-banding, but not when we're in a stable state,
because that can cause fixed elements to get pushed outside the doc. This happened when the keyboard
triggered bottom content insets on the scroll view.

LayoutTests:

* fast/visual-viewport/ios/bottom-bar-with-keyboard-expected.txt: Added.
* fast/visual-viewport/ios/bottom-bar-with-keyboard.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (211540 => 211541)


--- trunk/LayoutTests/ChangeLog	2017-02-01 23:49:41 UTC (rev 211540)
+++ trunk/LayoutTests/ChangeLog	2017-02-02 01:12:53 UTC (rev 211541)
@@ -1,3 +1,14 @@
+2017-02-01  Simon Fraser  <simon.fra...@apple.com>
+
+        [iOS WK2] With visual viewports, a fixed bottom bar can be clipped out when the keyboard is visible
+        https://bugs.webkit.org/show_bug.cgi?id=167710
+        rdar://problem/30100286
+
+        Reviewed by Wenson Hsieh.
+
+        * fast/visual-viewport/ios/bottom-bar-with-keyboard-expected.txt: Added.
+        * fast/visual-viewport/ios/bottom-bar-with-keyboard.html: Added.
+
 2017-02-01  Ryan Haddad  <ryanhad...@apple.com>
 
         Marking compositing/repaint/fixed-background-scroll.html as flaky on macOS WK1.

Added: trunk/LayoutTests/fast/visual-viewport/ios/bottom-bar-with-keyboard-expected.txt (0 => 211541)


--- trunk/LayoutTests/fast/visual-viewport/ios/bottom-bar-with-keyboard-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/visual-viewport/ios/bottom-bar-with-keyboard-expected.txt	2017-02-02 01:12:53 UTC (rev 211541)
@@ -0,0 +1,3 @@
+Layout viewport: {"top":0,"right":320,"bottom":548,"left":0,"width":320,"height":548}
+Visual viewport: {"top":375,"right":220,"bottom":548,"left":0,"width":220,"height":173}
+

Added: trunk/LayoutTests/fast/visual-viewport/ios/bottom-bar-with-keyboard.html (0 => 211541)


--- trunk/LayoutTests/fast/visual-viewport/ios/bottom-bar-with-keyboard.html	                        (rev 0)
+++ trunk/LayoutTests/fast/visual-viewport/ios/bottom-bar-with-keyboard.html	2017-02-02 01:12:53 UTC (rev 211541)
@@ -0,0 +1,58 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+    <meta name="viewport" content="initial-scale=1.0">
+    <style>
+        body {
+            height: 100%;
+        }
+        .fixed {
+            position: fixed;
+            background-color: silver;
+            bottom: 0;
+            padding: 10px;
+        }
+    </style>
+    <script>
+        if (window.testRunner) {
+            testRunner.waitUntilDone();
+            testRunner.dumpAsText();
+        }
+
+        function getFocusInputUIScript(x, y)
+        {
+            return `(function() {
+                uiController.didEndZoomingCallback = function() {
+                    uiController.uiScriptComplete();
+                }
+                
+                uiController.singleTapAtPoint(${x}, ${y}, function() {});
+            })();`;
+        }
+
+        function runTest()
+        {
+            if (!window.testRunner || !testRunner.runUIScript)
+                return;
+
+            var rect = document.getElementById('input').getBoundingClientRect();
+            // singleTapAtPoint takes document coordinates, so add scrollTop to clientRect.top.
+            testRunner.runUIScript(getFocusInputUIScript(rect.left, rect.top + document.scrollingElement.scrollTop), function() {
+                var output = 'Layout viewport: ' + JSON.stringify(internals.layoutViewportRect()) + '\nVisual viewport: ' + JSON.stringify(internals.visualViewportRect()) + '\n';
+                document.getElementById('results').innerText = output;
+
+                testRunner.notifyDone();
+            });
+        }
+
+        window.addEventListener('load', runTest, false);
+    </script>
+</head>
+<body>
+<pre id="results"></pre>
+<div class="fixed">
+    <input id="input" type="text">
+</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (211540 => 211541)


--- trunk/Source/WebCore/ChangeLog	2017-02-01 23:49:41 UTC (rev 211540)
+++ trunk/Source/WebCore/ChangeLog	2017-02-02 01:12:53 UTC (rev 211541)
@@ -1,3 +1,19 @@
+2017-02-01  Simon Fraser  <simon.fra...@apple.com>
+
+        [iOS WK2] With visual viewports, a fixed bottom bar can be clipped out when the keyboard is visible
+        https://bugs.webkit.org/show_bug.cgi?id=167710
+        rdar://problem/30100286
+
+        Reviewed by Wenson Hsieh.
+        
+        Add a bit of logging to show when RLC decides to not composite a fixed element which
+        is out of bounds.
+
+        Test: fast/visual-viewport/ios/bottom-bar-with-keyboard.html
+
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::requiresCompositingForPosition):
+
 2017-02-01  Eric Carlson  <eric.carl...@apple.com>
 
         [Mac] Update CARingBuffer class

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (211540 => 211541)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2017-02-01 23:49:41 UTC (rev 211540)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2017-02-02 01:12:53 UTC (rev 211541)
@@ -2751,6 +2751,7 @@
     if (!viewBounds.intersects(enclosingIntRect(absoluteBounds))) {
         if (viewportConstrainedNotCompositedReason)
             *viewportConstrainedNotCompositedReason = RenderLayer::NotCompositedForBoundsOutOfView;
+        LOG_WITH_STREAM(Compositing, stream << "Layer " << &layer << " bounds " << layerBounds << " outside visible rect " << viewBounds);
         return false;
     }
     

Modified: trunk/Source/WebKit2/ChangeLog (211540 => 211541)


--- trunk/Source/WebKit2/ChangeLog	2017-02-01 23:49:41 UTC (rev 211540)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-02 01:12:53 UTC (rev 211541)
@@ -1,3 +1,24 @@
+2017-02-01  Simon Fraser  <simon.fra...@apple.com>
+
+        [iOS WK2] With visual viewports, a fixed bottom bar can be clipped out when the keyboard is visible
+        https://bugs.webkit.org/show_bug.cgi?id=167710
+        rdar://problem/30100286
+
+        Reviewed by Wenson Hsieh.
+
+        The unobscuredRectInContentCoordinates passed to -didUpdateVisibleRect:... could project outside
+        of the bounds of the document, which is OK when rubber-banding, but not when we're in a stable state,
+        because that can cause fixed elements to get pushed outside the doc. This happened when the keyboard
+        triggered bottom content insets on the scroll view.
+
+        Fix by computing a rectangle which is the "allowed" bounds of fixed content, which is permitted
+        to extend outside the document bounds only when rubber-banding, and intersect unobscuredRectInContentCoordinates
+        with that rectangle.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _contentBoundsExtendedForRubberbandingWithScale:]):
+        (-[WKWebView _updateContentRectsWithState:]):
+
 2017-02-01  Enrica Casucci  <enr...@apple.com>
 
         WebProcess crashes in  int WTF::__throw_bad_variant_access<int> when expanding/shrinking a block selection.

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (211540 => 211541)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2017-02-01 23:49:41 UTC (rev 211540)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2017-02-02 01:12:53 UTC (rev 211541)
@@ -2087,6 +2087,31 @@
         || (contentSize.height + contentInset.top + contentInset.bottom) > boundsSize.height;
 }
 
+- (CGRect)_contentBoundsExtendedForRubberbandingWithScale:(CGFloat)scaleFactor
+{
+    CGPoint contentOffset = [_scrollView contentOffset];
+    CGPoint boundedOffset = contentOffsetBoundedInValidRange(_scrollView.get(), contentOffset);
+
+    CGFloat horiontalRubberbandAmountInContentCoordinates = (contentOffset.x - boundedOffset.x) / scaleFactor;
+    CGFloat verticalRubberbandAmountInContentCoordinates = (contentOffset.y - boundedOffset.y) / scaleFactor;
+
+    CGRect extendedBounds = [_contentView bounds];
+
+    if (horiontalRubberbandAmountInContentCoordinates < 0) {
+        extendedBounds.origin.x += horiontalRubberbandAmountInContentCoordinates;
+        extendedBounds.size.width -= horiontalRubberbandAmountInContentCoordinates;
+    } else if (horiontalRubberbandAmountInContentCoordinates > 0)
+        extendedBounds.size.width += horiontalRubberbandAmountInContentCoordinates;
+
+    if (verticalRubberbandAmountInContentCoordinates < 0) {
+        extendedBounds.origin.y += verticalRubberbandAmountInContentCoordinates;
+        extendedBounds.size.height -= verticalRubberbandAmountInContentCoordinates;
+    } else if (verticalRubberbandAmountInContentCoordinates > 0)
+        extendedBounds.size.height += verticalRubberbandAmountInContentCoordinates;
+
+    return extendedBounds;
+}
+
 - (void)_updateContentRectsWithState:(BOOL)inStableState
 {
     if (![self usesStandardContentView]) {
@@ -2113,11 +2138,12 @@
     if (!_haveSetObscuredInsets)
         computedContentInsetUnadjustedForKeyboard.bottom -= _totalScrollViewBottomInsetAdjustmentForKeyboard;
 
+    CGFloat scaleFactor = contentZoomScale(self);
+
     CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, computedContentInsetUnadjustedForKeyboard);
     CGRect unobscuredRectInContentCoordinates = _frozenUnobscuredContentRect ? _frozenUnobscuredContentRect.value() : [self convertRect:unobscuredRect toView:_contentView.get()];
+    unobscuredRectInContentCoordinates = CGRectIntersection(unobscuredRectInContentCoordinates, [self _contentBoundsExtendedForRubberbandingWithScale:scaleFactor]);
 
-    CGFloat scaleFactor = contentZoomScale(self);
-
 #if ENABLE(CSS_SCROLL_SNAP) && ENABLE(ASYNC_SCROLLING)
     if (inStableState) {
         WebKit::RemoteScrollingCoordinatorProxy* coordinator = _page->scrollingCoordinatorProxy();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to