[macOS] fast/forms/datalist/datalist-textinput-suggestions-order.html sometimes crash...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Dec 2018 02:11:58 +0000 (02:11 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Dec 2018 02:11:58 +0000 (02:11 +0000)
commit2af2a6f6bbd795d2ac6b36e481e52dda09f973f1
treedcf8fee0a4e2d05f1a5daffcd805ea8461faa3a8
parentcfa33609c15c190bd7ebe3eb4a31f8b3a6ca043a
[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:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239363 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.mm