RESOLVED FIXED 210702
[Cocoa] Use createNSArray in many more places that build NSArray objects from C++ collections
https://bugs.webkit.org/show_bug.cgi?id=210702
Summary [Cocoa] Use createNSArray in many more places that build NSArray objects from...
Darin Adler
Reported 2020-04-18 15:22:10 PDT
[Cocoa] Use createNSArray in many more places that build NSArray objects from C++ collections
Attachments
Patch (169.13 KB, patch)
2020-04-18 15:23 PDT, Darin Adler
no flags
Patch (169.29 KB, patch)
2020-04-18 17:18 PDT, Darin Adler
no flags
Patch (169.30 KB, patch)
2020-04-18 17:31 PDT, Darin Adler
no flags
Patch (198.45 KB, patch)
2020-04-19 10:10 PDT, Darin Adler
no flags
Patch (198.45 KB, patch)
2020-04-20 00:05 PDT, Darin Adler
achristensen: review+
ews-feeder: commit-queue-
Darin Adler
Comment 1 2020-04-18 15:23:21 PDT Comment hidden (obsolete)
Darin Adler
Comment 2 2020-04-18 17:18:35 PDT Comment hidden (obsolete)
Darin Adler
Comment 3 2020-04-18 17:31:06 PDT Comment hidden (obsolete)
Darin Adler
Comment 4 2020-04-18 18:05:09 PDT Comment hidden (obsolete)
Darin Adler
Comment 5 2020-04-19 10:10:46 PDT Comment hidden (obsolete)
Darin Adler
Comment 6 2020-04-20 00:05:31 PDT
Darin Adler
Comment 7 2020-04-20 12:12:56 PDT
All tests passing. Ready for review.
Alex Christensen
Comment 8 2020-04-21 09:22:44 PDT
Comment on attachment 396953 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=396953&action=review > Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.h:-29 > -#ifndef WebAccessibilityObjectWrapperBase_h Are we adding #pragma once in objc headers? > Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1739 > + return nil; I've been using nullptr instead of nil for RetainPtr because it's a C++ type. I guess once we transition to ARC we'll use nil, right? > Source/WebKitLegacy/mac/History/WebBackForwardList.mm:155 > +constexpr auto WebBackForwardListDictionaryEntriesKey = @"entries"; How do you feel about auto for objc types? I've tried to avoid it.
Darin Adler
Comment 9 2020-04-21 12:17:08 PDT
Comment on attachment 396953 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=396953&action=review >> Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.h:-29 >> -#ifndef WebAccessibilityObjectWrapperBase_h > > Are we adding #pragma once in objc headers? No, in fact we made a patch to remove #pragma once from them. They aren’t needed in Objective-C headers. >> Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1739 >> + return nil; > > I've been using nullptr instead of nil for RetainPtr because it's a C++ type. I guess once we transition to ARC we'll use nil, right? I don’t care at all which we use, but in case you are wondering how I choice nil, in my mind, the nil isn’t for RetainPtr, it’s for the pointer stored in RetainPtr. And yes, if we move to ARC we won’t need RetainPtr for Objective-C pointers any more, just for CF pointers. >> Source/WebKitLegacy/mac/History/WebBackForwardList.mm:155 >> +constexpr auto WebBackForwardListDictionaryEntriesKey = @"entries"; > > How do you feel about auto for objc types? I've tried to avoid it. I like it. I understand that others may not share my tastes.
Darin Adler
Comment 10 2020-04-21 12:24:58 PDT
Comment on attachment 396953 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=396953&action=review >>> Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:1739 >>> + return nil; >> >> I've been using nullptr instead of nil for RetainPtr because it's a C++ type. I guess once we transition to ARC we'll use nil, right? > > I don’t care at all which we use, but in case you are wondering how I choice nil, in my mind, the nil isn’t for RetainPtr, it’s for the pointer stored in RetainPtr. And yes, if we move to ARC we won’t need RetainPtr for Objective-C pointers any more, just for CF pointers. I think it really depends on how abstract the code we are writing is. If it’s a RetainPtr and the underlying type is unknown, like in a template, then I would use nullptr. Or if it might not even be a RetainPtr, then I might use { }.
EWS
Comment 11 2020-04-21 18:30:20 PDT
Tools/Scripts/svn-apply failed to apply attachment 396953 [details] to trunk. Please resolve the conflicts and upload a new patch.
Darin Adler
Comment 12 2020-04-21 18:51:01 PDT
Radar WebKit Bug Importer
Comment 13 2020-04-21 18:51:18 PDT
Alex Christensen
Comment 14 2020-04-24 14:49:33 PDT
Comment on attachment 396953 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=396953&action=review > Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:190 > + [result setThumbnailURLs:createNSArray(linkIconURLs).get()]; This caused a regression rdar://problem/62275343 because createNSArray(const Vector<URL>&) returns NSArray<NSString> because URL has operator const String&() const. We want a makeNSArrayElement that takes a URL (easy), and we want to get rid of that operator String (hard).
Darin Adler
Comment 15 2020-04-24 16:06:00 PDT
(In reply to Alex Christensen from comment #14) > This caused a regression rdar://problem/62275343 because createNSArray(const > Vector<URL>&) returns NSArray<NSString> So sorry about the breakage! Really frustrating that we have no regression tests for this. > We want a makeNSArrayElement that takes a URL (easy) OK. Or just use a lambda here. > and we want to get rid of that operator String (hard). I don’t agree that we want to do this. I can imagine we might do it, but I see arguments against it too.
Note You need to log in before you can comment on or make changes to this bug.