Deleting in a text input inside an iframe causes the page to scroll incorrectly
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jul 2016 23:44:44 +0000 (23:44 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jul 2016 23:44:44 +0000 (23:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=159654
rdar://problem/26805722

Reviewed by Zalan Bujtas.

Source/WebCore:

Editor::revealSelectionAfterEditingOperation() needs the same iOS-specific reveal
behavior as was added for typing in r202295.

Test: fast/forms/ios/delete-in-input-in-iframe.html

* editing/Editor.cpp:
(WebCore::Editor::revealSelectionAfterEditingOperation):

LayoutTests:

* fast/forms/ios/delete-in-input-in-iframe-expected.txt: Added.
* fast/forms/ios/delete-in-input-in-iframe.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@203097 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/forms/ios/delete-in-input-in-iframe-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/ios/delete-in-input-in-iframe.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/Editor.cpp

index b855b55..b67e2c4 100644 (file)
@@ -1,3 +1,14 @@
+2016-07-11  Simon Fraser  <simon.fraser@apple.com>
+
+        Deleting in a text input inside an iframe causes the page to scroll incorrectly
+        https://bugs.webkit.org/show_bug.cgi?id=159654
+        rdar://problem/26805722
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/forms/ios/delete-in-input-in-iframe-expected.txt: Added.
+        * fast/forms/ios/delete-in-input-in-iframe.html: Added.
+
 2016-07-11  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Honor the second argument to FontFaceSet.load and FontFaceSet.check
diff --git a/LayoutTests/fast/forms/ios/delete-in-input-in-iframe-expected.txt b/LayoutTests/fast/forms/ios/delete-in-input-in-iframe-expected.txt
new file mode 100644 (file)
index 0000000..98d4ddf
--- /dev/null
@@ -0,0 +1,5 @@
+Tests that typing into a text input in an iframe should not scroll.
+
+PASS: page did not scroll.
+Click to focus input
+
diff --git a/LayoutTests/fast/forms/ios/delete-in-input-in-iframe.html b/LayoutTests/fast/forms/ios/delete-in-input-in-iframe.html
new file mode 100644 (file)
index 0000000..7830690
--- /dev/null
@@ -0,0 +1,89 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+    <meta name="viewport" content="initial-scale=0.5">
+    <style>
+        button {
+            display: block;
+        }
+        iframe {
+            margin-top: 800px;
+        }
+    </style>
+    
+    <script src="resources/zooming-test-utils.js"></script>
+    <script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    if (window.internals)
+        internals.settings.setFrameFlatteningEnabled(true);
+
+    function getTypingUIScript()
+    {
+        return `
+            (function() {
+                uiController.typeCharacterUsingHardwareKeyboard('delete', function() {
+                    uiController.uiScriptComplete();
+                });
+            })();`
+    }
+
+    function buttonClicked()
+    {
+        document.getElementById('frame').contentDocument.getElementById('input').focus();
+    }
+    
+    function pageDidScroll()
+    {
+        document.getElementById('result').textContent = 'FAIL: page scrolled to ' + document.scrollingElement.scrollTop;
+    }
+
+    function testTyping()
+    {
+        window.addEventListener('scroll', pageDidScroll, false);
+
+        var uiScript = getTypingUIScript();
+        testRunner.runUIScript(uiScript, function() {
+            // Wait for any scroll to happen.
+            window.setTimeout(function() {
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            }, 100);
+        });
+    }
+
+    function doTest()
+    {
+        // Get the text field focused via a user event so we zoom to it.
+        var point = getPointInsideElement(document.getElementById('target'), 10, 10);
+
+        var uiScript = zoomAfterSingleTapUIScript(point.x, point.y, true);
+        testRunner.runUIScript(uiScript, function(result) {
+            window.setTimeout(function() {
+                testTyping();
+            }, 0);
+        });
+    }
+
+    window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+<p>Tests that typing into a text input in an iframe should not scroll.</p>
+<div id="result">
+    PASS: page did not scroll.
+</div>
+
+<button id="target" onclick="buttonClicked()">Click to focus input</button>
+
+<iframe id="frame" srcdoc="<style>input { margin: 400px 20px; }</style>
+<input id='input' type='text' value='aaa'>
+"></iframe>
+
+</body>
+</html>
index 02b04c7..197862a 100644 (file)
@@ -1,3 +1,19 @@
+2016-07-11  Simon Fraser  <simon.fraser@apple.com>
+
+        Deleting in a text input inside an iframe causes the page to scroll incorrectly
+        https://bugs.webkit.org/show_bug.cgi?id=159654
+        rdar://problem/26805722
+
+        Reviewed by Zalan Bujtas.
+
+        Editor::revealSelectionAfterEditingOperation() needs the same iOS-specific reveal
+        behavior as was added for typing in r202295.
+
+        Test: fast/forms/ios/delete-in-input-in-iframe.html
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::revealSelectionAfterEditingOperation):
+
 2016-07-11  Andy Estes  <aestes@apple.com>
 
         Fix indentation in FrameLoaderTypes.h
index 46d5888..1c80fd1 100644 (file)
@@ -2805,7 +2805,13 @@ void Editor::revealSelectionAfterEditingOperation(const ScrollAlignment& alignme
     if (m_ignoreCompositionSelectionChange)
         return;
 
-    m_frame.selection().revealSelection(SelectionRevealMode::Reveal, alignment, revealExtentOption);
+#if PLATFORM(IOS)
+    SelectionRevealMode revealMode = SelectionRevealMode::RevealUpToMainFrame;
+#else
+    SelectionRevealMode revealMode = SelectionRevealMode::Reveal;
+#endif
+
+    m_frame.selection().revealSelection(revealMode, alignment, revealExtentOption);
 }
 
 void Editor::setIgnoreCompositionSelectionChange(bool ignore, RevealSelection shouldRevealExistingSelection)