Changeset 228050 in webkit


Ignore:
Timestamp:
Feb 3, 2018 7:35:18 PM (6 years ago)
Author:
timothy_horton@apple.com
Message:

UI process sometimes crashes under -[WKContentView _lookupForWebView:]
https://bugs.webkit.org/show_bug.cgi?id=182460
<rdar://problem/33260602>

Reviewed by Wenson Hsieh.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _lookupForWebView:]):
If you have a range selection, but no rects for the selection, retrieving
the 0th element of selectionRects will crash the UI process. To fix, in
this case, use the rect for the starting caret instead.

It doesn't seem like the presentationRect is actually currently used for
the Lookup service, so the only impact is that we shouldn't crash anymore.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r228046 r228050  
     12018-02-03  Tim Horton  <timothy_horton@apple.com>
     2
     3        UI process sometimes crashes under -[WKContentView _lookupForWebView:]
     4        https://bugs.webkit.org/show_bug.cgi?id=182460
     5        <rdar://problem/33260602>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        * UIProcess/ios/WKContentViewInteraction.mm:
     10        (-[WKContentView _lookupForWebView:]):
     11        If you have a range selection, but no rects for the selection, retrieving
     12        the 0th element of selectionRects will crash the UI process. To fix, in
     13        this case, use the rect for the starting caret instead.
     14
     15        It doesn't seem like the presentationRect is actually currently used for
     16        the Lookup service, so the only impact is that we shouldn't crash anymore.
     17
    1182018-02-02  Michael Catanzaro  <mcatanzaro@igalia.com>
    219
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r227984 r228050  
    20052005        if (!selectedText)
    20062006            return;
    2007        
    2008         CGRect presentationRect = view->_page->editorState().selectionIsRange ? view->_page->editorState().postLayoutData().selectionRects[0].rect() : view->_page->editorState().postLayoutData().caretRectAtStart;
     2007
     2008        auto& editorState = view->_page->editorState();
     2009        auto& postLayoutData = editorState.postLayoutData();
     2010        CGRect presentationRect;
     2011        if (editorState.selectionIsRange && !postLayoutData.selectionRects.isEmpty())
     2012            presentationRect = postLayoutData.selectionRects[0].rect();
     2013        else
     2014            presentationRect = postLayoutData.caretRectAtStart;
    20092015       
    20102016        String selectionContext = textBefore + selectedText + textAfter;
    2011         if (view->_textSelectionAssistant) {
    2012             [view->_textSelectionAssistant lookup:selectionContext withRange:NSMakeRange(textBefore.length(), selectedText.length()) fromRect:presentationRect];
    2013         } else {
    2014             [view->_webSelectionAssistant lookup:selectionContext withRange:NSMakeRange(textBefore.length(), selectedText.length()) fromRect:presentationRect];
    2015         }
     2017        NSRange selectedRangeInContext = NSMakeRange(textBefore.length(), selectedText.length());
     2018
     2019        if (auto textSelectionAssistant = view->_textSelectionAssistant)
     2020            [textSelectionAssistant lookup:selectionContext withRange:selectedRangeInContext fromRect:presentationRect];
     2021        else
     2022            [view->_webSelectionAssistant lookup:selectionContext withRange:selectedRangeInContext fromRect:presentationRect];
    20162023    });
    20172024}
Note: See TracChangeset for help on using the changeset viewer.