[WK2] Action sheet should not dismiss when a DDAction with user interface is being...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Feb 2017 21:43:41 +0000 (21:43 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Feb 2017 21:43:41 +0000 (21:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168528
<rdar://problem/30515324>

Reviewed by Beth Dakin.

After r211643, -[WKActionSheet doneWithSheet] now dismisses the presenting view controller. This is called when
interaction with the sheet is finished and is a reasonable thing to do in most cases. However, when using data
detectors, we don't want to dismiss the presenting view controller, since DataDetector handles dismissing on its
own and expects that its completion handler will be invoked.

To fix this, we add a parameter to doneWithSheet: to indicate whether or not we should additionally dismiss the
presenting view controller, and pass in NO in the case where we are handing control over to DataDetector.

* UIProcess/ios/WKActionSheet.h:
* UIProcess/ios/WKActionSheet.mm:
(-[WKActionSheet doneWithSheet:]):
(-[WKActionSheet doneWithSheet]): Deleted.
* UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant showDataDetectorsSheet]):
(-[WKActionSheetAssistant cleanupSheet]):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/ios/WKActionSheet.h
Source/WebKit2/UIProcess/ios/WKActionSheet.mm
Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm

index 062174b..09ce4c7 100644 (file)
@@ -1,3 +1,27 @@
+2017-02-17  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [WK2] Action sheet should not dismiss when a DDAction with user interface is being presented
+        https://bugs.webkit.org/show_bug.cgi?id=168528
+        <rdar://problem/30515324>
+
+        Reviewed by Beth Dakin.
+
+        After r211643, -[WKActionSheet doneWithSheet] now dismisses the presenting view controller. This is called when
+        interaction with the sheet is finished and is a reasonable thing to do in most cases. However, when using data
+        detectors, we don't want to dismiss the presenting view controller, since DataDetector handles dismissing on its
+        own and expects that its completion handler will be invoked.
+
+        To fix this, we add a parameter to doneWithSheet: to indicate whether or not we should additionally dismiss the
+        presenting view controller, and pass in NO in the case where we are handing control over to DataDetector.
+
+        * UIProcess/ios/WKActionSheet.h:
+        * UIProcess/ios/WKActionSheet.mm:
+        (-[WKActionSheet doneWithSheet:]):
+        (-[WKActionSheet doneWithSheet]): Deleted.
+        * UIProcess/ios/WKActionSheetAssistant.mm:
+        (-[WKActionSheetAssistant showDataDetectorsSheet]):
+        (-[WKActionSheetAssistant cleanupSheet]):
+
 2017-02-17  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Remove EFL from WebKit2
index e3ba884..c2e00dd 100644 (file)
@@ -41,7 +41,7 @@ typedef NS_ENUM(NSInteger, WKActionSheetPresentationStyle) {
 
 @property (nonatomic, assign) id <WKActionSheetDelegate> sheetDelegate;
 @property (nonatomic) UIPopoverArrowDirection arrowDirections;
-- (void)doneWithSheet;
+- (void)doneWithSheet:(BOOL)dismiss;
 - (BOOL)presentSheet:(WKActionSheetPresentationStyle)style;
 - (BOOL)presentSheetFromRect:(CGRect)presentationRect;
 - (void)updateSheetPosition;
index 90d0756..6fb2957 100644 (file)
     return YES;
 }
 
-- (void)doneWithSheet
+- (void)doneWithSheet:(BOOL)dismiss
 {
-    if (_currentPresentingViewController)
+    if (dismiss && _currentPresentingViewController)
         [_currentPresentingViewController dismissViewControllerAnimated:YES completion:nil];
 
     _currentPresentingViewController = nil;
index 71e398d..1189ddd 100644 (file)
@@ -90,6 +90,7 @@ static LSAppLink *appLinkForURL(NSURL *url)
     RetainPtr<_WKActivatedElementInfo> _elementInfo;
     UIView *_view;
     BOOL _needsLinkIndicator;
+    BOOL _isPresentingDDUserInterface;
 }
 
 - (id <WKActionSheetAssistantDelegate>)delegate
@@ -545,10 +546,10 @@ static const CGFloat presentationElementRectPadding = 15;
     NSMutableArray *elementActions = [NSMutableArray array];
     for (NSUInteger actionNumber = 0; actionNumber < [dataDetectorsActions count]; actionNumber++) {
         DDAction *action = [dataDetectorsActions objectAtIndex:actionNumber];
+        RetainPtr<WKActionSheetAssistant> retainedSelf = self;
         _WKElementAction *elementAction = [_WKElementAction elementActionWithTitle:[action localizedName] actionHandler:^(_WKActivatedElementInfo *actionInfo) {
-            [[getDDDetectionControllerClass() sharedController] performAction:action
-                                                          fromAlertController:_interactionSheet.get()
-                                                          interactionDelegate:self];
+            retainedSelf.get()->_isPresentingDDUserInterface = action.hasUserInterface;
+            [[getDDDetectionControllerClass() sharedController] performAction:action fromAlertController:retainedSelf.get()->_interactionSheet.get() interactionDelegate:retainedSelf.get()];
         }];
         elementAction.dismissalHandler = ^{
             return (BOOL)!action.hasUserInterface;
@@ -573,11 +574,12 @@ static const CGFloat presentationElementRectPadding = 15;
     if ([delegate respondsToSelector:@selector(actionSheetAssistantDidStopInteraction:)])
         [delegate actionSheetAssistantDidStopInteraction:self];
 
-    [_interactionSheet doneWithSheet];
+    [_interactionSheet doneWithSheet:!_isPresentingDDUserInterface];
     [_interactionSheet setSheetDelegate:nil];
     _interactionSheet = nil;
     _elementInfo = nil;
     _needsLinkIndicator = NO;
+    _isPresentingDDUserInterface = NO;
 }
 
 @end