Title: [211936] releases/WebKitGTK/webkit-2.14
Revision
211936
Author
[email protected]
Date
2017-02-09 00:54:57 -0800 (Thu, 09 Feb 2017)

Log Message

Merge r208745 - Correct handling of changing input type
https://bugs.webkit.org/show_bug.cgi?id=164759
<rdar://problem/29211174>

Reviewed by Darin Adler.

Source/WebCore:

Test: fast/forms/search-cancel-button-change-input.html

It is possible for _javascript_ to change the type property of an input field. WebKit
needs to gracefully handle this case.

Add a type traits specialization so we can properly downcast InputType elements.
Use this to only call search functions on actual search input types.

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::onSearch): Only perform search functions if the
input type is actually a search field.
* html/InputType.h: Add type traits specialization for 'downcast' template.
* html/SearchInputType.h: Ditto.

LayoutTests:

* fast/forms/search-cancel-button-change-input-expected.txt: Added.
* fast/forms/search-cancel-button-change-input.html: Added.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog (211935 => 211936)


--- releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog	2017-02-09 08:54:46 UTC (rev 211935)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog	2017-02-09 08:54:57 UTC (rev 211936)
@@ -1,3 +1,14 @@
+2016-11-14  Brent Fulgham  <[email protected]>
+
+        Correct handling of changing input type
+        https://bugs.webkit.org/show_bug.cgi?id=164759
+        <rdar://problem/29211174>
+
+        Reviewed by Darin Adler.
+
+        * fast/forms/search-cancel-button-change-input-expected.txt: Added.
+        * fast/forms/search-cancel-button-change-input.html: Added.
+
 2016-11-11  Brent Fulgham  <[email protected]>
 
         Neutered ArrayBuffers are not properly serialized

Added: releases/WebKitGTK/webkit-2.14/LayoutTests/fast/forms/search-cancel-button-change-input-expected.txt (0 => 211936)


--- releases/WebKitGTK/webkit-2.14/LayoutTests/fast/forms/search-cancel-button-change-input-expected.txt	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/fast/forms/search-cancel-button-change-input-expected.txt	2017-02-09 08:54:57 UTC (rev 211936)
@@ -0,0 +1,10 @@
+Tests that changing input type in a cancel button handler works properly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Search event was not triggered.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: releases/WebKitGTK/webkit-2.14/LayoutTests/fast/forms/search-cancel-button-change-input.html (0 => 211936)


