Title: [239363] trunk/Source/WebKit
Revision
239363
Author
wenson_hs...@apple.com
Date
2018-12-18 18:11:58 -0800 (Tue, 18 Dec 2018)

Log Message

[macOS] fast/forms/datalist/datalist-textinput-suggestions-order.html sometimes crashes after r239337
https://bugs.webkit.org/show_bug.cgi?id=192836
<rdar://problem/45321184>

Reviewed by Tim Horton.

r239337 exposed a subtle issue in the implementation of `-[WKDataListSuggestionsView updateWithInformation:]`,
wherein we might end up recomputing information for table view cells at rows that no longer exist. This currently
happens because we first set the datalist's `_suggestions`, then change the table view's frame, and then finally
reload the table view; however, in the case where the number of suggestions decreased and the frame changed
(which prompts AppKit to ask us again for table cell views), we'll attempt to access an out-of-bounds index in
the `_suggestions` vector.

To address this, we change our suggestions and immediately reload the table view before updating `NSTableView`'s
frame, so that we only provide table view cells for rows that actually correspond to items in `_suggestions`.

* UIProcess/mac/WebDataListSuggestionsDropdownMac.mm:
(-[WKDataListSuggestionsView updateWithInformation:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (239362 => 239363)


--- trunk/Source/WebKit/ChangeLog	2018-12-19 01:25:52 UTC (rev 239362)
+++ trunk/Source/WebKit/ChangeLog	2018-12-19 02:11:58 UTC (rev 239363)
@@ -1,3 +1,24 @@
+2018-12-18  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [macOS] fast/forms/datalist/datalist-textinput-suggestions-order.html sometimes crashes after r239337
+        https://bugs.webkit.org/show_bug.cgi?id=192836
+        <rdar://problem/45321184>
+
+        Reviewed by Tim Horton.
+
+        r239337 exposed a subtle issue in the implementation of `-[WKDataListSuggestionsView updateWithInformation:]`,
+        wherein we might end up recomputing information for table view cells at rows that no longer exist. This currently
+        happens because we first set the datalist's `_suggestions`, then change the table view's frame, and then finally
+        reload the table view; however, in the case where the number of suggestions decreased and the frame changed
+        (which prompts AppKit to ask us again for table cell views), we'll attempt to access an out-of-bounds index in
+        the `_suggestions` vector.
+
+        To address this, we change our suggestions and immediately reload the table view before updating `NSTableView`'s
+        frame, so that we only provide table view cells for rows that actually correspond to items in `_suggestions`.
+
+        * UIProcess/mac/WebDataListSuggestionsDropdownMac.mm:
+        (-[WKDataListSuggestionsView updateWithInformation:]):
+
 2018-12-18  Jiewen Tan  <jiewen_...@apple.com>
 
         [Mac] Layout Test http/wpt/webauthn/public-key-credential-create-success-hid.https.html and http/wpt/webauthn/public-key-credential-get-success-hid.https.html are flaky

Modified: trunk/Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.mm (239362 => 239363)


--- trunk/Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.mm	2018-12-19 01:25:52 UTC (rev 239362)
+++ trunk/Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.mm	2018-12-19 02:11:58 UTC (rev 239363)
@@ -346,9 +346,10 @@
 - (void)updateWithInformation:(WebCore::DataListSuggestionInformation&&)information
 {
     _suggestions = WTFMove(information.suggestions);
+    [_table reload];
+
     [_enclosingWindow setFrame:[self dropdownRectForElementRect:information.elementRect] display:YES];
     [_table setVisibleRect:[_enclosingWindow frame]];
-    [_table reload];
 }
 
 - (void)moveSelectionByDirection:(const String&)direction
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to