Title: [242587] trunk
Revision
242587
Author
[email protected]
Date
2019-03-06 19:11:38 -0800 (Wed, 06 Mar 2019)

Log Message

Crash when attempting to change input type while dismissing datalist suggestions
https://bugs.webkit.org/show_bug.cgi?id=195384
<rdar://problem/48563718>

Reviewed by Brent Fulgham.

Source/WebCore:

When closing a datalist suggestion menu, WebPageProxy sends a message to WebPage instructing it to tell its
active datalist suggestions picker to close. However, for a myriad of reasons, the suggestions picker (kept
alive by its text input type) may have already gone away by this point. To mitigate this, make WebPage weakly
reference its active datalist suggestions picker.

Test: fast/forms/datalist/change-input-type-after-closing-datalist-suggestions.html

* platform/DataListSuggestionPicker.h:

Make DataListSuggestionPicker capable of being weakly referenced. Additionally, fix some minor preexisting
issues in this header (#imports instead of #includes, as well as an unnecessary include of IntRect.h).

Source/WebKit:

See WebCore ChangeLog for more details.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setActiveDataListSuggestionPicker):
(WebKit::WebPage::didSelectDataListOption):
(WebKit::WebPage::didCloseSuggestions):
* WebProcess/WebPage/WebPage.h:

Turn m_activeDataListSuggestionPicker from a raw pointer into a WeakPtr.

LayoutTests:

Add a new layout test to exercise this scenario.

* fast/forms/datalist/change-input-type-after-closing-datalist-suggestions-expected.txt: Added.
* fast/forms/datalist/change-input-type-after-closing-datalist-suggestions.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (242586 => 242587)


--- trunk/LayoutTests/ChangeLog	2019-03-07 03:03:21 UTC (rev 242586)
+++ trunk/LayoutTests/ChangeLog	2019-03-07 03:11:38 UTC (rev 242587)
@@ -1,3 +1,16 @@
+2019-03-06  Wenson Hsieh  <[email protected]>
+
+        Crash when attempting to change input type while dismissing datalist suggestions
+        https://bugs.webkit.org/show_bug.cgi?id=195384
+        <rdar://problem/48563718>
+
+        Reviewed by Brent Fulgham.
+
+        Add a new layout test to exercise this scenario.
+
+        * fast/forms/datalist/change-input-type-after-closing-datalist-suggestions-expected.txt: Added.
+        * fast/forms/datalist/change-input-type-after-closing-datalist-suggestions.html: Added.
+
 2019-03-06  Justin Fan  <[email protected]>
 
         [Web GPU] GPUTexture and GPUTextureView updates, and related GPUBindGroup updates

Added: trunk/LayoutTests/fast/forms/datalist/change-input-type-after-closing-datalist-suggestions-expected.txt (0 => 242587)


--- trunk/LayoutTests/fast/forms/datalist/change-input-type-after-closing-datalist-suggestions-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/datalist/change-input-type-after-closing-datalist-suggestions-expected.txt	2019-03-07 03:11:38 UTC (rev 242587)
@@ -0,0 +1,3 @@
+This test verifies that the type of an input with an associated datalist can be changed immediately after the datalist suggestions menu is closed. To test manually, load this page and check that it does not crash.
+
+

Added: trunk/LayoutTests/fast/forms/datalist/change-input-type-after-closing-datalist-suggestions.html (0 => 242587)


--- trunk/LayoutTests/fast/forms/datalist/change-input-type-after-closing-datalist-suggestions.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/datalist/change-input-type-after-closing-datalist-suggestions.html	2019-03-07 03:11:38 UTC (rev 242587)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <p>This test verifies that the type of an input with an associated datalist can be changed immediately after the datalist suggestions menu is closed. To test manually, load this page and check that it does not crash.</p>
+    <input value="a" id="input" list="datalist">
+    <datalist id="datalist">
+        <option>a</option>
+    </datalist>
+</body>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    input.select();
+    document.execCommand("Delete");
+    input.type = "button";
+</script>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (242586 => 242587)


