Title: [209210] branches/safari-602-branch

Diff

Modified: branches/safari-602-branch/LayoutTests/ChangeLog (209209 => 209210)


--- branches/safari-602-branch/LayoutTests/ChangeLog	2016-12-01 22:23:54 UTC (rev 209209)
+++ branches/safari-602-branch/LayoutTests/ChangeLog	2016-12-01 22:23:59 UTC (rev 209210)
@@ -1,5 +1,20 @@
 2016-12-01  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r208745. rdar://problem/29277336
+
+    2016-11-14  Brent Fulgham  <bfulg...@apple.com>
+
+            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-12-01  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r208825. rdar://problem/29277338
 
     2016-11-16  Brent Fulgham  <bfulg...@apple.com>

Added: branches/safari-602-branch/LayoutTests/fast/forms/search-cancel-button-change-input-expected.txt (0 => 209210)


--- branches/safari-602-branch/LayoutTests/fast/forms/search-cancel-button-change-input-expected.txt	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/fast/forms/search-cancel-button-change-input-expected.txt	2016-12-01 22:23:59 UTC (rev 209210)
@@ -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: branches/safari-602-branch/LayoutTests/fast/forms/search-cancel-button-change-input.html (0 => 209210)


--- branches/safari-602-branch/LayoutTests/fast/forms/search-cancel-button-change-input.html	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/fast/forms/search-cancel-button-change-input.html	2016-12-01 22:23:59 UTC (rev 209210)
@@ -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: branches/safari-602-branch/Source/WebCore/ChangeLog (209209 => 209210)


--- branches/safari-602-branch/Source/WebCore/ChangeLog	2016-12-01 22:23:54 UTC (rev 209209)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog	2016-12-01 22:23:59 UTC (rev 209210)
@@ -1,5 +1,31 @@
 2016-12-01  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r208745. rdar://problem/29277336
+
+    2016-11-14  Brent Fulgham  <bfulg...@apple.com>
+
+            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-12-01  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r208825. rdar://problem/29277338
 
     2016-11-16  Brent Fulgham  <bfulg...@apple.com>

Modified: branches/safari-602-branch/Source/WebCore/WebCore.order (209209 => 209210)


--- branches/safari-602-branch/Source/WebCore/WebCore.order	2016-12-01 22:23:54 UTC (rev 209209)
+++ branches/safari-602-branch/Source/WebCore/WebCore.order	2016-12-01 22:23:59 UTC (rev 209210)
@@ -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: branches/safari-602-branch/Source/WebCore/html/HTMLInputElement.cpp (209209 => 209210)


--- branches/safari-602-branch/Source/WebCore/html/HTMLInputElement.cpp	2016-12-01 22:23:54 UTC (rev 209209)
+++ branches/safari-602-branch/Source/WebCore/html/HTMLInputElement.cpp	2016-12-01 22:23:59 UTC (rev 209210)
@@ -1437,9 +1437,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: branches/safari-602-branch/Source/WebCore/html/InputType.h (209209 => 209210)


--- branches/safari-602-branch/Source/WebCore/html/InputType.h	2016-12-01 22:23:54 UTC (rev 209209)
+++ branches/safari-602-branch/Source/WebCore/html/InputType.h	2016-12-01 22:23:59 UTC (rev 209210)
@@ -327,4 +327,8 @@
 
 } // 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: branches/safari-602-branch/Source/WebCore/html/SearchInputType.h (209209 => 209210)


--- branches/safari-602-branch/Source/WebCore/html/SearchInputType.h	2016-12-01 22:23:54 UTC (rev 209209)
+++ branches/safari-602-branch/Source/WebCore/html/SearchInputType.h	2016-12-01 22:23:59 UTC (rev 209210)
@@ -72,4 +72,5 @@
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_INPUT_TYPE(SearchInputType, isSearchField())
 #endif // SearchInputType_h
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to