Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

This test requires WebKitTestRunner. To manually test, load the page in a configuration where drag and drop is enabled by default; long press the image to show the context menu, and verify that the context menu remains visible

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS startedDrag became true
PASS previewBounds.width is >= 0
PASS previewBounds.height is >= 0
PASS successfullyParsed is true

TEST COMPLETE

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE HTML><!-- webkit-test-runner [ dragInteractionPolicy=always-enable useFlexibleViewport=true ] -->
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<style>
body, html {
margin: 0;
}
</style>
<script src="../../../resources/js-test.js"></script>
<script src="../../../resources/ui-helper.js"></script>
<script>
jsTestIsAsync = true;

addEventListener("load", async () => {
description("This test requires WebKitTestRunner. To manually test, load the page in a configuration where drag and drop is enabled by default; long press the image to show the context menu, and verify that the context menu remains visible");

startedDrag = false;

let image = document.querySelector("img");
image.addEventListener("dragstart", () => {
const startTime = Date.now();
while (true) {
if (Date.now() - startTime > 2500)
break;
}
getSelection().setPosition(document.body, 1);
startedDrag = true;
});

if (!window.testRunner)
return;

await UIHelper.longPressElement(image);
await UIHelper.waitForContextMenuToShow();
await shouldBecomeEqual("startedDrag", "true");
await UIHelper.delayFor(1000);

previewBounds = await UIHelper.contextMenuPreviewRect();
shouldBeGreaterThanOrEqual("previewBounds.width", "0");
shouldBeGreaterThanOrEqual("previewBounds.height", "0");

await UIHelper.activateAt(1, 1);
await UIHelper.waitForContextMenuToHide();

finishJSTest();
});
</script>
</head>
<body>
<img src="../resources/abe.png">
<p id="description"></p>
<p id="console"></p>
</body>
</html>
8 changes: 8 additions & 0 deletions Source/WebKit/UIProcess/ios/UIKitUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@
@property (nonatomic, readonly) BOOL _wk_isInFullscreenPresentation;
@end

#if USE(UICONTEXTMENU)

@interface UIContextMenuInteraction (WebKitInternal)
@property (nonatomic, readonly) BOOL _wk_isMenuVisible;
@end

#endif

namespace WebKit {

RetainPtr<UIAlertController> createUIAlertController(NSString *title, NSString *message);
Expand Down
18 changes: 18 additions & 0 deletions Source/WebKit/UIProcess/ios/UIKitUtilities.mm
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,24 @@ - (BOOL)_wk_hasRecognizedOrEnded

@end

#if USE(UICONTEXTMENU)

@implementation UIContextMenuInteraction (WebKitInternal)

- (BOOL)_wk_isMenuVisible
{
bool contextMenuIsVisible = false;
[self updateVisibleMenuWithBlock:makeBlockPtr([&contextMenuIsVisible](UIMenu *menu) {
contextMenuIsVisible = true;
return menu;
}).get()];
return contextMenuIsVisible;
}

@end

#endif // USE(UICONTEXTMENU)

namespace WebKit {

RetainPtr<UIAlertController> createUIAlertController(NSString *title, NSString *message)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ @interface WKContentView (UITextSelectionDisplayInteraction) <UITextSelectionDis

WKSelectionDrawingInfo::WKSelectionDrawingInfo(const EditorState& editorState)
{
if (editorState.selectionIsNone) {
if (editorState.selectionIsNone || (!editorState.selectionIsRange && !editorState.isContentEditable)) {
type = SelectionType::None;
return;
}
Expand Down
6 changes: 6 additions & 0 deletions Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#import "RemoteLayerTreeNode.h"
#import "RemoteLayerTreeViews.h"
#import "UIKitUtilities.h"
#import "WKContentViewInteraction.h"
#import <WebCore/TileController.h>
#import <wtf/TZoneMallocInlines.h>
Expand Down Expand Up @@ -296,6 +297,11 @@ - (void)willBeginDragLift
if (_hideEditMenuScope)
return;

#if USE(UICONTEXTMENU)
if (self.contextMenuInteraction._wk_isMenuVisible)
return;
#endif

_hideEditMenuScope = WTF::makeUnique<WebKit::HideEditMenuScope>(self, WebKit::DeactivateSelection::Yes);
}

Expand Down