--- trunk/Source/WebCore/ChangeLog	2019-03-07 03:03:21 UTC (rev 242586)
+++ trunk/Source/WebCore/ChangeLog	2019-03-07 03:11:38 UTC (rev 242587)
@@ -1,3 +1,23 @@
+2019-03-06  Wenson Hsieh  <[email protected]>
+
+        Crash when attempting to change input type while dismissing datalist suggestions
+        https://bugs.webkit.org/show_bug.cgi?id=195384
+        <rdar://problem/48563718>
+
+        Reviewed by Brent Fulgham.
+
+        When closing a datalist suggestion menu, WebPageProxy sends a message to WebPage instructing it to tell its
+        active datalist suggestions picker to close. However, for a myriad of reasons, the suggestions picker (kept
+        alive by its text input type) may have already gone away by this point. To mitigate this, make WebPage weakly
+        reference its active datalist suggestions picker.
+
+        Test: fast/forms/datalist/change-input-type-after-closing-datalist-suggestions.html
+
+        * platform/DataListSuggestionPicker.h:
+
+        Make DataListSuggestionPicker capable of being weakly referenced. Additionally, fix some minor preexisting
+        issues in this header (#imports instead of #includes, as well as an unnecessary include of IntRect.h).
+
 2019-03-06  Ryan Haddad  <[email protected]>
 
         Remove an unneeded assert that was added with r242113

Modified: trunk/Source/WebCore/platform/DataListSuggestionPicker.h (242586 => 242587)


--- trunk/Source/WebCore/platform/DataListSuggestionPicker.h	2019-03-07 03:03:21 UTC (rev 242586)
+++ trunk/Source/WebCore/platform/DataListSuggestionPicker.h	2019-03-07 03:11:38 UTC (rev 242587)
@@ -27,14 +27,13 @@
 
 #if ENABLE(DATALIST_ELEMENT)
 
-#import "DataListSuggestionInformation.h"
-#import "IntRect.h"
+#include "DataListSuggestionInformation.h"
+#include <wtf/WeakPtr.h>
+#include <wtf/text/WTFString.h>
 
-#import <wtf/text/WTFString.h>
-
 namespace WebCore {
 
-class DataListSuggestionPicker {
+class DataListSuggestionPicker : public CanMakeWeakPtr<DataListSuggestionPicker> {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     virtual ~DataListSuggestionPicker() = default;

Modified: trunk/Source/WebKit/ChangeLog (242586 => 242587)


--- trunk/Source/WebKit/ChangeLog	2019-03-07 03:03:21 UTC (rev 242586)
+++ trunk/Source/WebKit/ChangeLog	2019-03-07 03:11:38 UTC (rev 242587)
@@ -1,3 +1,21 @@
+2019-03-06  Wenson Hsieh  <[email protected]>
+
+        Crash when attempting to change input type while dismissing datalist suggestions
+        https://bugs.webkit.org/show_bug.cgi?id=195384
+        <rdar://problem/48563718>
+
+        Reviewed by Brent Fulgham.
+
+        See WebCore ChangeLog for more details.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setActiveDataListSuggestionPicker):
+        (WebKit::WebPage::didSelectDataListOption):
+        (WebKit::WebPage::didCloseSuggestions):
+        * WebProcess/WebPage/WebPage.h:
+
+        Turn m_activeDataListSuggestionPicker from a raw pointer into a WeakPtr.
+
 2019-03-06  Chris Dumez  <[email protected]>
 
         [iOS] ProcessDidResume() IPC should be sent upon resuming when ProcessWillSuspendImminently() IPC was sent

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (242586 => 242587)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-03-07 03:03:21 UTC (rev 242586)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-03-07 03:11:38 UTC (rev 242587)
@@ -3899,19 +3899,19 @@
 
 void WebPage::setActiveDataListSuggestionPicker(WebDataListSuggestionPicker* dataListSuggestionPicker)
 {
-    m_activeDataListSuggestionPicker = dataListSuggestionPicker;
+    m_activeDataListSuggestionPicker = makeWeakPtr(dataListSuggestionPicker);
 }
 
 void WebPage::didSelectDataListOption(const String& selectedOption)
 {
-    m_activeDataListSuggestionPicker->didSelectOption(selectedOption);
+    if (m_activeDataListSuggestionPicker)
+        m_activeDataListSuggestionPicker->didSelectOption(selectedOption);
 }
 
 void WebPage::didCloseSuggestions()
 {
-    if (m_activeDataListSuggestionPicker)
-        m_activeDataListSuggestionPicker->didCloseSuggestions();
-    m_activeDataListSuggestionPicker = nullptr;
+    if (auto picker = std::exchange(m_activeDataListSuggestionPicker, nullptr))
+        picker->didCloseSuggestions();
 }
 
 #endif

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (242586 => 242587)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-03-07 03:03:21 UTC (rev 242586)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-03-07 03:11:38 UTC (rev 242587)
@@ -1657,7 +1657,7 @@
 #endif
 
 #if ENABLE(DATALIST_ELEMENT)
-    WebDataListSuggestionPicker* m_activeDataListSuggestionPicker { nullptr };
+    WeakPtr<WebDataListSuggestionPicker> m_activeDataListSuggestionPicker;
 #endif
 
     RefPtr<WebOpenPanelResultListener> m_activeOpenPanelResultListener;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to