Title: [202578] trunk
Revision
202578
Author
rn...@webkit.org
Date
2016-06-28 11:20:42 -0700 (Tue, 28 Jun 2016)

Log Message

REGRESSION(r201471): FormClient.textFieldDidEndEditing is no longer called when a text field is removed
https://bugs.webkit.org/show_bug.cgi?id=159199
Source/WebCore:

<rdar://problem/26748189>

Reviewed by Alexey Proskuryakov.

The bug was caused by HTMLInputElement's endEditing no longer getting called due to the behavior change.
Preserve the WebKit2 API semantics by manually calling HTMLInputElement::endEditing in setFocusedElement.

Tests: WebKit2TextFieldDidBeginAndEndEditing

* dom/Document.cpp:
(WebCore::Document::setFocusedElement):

Tools:


Reviewed by Alexey Proskuryakov.

Added a test case for removing a text field. Also fixed the flakiness and re-enabled it on Mac.

* TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp:
* TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing_Bundle.cpp:
* TestWebKitAPI/Tests/WebKit2/input-focus-blur.html: Focus a div upfront to avoid the flakiness from
an input element getting automatically focused on Mac.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (202577 => 202578)


--- trunk/Source/WebCore/ChangeLog	2016-06-28 18:12:23 UTC (rev 202577)
+++ trunk/Source/WebCore/ChangeLog	2016-06-28 18:20:42 UTC (rev 202578)
@@ -1,3 +1,19 @@
+2016-06-28  Ryosuke Niwa  <rn...@webkit.org>
+
+        REGRESSION(r201471): FormClient.textFieldDidEndEditing is no longer called when a text field is removed
+        https://bugs.webkit.org/show_bug.cgi?id=159199
+        <rdar://problem/26748189>
+
+        Reviewed by Alexey Proskuryakov.
+
+        The bug was caused by HTMLInputElement's endEditing no longer getting called due to the behavior change.
+        Preserve the WebKit2 API semantics by manually calling HTMLInputElement::endEditing in setFocusedElement.
+
+        Tests: WebKit2TextFieldDidBeginAndEndEditing
+
+        * dom/Document.cpp:
+        (WebCore::Document::setFocusedElement):
+
 2016-06-28  Frederic Wang  <fw...@igalia.com>
 
         Phrasing content should be accepted in <mo> elements

Modified: trunk/Source/WebCore/dom/Document.cpp (202577 => 202578)


--- trunk/Source/WebCore/dom/Document.cpp	2016-06-28 18:12:23 UTC (rev 202577)
+++ trunk/Source/WebCore/dom/Document.cpp	2016-06-28 18:20:42 UTC (rev 202578)
@@ -82,6 +82,7 @@
 #include "HTMLHtmlElement.h"
 #include "HTMLIFrameElement.h"
 #include "HTMLImageElement.h"
+#include "HTMLInputElement.h"
 #include "HTMLLinkElement.h"
 #include "HTMLMediaElement.h"
 #include "HTMLNameCollection.h"
@@ -3808,8 +3809,11 @@
                 focusChangeBlocked = true;
                 newFocusedElement = nullptr;
             }
-        } else
+        } else {
+            if (is<HTMLInputElement>(*oldFocusedElement))
+                downcast<HTMLInputElement>(*oldFocusedElement).endEditing();
             ASSERT(!m_focusedElement);
+        }
 
         if (oldFocusedElement->isRootEditableElement())
             frame()->editor().didEndEditing();

Modified: trunk/Tools/ChangeLog (202577 => 202578)


--- trunk/Tools/ChangeLog	2016-06-28 18:12:23 UTC (rev 202577)
+++ trunk/Tools/ChangeLog	2016-06-28 18:20:42 UTC (rev 202578)
@@ -1,3 +1,17 @@
+2016-06-28  Ryosuke Niwa  <rn...@webkit.org>
+
+        REGRESSION(r201471): FormClient.textFieldDidEndEditing is no longer called when a text field is removed
+        https://bugs.webkit.org/show_bug.cgi?id=159199
+
+        Reviewed by Alexey Proskuryakov.
+
+        Added a test case for removing a text field. Also fixed the flakiness and re-enabled it on Mac.
+
+        * TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp:
+        * TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing_Bundle.cpp:
+        * TestWebKitAPI/Tests/WebKit2/input-focus-blur.html: Focus a div upfront to avoid the flakiness from
+        an input element getting automatically focused on Mac.
+
 2016-06-28  Per Arne Vollan  <pvol...@apple.com>
 
         [Win] Custom elements tests are failing.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp (202577 => 202578)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp	2016-06-28 18:12:23 UTC (rev 202577)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp	2016-06-28 18:20:42 UTC (rev 202578)
@@ -25,7 +25,7 @@
 
 #include "config.h"
 
-#if WK_HAVE_C_SPI && !PLATFORM(MAC)
+#if WK_HAVE_C_SPI
 
 #include "PlatformUtilities.h"
 #include "PlatformWebView.h"
@@ -126,6 +126,12 @@
     executeJavaScriptAndCheckDidReceiveMessage("blurTextField('input')", "DidReceiveTextFieldDidEndEditing");
 }
 
+TEST_F(WebKit2TextFieldBeginAndEditEditingTest, TextFieldDidEndShouldBeDispatchedForRemovedFocusField)
+{
+    executeJavaScriptAndCheckDidReceiveMessage("focusTextField('input')", "DidReceiveTextFieldDidBeginEditing");
+    executeJavaScriptAndCheckDidReceiveMessage("removeTextField('input')", "DidReceiveTextFieldDidEndEditing");
+}
+
 } // namespace TestWebKitAPI
 
 #endif

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing_Bundle.cpp (202577 => 202578)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing_Bundle.cpp	2016-06-28 18:12:23 UTC (rev 202577)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing_Bundle.cpp	2016-06-28 18:20:42 UTC (rev 202578)
@@ -25,7 +25,7 @@
 
 #include "config.h"
 
-#if WK_HAVE_C_SPI && !PLATFORM(MAC)
+#if WK_HAVE_C_SPI
 
 #include "InjectedBundleTest.h"
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2/input-focus-blur.html (202577 => 202578)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/input-focus-blur.html	2016-06-28 18:12:23 UTC (rev 202577)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/input-focus-blur.html	2016-06-28 18:20:42 UTC (rev 202578)
@@ -1,9 +1,13 @@
 <!DOCTYPE html>
 <html>
 <body>
+<div tabindex=0></div>
 <input id="input" type="text">
 <input id="readonly" type="text" readonly>
 <script>
+
+document.querySelector('div').focus();
+
 function focusTextField(id)
 {
     document.getElementById(id).focus();
@@ -13,6 +17,12 @@
 {
     document.getElementById(id).blur();
 }
+
+function removeTextField(id)
+{
+    document.getElementById(id).remove();
+}
+
 </script>
 </body>
 </html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to