Title: [216213] trunk/Source/WebKit2
Revision
216213
Author
wenson_hs...@apple.com
Date
2017-05-04 15:35:31 -0700 (Thu, 04 May 2017)

Log Message

[WK2] Image action sheets sometimes do not dismiss when beginning data interaction
https://bugs.webkit.org/show_bug.cgi?id=171687
<rdar://problem/31996534>

Reviewed by Beth Dakin.

When presenting an image sheet using WKActionSheetAssistant, we may present the popover asynchronously. In this
case, even if -cleanupSheet is invoked after -showImageSheet, the popover will still be presented. To fix this,
add a flag, _hasPendingActionSheet, that is set to true when an image action sheet will be presented in the
future.

In cleanupSheet, we revert this flag to NO, and in the sheet presentation block, we first check to see if there
is a pending action sheet. If there is not, then simply do not invoke the image sheet presentation block.

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

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (216212 => 216213)


--- trunk/Source/WebKit2/ChangeLog	2017-05-04 22:28:22 UTC (rev 216212)
+++ trunk/Source/WebKit2/ChangeLog	2017-05-04 22:35:31 UTC (rev 216213)
@@ -1,5 +1,25 @@
 2017-05-04  Wenson Hsieh  <wenson_hs...@apple.com>
 
+        [WK2] Image action sheets sometimes do not dismiss when beginning data interaction
+        https://bugs.webkit.org/show_bug.cgi?id=171687
+        <rdar://problem/31996534>
+
+        Reviewed by Beth Dakin.
+
+        When presenting an image sheet using WKActionSheetAssistant, we may present the popover asynchronously. In this
+        case, even if -cleanupSheet is invoked after -showImageSheet, the popover will still be presented. To fix this,
+        add a flag, _hasPendingActionSheet, that is set to true when an image action sheet will be presented in the
+        future.
+
+        In cleanupSheet, we revert this flag to NO, and in the sheet presentation block, we first check to see if there
+        is a pending action sheet. If there is not, then simply do not invoke the image sheet presentation block.
+
+        * UIProcess/ios/WKActionSheetAssistant.mm:
+        (-[WKActionSheetAssistant showImageSheet]):
+        (-[WKActionSheetAssistant cleanupSheet]):
+
+2017-05-04  Wenson Hsieh  <wenson_hs...@apple.com>
+
         [WK2] Add support for keeping the selection in a focused editable element when dragging begins
         https://bugs.webkit.org/show_bug.cgi?id=171585
         <rdar://problem/31544320>

Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm (216212 => 216213)


--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm	2017-05-04 22:28:22 UTC (rev 216212)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm	2017-05-04 22:35:31 UTC (rev 216213)
@@ -91,6 +91,7 @@
     UIView *_view;
     BOOL _needsLinkIndicator;
     BOOL _isPresentingDDUserInterface;
+    BOOL _hasPendingActionSheet;
 }
 
 - (id <WKActionSheetAssistantDelegate>)delegate
@@ -365,7 +366,13 @@
     if (positionInformation.url.isEmpty() && positionInformation.image && [delegate respondsToSelector:@selector(actionSheetAssistant:getAlternateURLForImage:completion:)]) {
         RetainPtr<UIImage> uiImage = adoptNS([[UIImage alloc] initWithCGImage:positionInformation.image->makeCGImageCopy().get()]);
 
+        _hasPendingActionSheet = YES;
+        RetainPtr<WKActionSheetAssistant> retainedSelf(self);
         [delegate actionSheetAssistant:self getAlternateURLForImage:uiImage.get() completion:^(NSURL *alternateURL, NSDictionary *userInfo) {
+            if (!retainedSelf->_hasPendingActionSheet)
+                return;
+
+            retainedSelf->_hasPendingActionSheet = NO;
             showImageSheetWithAlternateURLBlock(alternateURL, userInfo);
         }];
         return;
@@ -597,6 +604,7 @@
     _elementInfo = nil;
     _needsLinkIndicator = NO;
     _isPresentingDDUserInterface = NO;
+    _hasPendingActionSheet = NO;
 }
 
 @end
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to