Title: [281352] trunk/Source/WebKit
Revision
281352
Author
[email protected]
Date
2021-08-20 17:14:10 -0700 (Fri, 20 Aug 2021)

Log Message

[macCatalyst] Crash when clicking a phone number link
https://bugs.webkit.org/show_bug.cgi?id=229344
rdar://81804638

Reviewed by Tim Horton.

Clicking on a phone number link should present data detection UI.
However, `-[WKActionSheetAssistant _elementActionForDDAction:]` always
returns nil on Catalyst, resulting in crash when attempting to add the
returned action to an NSArray.

Given that the methods used in `_elementActionForDDAction:` are available
on Catalyst, fix the crash by ensuring the method does not return nil, and
only making the method available on platforms where ENABLE(DATA_DETECTION)
is defined.

* UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant _elementActionForDDAction:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (281351 => 281352)


--- trunk/Source/WebKit/ChangeLog	2021-08-21 00:00:57 UTC (rev 281351)
+++ trunk/Source/WebKit/ChangeLog	2021-08-21 00:14:10 UTC (rev 281352)
@@ -1,3 +1,24 @@
+2021-08-20  Aditya Keerthi  <[email protected]>
+
+        [macCatalyst] Crash when clicking a phone number link
+        https://bugs.webkit.org/show_bug.cgi?id=229344
+        rdar://81804638
+
+        Reviewed by Tim Horton.
+
+        Clicking on a phone number link should present data detection UI.
+        However, `-[WKActionSheetAssistant _elementActionForDDAction:]` always
+        returns nil on Catalyst, resulting in crash when attempting to add the
+        returned action to an NSArray.
+
+        Given that the methods used in `_elementActionForDDAction:` are available
+        on Catalyst, fix the crash by ensuring the method does not return nil, and
+        only making the method available on platforms where ENABLE(DATA_DETECTION)
+        is defined.
+
+        * UIProcess/ios/WKActionSheetAssistant.mm:
+        (-[WKActionSheetAssistant _elementActionForDDAction:]):
+
 2021-08-20  Alex Christensen  <[email protected]>
 
         Make UIEventAttribution tests less platform dependent

Modified: trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm (281351 => 281352)


--- trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm	2021-08-21 00:00:57 UTC (rev 281351)
+++ trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm	2021-08-21 00:14:10 UTC (rev 281352)
@@ -190,23 +190,6 @@
     return [self superviewForSheet];
 }
 
-- (_WKElementAction *)_elementActionForDDAction:(DDAction *)action
-{
-#if PLATFORM(IOS) && !PLATFORM(MACCATALYST)
-    auto retainedSelf = retainPtr(self);
-    _WKElementAction *elementAction = [_WKElementAction elementActionWithTitle:action.localizedName actionHandler:^(_WKActivatedElementInfo *actionInfo) {
-        retainedSelf->_isPresentingDDUserInterface = action.hasUserInterface;
-        [[getDDDetectionControllerClass() sharedController] performAction:action fromAlertController:retainedSelf->_interactionSheet.get() interactionDelegate:retainedSelf.get()];
-    }];
-    elementAction.dismissalHandler = ^BOOL {
-        return !action.hasUserInterface;
-    };
-    return elementAction;
-#else
-    return nil;
-#endif
-}
-
 static const CGFloat presentationElementRectPadding = 15;
 
 - (CGRect)presentationRectForElementUsingClosestIndicatedRect
@@ -734,6 +717,23 @@
 
 #endif // USE(UICONTEXTMENU)
 
+#if ENABLE(DATA_DETECTION)
+
+- (_WKElementAction *)_elementActionForDDAction:(DDAction *)action
+{
+    auto retainedSelf = retainPtr(self);
+    _WKElementAction *elementAction = [_WKElementAction elementActionWithTitle:action.localizedName actionHandler:^(_WKActivatedElementInfo *actionInfo) {
+        retainedSelf->_isPresentingDDUserInterface = action.hasUserInterface;
+        [[getDDDetectionControllerClass() sharedController] performAction:action fromAlertController:retainedSelf->_interactionSheet.get() interactionDelegate:retainedSelf.get()];
+    }];
+    elementAction.dismissalHandler = ^BOOL {
+        return !action.hasUserInterface;
+    };
+    return elementAction;
+}
+
+#endif // ENABLE(DATA_DETECTION)
+
 - (void)showDataDetectorsUIForPositionInformation:(const WebKit::InteractionInformationAtPosition&)positionInformation
 {
 #if ENABLE(DATA_DETECTION)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to