--- releases/WebKitGTK/webkit-2.14/LayoutTests/fast/forms/search-cancel-button-change-input.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/fast/forms/search-cancel-button-change-input.html	2017-02-09 08:54:57 UTC (rev 211936)
@@ -0,0 +1,58 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+description('Tests that changing input type in a cancel button handler works properly.');
+
+window.jsTestIsAsync = true;
+
+var inputElement;
+var workProduct = [];
+
+function finish() {
+    testPassed("Search event was not triggered.");
+    finishJSTest();
+}
+
+function handleSearch(e) {
+    testFailed("A search event was triggered.");
+    finishJSTest();
+}
+
+function changeType(e) {
+    inputElement["type"] = "image"
+    setTimeout(function() {
+        finish();
+    }, 0);
+}
+
+function clickCancel() {
+    var cancelButtonPosition = searchCancelButtonPosition(inputElement);
+
+    eventSender.mouseMoveTo(cancelButtonPosition.x, cancelButtonPosition.y);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+function runTest() {
+    if (!window.testRunner) {
+        testRunner.dumpAsText(true);
+        testRunner.waitUntilDone();
+    }
+
+    inputElement = document.getElementById("target");
+
+    inputElement.addEventListener("input", changeType);
+
+    setTimeout(function() {
+        clickCancel();
+    }, 0);
+}
+</script>
+</head>
+<body _onload_="runTest()">
+    <input id="target" type="search" _onSearch_="handleSearch();" value="Click the cancel button."></input>
+</body>
+</html>

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog (211935 => 211936)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2017-02-09 08:54:46 UTC (rev 211935)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2017-02-09 08:54:57 UTC (rev 211936)
@@ -1,3 +1,25 @@
+2016-11-14  Brent Fulgham  <[email protected]>
+
+        Correct handling of changing input type
+        https://bugs.webkit.org/show_bug.cgi?id=164759
+        <rdar://problem/29211174>
+
+        Reviewed by Darin Adler.
+
+        Test: fast/forms/search-cancel-button-change-input.html
+
+        It is possible for _javascript_ to change the type property of an input field. WebKit
+        needs to gracefully handle this case.
+
+        Add a type traits specialization so we can properly downcast InputType elements.
+        Use this to only call search functions on actual search input types.
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::onSearch): Only perform search functions if the
+        input type is actually a search field.
+        * html/InputType.h: Add type traits specialization for 'downcast' template.
+        * html/SearchInputType.h: Ditto.
+
 2016-11-11  Brent Fulgham  <[email protected]>
 
         Unreviewed build fix after r208628

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/WebCore.order (211935 => 211936)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/WebCore.order	2017-02-09 08:54:46 UTC (rev 211935)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/WebCore.order	2017-02-09 08:54:57 UTC (rev 211936)
@@ -5834,7 +5834,6 @@
 __ZN7WebCore17MarkupAccumulator13appendElementERN3WTF13StringBuilderEPNS_7ElementEPNS1_7HashMapIPNS1_16AtomicStringImplES8_NS1_7PtrHashIS8_EENS1_10HashTraitsIS8_EESC_EE
 __ZN7WebCore17MarkupAccumulator13appendOpenTagERN3WTF13StringBuilderEPNS_7ElementEPNS1_7HashMapIPNS1_16AtomicStringImplES8_NS1_7PtrHashIS8_EENS1_10HashTraitsIS8_EESC_EE
 __ZNK7WebCore7Element22nodeNamePreservingCaseEv
-__ZNK7WebCore13QualifiedName8toStringEv
 __ZNK7WebCore7Element13hasAttributesEv
 __ZN7WebCore17MarkupAccumulator22appendCustomAttributesERN3WTF13StringBuilderEPNS_7ElementEPNS1_7HashMapIPNS1_16AtomicStringImplES8_NS1_7PtrHashIS8_EENS1_10HashTraitsIS8_EESC_EE
 __ZN7WebCore17MarkupAccumulator14appendCloseTagERN3WTF13StringBuilderEPNS_7ElementE

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/html/HTMLInputElement.cpp (211935 => 211936)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/html/HTMLInputElement.cpp	2017-02-09 08:54:46 UTC (rev 211935)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/html/HTMLInputElement.cpp	2017-02-09 08:54:57 UTC (rev 211936)
@@ -1436,9 +1436,13 @@
 
 void HTMLInputElement::onSearch()
 {
-    ASSERT(isSearchField());
+    // The type of the input element could have changed during event handling. If we are no longer
+    // a search field, don't try to do search things.
+    if (!isSearchField())
+        return;
+
     if (m_inputType)
-        static_cast<SearchInputType*>(m_inputType.get())->stopSearchEventTimer();
+        downcast<SearchInputType>(*m_inputType.get()).stopSearchEventTimer();
     dispatchEvent(Event::create(eventNames().searchEvent, true, false));
 }
 

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/html/InputType.h (211935 => 211936)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/html/InputType.h	2017-02-09 08:54:46 UTC (rev 211935)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/html/InputType.h	2017-02-09 08:54:57 UTC (rev 211936)
@@ -327,4 +327,9 @@
 
 } // namespace WebCore
 
+#define SPECIALIZE_TYPE_TRAITS_INPUT_TYPE(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
+static bool isType(const WebCore::InputType& input) { return input.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
 #endif

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/html/SearchInputType.h (211935 => 211936)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/html/SearchInputType.h	2017-02-09 08:54:46 UTC (rev 211935)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/html/SearchInputType.h	2017-02-09 08:54:57 UTC (rev 211936)
@@ -72,4 +72,6 @@
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_INPUT_TYPE(SearchInputType, isSearchField())
+
 #endif // SearchInputType_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to