Title: [261303] trunk/Source/WebKit
Revision
261303
Author
[email protected]
Date
2020-05-07 10:17:25 -0700 (Thu, 07 May 2020)

Log Message

ContextMenu: entire webpage pops and disappears to generate preview of embedded image
https://bugs.webkit.org/show_bug.cgi?id=211272
<rdar://problem/62482013>

Reviewed by Tim Horton.

The ActionSheetAssistant is always around, so using the presence of one
to determine if we need to remove the _contextMenuHintContainerView is incorrect
and causes it to be around on the next invocation of the context menu, and
causing the failure of the creation of a new preview, which then will default to
popping the whole page. We need to ask the ActionSheetAssistant if it is actively showing
anything, and then correctly clean up the _contextMenuHintContainerView after the
end of the interactions for FileUploadMenu and ActionSheetAssistant are done with their
interactions.

* UIProcess/ios/WKActionSheetAssistant.h:
* UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant removeContextMenuInteraction]):
(-[WKActionSheetAssistant hasContextMenuInteraction]):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView removeContextMenuViewIfPossibleForActionSheetAssistant:]):
(-[WKContentView _canRemoveContextMenuView]):
(-[WKContentView _removeContextMenuViewIfPossible]):
(-[WKContentView contextMenuInteraction:willEndForConfiguration:animator:]):
* UIProcess/ios/forms/WKFileUploadPanel.mm:
(-[WKFileUploadPanel removeContextMenuInteraction]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (261302 => 261303)


--- trunk/Source/WebKit/ChangeLog	2020-05-07 17:14:01 UTC (rev 261302)
+++ trunk/Source/WebKit/ChangeLog	2020-05-07 17:17:25 UTC (rev 261303)
@@ -1,3 +1,33 @@
+2020-05-07  Megan Gardner  <[email protected]>
+
+        ContextMenu: entire webpage pops and disappears to generate preview of embedded image
+        https://bugs.webkit.org/show_bug.cgi?id=211272
+        <rdar://problem/62482013>
+
+        Reviewed by Tim Horton.
+
+        The ActionSheetAssistant is always around, so using the presence of one
+        to determine if we need to remove the _contextMenuHintContainerView is incorrect
+        and causes it to be around on the next invocation of the context menu, and 
+        causing the failure of the creation of a new preview, which then will default to
+        popping the whole page. We need to ask the ActionSheetAssistant if it is actively showing
+        anything, and then correctly clean up the _contextMenuHintContainerView after the 
+        end of the interactions for FileUploadMenu and ActionSheetAssistant are done with their
+        interactions. 
+
+        * UIProcess/ios/WKActionSheetAssistant.h:
+        * UIProcess/ios/WKActionSheetAssistant.mm:
+        (-[WKActionSheetAssistant removeContextMenuInteraction]):
+        (-[WKActionSheetAssistant hasContextMenuInteraction]):
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView removeContextMenuViewIfPossibleForActionSheetAssistant:]):
+        (-[WKContentView _canRemoveContextMenuView]):
+        (-[WKContentView _removeContextMenuViewIfPossible]):
+        (-[WKContentView contextMenuInteraction:willEndForConfiguration:animator:]):
+        * UIProcess/ios/forms/WKFileUploadPanel.mm:
+        (-[WKFileUploadPanel removeContextMenuInteraction]):
+
 2020-05-07  Chris Dumez  <[email protected]>
 
         Simplify several IPC sending call sites in the UIProcess

Modified: trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h (261302 => 261303)


--- trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h	2020-05-07 17:14:01 UTC (rev 261302)
+++ trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h	2020-05-07 17:17:25 UTC (rev 261303)
@@ -66,6 +66,7 @@
 - (CGPoint)contextMenuPresentationLocationForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
 #if USE(UICONTEXTMENU)
 - (UITargetedPreview *)createTargetedContextMenuHintForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
+- (void)removeContextMenuViewIfPossibleForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
 #endif
 
 @end
@@ -72,6 +73,7 @@
 
 #if ENABLE(DATA_DETECTION) && USE(UICONTEXTMENU)
 @interface WKActionSheetAssistant : NSObject <WKActionSheetDelegate, DDDetectionControllerInteractionDelegate, UIContextMenuInteractionDelegate>
