Bug 208779 - Adopt Context Menus for Data Detectors
Summary: Adopt Context Menus for Data Detectors
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: 2020-03-07 16:47 PST by Megan Gardner
Modified: 2020-03-08 01:00 PST (History)
3 users (show)

See Also:


Attachments
Patch (8.13 KB, patch)
2020-03-07 16:54 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (8.26 KB, patch)
2020-03-07 17:24 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (9.19 KB, patch)
2020-03-07 20:36 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (8.99 KB, patch)
2020-03-07 22:24 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (10.23 KB, patch)
2020-03-07 22:50 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (10.35 KB, patch)
2020-03-07 22:56 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (10.35 KB, patch)
2020-03-07 23:02 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (10.31 KB, patch)
2020-03-07 23:16 PST, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch for landing (10.30 KB, patch)
2020-03-08 00:17 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 2020-03-07 16:47:29 PST
Adopt Context Menus for Data Detectors
Comment 1 Megan Gardner 2020-03-07 16:54:36 PST
Created attachment 392914 [details]
Patch
Comment 2 Tim Horton 2020-03-07 17:07:03 PST
Comment on attachment 392914 [details]
Patch

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

> Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h:65
> +- (CGPoint)contextMenuDisplayLocation;

Cocoa tradition is to pass the object that's delegating behavior to the delegate methods. You even realized why, earlier (so that you can have one object be the delegate of multiple instances of the same class). See all of the others above.

> Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm:738
> +- (_UIContextMenuStyle *)_contextMenuInteraction:(UIContextMenuInteraction *)interaction styleForMenuWithConfiguration:(UIContextMenuConfiguration *)configuration

Missing a newline
Comment 3 Megan Gardner 2020-03-07 17:24:33 PST
Created attachment 392918 [details]
Patch
Comment 4 Tim Horton 2020-03-07 17:43:56 PST
Comment on attachment 392918 [details]
Patch

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

> Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm:691
> +    [self ensureContextMenuInteraction];

Seems bad that we make and install it, and then don't present it, which means we won't remove it. I think this needs to be JUST before the -present

> Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm:694
> +    if ([delegate respondsToSelector:@selector(contextMenuDisplayLocation)]) {
> +        [_dataDetectorContextMenuInteraction _presentMenuAtLocation:[delegate contextMenuDisplayLocation]];

You forgot to change the name here
Comment 5 Megan Gardner 2020-03-07 18:40:56 PST
<rdar://problem/59358079>
Comment 6 Megan Gardner 2020-03-07 20:36:50 PST
Created attachment 392935 [details]
Patch
Comment 7 Megan Gardner 2020-03-07 22:24:56 PST
Created attachment 392937 [details]
Patch
Comment 8 Tim Horton 2020-03-07 22:38:33 PST
Comment on attachment 392937 [details]
Patch

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

> Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h:65
> +- (CGPoint)contextMenuDisplayLocationForActionSheetAssistant:(WKActionSheetAssistant *)assistant;

Maybe "presentation" or "origin" instead of "display", but I don't really care.

> Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm:719
> +- (UIContextMenuConfiguration *)contextMenuInteraction:(UIContextMenuInteraction *)interaction configurationForMenuAtLocation:(CGPoint)location

USE(UICONTEXTMENU)?

> Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm:747
> +    if ([delegate respondsToSelector:@selector(contextMenuDisplayLocationForActionSheetAssistant:)])
> +        center = [delegate contextMenuDisplayLocationForActionSheetAssistant:self];
> +    RetainPtr<UIPreviewParameters> unusedPreviewParameters = adoptNS([[UIPreviewParameters alloc] init]);
> +    RetainPtr<UIPreviewTarget> previewTarget = adoptNS([[UIPreviewTarget alloc] initWithContainer:_view.getAutoreleased() center:center]);
> +    RetainPtr<UITargetedPreview> preview = adoptNS([[UITargetedPreview alloc] initWithView:_view.getAutoreleased() parameters:unusedPreviewParameters.get() target:previewTarget.get()]);

How ugly is the hint? We probably want to share some of this with the better code in WKContentViewInteraction, but that can be in a follow-up
Comment 9 Wenson Hsieh 2020-03-07 22:39:30 PST
Comment on attachment 392937 [details]
Patch

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

> Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm:645
> +
> +- (void)ensureContextMenuInteraction

Generally, -ensure* methods should return the object they’re ensuring (in this case, the _dataDetectorContextMenuInteraction). I think that if you added a return _dataDetectorContextMenuInteraction.get(); at the end here, it would allow you to then do this below:

        auto delegate = _delegate.get();
        if ([delegate respondsToSelector:@selector(contextMenuDisplayLocationForActionSheetAssistant:)]) {
            [[self ensureContextMenuInteraction] _presentMenuAtLocation:[delegate contextMenuDisplayLocationForActionSheetAssistant:self]];
            return;
        }

I believe this would also address Tim’s earlier comment in https://bugs.webkit.org/show_bug.cgi?id=208779#c4.
Comment 10 Megan Gardner 2020-03-07 22:50:48 PST
Created attachment 392938 [details]
Patch
Comment 11 Megan Gardner 2020-03-07 22:56:28 PST
Created attachment 392939 [details]
Patch
Comment 12 Megan Gardner 2020-03-07 23:02:29 PST
Created attachment 392940 [details]
Patch
Comment 13 Megan Gardner 2020-03-07 23:16:17 PST
Created attachment 392941 [details]
Patch
Comment 14 Megan Gardner 2020-03-08 00:17:12 PST
Created attachment 392944 [details]
Patch for landing
Comment 15 WebKit Commit Bot 2020-03-08 01:00:54 PST
Comment on attachment 392944 [details]
Patch for landing

Clearing flags on attachment: 392944

Committed r258102: <https://trac.webkit.org/changeset/258102>
Comment 16 WebKit Commit Bot 2020-03-08 01:00:56 PST
All reviewed patches have been landed.  Closing bug.