Title: [248469] trunk/Source
Revision
248469
Author
timothy_hor...@apple.com
Date
2019-08-09 12:50:44 -0700 (Fri, 09 Aug 2019)

Log Message

Tapping buttons in Data Detectors lookup previews doesn't work
https://bugs.webkit.org/show_bug.cgi?id=200579
<rdar://problem/54056519>

Reviewed by Megan Gardner.

Source/WebCore/PAL:

* pal/spi/ios/DataDetectorsUISPI.h:

Source/WebKit:

* Platform/spi/ios/UIKitSPI.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _contextMenuInteraction:styleForMenuWithConfiguration:]):
If a Data Detectors context menu wants the action menu style, provide it.

(-[WKContentView contextMenuInteraction:willPerformPreviewActionForMenuWithConfiguration:animator:]):
If a Data Detectors context menu provides a view controller to present
on context menu commit, present it. We present on top of the same view
controller that is currently presenting the context menu, but modally
instead of inside the context menu.

If a Data Detectors context menu instead provides a URL to launch on
context menu commit, call openURL.

In both cases, change the commit style to pop, since we're committing
instead of dismissing.

Modified Paths

Diff

Modified: trunk/Source/WebCore/PAL/ChangeLog (248468 => 248469)


--- trunk/Source/WebCore/PAL/ChangeLog	2019-08-09 17:46:12 UTC (rev 248468)
+++ trunk/Source/WebCore/PAL/ChangeLog	2019-08-09 19:50:44 UTC (rev 248469)
@@ -1,3 +1,13 @@
+2019-08-09  Tim Horton  <timothy_hor...@apple.com>
+
+        Tapping buttons in Data Detectors lookup previews doesn't work
+        https://bugs.webkit.org/show_bug.cgi?id=200579
+        <rdar://problem/54056519>
+
+        Reviewed by Megan Gardner.
+
+        * pal/spi/ios/DataDetectorsUISPI.h:
+
 2019-08-07  Dean Jackson  <d...@apple.com>
 
         Context menu on a universal link produces a blank preview

Modified: trunk/Source/WebCore/PAL/pal/spi/ios/DataDetectorsUISPI.h (248468 => 248469)


--- trunk/Source/WebCore/PAL/pal/spi/ios/DataDetectorsUISPI.h	2019-08-09 17:46:12 UTC (rev 248468)
+++ trunk/Source/WebCore/PAL/pal/spi/ios/DataDetectorsUISPI.h	2019-08-09 19:50:44 UTC (rev 248469)
@@ -83,6 +83,7 @@
 SOFT_LINK_PRIVATE_FRAMEWORK(DataDetectorsUI)
 #if HAVE(LINK_PREVIEW) && USE(UICONTEXTMENU)
 SOFT_LINK_CLASS(DataDetectorsUI, DDContextMenuAction);
+SOFT_LINK_CLASS(DataDetectorsUI, DDContextMenuConfiguration);
 #endif
 SOFT_LINK_CLASS(DataDetectorsUI, DDDetectionController)
 SOFT_LINK_CONSTANT(DataDetectorsUI, kDataDetectorsLeadingText, const NSString *)

Modified: trunk/Source/WebKit/ChangeLog (248468 => 248469)


--- trunk/Source/WebKit/ChangeLog	2019-08-09 17:46:12 UTC (rev 248468)
+++ trunk/Source/WebKit/ChangeLog	2019-08-09 19:50:44 UTC (rev 248469)
@@ -1,3 +1,28 @@
+2019-08-09  Tim Horton  <timothy_hor...@apple.com>
+
+        Tapping buttons in Data Detectors lookup previews doesn't work
+        https://bugs.webkit.org/show_bug.cgi?id=200579
+        <rdar://problem/54056519>
+
+        Reviewed by Megan Gardner.
+
+        * Platform/spi/ios/UIKitSPI.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _contextMenuInteraction:styleForMenuWithConfiguration:]):
+        If a Data Detectors context menu wants the action menu style, provide it.
+
+        (-[WKContentView contextMenuInteraction:willPerformPreviewActionForMenuWithConfiguration:animator:]):
+        If a Data Detectors context menu provides a view controller to present
+        on context menu commit, present it. We present on top of the same view
+        controller that is currently presenting the context menu, but modally
+        instead of inside the context menu.
+
+        If a Data Detectors context menu instead provides a URL to launch on
+        context menu commit, call openURL.
+
+        In both cases, change the commit style to pop, since we're committing
+        instead of dismissing.
+
 2019-08-08  Dean Jackson  <d...@apple.com>
 
         REGRESSION (52279987): Most of the WKUIDelegate contextMenu delegate methods are not being called

Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (248468 => 248469)


