Changeset 239363 in webkit


Ignore:
Timestamp:
Dec 18, 2018 6:11:58 PM (5 years ago)
Author:
Wenson Hsieh
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:]):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r239362 r239363  
     12018-12-18  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [macOS] fast/forms/datalist/datalist-textinput-suggestions-order.html sometimes crashes after r239337
     4        https://bugs.webkit.org/show_bug.cgi?id=192836
     5        <rdar://problem/45321184>
     6
     7        Reviewed by Tim Horton.
     8
     9        r239337 exposed a subtle issue in the implementation of `-[WKDataListSuggestionsView updateWithInformation:]`,
     10        wherein we might end up recomputing information for table view cells at rows that no longer exist. This currently
     11        happens because we first set the datalist's `_suggestions`, then change the table view's frame, and then finally
     12        reload the table view; however, in the case where the number of suggestions decreased and the frame changed
     13        (which prompts AppKit to ask us again for table cell views), we'll attempt to access an out-of-bounds index in
     14        the `_suggestions` vector.
     15
     16        To address this, we change our suggestions and immediately reload the table view before updating `NSTableView`'s
     17        frame, so that we only provide table view cells for rows that actually correspond to items in `_suggestions`.
     18
     19        * UIProcess/mac/WebDataListSuggestionsDropdownMac.mm:
     20        (-[WKDataListSuggestionsView updateWithInformation:]):
     21
    1222018-12-18  Jiewen Tan  <jiewen_tan@apple.com>
    223
  • trunk/Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.mm

    r238166 r239363  
    347347{
    348348    _suggestions = WTFMove(information.suggestions);
     349    [_table reload];
     350
    349351    [_enclosingWindow setFrame:[self dropdownRectForElementRect:information.elementRect] display:YES];
    350352    [_table setVisibleRect:[_enclosingWindow frame]];
    351     [_table reload];
    352353}
    353354
Note: See TracChangeset for help on using the changeset viewer.