Title: [228050] trunk/Source/WebKit
- Revision
- 228050
- Author
- [email protected]
- Date
- 2018-02-03 19:35:18 -0800 (Sat, 03 Feb 2018)
Log 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.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (228049 => 228050)
--- trunk/Source/WebKit/ChangeLog 2018-02-03 22:39:10 UTC (rev 228049)
+++ trunk/Source/WebKit/ChangeLog 2018-02-04 03:35:18 UTC (rev 228050)
@@ -1,3 +1,20 @@
+2018-02-03 Tim Horton <[email protected]>
+
+ 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.
+
2018-02-02 Michael Catanzaro <[email protected]>
Remove remaining dead !USE(NETWORK_SESSION) code
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (228049 => 228050)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2018-02-03 22:39:10 UTC (rev 228049)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2018-02-04 03:35:18 UTC (rev 228050)
@@ -2004,15 +2004,22 @@
return;
if (!selectedText)
return;
+
+ auto& editorState = view->_page->editorState();
+ auto& postLayoutData = editorState.postLayoutData();
+ CGRect presentationRect;
+ if (editorState.selectionIsRange && !postLayoutData.selectionRects.isEmpty())
+ presentationRect = postLayoutData.selectionRects[0].rect();
+ else
+ presentationRect = postLayoutData.caretRectAtStart;
- CGRect presentationRect = view->_page->editorState().selectionIsRange ? view->_page->editorState().postLayoutData().selectionRects[0].rect() : view->_page->editorState().postLayoutData().caretRectAtStart;
-
String selectionContext = textBefore + selectedText + textAfter;
- if (view->_textSelectionAssistant) {
- [view->_textSelectionAssistant lookup:selectionContext withRange:NSMakeRange(textBefore.length(), selectedText.length()) fromRect:presentationRect];
- } else {
- [view->_webSelectionAssistant lookup:selectionContext withRange:NSMakeRange(textBefore.length(), selectedText.length()) fromRect:presentationRect];
- }
+ NSRange selectedRangeInContext = NSMakeRange(textBefore.length(), selectedText.length());
+
+ if (auto textSelectionAssistant = view->_textSelectionAssistant)
+ [textSelectionAssistant lookup:selectionContext withRange:selectedRangeInContext fromRect:presentationRect];
+ else
+ [view->_webSelectionAssistant lookup:selectionContext withRange:selectedRangeInContext fromRect:presentationRect];
});
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes