Title: [212574] trunk/Source/WebKit2
Revision
212574
Author
wenson_hs...@apple.com
Date
2017-02-17 13:43:41 -0800 (Fri, 17 Feb 2017)

Log Message

[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]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (212573 => 212574)


--- trunk/Source/WebKit2/ChangeLog	2017-02-17 21:40:37 UTC (rev 212573)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-17 21:43:41 UTC (rev 212574)
@@ -1,3 +1,27 @@
+2017-02-17  Wenson Hsieh  <wenson_hs...@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  <mcatanz...@igalia.com>
 
         Remove EFL from WebKit2

Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.h (212573 => 212574)


--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.h	2017-02-17 21:40:37 UTC (rev 212573)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.h	2017-02-17 21:43:41 UTC (rev 212574)
@@ -41,7 +41,7 @@
 
 @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;

Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.mm (212573 => 212574)


--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.mm	2017-02-17 21:40:37 UTC (rev 212573)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.mm	2017-02-17 21:43:41 UTC (rev 212574)
@@ -119,9 +119,9 @@
     return YES;
 }
 
-- (void)doneWithSheet
+- (void)doneWithSheet:(BOOL)dismiss
 {
-    if (_currentPresentingViewController)
+    if (dismiss && _currentPresentingViewController)
         [_currentPresentingViewController dismissViewControllerAnimated:YES completion:nil];
 
     _currentPresentingViewController = nil;

Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm (212573 => 212574)


--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm	2017-02-17 21:40:37 UTC (rev 212573)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm	2017-02-17 21:43:41 UTC (rev 212574)
@@ -90,6 +90,7 @@
     RetainPtr<_WKActivatedElementInfo> _elementInfo;
     UIView *_view;
     BOOL _needsLinkIndicator;
+    BOOL _isPresentingDDUserInterface;
 }
 
 - (id <WKActionSheetAssistantDelegate>)delegate
@@ -545,10 +546,10 @@
     NSMutableArray *elementActions = [NSMutableArray array];
     for (NSUInteger actionNumber = 0; actionNumber < [dataDetectorsActions count]; actionNumber++) {
         DDAction *action = "" 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 @@
     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
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to