RESOLVED FIXED196435
[iOS] Refactor some logic for inserting pasted or dropped virtual card files as attachment elements
https://bugs.webkit.org/show_bug.cgi?id=196435
Summary [iOS] Refactor some logic for inserting pasted or dropped virtual card files ...
Wenson Hsieh
Reported 2019-03-31 18:07:21 PDT
Attachments
Patch (12.09 KB, patch)
2019-03-31 18:15 PDT, Wenson Hsieh
darin: review+
Patch for landing (12.06 KB, patch)
2019-04-01 09:06 PDT, Wenson Hsieh
no flags
Wenson Hsieh
Comment 1 2019-03-31 18:15:08 PDT
Darin Adler
Comment 2 2019-04-01 08:43:17 PDT
Comment on attachment 366379 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=366379&action=review > Source/WebCore/platform/ios/PasteboardIOS.mm:204 > + // we would prefer to insert an Apple maps link instead. "Apple Maps link", not "Apple maps link" > Source/WebCore/platform/ios/PasteboardIOS.mm:256 > +inline static void readURLAlongsideAttachmentIfNecessary(PasteboardWebContentReader& reader, PasteboardStrategy& strategy, const String& typeIdentifier, const String& pasteboardName, int itemIndex) I don’t think we need to write inline here. Doesn’t affect the compiler’s decision on whether to inline in practice these days, just the ability to include the same function in multiple translation units. > Source/WebCore/platform/ios/PasteboardIOS.mm:260 > + auto cfType = typeIdentifier.createCFString(); > + if (!UTTypeConformsTo(cfType.get(), kUTTypeVCard)) > + return; I think this reads better without the local variable. Without RetainPtr, we would need it so we can write the release, but with RetainPtr it can just be one expression. > Source/WebCore/platform/ios/PasteboardIOS.mm:278 > + auto cfType = info.contentTypeForHighestFidelityItem().createCFString(); > + if (UTTypeConformsTo(cfType.get(), kUTTypeVCard)) > + return true; Ditto. Or if we do have a local variable then I suggest it contain the type as a WTF::String, use it above for the isEmpty() check, and put the createCFString call into the call to UTTypeConformsTo. Also might just return UTTypeConformsTo instead of if (x) return true; return false;
Wenson Hsieh
Comment 3 2019-04-01 09:05:56 PDT
Comment on attachment 366379 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=366379&action=review Thanks for the review! >> Source/WebCore/platform/ios/PasteboardIOS.mm:204 >> + // we would prefer to insert an Apple maps link instead. > > "Apple Maps link", not "Apple maps link" Fixed! >> Source/WebCore/platform/ios/PasteboardIOS.mm:256 >> +inline static void readURLAlongsideAttachmentIfNecessary(PasteboardWebContentReader& reader, PasteboardStrategy& strategy, const String& typeIdentifier, const String& pasteboardName, int itemIndex) > > I don’t think we need to write inline here. Doesn’t affect the compiler’s decision on whether to inline in practice these days, just the ability to include the same function in multiple translation units. Ok! Removed `inline` from the two new static helper functions here. >> Source/WebCore/platform/ios/PasteboardIOS.mm:260 >> + return; > > I think this reads better without the local variable. Without RetainPtr, we would need it so we can write the release, but with RetainPtr it can just be one expression. Sounds good — removed the local variable. >> Source/WebCore/platform/ios/PasteboardIOS.mm:278 >> + return true; > > Ditto. Or if we do have a local variable then I suggest it contain the type as a WTF::String, use it above for the isEmpty() check, and put the createCFString call into the call to UTTypeConformsTo. > > Also might just return UTTypeConformsTo instead of if (x) return true; return false; Removed the local variable and changed the last part to be a single return statement.
Wenson Hsieh
Comment 4 2019-04-01 09:06:43 PDT
Created attachment 366399 [details] Patch for landing
WebKit Commit Bot
Comment 5 2019-04-01 09:45:31 PDT
Comment on attachment 366399 [details] Patch for landing Clearing flags on attachment: 366399 Committed r243695: <https://trac.webkit.org/changeset/243695>
Note You need to log in before you can comment on or make changes to this bug.