Title: [207486] trunk
Revision
207486
Author
rn...@webkit.org
Date
2016-10-18 13:40:03 -0700 (Tue, 18 Oct 2016)

Log Message

REGRESSION (r201471): Keyboard remains visible when swiping back on twitter.com
https://bugs.webkit.org/show_bug.cgi?id=163581
<rdar://problem/27739558>

Reviewed by Simon Fraser.

Source/WebCore:

The bug was caused by Chrome::elementDidBlur not getting called, which resulted in
StopAssistingNode not getting sent to the UI process.

Test: fast/forms/ios/hide-keyboard-on-node-removal.html

* dom/Document.cpp:
(WebCore::Document::setFocusedElement): Restore the behavior prior to r201471 by calling
Chrome::elementDidBlur explicitly.
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::dispatchBlurEvent): Added a comment about ordering.

LayoutTests:

Added a regression test for hiding a keyboard when the focused element is removed from the DOM.

* fast/forms/ios/hide-keyboard-on-node-removal-expected.txt: Added.
* fast/forms/ios/hide-keyboard-on-node-removal.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207485 => 207486)


--- trunk/LayoutTests/ChangeLog	2016-10-18 20:36:53 UTC (rev 207485)
+++ trunk/LayoutTests/ChangeLog	2016-10-18 20:40:03 UTC (rev 207486)
@@ -1,3 +1,16 @@
+2016-10-18  Ryosuke Niwa  <rn...@webkit.org>
+
+        REGRESSION (r201471): Keyboard remains visible when swiping back on twitter.com
+        https://bugs.webkit.org/show_bug.cgi?id=163581
+        <rdar://problem/27739558>
+
+        Reviewed by Simon Fraser.
+
+        Added a regression test for hiding a keyboard when the focused element is removed from the DOM.
+
+        * fast/forms/ios/hide-keyboard-on-node-removal-expected.txt: Added.
+        * fast/forms/ios/hide-keyboard-on-node-removal.html: Added.
+
 2016-10-18  Ryan Haddad  <ryanhad...@apple.com>
 
         Marking media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-buttons-styles.html as flaky on mac-wk1.

Added: trunk/LayoutTests/fast/forms/ios/hide-keyboard-on-node-removal-expected.txt (0 => 207486)


--- trunk/LayoutTests/fast/forms/ios/hide-keyboard-on-node-removal-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/hide-keyboard-on-node-removal-expected.txt	2016-10-18 20:40:03 UTC (rev 207486)
@@ -0,0 +1,4 @@
+Test that the keyboard disappears when the focused element is removed.
+To manually test, focus the text field below and type any character on iOS. The keyboard should be dismissed.
+
+PASS

Added: trunk/LayoutTests/fast/forms/ios/hide-keyboard-on-node-removal.html (0 => 207486)


--- trunk/LayoutTests/fast/forms/ios/hide-keyboard-on-node-removal.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/hide-keyboard-on-node-removal.html	2016-10-18 20:40:03 UTC (rev 207486)
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta name="viewport" content="width=device-width">
+</head>
+<body>
+<p>Test that the keyboard disappears when the focused element is removed.<br>
+To manually test, focus the text field below and type any character on iOS. The keyboard should be dismissed.</p>
+<input _oninput_="this.remove();">
+<div id="result"></div>
+<script>
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+if (window.testRunner && testRunner.runUIScript) {
+    testRunner.waitUntilDone();
+
+    var input = document.querySelector('input');
+
+    const x = input.offsetLeft + 5;
+    const y = input.offsetTop + 5;
+    testRunner.runUIScript(`
+        uiController.didShowKeyboardCallback = function() { uiController.uiScriptComplete(); }
+        uiController.singleTapAtPoint(${x}, ${y}, function() {});`,
+    function () {
+        function endTest(result) {
+            document.getElementById('result').textContent = result;
+            testRunner.notifyDone();
+        }
+        setTimeout(endTest.bind(this, 'FAIL'), 5000);
+        testRunner.runUIScript(`
+            uiController.didHideKeyboardCallback = function() { uiController.uiScriptComplete(); }
+            uiController.typeCharacterUsingHardwareKeyboard('a', function () { });`,
+            endTest.bind(this, 'PASS'));
+    });
+}
+
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (207485 => 207486)


--- trunk/Source/WebCore/ChangeLog	2016-10-18 20:36:53 UTC (rev 207485)
+++ trunk/Source/WebCore/ChangeLog	2016-10-18 20:40:03 UTC (rev 207486)
@@ -1,3 +1,22 @@
+2016-10-18  Ryosuke Niwa  <rn...@webkit.org>
+
+        REGRESSION (r201471): Keyboard remains visible when swiping back on twitter.com
+        https://bugs.webkit.org/show_bug.cgi?id=163581
+        <rdar://problem/27739558>
+
+        Reviewed by Simon Fraser.
+
+        The bug was caused by Chrome::elementDidBlur not getting called, which resulted in
+        StopAssistingNode not getting sent to the UI process.
+
+        Test: fast/forms/ios/hide-keyboard-on-node-removal.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::setFocusedElement): Restore the behavior prior to r201471 by calling
+        Chrome::elementDidBlur explicitly.
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::dispatchBlurEvent): Added a comment about ordering.
+
 2016-10-17  Anders Carlsson  <ander...@apple.com>
 
         Move some history specific HistoryItem code to WebHistoryItem

Modified: trunk/Source/WebCore/dom/Document.cpp (207485 => 207486)


--- trunk/Source/WebCore/dom/Document.cpp	2016-10-18 20:36:53 UTC (rev 207485)
+++ trunk/Source/WebCore/dom/Document.cpp	2016-10-18 20:40:03 UTC (rev 207486)
@@ -3674,8 +3674,11 @@
                 newFocusedElement = nullptr;
             }
         } else {
+            // Match the order in HTMLTextFormControlElement::dispatchBlurEvent.
             if (is<HTMLInputElement>(*oldFocusedElement))
                 downcast<HTMLInputElement>(*oldFocusedElement).endEditing();
+            if (page())
+                page()->chrome().client().elementDidBlur(oldFocusedElement.get());
             ASSERT(!m_focusedElement);
         }
 

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (207485 => 207486)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2016-10-18 20:36:53 UTC (rev 207485)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2016-10-18 20:40:03 UTC (rev 207486)
@@ -101,6 +101,7 @@
 {
     if (supportsPlaceholder())
         updatePlaceholderVisibility();
+    // Match the order in Document::setFocusedElement.
     handleBlurEvent();
     HTMLFormControlElementWithState::dispatchBlurEvent(WTFMove(newFocusedElement));
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to