Title: [248061] branches/safari-608-branch/Source/WebKit
Revision
248061
Author
[email protected]
Date
2019-07-31 13:56:25 -0700 (Wed, 31 Jul 2019)

Log Message

Cherry-pick r247920. rdar://problem/53764045

    Contextual menu does not present when holding an embedded photo but works with link and attachments
    https://bugs.webkit.org/show_bug.cgi?id=200239
    <rdar://problem/53318733>

    Reviewed by Tim Horton.

    If the user long-pressed on an image, and the client implemented the new API but did
    not provide a configuration, we were not falling back to the default behaviour of
    giving a menu allowing the user to copy/share/save the image.

    * UIProcess/ios/WKContentViewInteraction.mm:
    (-[WKContentView continueContextMenuInteraction:]): If we get through the delegates,
    and the element is an image, return the default configuration.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247920 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (248060 => 248061)


--- branches/safari-608-branch/Source/WebKit/ChangeLog	2019-07-31 20:56:23 UTC (rev 248060)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog	2019-07-31 20:56:25 UTC (rev 248061)
@@ -1,5 +1,41 @@
 2019-07-31  Alan Coon  <[email protected]>
 
+        Cherry-pick r247920. rdar://problem/53764045
+
+    Contextual menu does not present when holding an embedded photo but works with link and attachments
+    https://bugs.webkit.org/show_bug.cgi?id=200239
+    <rdar://problem/53318733>
+    
+    Reviewed by Tim Horton.
+    
+    If the user long-pressed on an image, and the client implemented the new API but did
+    not provide a configuration, we were not falling back to the default behaviour of
+    giving a menu allowing the user to copy/share/save the image.
+    
+    * UIProcess/ios/WKContentViewInteraction.mm:
+    (-[WKContentView continueContextMenuInteraction:]): If we get through the delegates,
+    and the element is an image, return the default configuration.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247920 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-07-29  Dean Jackson  <[email protected]>
+
+            Contextual menu does not present when holding an embedded photo but works with link and attachments
+            https://bugs.webkit.org/show_bug.cgi?id=200239
+            <rdar://problem/53318733>
+
+            Reviewed by Tim Horton.
+
+            If the user long-pressed on an image, and the client implemented the new API but did
+            not provide a configuration, we were not falling back to the default behaviour of
+            giving a menu allowing the user to copy/share/save the image.
+
+            * UIProcess/ios/WKContentViewInteraction.mm:
+            (-[WKContentView continueContextMenuInteraction:]): If we get through the delegates,
+            and the element is an image, return the default configuration.
+
+2019-07-31  Alan Coon  <[email protected]>
+
         Cherry-pick r247905. rdar://problem/53764224
 
     Possible use-after-move under NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated()

Modified: branches/safari-608-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (248060 => 248061)


--- branches/safari-608-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-07-31 20:56:23 UTC (rev 248060)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-07-31 20:56:25 UTC (rev 248061)
@@ -7961,6 +7961,35 @@
             return;
         }
 
+        if (strongSelf->_positionInformation.isImage) {
+            ASSERT(strongSelf->_positionInformation.image);
+            auto cgImage = strongSelf->_positionInformation.image->makeCGImageCopy();
+
+            strongSelf->_contextMenuActionProviderDelegateNeedsOverride = NO;
+
+            auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithInteractionInformationAtPosition:strongSelf->_positionInformation]);
+
+            UIContextMenuActionProvider actionMenuProvider = [weakSelf, elementInfo] (NSArray<UIMenuElement *> *) -> UIMenu * {
+                auto strongSelf = weakSelf.get();
+                if (!strongSelf)
+                    return nil;
+
+                RetainPtr<NSArray<_WKElementAction *>> defaultActionsFromAssistant = [strongSelf->_actionSheetAssistant defaultActionsForImageSheet:elementInfo.get()];
+                auto actions = menuElementsFromDefaultActions(defaultActionsFromAssistant, elementInfo);
+                return [UIMenu menuWithTitle:@"" children:actions];
+            };
+
+            UIContextMenuContentPreviewProvider contentPreviewProvider = [weakSelf, cgImage, elementInfo] () -> UIViewController * {
+                auto strongSelf = weakSelf.get();
+                if (!strongSelf)
+                    return nil;
+
+                return [[WKImagePreviewViewController alloc] initWithCGImage:cgImage defaultActions:nil elementInfo:elementInfo.get()];
+            };
+
+            return continueWithContextMenuConfiguration([UIContextMenuConfiguration configurationWithIdentifier:nil previewProvider:contentPreviewProvider actionProvider:actionMenuProvider]);
+        }
+
         // At this point we have an object we might want to show a context menu for, but the
         // client was unable to handle it. Before giving up, we ask DataDetectors.
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to