- Revision
- 225714
- Author
- [email protected]
- Date
- 2017-12-08 16:00:09 -0800 (Fri, 08 Dec 2017)
Log Message
When the iPhone keyboard is up, sometimes we never commit a stable update and re-show the caret
https://bugs.webkit.org/show_bug.cgi?id=180498
Reviewed by Tim Horton.
Source/WebKit:
When the keyboard is showing, we would think that the page was in a rubber-banding state
because contentOffsetBoundedInValidRange() would always clamp the content offset to a different
value.
This happened because scrollView.contentInset don't change when the keyboard is showing,
but UIKit actually consults scrollView.adjustedContentInset, which does. If we use
scrollView.adjustedContentInset in this computation, we'll get a correct answer.
Also rewrote the clamping logic to be more similar to what UIKit does internally when computing
min/max content offset.
* UIProcess/API/Cocoa/WKWebView.mm:
(contentOffsetBoundedInValidRange):
LayoutTests:
Test that completes once a stable update is received after showing the keyboard.
* fast/visual-viewport/ios/stable-update-with-keyboard-expected.txt: Added.
* fast/visual-viewport/ios/stable-update-with-keyboard.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (225713 => 225714)
--- trunk/LayoutTests/ChangeLog 2017-12-08 23:53:45 UTC (rev 225713)
+++ trunk/LayoutTests/ChangeLog 2017-12-09 00:00:09 UTC (rev 225714)
@@ -1,3 +1,15 @@
+2017-12-06 Simon Fraser <[email protected]>
+
+ When the iPhone keyboard is up, sometimes we never commit a stable update and re-show the caret
+ https://bugs.webkit.org/show_bug.cgi?id=180498
+
+ Reviewed by Tim Horton.
+
+ Test that completes once a stable update is received after showing the keyboard.
+
+ * fast/visual-viewport/ios/stable-update-with-keyboard-expected.txt: Added.
+ * fast/visual-viewport/ios/stable-update-with-keyboard.html: Added.
+
2017-12-08 Daniel Bates <[email protected]>
Remove unnecessary prefix from AutoFillButtonType enumerators
Added: trunk/LayoutTests/fast/visual-viewport/ios/stable-update-with-keyboard-expected.txt (0 => 225714)
--- trunk/LayoutTests/fast/visual-viewport/ios/stable-update-with-keyboard-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/visual-viewport/ios/stable-update-with-keyboard-expected.txt 2017-12-09 00:00:09 UTC (rev 225714)
@@ -0,0 +1,8 @@
+PASS: got stable update
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This test will time out if no stable update is received.
+
+
+
Added: trunk/LayoutTests/fast/visual-viewport/ios/stable-update-with-keyboard.html (0 => 225714)
--- trunk/LayoutTests/fast/visual-viewport/ios/stable-update-with-keyboard.html (rev 0)
+++ trunk/LayoutTests/fast/visual-viewport/ios/stable-update-with-keyboard.html 2017-12-09 00:00:09 UTC (rev 225714)
@@ -0,0 +1,71 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+ <meta name="viewport" content="initial-scale=1.0">
+ <style>
+ .spacer-above {
+ background-color: silver;
+ height: 600px;
+ }
+ .spacer-below {
+ background-color: silver;
+ height: 80px;
+ }
+ input {
+ display: block;
+ margin: 60px 30px;
+ }
+ </style>
+ <script src=""
+ <script>
+ var jsTestIsAsync = true;
+
+ function getScrollDownUIScript()
+ {
+ return `(function() {
+ uiController.immediateScrollToOffset(0, 800);
+ })();`;
+ }
+
+ function getFocusInputUIScript(x, y)
+ {
+ return `(function() {
+
+ uiController.didShowKeyboardCallback = function() {
+ uiController.doAfterNextStablePresentationUpdate(function() {
+ uiController.uiScriptComplete();
+ });
+ };
+ uiController.singleTapAtPoint(${x}, ${y}, function() {});
+ })();`;
+ }
+
+ function runTest()
+ {
+ if (!window.testRunner || !testRunner.runUIScript)
+ return;
+
+ testRunner.runUIScript(getScrollDownUIScript(), function() {
+ window.setTimeout(function() {
+ 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() {
+ debug('PASS: got stable update');
+ finishJSTest();
+ });
+ }, 0);
+ });
+ }
+
+ window.addEventListener('load', runTest, false);
+ </script>
+</head>
+<body>
+<p>This test will time out if no stable update is received.</p>
+<div class="spacer-above"></div>
+<input id="input" type="text"/>
+<div class="spacer-below"></div>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebKit/ChangeLog (225713 => 225714)
--- trunk/Source/WebKit/ChangeLog 2017-12-08 23:53:45 UTC (rev 225713)
+++ trunk/Source/WebKit/ChangeLog 2017-12-09 00:00:09 UTC (rev 225714)
@@ -1,3 +1,24 @@
+2017-12-06 Simon Fraser <[email protected]>
+
+ When the iPhone keyboard is up, sometimes we never commit a stable update and re-show the caret
+ https://bugs.webkit.org/show_bug.cgi?id=180498
+
+ Reviewed by Tim Horton.
+
+ When the keyboard is showing, we would think that the page was in a rubber-banding state
+ because contentOffsetBoundedInValidRange() would always clamp the content offset to a different
+ value.
+
+ This happened because scrollView.contentInset don't change when the keyboard is showing,
+ but UIKit actually consults scrollView.adjustedContentInset, which does. If we use
+ scrollView.adjustedContentInset in this computation, we'll get a correct answer.
+
+ Also rewrote the clamping logic to be more similar to what UIKit does internally when computing
+ min/max content offset.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (contentOffsetBoundedInValidRange):
+
2017-12-08 Chris Dumez <[email protected]>
Clearing all Website Data should remove service worker registrations on disk
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (225713 => 225714)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2017-12-08 23:53:45 UTC (rev 225713)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2017-12-09 00:00:09 UTC (rev 225714)
@@ -1629,18 +1629,19 @@
static CGPoint contentOffsetBoundedInValidRange(UIScrollView *scrollView, CGPoint contentOffset)
{
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
+ UIEdgeInsets contentInsets = scrollView.adjustedContentInset;
+#else
UIEdgeInsets contentInsets = scrollView.contentInset;
+#endif
+
CGSize contentSize = scrollView.contentSize;
CGSize scrollViewSize = scrollView.bounds.size;
- CGFloat maxHorizontalOffset = contentSize.width + contentInsets.right - scrollViewSize.width;
- contentOffset.x = std::min(maxHorizontalOffset, contentOffset.x);
- contentOffset.x = std::max(-contentInsets.left, contentOffset.x);
+ CGPoint minimumContentOffset = CGPointMake(-contentInsets.left, -contentInsets.top);
+ CGPoint maximumContentOffset = CGPointMake(std::max(minimumContentOffset.x, contentSize.width + contentInsets.right - scrollViewSize.width), std::max(minimumContentOffset.y, contentSize.height + contentInsets.bottom - scrollViewSize.height));
- CGFloat maxVerticalOffset = contentSize.height + contentInsets.bottom - scrollViewSize.height;
- contentOffset.y = std::min(maxVerticalOffset, contentOffset.y);
- contentOffset.y = std::max(-contentInsets.top, contentOffset.y);
- return contentOffset;
+ return CGPointMake(std::max(std::min(contentOffset.x, maximumContentOffset.x), minimumContentOffset.x), std::max(std::min(contentOffset.y, maximumContentOffset.y), minimumContentOffset.y));
}
static void changeContentOffsetBoundedInValidRange(UIScrollView *scrollView, WebCore::FloatPoint contentOffset)