--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2019-08-09 17:46:12 UTC (rev 248468)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2019-08-09 19:50:44 UTC (rev 248469)
@@ -90,6 +90,7 @@
 #import <UIKit/UIPreviewAction_Private.h>
 #import <UIKit/UIPreviewItemController.h>
 #if USE(UICONTEXTMENU)
+#import <UIKit/UIContextMenuInteraction_ForSpringBoardOnly.h>
 #import <UIKit/UIContextMenuInteraction_ForWebKitOnly.h>
 #endif
 #endif

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (248468 => 248469)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-08-09 17:46:12 UTC (rev 248468)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-08-09 19:50:44 UTC (rev 248469)
@@ -8225,6 +8225,23 @@
     return std::exchange(_contextMenuInteractionTargetedPreview, nil).autorelease();
 }
 
+- (nullable _UIContextMenuStyle *)_contextMenuInteraction:(UIContextMenuInteraction *)interaction styleForMenuWithConfiguration:(UIContextMenuConfiguration *)configuration
+{
+#if defined(DD_CONTEXT_MENU_SPI_VERSION) && DD_CONTEXT_MENU_SPI_VERSION >= 2
+    if ([configuration isKindOfClass:getDDContextMenuConfigurationClass()]) {
+        DDContextMenuConfiguration *ddConfiguration = static_cast<DDContextMenuConfiguration *>(configuration);
+
+        if (ddConfiguration.prefersActionMenuStyle) {
+            _UIContextMenuStyle *style = [_UIContextMenuStyle defaultStyle];
+            style.preferredLayout = _UIContextMenuLayoutActionsOnly;
+            return style;
+        }
+    }
+#endif
+
+    return nil;
+}
+
 - (void)contextMenuInteraction:(UIContextMenuInteraction *)interaction willPerformPreviewActionForMenuWithConfiguration:(UIContextMenuConfiguration *)configuration animator:(id<UIContextMenuInteractionCommitAnimating>)animator
 {
     if (!_webView)
@@ -8276,6 +8293,45 @@
         [uiDelegate _webView:_webView contextMenuForElement:_contextMenuElementInfo.get() willCommitWithAnimator:animator];
         ALLOW_DEPRECATED_DECLARATIONS_END
     }
+
+#if defined(DD_CONTEXT_MENU_SPI_VERSION) && DD_CONTEXT_MENU_SPI_VERSION >= 2
+    if ([configuration isKindOfClass:getDDContextMenuConfigurationClass()]) {
+        DDContextMenuConfiguration *ddConfiguration = static_cast<DDContextMenuConfiguration *>(configuration);
+
+        BOOL shouldExpandPreview = NO;
+        RetainPtr<UIViewController> presentedViewController;
+
+#if defined(DD_CONTEXT_MENU_SPI_VERSION) && DD_CONTEXT_MENU_SPI_VERSION >= 3
+        shouldExpandPreview = !!ddConfiguration.interactionViewControllerProvider;
+        if (shouldExpandPreview)
+            presentedViewController = ddConfiguration.interactionViewControllerProvider();
+#else
+        shouldExpandPreview = ddConfiguration.expandPreviewOnInteraction;
+        presentedViewController = animator.previewViewController;
+#endif
+
+        if (shouldExpandPreview) {
+            animator.preferredCommitStyle = UIContextMenuInteractionCommitStylePop;
+
+            // We will re-present modally on the same VC that is currently presenting the preview in a context menu.
+            RetainPtr<UIViewController> presentingViewController = animator.previewViewController.presentingViewController;
+
+            [animator addAnimations:^{
+                [presentingViewController presentViewController:presentedViewController.get() animated:NO completion:nil];
+            }];
+            return;
+        }
+
+        if (NSURL *interactionURL = ddConfiguration.interactionURL) {
+            animator.preferredCommitStyle = UIContextMenuInteractionCommitStylePop;
+
+            [animator addAnimations:^{
+                [[UIApplication sharedApplication] openURL:interactionURL withCompletionHandler:nil];
+            }];
+            return;
+        }
+    }
+#endif
 }
 
 - (void)contextMenuInteraction:(UIContextMenuInteraction *)interaction willEndForConfiguration:(UIContextMenuConfiguration *)configuration animator:(nullable id<UIContextMenuInteractionAnimating>)animator
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to