+- (BOOL)hasContextMenuInteraction;
 #else
 @interface WKActionSheetAssistant : NSObject <WKActionSheetDelegate>
 #endif

Modified: trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm (261302 => 261303)


--- trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm	2020-05-07 17:14:01 UTC (rev 261302)
+++ trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm	2020-05-07 17:17:25 UTC (rev 261303)
@@ -641,6 +641,8 @@
     if (_dataDetectorContextMenuInteraction) {
         [_view removeInteraction:_dataDetectorContextMenuInteraction.get()];
         _dataDetectorContextMenuInteraction = nil;
+        if ([_delegate respondsToSelector:@selector(removeContextMenuViewIfPossibleForActionSheetAssistant:)])
+            return [_delegate removeContextMenuViewIfPossibleForActionSheetAssistant:self];
     }
 }
 
@@ -651,6 +653,11 @@
         [_view addInteraction:_dataDetectorContextMenuInteraction.get()];
     }
 }
+
+- (BOOL)hasContextMenuInteraction
+{
+    return !!_dataDetectorContextMenuInteraction;
+}
 #endif
 
 - (void)showDataDetectorsSheet

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (261302 => 261303)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2020-05-07 17:14:01 UTC (rev 261302)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2020-05-07 17:17:25 UTC (rev 261303)
@@ -594,6 +594,7 @@
 
 #if USE(UICONTEXTMENU)
 - (UITargetedPreview *)_createTargetedContextMenuHintPreviewIfPossible;
+- (void)_removeContextMenuViewIfPossible;
 #endif
 
 @end

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (261302 => 261303)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-05-07 17:14:01 UTC (rev 261302)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-05-07 17:17:25 UTC (rev 261303)
@@ -6966,6 +6966,11 @@
     return [self _createTargetedContextMenuHintPreviewIfPossible];
 }
 
+- (void)removeContextMenuViewIfPossibleForActionSheetAssistant:(WKActionSheetAssistant *)assistant
+{
+    [self _removeContextMenuViewIfPossible];
+}
+
 #endif // USE(UICONTEXTMENU)
 
 - (BOOL)_shouldUseContextMenus
@@ -7669,6 +7674,21 @@
     return _contextMenuInteractionTargetedPreview.get();
 }
 
+- (void)_removeContextMenuViewIfPossible
+{
+    // If a new _contextMenuElementInfo is installed, we've started another interaction,
+    // and removing the hint container view will cause the animation to break.
+    if (_contextMenuElementInfo)
+        return;
+    // We are also using this container for the file upload panel...
+    if (_fileUploadPanel)
+        return;
+    // and the action sheet assistant.
+    if ([_actionSheetAssistant hasContextMenuInteraction])
+        return;
+    [std::exchange(_contextMenuHintContainerView, nil) removeFromSuperview];
+}
+
 #endif // USE(UICONTEXTMENU)
 
 #if HAVE(UI_WK_DOCUMENT_CONTEXT)
@@ -9363,17 +9383,7 @@
         auto strongSelf = weakSelf.get();
         if (!strongSelf)
             return;
-        // If a new _contextMenuElementInfo is installed, we've started another interaction,
-        // and removing the hint container view will cause the animation to break.
-        if (strongSelf->_contextMenuElementInfo)
-            return;
-        // We are also using this container for the file upload panel...
-        if (strongSelf->_fileUploadPanel)
-            return;
-        // and the action sheet assistant.
-        if (strongSelf->_actionSheetAssistant)
-            return;
-        [std::exchange(strongSelf->_contextMenuHintContainerView, nil) removeFromSuperview];
+        [strongSelf _removeContextMenuViewIfPossible];
     }];
 }
 

Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm (261302 => 261303)


--- trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm	2020-05-07 17:14:01 UTC (rev 261302)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm	2020-05-07 17:17:25 UTC (rev 261303)
@@ -475,6 +475,7 @@
     if (_documentContextMenuInteraction) {
         [_view removeInteraction:_documentContextMenuInteraction.get()];
         _documentContextMenuInteraction = nil;
+        [_view _removeContextMenuViewIfPossible];
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to