Title: [203097] trunk
Revision
203097
Author
[email protected]
Date
2016-07-11 16:44:44 -0700 (Mon, 11 Jul 2016)

Log Message

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.

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (203096 => 203097)


--- trunk/LayoutTests/ChangeLog	2016-07-11 23:39:29 UTC (rev 203096)
+++ trunk/LayoutTests/ChangeLog	2016-07-11 23:44:44 UTC (rev 203097)
@@ -1,3 +1,14 @@
+2016-07-11  Simon Fraser  <[email protected]>
+
+        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  <[email protected]>
 
         Honor the second argument to FontFaceSet.load and FontFaceSet.check

Added: trunk/LayoutTests/fast/forms/ios/delete-in-input-in-iframe-expected.txt (0 => 203097)


--- trunk/LayoutTests/fast/forms/ios/delete-in-input-in-iframe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/delete-in-input-in-iframe-expected.txt	2016-07-11 23:44:44 UTC (rev 203097)
@@ -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
+

Added: trunk/LayoutTests/fast/forms/ios/delete-in-input-in-iframe.html (0 => 203097)


--- trunk/LayoutTests/fast/forms/ios/delete-in-input-in-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/delete-in-input-in-iframe.html	2016-07-11 23:44:44 UTC (rev 203097)
@@ -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=""
+    <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>

Modified: trunk/Source/WebCore/ChangeLog (203096 => 203097)


--- trunk/Source/WebCore/ChangeLog	2016-07-11 23:39:29 UTC (rev 203096)
+++ trunk/Source/WebCore/ChangeLog	2016-07-11 23:44:44 UTC (rev 203097)
@@ -1,3 +1,19 @@
+2016-07-11  Simon Fraser  <[email protected]>
+
+        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  <[email protected]>
 
         Fix indentation in FrameLoaderTypes.h

Modified: trunk/Source/WebCore/editing/Editor.cpp (203096 => 203097)


--- trunk/Source/WebCore/editing/Editor.cpp	2016-07-11 23:39:29 UTC (rev 203096)
+++ trunk/Source/WebCore/editing/Editor.cpp	2016-07-11 23:44:44 UTC (rev 203097)
@@ -2805,7 +2805,13 @@
     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)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to