Bug 239748 - Adjust some image transcoding behaviors related to "Copy Cropped Image"
Summary: Adjust some image transcoding behaviors related to "Copy Cropped Image"
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-04-25 16:42 PDT by Wenson Hsieh
Modified: 2022-04-26 11:29 PDT (History)
6 users (show)

See Also:


Attachments
Patch (20.90 KB, patch)
2022-04-25 21:52 PDT, Wenson Hsieh
katherine_cheney: review+
Details | Formatted Diff | Diff
Patch for landing (21.33 KB, patch)
2022-04-26 08:55 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2022-04-25 16:42:54 PDT
rdar://92287000
Comment 1 Wenson Hsieh 2022-04-25 21:52:29 PDT
Created attachment 458327 [details]
Patch
Comment 2 Kate Cheney 2022-04-26 08:25:30 PDT
Comment on attachment 458327 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=458327&action=review

looks good! A couple Qs

> Source/WebKit/Platform/cocoa/CocoaImage.mm:-56
> -    if (CFStringGetLength(preferredMIMEType)) {

should we keep this check or add an assert that the CFStringRef isn't empty for future callers?

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:11034
> +        auto [data, type] = WebKit::imageDataForCroppedImageResult(result, (__bridge CFStringRef)sourceMIMEType.get());

Do we no longer need to worry about if the result is nil in this case?
Comment 3 Wenson Hsieh 2022-04-26 08:43:51 PDT
Comment on attachment 458327 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=458327&action=review

Thanks for the review!

>> Source/WebKit/Platform/cocoa/CocoaImage.mm:-56
>> -    if (CFStringGetLength(preferredMIMEType)) {
> 
> should we keep this check or add an assert that the CFStringRef isn't empty for future callers?

Good call! Will add a `ASSERT(CFStringGetLength(preferredMIMEType));` here.

>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:11034
>> +        auto [data, type] = WebKit::imageDataForCroppedImageResult(result, (__bridge CFStringRef)sourceMIMEType.get());
> 
> Do we no longer need to worry about if the result is nil in this case?

Good catch! I originally fell back to the original image in the case where the "markup image conversion" failed, but this is no longer desired behavior. That said, in the case where `result` is null, we should be bailing from this codepath altogether — I'll add an early return for the `!result` case above.
Comment 4 Wenson Hsieh 2022-04-26 08:55:39 PDT
Created attachment 458373 [details]
Patch for landing
Comment 5 EWS 2022-04-26 11:29:14 PDT
Committed r293436 (249994@main): <https://commits.webkit.org/249994@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 458373 [details].