Title: [247327] trunk
Revision
247327
Author
[email protected]
Date
2019-07-10 14:12:47 -0700 (Wed, 10 Jul 2019)

Log Message

[iOS] REGRESSION(r244851): Revealing caret sometimes fails when content inset is used
https://bugs.webkit.org/show_bug.cgi?id=199662

Reviewed by Simon Fraser.

Source/WebCore:

The bug was caused by ScrollableArea::maximumScrollPosition using ScrollableArea::visibleSize, which does not
take the content insets into account correctly, rather than FrameView::visualViewportRectExpandedByContentInsets,
which does, and is used for "viewRect" in RenderLayer::scrollRectToVisible.

Override the maximum scroll position using visualViewportRectExpandedByContentInsets in iOS to fix the issue.

Test: editing/selection/ios/autoscroll-with-top-content-inset-2.html

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollRectToVisible): Fixed the bug.

LayoutTests:

Added a regression test.

* editing/selection/ios/autoscroll-with-top-content-inset-2-expected.txt: Added.
* editing/selection/ios/autoscroll-with-top-content-inset-2.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (247326 => 247327)


--- trunk/LayoutTests/ChangeLog	2019-07-10 20:40:05 UTC (rev 247326)
+++ trunk/LayoutTests/ChangeLog	2019-07-10 21:12:47 UTC (rev 247327)
@@ -1,3 +1,15 @@
+2019-07-10  Ryosuke Niwa  <[email protected]>
+
+        [iOS] REGRESSION(r244851): Revealing caret sometimes fails when content inset is used
+        https://bugs.webkit.org/show_bug.cgi?id=199662
+
+        Reviewed by Simon Fraser.
+
+        Added a regression test.
+
+        * editing/selection/ios/autoscroll-with-top-content-inset-2-expected.txt: Added.
+        * editing/selection/ios/autoscroll-with-top-content-inset-2.html: Added.
+
 2019-07-10  Saam Barati  <[email protected]>
 
         [WHLSL Import more JS reference spec tests

Added: trunk/LayoutTests/editing/selection/ios/autoscroll-with-top-content-inset-2-expected.txt (0 => 247327)


--- trunk/LayoutTests/editing/selection/ios/autoscroll-with-top-content-inset-2-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/ios/autoscroll-with-top-content-inset-2-expected.txt	2019-07-10 21:12:47 UTC (rev 247327)
@@ -0,0 +1 @@
+PASS - caret appeared within the visual viewport

Added: trunk/LayoutTests/editing/selection/ios/autoscroll-with-top-content-inset-2.html (0 => 247327)


--- trunk/LayoutTests/editing/selection/ios/autoscroll-with-top-content-inset-2.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/ios/autoscroll-with-top-content-inset-2.html	2019-07-10 21:12:47 UTC (rev 247327)
@@ -0,0 +1,41 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true, contentInset.top=150 ] -->
+<html>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<head>
+<script src=""
+<script src=""
+<script>
+
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+}
+
+async function run()
+{
+    await UIHelper.setHardwareKeyboardAttached(false);
+    await UIHelper.activateAndWaitForInputSessionAt(10, 10);
+
+    for (let i = 0; i < 150; i++)
+        document.execCommand('insertParagraph');
+
+    window.scrollTo(0, 0);
+    await UIHelper.ensurePresentationUpdate();
+    await UIHelper.enterText('hello');
+
+    const keyboardRect = await UIHelper.inputViewBounds();
+    const scrollTop = document.scrollingElement.scrollTop;
+    const viewportHeight = visualViewport.height;
+    const caretRect = getSelection().getRangeAt(0).getBoundingClientRect();
+
+    document.body.textContent = caretRect.y + caretRect.height <= visualViewport.height
+        ? 'PASS - caret appeared within the visual viewport'
+        : 'FAIL - caret appeared below the visual viewport';
+
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+</script>
+</head>
+<body contenteditable _onload_="run()"></body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (247326 => 247327)


--- trunk/Source/WebCore/ChangeLog	2019-07-10 20:40:05 UTC (rev 247326)
+++ trunk/Source/WebCore/ChangeLog	2019-07-10 21:12:47 UTC (rev 247327)
@@ -1,3 +1,21 @@
+2019-07-10  Ryosuke Niwa  <[email protected]>
+
+        [iOS] REGRESSION(r244851): Revealing caret sometimes fails when content inset is used
+        https://bugs.webkit.org/show_bug.cgi?id=199662
+
+        Reviewed by Simon Fraser.
+
+        The bug was caused by ScrollableArea::maximumScrollPosition using ScrollableArea::visibleSize, which does not
+        take the content insets into account correctly, rather than FrameView::visualViewportRectExpandedByContentInsets,
+        which does, and is used for "viewRect" in RenderLayer::scrollRectToVisible.
+
+        Override the maximum scroll position using visualViewportRectExpandedByContentInsets in iOS to fix the issue.
+
+        Test: editing/selection/ios/autoscroll-with-top-content-inset-2.html
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollRectToVisible): Fixed the bug.
+
 2019-07-10  Ryan Haddad  <[email protected]>
 
         Unreviewed, rolling out r247316.

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (247326 => 247327)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2019-07-10 20:40:05 UTC (rev 247326)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2019-07-10 21:12:47 UTC (rev 247327)
@@ -2678,10 +2678,13 @@
 #if !PLATFORM(IOS_FAMILY)
             LayoutRect viewRect = frameView.visibleContentRect();
 #else
-            // FIXME: ContentInsets should be taken care of in UI process side.
+            // FIXME: ContentInsets should be taken care of in UI process side. webkit.org/b/199682
             // To do that, getRectToExpose needs to return the additional scrolling to do beyond content rect.
             LayoutRect viewRect = frameView.visualViewportRectExpandedByContentInsets();
 
+            // FIXME: webkit.org/b/199683 FrameView::visibleContentRect is wrong when content insets are present
+            maxScrollPosition = frameView.scrollPositionFromOffset(ScrollPosition(frameView.totalContentsSize() - flooredIntSize(viewRect.size())));
+
             auto contentInsets = page().contentInsets();
             minScrollPosition.move(-contentInsets.left(), -contentInsets.top());
             maxScrollPosition.move(contentInsets.right(), contentInsets.bottom());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to