Bug 234162 - Image does not update after Markup Pane is dismissed.
Summary: Image does not update after Markup Pane is dismissed.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Megan Gardner
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-12-10 11:37 PST by Megan Gardner
Modified: 2021-12-10 16:49 PST (History)
9 users (show)

See Also:


Attachments
Patch (19.57 KB, patch)
2021-12-10 11:47 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (19.56 KB, patch)
2021-12-10 13:54 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch for landing (19.55 KB, patch)
2021-12-10 15:57 PST, Megan Gardner
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Megan Gardner 2021-12-10 11:37:41 PST
Image does not update after Markup Pane is dismissed.
Comment 1 Megan Gardner 2021-12-10 11:47:26 PST
Created attachment 446773 [details]
Patch
Comment 2 Devin Rousso 2021-12-10 12:09:15 PST
Comment on attachment 446773 [details]
Patch

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

r=me

> Source/WebCore/dom/mac/ImageControlsMac.cpp:133
> +        if (!is<HTMLImageElement>(*shadowHost))

NIT: you can merge this with the above `if (!shadowHost)` since `is` checks for an invalid pointer
```
    if (!is<HTMLImageElement>(shadowHost))
        return false;
```

> Source/WebCore/dom/mac/ImageControlsMac.cpp:135
> +        HTMLImageElement& imageElement = downcast<HTMLImageElement>(*shadowHost);

NIT: Chould we move this inside the `if` since it's not used outside?

> Source/WebCore/page/ChromeClient.h:535
> +    virtual void handleImageServiceClick(const IntPoint&, Image&, bool /*isEditable*/, const IntRect&, const String&) { }

I'd include the name like `const String& /* attachmentID */` as it's not really clear otherwise what it's for.

> Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm:153
> +- (void)setData:(NSData *)data newContentType:(NSString *)newContentType

NIT: Do we actually need this?  Can't we just `[attachment setData:data newContentType:String(NSPasteboardTypeTIFF) newFilename:nil completion:nil];`?

> Source/WebKit/UIProcess/mac/WKSharingServicePickerDelegate.mm:151
> +        [itemProvider loadDataRepresentationForTypeIdentifier:(NSString *)kUTTypeData completionHandler:^(NSData *data, NSError *error) {

NIT: Is the `(NSString *)` cast necessary?

> Source/WebKit/UIProcess/mac/WKSharingServicePickerDelegate.mm:155
> +            auto apiAttachment = _menuProxy->page()->attachmentForIdentifier(_attachmentID);

Do we need to check that `_menuProxy` and/or `_menuProxy->page()` exist at this point?
```
    WebPageProxy* page = _menuProxy ? _menyProxy->page() : nullptr;
    if (!page)
        return;

    auto apiAttachment = page->attachmentForIdentifier(_attachmentID);
    ...
```

> Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:247
> +    [[WKSharingServicePickerDelegate sharedSharingServicePickerDelegate] setAttachmentID:m_context.controlledImageAttachmentID()];

```
    [WKSharingServicePickerDelegate.sharedSharingServicePickerDelegate setAttachmentID:m_context.controlledImageAttachmentID()];
```

> Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:384
> +    void handleImageServiceClick(const WebCore::IntPoint&, WebCore::Image&, bool isEditable, const WebCore::IntRect&, const String&) final;

ditto (Source/WebCore/page/ChromeClient.h:535)
Comment 3 Megan Gardner 2021-12-10 13:32:01 PST
Comment on attachment 446773 [details]
Patch

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

>> Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm:153
>> +- (void)setData:(NSData *)data newContentType:(NSString *)newContentType
> 
> NIT: Do we actually need this?  Can't we just `[attachment setData:data newContentType:String(NSPasteboardTypeTIFF) newFilename:nil completion:nil];`?

Well, the old SPI is deprecated, so it's probably best to make this separate from that.

>> Source/WebKit/UIProcess/mac/WKSharingServicePickerDelegate.mm:155
>> +            auto apiAttachment = _menuProxy->page()->attachmentForIdentifier(_attachmentID);
> 
> Do we need to check that `_menuProxy` and/or `_menuProxy->page()` exist at this point?
> ```
>     WebPageProxy* page = _menuProxy ? _menyProxy->page() : nullptr;
>     if (!page)
>         return;
> 
>     auto apiAttachment = page->attachmentForIdentifier(_attachmentID);
>     ...
> ```

Well, we don't check about 10 lines down from this in pre-existing code, so if we should we should in both places.

>> Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:247
>> +    [[WKSharingServicePickerDelegate sharedSharingServicePickerDelegate] setAttachmentID:m_context.controlledImageAttachmentID()];
> 
> ```
>     [WKSharingServicePickerDelegate.sharedSharingServicePickerDelegate setAttachmentID:m_context.controlledImageAttachmentID()];
> ```

literally every other line in this file that calls something on the shared delegate uses the [] method, I'd prefer it to be consistent.
Comment 4 Megan Gardner 2021-12-10 13:54:16 PST
Created attachment 446806 [details]
Patch
Comment 5 Megan Gardner 2021-12-10 15:57:26 PST
Created attachment 446835 [details]
Patch for landing
Comment 6 EWS 2021-12-10 16:48:05 PST
Committed r286886 (245115@main): <https://commits.webkit.org/245115@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 446835 [details].
Comment 7 Radar WebKit Bug Importer 2021-12-10 16:49:19 PST
<rdar://problem/86346270>