Changeset 228079 in webkit


Ignore:
Timestamp:
Feb 4, 2018 9:30:58 PM (6 years ago)
Author:
jmarcell@apple.com
Message:

Cherry-pick r228050. rdar://problem/37220143

Location:
branches/safari-605-branch/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-605-branch/Source/WebKit/ChangeLog

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

    r227883 r228079  
    19351935        if (!selectedText)
    19361936            return;
    1937        
    1938         CGRect presentationRect = view->_page->editorState().selectionIsRange ? view->_page->editorState().postLayoutData().selectionRects[0].rect() : view->_page->editorState().postLayoutData().caretRectAtStart;
     1937
     1938        auto& editorState = view->_page->editorState();
     1939        auto& postLayoutData = editorState.postLayoutData();
     1940        CGRect presentationRect;
     1941        if (editorState.selectionIsRange && !postLayoutData.selectionRects.isEmpty())
     1942            presentationRect = postLayoutData.selectionRects[0].rect();
     1943        else
     1944            presentationRect = postLayoutData.caretRectAtStart;
    19391945       
    19401946        String selectionContext = textBefore + selectedText + textAfter;
    1941         if (view->_textSelectionAssistant) {
    1942             [view->_textSelectionAssistant lookup:selectionContext withRange:NSMakeRange(textBefore.length(), selectedText.length()) fromRect:presentationRect];
    1943         } else {
    1944             [view->_webSelectionAssistant lookup:selectionContext withRange:NSMakeRange(textBefore.length(), selectedText.length()) fromRect:presentationRect];
    1945         }
     1947        NSRange selectedRangeInContext = NSMakeRange(textBefore.length(), selectedText.length());
     1948
     1949        if (auto textSelectionAssistant = view->_textSelectionAssistant)
     1950            [textSelectionAssistant lookup:selectionContext withRange:selectedRangeInContext fromRect:presentationRect];
     1951        else
     1952            [view->_webSelectionAssistant lookup:selectionContext withRange:selectedRangeInContext fromRect:presentationRect];
    19461953    });
    19471954}
Note: See TracChangeset for help on using the changeset viewer.