Title: [244474] trunk/Source/WebKit
- Revision
- 244474
- Author
- [email protected]
- Date
- 2019-04-19 16:49:09 -0700 (Fri, 19 Apr 2019)
Log Message
Use RetainPtr and rename +autocorrectionRectsWithRects:lastRect: to +autocorrectionRectsWithFirstCGRect:lastCGRect:
https://bugs.webkit.org/show_bug.cgi?id=197122
Reviewed by Wenson Hsieh.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView requestAutocorrectionRectsForString:withCompletionHandler:]): Renamed; formerly named +autocorrectionRectsWithRects:lastRect:.
While I am here use else-branch to initialize firstRect and lastRect just to make the code closer to the optimal
assembly. Also use Vector::{isEmpty, first, last}() instead of using the index operator overload and size() for
emptiness checks. The code is more readable at the cost being ever so slightly slower (due to the overflow checks
in first() and last()), but this code is likely not hot enough for it to matter.
(-[WKContentView applyAutocorrection:toString:withCompletionHandler:]): Update for renaming.
(+[WKAutocorrectionRects autocorrectionRectsWithFirstCGRect:lastCGRect:]): Ditto.
(+[WKAutocorrectionRects autocorrectionRectsWithRects:lastRect:]): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (244473 => 244474)
--- trunk/Source/WebKit/ChangeLog 2019-04-19 23:48:41 UTC (rev 244473)
+++ trunk/Source/WebKit/ChangeLog 2019-04-19 23:49:09 UTC (rev 244474)
@@ -1,5 +1,22 @@
2019-04-19 Daniel Bates <[email protected]>
+ Use RetainPtr and rename +autocorrectionRectsWithRects:lastRect: to +autocorrectionRectsWithFirstCGRect:lastCGRect:
+ https://bugs.webkit.org/show_bug.cgi?id=197122
+
+ Reviewed by Wenson Hsieh.
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView requestAutocorrectionRectsForString:withCompletionHandler:]): Renamed; formerly named +autocorrectionRectsWithRects:lastRect:.
+ While I am here use else-branch to initialize firstRect and lastRect just to make the code closer to the optimal
+ assembly. Also use Vector::{isEmpty, first, last}() instead of using the index operator overload and size() for
+ emptiness checks. The code is more readable at the cost being ever so slightly slower (due to the overflow checks
+ in first() and last()), but this code is likely not hot enough for it to matter.
+ (-[WKContentView applyAutocorrection:toString:withCompletionHandler:]): Update for renaming.
+ (+[WKAutocorrectionRects autocorrectionRectsWithFirstCGRect:lastCGRect:]): Ditto.
+ (+[WKAutocorrectionRects autocorrectionRectsWithRects:lastRect:]): Deleted.
+
+2019-04-19 Daniel Bates <[email protected]>
+
-[WKAutocorrectionContext emptyAutocorrectionContext:] generates invalid empty context
https://bugs.webkit.org/show_bug.cgi?id=197119
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (244473 => 244474)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-04-19 23:48:41 UTC (rev 244473)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-04-19 23:49:09 UTC (rev 244474)
@@ -285,7 +285,7 @@
@end
@interface WKAutocorrectionRects : UIWKAutocorrectionRects
-+ (WKAutocorrectionRects *)autocorrectionRectsWithRects:(CGRect)firstRect lastRect:(CGRect)lastRect;
++ (WKAutocorrectionRects *)autocorrectionRectsWithFirstCGRect:(CGRect)firstRect lastCGRect:(CGRect)lastRect;
@end
@interface WKAutocorrectionContext : UIWKAutocorrectionContext
@@ -3467,13 +3467,16 @@
}
_page->requestAutocorrectionData(input, [view = retainPtr(self), completion = makeBlockPtr(completionHandler)](auto& rects, auto& fontName, double fontSize, uint64_t traits, auto) {
- CGRect firstRect = CGRectZero;
- CGRect lastRect = CGRectZero;
- if (rects.size()) {
- firstRect = rects[0];
- lastRect = rects[rects.size() - 1];
+ CGRect firstRect;
+ CGRect lastRect;
+ if (rects.isEmpty()) {
+ firstRect = CGRectZero;
+ lastRect = CGRectZero;
+ } else {
+ firstRect = rects.first();
+ lastRect = rects.last();
}
-
+
view->_autocorrectionData.fontName = fontName;
view->_autocorrectionData.fontSize = fontSize;
view->_autocorrectionData.fontTraits = traits;
@@ -3480,7 +3483,7 @@
view->_autocorrectionData.textFirstRect = firstRect;
view->_autocorrectionData.textLastRect = lastRect;
- completion(rects.size() ? [WKAutocorrectionRects autocorrectionRectsWithRects:firstRect lastRect:lastRect] : nil);
+ completion(!rects.isEmpty() ? [WKAutocorrectionRects autocorrectionRectsWithFirstCGRect:firstRect lastCGRect:lastRect] : nil);
});
}
@@ -3671,13 +3674,13 @@
if (useSyncRequest) {
if (completionHandler)
- completionHandler(_page->applyAutocorrection(correction, input) ? [WKAutocorrectionRects autocorrectionRectsWithRects:_autocorrectionData.textFirstRect lastRect:_autocorrectionData.textLastRect] : nil);
+ completionHandler(_page->applyAutocorrection(correction, input) ? [WKAutocorrectionRects autocorrectionRectsWithFirstCGRect:_autocorrectionData.textFirstRect lastCGRect:_autocorrectionData.textLastRect] : nil);
return;
}
_page->applyAutocorrection(correction, input, [view = retainPtr(self), completion = makeBlockPtr(completionHandler)](auto& string, auto error) {
if (completion)
- completion(!string.isNull() ? [WKAutocorrectionRects autocorrectionRectsWithRects:view->_autocorrectionData.textFirstRect lastRect:view->_autocorrectionData.textLastRect] : nil);
+ completion(!string.isNull() ? [WKAutocorrectionRects autocorrectionRectsWithFirstCGRect:view->_autocorrectionData.textFirstRect lastCGRect:view->_autocorrectionData.textLastRect] : nil);
});
}
@@ -7672,12 +7675,12 @@
@implementation WKAutocorrectionRects
-+ (WKAutocorrectionRects *)autocorrectionRectsWithRects:(CGRect)firstRect lastRect:(CGRect)lastRect
++ (WKAutocorrectionRects *)autocorrectionRectsWithFirstCGRect:(CGRect)firstRect lastCGRect:(CGRect)lastRect
{
- WKAutocorrectionRects *rects =[[WKAutocorrectionRects alloc] init];
- rects.firstRect = firstRect;
- rects.lastRect = lastRect;
- return [rects autorelease];
+ auto rects = adoptNS([[WKAutocorrectionRects alloc] init]);
+ [rects setFirstRect:firstRect];
+ [rects setLastRect:lastRect];
+ return rects.autorelease();
}
@end
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes