RESOLVED FIXED 188955
[Cocoa] Adapt more WebKit code to be ARC-compatible
https://bugs.webkit.org/show_bug.cgi?id=188955
Summary [Cocoa] Adapt more WebKit code to be ARC-compatible
Darin Adler
Reported 2018-08-26 14:14:52 PDT
[Cocoa] Adapt more WebKit code to be ARC-compatible
Attachments
Patch (77.63 KB, patch)
2018-08-26 14:42 PDT, Darin Adler
no flags
Patch (79.13 KB, patch)
2018-08-26 15:11 PDT, Darin Adler
andersca: review+
Darin Adler
Comment 1 2018-08-26 14:42:58 PDT Comment hidden (obsolete)
EWS Watchlist
Comment 2 2018-08-26 14:44:52 PDT Comment hidden (obsolete)
Darin Adler
Comment 3 2018-08-26 15:11:34 PDT
EWS Watchlist
Comment 4 2018-08-26 15:13:59 PDT
Attachment 348104 [details] did not pass style-queue: ERROR: Source/WebKit/UIProcess/WebPageProxy.cpp:7329: Declaration has space between type name and * in NSObject *WebPageProxy [whitespace/declaration] [3] Total errors found: 1 in 40 files If any of these errors are false positives, please file a bug against check-webkit-style.
Darin Adler
Comment 5 2018-08-26 18:05:38 PDT
Looks like it’s compiling and passing tests everywhere.
Anders Carlsson
Comment 6 2018-08-27 07:04:25 PDT
Comment on attachment 348104 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=348104&action=review > Source/WebKit/Shared/API/c/cf/WKStringCF.mm:55 > + CFRetain(cfString); > + return toAPI(static_cast<API::String*>(&[(WKNSString *)(__bridge NSString *)cfString _apiObject])); I'd put the CFRetain inside the toAPI call instead of on a separate line. > Source/WebKit/Shared/API/c/cf/WKURLCF.mm:58 > + CFRetain(cfURL); Same here. > Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:2054 > - [[event retain] autorelease]; > + CFRetain((__bridge CFTypeRef)event); > + CFAutorelease((__bridge CFTypeRef)event); I seem to remember that you can do something like __autoreleasing NSEvent *autoreleasedEvent = event; (I think we've done something similar in Safari). > Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:2074 > - [[event retain] autorelease]; > + CFRetain((__bridge CFTypeRef)event); > + CFAutorelease((__bridge CFTypeRef)event); Same thing here.
Darin Adler
Comment 7 2018-08-27 08:47:11 PDT
Comment on attachment 348104 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=348104&action=review >> Source/WebKit/Shared/API/c/cf/WKStringCF.mm:55 >> + return toAPI(static_cast<API::String*>(&[(WKNSString *)(__bridge NSString *)cfString _apiObject])); > > I'd put the CFRetain inside the toAPI call instead of on a separate line. Done. The reason I didn’t do that originally is that I wanted a construction where the __bridge cast will warn if we use the wrong toll-free bridged type and I was worried that CFRetain would cause the expression to dumb down its type from CFStringRef to CFTypeRef. But frankly I have no idea if it will do that or not, and I also guess the warning is not so important that I should work so hard to preserve it. >> Source/WebKit/Shared/API/c/cf/WKURLCF.mm:58 >> + CFRetain(cfURL); > > Same here. Done. >> Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm:2054 >> + CFAutorelease((__bridge CFTypeRef)event); > > I seem to remember that you can do something like > > __autoreleasing NSEvent *autoreleasedEvent = event; > > (I think we've done something similar in Safari). I like the idea of moving to a better idiom. The thing I recall in Safari is a macro: #define AUTORELEASING_PROTECT(object) ({ __autoreleasing volatile id protector = object; (void)protector; }) I am not sure that’s better than explicit calls to CFRetain and CFAutorelease. I’d be happy to switch idioms to something we like better: It will be easy to find all the call sites by searching for CFAutorelease; so far there are only 4, these 3 in WebKit and 1 I already landed in WebCore. For now I’d prefer to land these as just CFRetain/CFAutorelease since I’m not sure I prefer an idiom involving volatile and unused local variables.
Darin Adler
Comment 8 2018-08-27 08:51:30 PDT
Radar WebKit Bug Importer
Comment 9 2018-08-27 08:52:24 PDT
Note You need to log in before you can comment on or make changes to this bug.