[iOS DnD] Elements in the DOM with the `draggable` attribute should be draggable
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Sep 2017 19:06:00 +0000 (19:06 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Sep 2017 19:06:00 +0000 (19:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=176664
<rdar://problem/32596156>

Reviewed by Tim Horton.

Source/WebKit:

Makes a simple adjustment in DragDropInteractionState::previewForDragItem to respect the drag image supplied to
the UI process during a "DHTML"-defined drag (i.e. DragSourceActionDHTML).

Test: DataInteractionTests.CanStartDragOnDivWithDraggableAttribute

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _simulateDataInteractionEntered:]): Deleted.
(-[WKWebView _simulateDataInteractionUpdated:]): Deleted.
(-[WKWebView _simulateDataInteractionPerformOperation:]): Deleted.
(-[WKWebView _simulateDataInteractionEnded:]): Deleted.
(-[WKWebView _simulateDataInteractionSessionDidEnd:]): Deleted.
(-[WKWebView _simulateWillBeginDataInteractionWithSession:]): Deleted.
(-[WKWebView _simulatedItemsForSession:]): Deleted.
(-[WKWebView _simulateItemsForAddingToSession:atLocation:completion:]): Deleted.
(-[WKWebView _simulatePrepareForDataInteractionSession:completion:]): Deleted.

Remove all -_simulate*: testing helpers on WKWebView.

* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/ios/DragDropInteractionState.mm:
(WebKit::shouldUseDragImageToCreatePreviewForDragSource):
(WebKit::shouldUseTextIndicatorToCreatePreviewForDragSource):

Add shouldUseDragImageToCreatePreviewForDragSource, which returns YES when dragging an image or DHTML-defined
draggable element and the drag image exists. This is called from previewForDragItem when constructing the drag
preview for a given UIDragItem.

(WebKit::DragDropInteractionState::previewForDragItem const):
(WebKit::shouldUseTextIndicatorToCreatePreviewForDragAction): Deleted.
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _simulateDataInteractionEntered:]): Deleted.
(-[WKContentView _simulateDataInteractionUpdated:]): Deleted.
(-[WKContentView _simulateDataInteractionEnded:]): Deleted.
(-[WKContentView _simulateDataInteractionPerformOperation:]): Deleted.
(-[WKContentView _simulateDataInteractionSessionDidEnd:]): Deleted.
(-[WKContentView _simulateWillBeginDataInteractionWithSession:]): Deleted.
(-[WKContentView _simulatedItemsForSession:]): Deleted.
(-[WKContentView _simulatePrepareForDataInteractionSession:completion:]): Deleted.
(-[WKContentView _simulateItemsForAddingToSession:atLocation:completion:]): Deleted.

Remove all -_simulate*: testing helpers on WKContentView.

Tools:

Adds a new API test checking that elements marked as drag sources via the `draggable` attribute can be dragged
with a non-null drag preview. Additionally, refactor the drag and drop simulator to not plumb drag/drop
interaction delegate calls through to the WKContentView via -_simulate*-prefixed testing SPI, but rather
by grabbing the WKWebView's drag and drop interaction delegates (i.e. the WKContentView) and calling delegate
methods directly. This avoids requiring boilerplate plumbing on WKWebView and WKContentView for each of the drag
and drop delegate methods, so these have been removed from WKWebView and WKContentView.

Additionally, renames MockDataOperationSession and MockDataInteractionSession to MockDragSession and
MockDropSession, respectively, and adjusts their ivars on DataInteractionSimulator to match.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/custom-draggable-div.html: Added.

Add a new test harness covering dragging and dropping elements with the draggable attribute, using DataTransfer
API (setData and getData) as well.

* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/ios/DataInteractionSimulator.h:
* TestWebKitAPI/ios/DataInteractionSimulator.mm:
(-[WKWebView dropInteractionDelegate]):
(-[WKWebView dragInteractionDelegate]):
(-[WKWebView dropInteraction]):
(-[WKWebView dragInteraction]):

Add testing utilities to ask a WKWebView for information about its drag/drop interactions and delegates. In this
case, this will return the WKWebView's WKContentView.

(-[DataInteractionSimulator _resetSimulatedState]):
(-[DataInteractionSimulator simulateAllTouchesCanceled:]):
(-[DataInteractionSimulator runFrom:to:additionalItemRequestLocations:]):
(-[DataInteractionSimulator _concludeDataInteractionAndPerformOperationIfNecessary]):
(-[DataInteractionSimulator _sendQueuedAdditionalItemRequest]):
(-[DataInteractionSimulator _advanceProgress]):

When beginning a drag session, ask the delegate for targeted lift previews and verify that these are non-null.
This check would fail prior to the tweak in DragDropInteractionState in this patch.

(-[DataInteractionSimulator _webView:showCustomSheetForElement:]):
(-[MockDataOperationSession initWithProviders:location:window:allowMove:]): Deleted.
(-[MockDataOperationSession session]): Deleted.
(-[MockDataOperationSession isLocal]): Deleted.
(-[MockDataOperationSession progress]): Deleted.
(-[MockDataOperationSession setProgressIndicatorStyle:]): Deleted.
(-[MockDataOperationSession progressIndicatorStyle]): Deleted.
(-[MockDataOperationSession operationMask]): Deleted.
(-[MockDataOperationSession localDragSession]): Deleted.
(-[MockDataOperationSession hasItemsConformingToTypeIdentifier:]): Deleted.
(-[MockDataOperationSession canCreateItemsOfClass:]): Deleted.
(-[MockDataOperationSession loadObjectsOfClass:completion:]): Deleted.
(-[MockDataInteractionSession initWithWindow:allowMove:]): Deleted.
(-[MockDataInteractionSession localOperationMask]): Deleted.
(-[MockDataInteractionSession externalOperationMask]): Deleted.

Replace various places where we called -_simulate* methods on WKWebView with calls to the
UIDragInteractionDelegate or UIDropInteractionDelegate (the WKContentView) instead. Also, adjust for some
mechanical renaming of drag and drop sessions.

(-[MockDataInteractionSession session]): Deleted.
* TestWebKitAPI/ios/UIKitSPI.h:

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

13 files changed:
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/ios/DragDropInteractionState.mm
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/custom-draggable-div.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm
Tools/TestWebKitAPI/ios/DataInteractionSimulator.h
Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm
Tools/TestWebKitAPI/ios/UIKitSPI.h

index e5a1854542a6e690af1f9dc84c72c6668703e7ef..de41a9d32fe215aa58699b151ee08102d2ed9025 100644 (file)
@@ -1,3 +1,54 @@
+2017-09-11  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS DnD] Elements in the DOM with the `draggable` attribute should be draggable
+        https://bugs.webkit.org/show_bug.cgi?id=176664
+        <rdar://problem/32596156>
+
+        Reviewed by Tim Horton.
+
+        Makes a simple adjustment in DragDropInteractionState::previewForDragItem to respect the drag image supplied to
+        the UI process during a "DHTML"-defined drag (i.e. DragSourceActionDHTML).
+
+        Test: DataInteractionTests.CanStartDragOnDivWithDraggableAttribute
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _simulateDataInteractionEntered:]): Deleted.
+        (-[WKWebView _simulateDataInteractionUpdated:]): Deleted.
+        (-[WKWebView _simulateDataInteractionPerformOperation:]): Deleted.
+        (-[WKWebView _simulateDataInteractionEnded:]): Deleted.
+        (-[WKWebView _simulateDataInteractionSessionDidEnd:]): Deleted.
+        (-[WKWebView _simulateWillBeginDataInteractionWithSession:]): Deleted.
+        (-[WKWebView _simulatedItemsForSession:]): Deleted.
+        (-[WKWebView _simulateItemsForAddingToSession:atLocation:completion:]): Deleted.
+        (-[WKWebView _simulatePrepareForDataInteractionSession:completion:]): Deleted.
+
+        Remove all -_simulate*: testing helpers on WKWebView.
+
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/ios/DragDropInteractionState.mm:
+        (WebKit::shouldUseDragImageToCreatePreviewForDragSource):
+        (WebKit::shouldUseTextIndicatorToCreatePreviewForDragSource):
+
+        Add shouldUseDragImageToCreatePreviewForDragSource, which returns YES when dragging an image or DHTML-defined
+        draggable element and the drag image exists. This is called from previewForDragItem when constructing the drag
+        preview for a given UIDragItem.
+
+        (WebKit::DragDropInteractionState::previewForDragItem const):
+        (WebKit::shouldUseTextIndicatorToCreatePreviewForDragAction): Deleted.
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _simulateDataInteractionEntered:]): Deleted.
+        (-[WKContentView _simulateDataInteractionUpdated:]): Deleted.
+        (-[WKContentView _simulateDataInteractionEnded:]): Deleted.
+        (-[WKContentView _simulateDataInteractionPerformOperation:]): Deleted.
+        (-[WKContentView _simulateDataInteractionSessionDidEnd:]): Deleted.
+        (-[WKContentView _simulateWillBeginDataInteractionWithSession:]): Deleted.
+        (-[WKContentView _simulatedItemsForSession:]): Deleted.
+        (-[WKContentView _simulatePrepareForDataInteractionSession:completion:]): Deleted.
+        (-[WKContentView _simulateItemsForAddingToSession:atLocation:completion:]): Deleted.
+
+        Remove all -_simulate*: testing helpers on WKContentView.
+
 2017-09-11  Alex Christensen  <achristensen@webkit.org>
 
         Modernize BoxExtent into RectEdges
index c30a6774b37cd5356731110c4c26da610c6a942e..4caf6635a3fed2c2f4eda99ca0c8ae23d7016d1d 100644 (file)
@@ -5793,73 +5793,6 @@ static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISe
 
 #if PLATFORM(IOS)
 
-- (void)_simulateDataInteractionEntered:(id)info
-{
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulateDataInteractionEntered:info];
-#endif
-}
-
-- (NSUInteger)_simulateDataInteractionUpdated:(id)info
-{
-#if ENABLE(DATA_INTERACTION)
-    return [_contentView _simulateDataInteractionUpdated:info];
-#else
-    return 0;
-#endif
-}
-
-- (void)_simulateDataInteractionPerformOperation:(id)info
-{
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulateDataInteractionPerformOperation:info];
-#endif
-}
-
-- (void)_simulateDataInteractionEnded:(id)info
-{
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulateDataInteractionEnded:info];
-#endif
-}
-
-- (void)_simulateDataInteractionSessionDidEnd:(id)session
-{
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulateDataInteractionSessionDidEnd:session];
-#endif
-}
-
-- (void)_simulateWillBeginDataInteractionWithSession:(id)session
-{
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulateWillBeginDataInteractionWithSession:session];
-#endif
-}
-
-- (NSArray *)_simulatedItemsForSession:(id)session
-{
-#if ENABLE(DATA_INTERACTION)
-    return [_contentView _simulatedItemsForSession:session];
-#else
-    return @[ ];
-#endif
-}
-
-- (void)_simulateItemsForAddingToSession:(id)session atLocation:(CGPoint)location completion:(void(^)(NSArray *))completion
-{
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulateItemsForAddingToSession:session atLocation:location completion:completion];
-#endif
-}
-
-- (void)_simulatePrepareForDataInteractionSession:(id)session completion:(dispatch_block_t)completion
-{
-#if ENABLE(DATA_INTERACTION)
-    [_contentView _simulatePrepareForDataInteractionSession:session completion:completion];
-#endif
-}
-
 - (CGRect)_dragCaretRect
 {
 #if ENABLE(DRAG_SUPPORT)
index 840bec73a4e332a9e7e91c694d6f2eda646f74a4..c6c3bcbc323a4c9abad1819ab45a2278e302f4d4 100644 (file)
@@ -378,16 +378,6 @@ typedef NS_OPTIONS(NSInteger, _WKRectEdge) {
 @property (nonatomic, readonly) NSNumber *_stableStateOverride WK_API_AVAILABLE(ios(10.3));
 
 - (NSDictionary *)_propertiesOfLayerWithID:(unsigned long long)layerID WK_API_AVAILABLE(ios(WK_IOS_TBA));
-
-- (void)_simulateDataInteractionEntered:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
-- (NSUInteger)_simulateDataInteractionUpdated:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
-- (void)_simulateDataInteractionPerformOperation:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
-- (void)_simulateDataInteractionEnded:(id)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
-- (void)_simulateDataInteractionSessionDidEnd:(id)session WK_API_AVAILABLE(ios(WK_IOS_TBA));
-- (void)_simulateWillBeginDataInteractionWithSession:(id)session WK_API_AVAILABLE(ios(WK_IOS_TBA));
-- (NSArray *)_simulatedItemsForSession:(id)session WK_API_AVAILABLE(ios(WK_IOS_TBA));
-- (void)_simulateItemsForAddingToSession:(id)session atLocation:(CGPoint)location completion:(void(^)(NSArray *))completion WK_API_AVAILABLE(ios(WK_IOS_TBA));
-- (void)_simulatePrepareForDataInteractionSession:(id)session completion:(dispatch_block_t)completion WK_API_AVAILABLE(ios(WK_IOS_TBA));
 - (void)_simulateLongPressActionAtLocation:(CGPoint)location;
 
 @property (nonatomic, readonly) CGRect _dragCaretRect WK_API_AVAILABLE(ios(WK_IOS_TBA));
index e52dba995bd5ba1a887f3ae4f88f916d429318b5..cd30d2bfaf781b2f81fd4e4da168e22da26aedda 100644 (file)
@@ -94,13 +94,24 @@ static RetainPtr<UIImage> uiImageForImage(Image* image)
     return adoptNS([[UIImage alloc] initWithCGImage:cgImage.get()]);
 }
 
-static bool shouldUseTextIndicatorToCreatePreviewForDragAction(DragSourceAction action)
+static bool shouldUseDragImageToCreatePreviewForDragSource(const DragSourceState& source)
 {
-    if (action & (DragSourceActionLink | DragSourceActionSelection))
+    if (!source.image)
+        return false;
+
+    return source.action & (DragSourceActionDHTML | DragSourceActionImage);
+}
+
+static bool shouldUseTextIndicatorToCreatePreviewForDragSource(const DragSourceState& source)
+{
+    if (!source.indicatorData)
+        return false;
+
+    if (source.action & (DragSourceActionLink | DragSourceActionSelection))
         return true;
 
 #if ENABLE(ATTACHMENT_ELEMENT)
-    if (action & DragSourceActionAttachment)
+    if (source.action & DragSourceActionAttachment)
         return true;
 #endif
 
@@ -148,12 +159,12 @@ UITargetedDragPreview *DragDropInteractionState::previewForDragItem(UIDragItem *
         return nil;
 
     auto& source = foundSource.value();
-    if ((source.action & DragSourceActionImage) && source.image) {
+    if (shouldUseDragImageToCreatePreviewForDragSource(source)) {
         Vector<FloatRect> emptyClippingRects;
         return createTargetedDragPreview(source.image.get(), contentView, previewContainer, source.elementBounds, emptyClippingRects, nil);
     }
 
-    if (shouldUseTextIndicatorToCreatePreviewForDragAction(source.action) && source.indicatorData) {
+    if (shouldUseTextIndicatorToCreatePreviewForDragSource(source)) {
         auto indicator = source.indicatorData.value();
         auto textIndicatorImage = uiImageForImage(indicator.contentImage.get());
         return createTargetedDragPreview(textIndicatorImage.get(), contentView, previewContainer, indicator.textBoundingRectInRootViewCoordinates, indicator.textRectsInBoundingRectCoordinates, [UIColor colorWithCGColor:cachedCGColor(indicator.estimatedBackgroundColor)]);
index 7df9bd2618ced5b2615cab559b939f6b8fdafb0f..6d7b1a12f331f556e0208f88cd2447fa82050770 100644 (file)
@@ -325,24 +325,13 @@ FOR_EACH_WKCONTENTVIEW_ACTION(DECLARE_WKCONTENTVIEW_ACTION_FOR_WEB_VIEW)
 - (void)_startDrag:(RetainPtr<CGImageRef>)image item:(const WebCore::DragItem&)item;
 - (void)_didConcludeEditDataInteraction:(std::optional<WebCore::TextIndicatorData>)data;
 - (void)_didChangeDataInteractionCaretRect:(CGRect)previousRect currentRect:(CGRect)rect;
-
-- (void)_simulateDataInteractionEntered:(id)info;
-- (NSUInteger)_simulateDataInteractionUpdated:(id)info;
-- (void)_simulateDataInteractionPerformOperation:(id)info;
-- (void)_simulateDataInteractionEnded:(id)info;
-- (void)_simulateDataInteractionSessionDidEnd:(id)session;
-- (void)_simulateWillBeginDataInteractionWithSession:(id)session;
-- (NSArray *)_simulatedItemsForSession:(id)session;
-- (void)_simulatePrepareForDataInteractionSession:(id)session completion:(dispatch_block_t)completion;
-- (void)_simulateItemsForAddingToSession:(id)session atLocation:(CGPoint)location completion:(void(^)(NSArray *))completion;
 #endif
 
-- (void)_simulateLongPressActionAtLocation:(CGPoint)location;
-
 @end
 
 @interface WKContentView (WKTesting)
 
+- (void)_simulateLongPressActionAtLocation:(CGPoint)location;
 - (void)selectFormAccessoryPickerRow:(NSInteger)rowIndex;
 - (NSDictionary *)_contentsOfUserInterfaceItem:(NSString *)userInterfaceItem;
 
index 1063ee28dfa994b910a413a0783d488b83913748..0f9d21c178167a66ceeb500896c0659469591721 100644 (file)
@@ -4823,54 +4823,11 @@ static NSArray<UIItemProvider *> *extractItemProvidersFromDropSession(id <UIDrop
     _page->dragEnded(roundedIntPoint(client), roundedIntPoint(global), DragOperationNone);
 }
 
-#pragma mark - Unit testing support
-
-- (void)_simulateDataInteractionEntered:(id)session
-{
-    [self dropInteraction:_dropInteraction.get() sessionDidEnter:session];
-}
-
-- (NSUInteger)_simulateDataInteractionUpdated:(id)session
-{
-    return [self dropInteraction:_dropInteraction.get() sessionDidUpdate:session].operation;
-}
-
-- (void)_simulateDataInteractionEnded:(id)session
-{
-    [self dropInteraction:_dropInteraction.get() sessionDidEnd:session];
-}
-
-- (void)_simulateDataInteractionPerformOperation:(id)session
-{
-    [self dropInteraction:_dropInteraction.get() performDrop:session];
-}
-
-- (void)_simulateDataInteractionSessionDidEnd:(id)session
-{
-    [self dragInteraction:_dragInteraction.get() session:session didEndWithOperation:UIDropOperationCopy];
-}
-
-- (void)_simulateWillBeginDataInteractionWithSession:(id)session
-{
-    [self dragInteraction:_dragInteraction.get() sessionWillBegin:session];
-}
-
-- (NSArray *)_simulatedItemsForSession:(id)session
-{
-    return [self dragInteraction:_dragInteraction.get() itemsForBeginningSession:session];
-}
-
-- (void)_simulatePrepareForDataInteractionSession:(id)session completion:(dispatch_block_t)completion
-{
-    [self _dragInteraction:_dragInteraction.get() prepareForSession:session completion:completion];
-}
+#endif
 
-- (void)_simulateItemsForAddingToSession:(id)session atLocation:(CGPoint)location completion:(void(^)(NSArray *))completion
-{
-    [self _dragInteraction:_dragInteraction.get() itemsForAddingToSession:session withTouchAtPoint:location completion:completion];
-}
+@end
 
-#endif
+@implementation WKContentView (WKTesting)
 
 - (void)_simulateLongPressActionAtLocation:(CGPoint)location
 {
@@ -4881,10 +4838,6 @@ static NSArray<UIItemProvider *> *extractItemProvidersFromDropSession(id <UIDrop
     } forRequest:InteractionInformationRequest(roundedIntPoint(location))];
 }
 
-@end
-
-@implementation WKContentView (WKTesting)
-
 - (void)selectFormAccessoryPickerRow:(NSInteger)rowIndex
 {
     if ([_inputPeripheral isKindOfClass:[WKFormSelectControl self]])
index e19be5a6050911691cdca7dcbc48c841eeca4292..35afa9e69953e25df9c81dff3aa81875885a9d22 100644 (file)
@@ -1,3 +1,72 @@
+2017-09-11  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS DnD] Elements in the DOM with the `draggable` attribute should be draggable
+        https://bugs.webkit.org/show_bug.cgi?id=176664
+        <rdar://problem/32596156>
+
+        Reviewed by Tim Horton.
+
+        Adds a new API test checking that elements marked as drag sources via the `draggable` attribute can be dragged
+        with a non-null drag preview. Additionally, refactor the drag and drop simulator to not plumb drag/drop
+        interaction delegate calls through to the WKContentView via -_simulate*-prefixed testing SPI, but rather
+        by grabbing the WKWebView's drag and drop interaction delegates (i.e. the WKContentView) and calling delegate
+        methods directly. This avoids requiring boilerplate plumbing on WKWebView and WKContentView for each of the drag
+        and drop delegate methods, so these have been removed from WKWebView and WKContentView.
+
+        Additionally, renames MockDataOperationSession and MockDataInteractionSession to MockDragSession and
+        MockDropSession, respectively, and adjusts their ivars on DataInteractionSimulator to match.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/custom-draggable-div.html: Added.
+
+        Add a new test harness covering dragging and dropping elements with the draggable attribute, using DataTransfer
+        API (setData and getData) as well.
+
+        * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/ios/DataInteractionSimulator.h:
+        * TestWebKitAPI/ios/DataInteractionSimulator.mm:
+        (-[WKWebView dropInteractionDelegate]):
+        (-[WKWebView dragInteractionDelegate]):
+        (-[WKWebView dropInteraction]):
+        (-[WKWebView dragInteraction]):
+
+        Add testing utilities to ask a WKWebView for information about its drag/drop interactions and delegates. In this
+        case, this will return the WKWebView's WKContentView.
+
+        (-[DataInteractionSimulator _resetSimulatedState]):
+        (-[DataInteractionSimulator simulateAllTouchesCanceled:]):
+        (-[DataInteractionSimulator runFrom:to:additionalItemRequestLocations:]):
+        (-[DataInteractionSimulator _concludeDataInteractionAndPerformOperationIfNecessary]):
+        (-[DataInteractionSimulator _sendQueuedAdditionalItemRequest]):
+        (-[DataInteractionSimulator _advanceProgress]):
+
+        When beginning a drag session, ask the delegate for targeted lift previews and verify that these are non-null.
+        This check would fail prior to the tweak in DragDropInteractionState in this patch.
+
+        (-[DataInteractionSimulator _webView:showCustomSheetForElement:]):
+        (-[MockDataOperationSession initWithProviders:location:window:allowMove:]): Deleted.
+        (-[MockDataOperationSession session]): Deleted.
+        (-[MockDataOperationSession isLocal]): Deleted.
+        (-[MockDataOperationSession progress]): Deleted.
+        (-[MockDataOperationSession setProgressIndicatorStyle:]): Deleted.
+        (-[MockDataOperationSession progressIndicatorStyle]): Deleted.
+        (-[MockDataOperationSession operationMask]): Deleted.
+        (-[MockDataOperationSession localDragSession]): Deleted.
+        (-[MockDataOperationSession hasItemsConformingToTypeIdentifier:]): Deleted.
+        (-[MockDataOperationSession canCreateItemsOfClass:]): Deleted.
+        (-[MockDataOperationSession loadObjectsOfClass:completion:]): Deleted.
+        (-[MockDataInteractionSession initWithWindow:allowMove:]): Deleted.
+        (-[MockDataInteractionSession localOperationMask]): Deleted.
+        (-[MockDataInteractionSession externalOperationMask]): Deleted.
+
+        Replace various places where we called -_simulate* methods on WKWebView with calls to the
+        UIDragInteractionDelegate or UIDropInteractionDelegate (the WKContentView) instead. Also, adjust for some
+        mechanical renaming of drag and drop sessions.
+
+        (-[MockDataInteractionSession session]): Deleted.
+        * TestWebKitAPI/ios/UIKitSPI.h:
+
 2017-09-11  Joseph Pecoraro  <pecoraro@apple.com>
 
         Make the WPT entry point for LayoutTests/http/wpt more discoverable
index ccc3c3be738803c4251dbd6ee0452357c9ba1394..edcb243e27d49464f1aa58e3ff77c928d2773730 100644 (file)
                F4856CA31E649EA8009D7EE7 /* attachment-element.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4856CA21E6498A8009D7EE7 /* attachment-element.html */; };
                F4A32EC41F05F3850047C544 /* dragstart-change-selection-offscreen.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4A32EC31F05F3780047C544 /* dragstart-change-selection-offscreen.html */; };
                F4A32ECB1F0643370047C544 /* contenteditable-in-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4A32ECA1F0642F40047C544 /* contenteditable-in-iframe.html */; };
+               F4AB578A1F65165400DB0DA1 /* custom-draggable-div.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4AB57891F65164B00DB0DA1 /* custom-draggable-div.html */; };
                F4B825D81EF4DBFB006E417F /* compressed-files.zip in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4B825D61EF4DBD4006E417F /* compressed-files.zip */; };
                F4BFA68E1E4AD08000154298 /* DragAndDropPasteboardTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */; };
                F4C2AB221DD6D95E00E06D5B /* enormous-video-with-sound.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */; };
                                5142B2731517C8C800C32B19 /* ContextMenuCanCopyURL.html in Copy Resources */,
                                5C2936961D5C00ED00DEAB1E /* CookieMessage.html in Copy Resources */,
                                7AEAD4811E20122700416EFE /* CrossPartitionFileSchemeAccess.html in Copy Resources */,
+                               F4AB578A1F65165400DB0DA1 /* custom-draggable-div.html in Copy Resources */,
                                290F4275172A221C00939FF0 /* custom-protocol-sync-xhr.html in Copy Resources */,
                                F4512E131F60C44600BB369E /* DataTransferItem-getAsEntry.html in Copy Resources */,
                                C07E6CB213FD73930038B22B /* devicePixelRatio.html in Copy Resources */,
                F493247C1F44DF8D006F4336 /* UIKitSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIKitSPI.h; sourceTree = "<group>"; };
                F4A32EC31F05F3780047C544 /* dragstart-change-selection-offscreen.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "dragstart-change-selection-offscreen.html"; sourceTree = "<group>"; };
                F4A32ECA1F0642F40047C544 /* contenteditable-in-iframe.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "contenteditable-in-iframe.html"; sourceTree = "<group>"; };
+               F4AB57891F65164B00DB0DA1 /* custom-draggable-div.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "custom-draggable-div.html"; sourceTree = "<group>"; };
                F4B825D61EF4DBD4006E417F /* compressed-files.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "compressed-files.zip"; sourceTree = "<group>"; };
                F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropPasteboardTests.mm; sourceTree = "<group>"; };
                F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "enormous-video-with-sound.html"; sourceTree = "<group>"; };
                                F4A32ECA1F0642F40047C544 /* contenteditable-in-iframe.html */,
                                A16F66B91C40EA2000BD4D24 /* ContentFiltering.html */,
                                5C2936941D5BFD1900DEAB1E /* CookieMessage.html */,
+                               F4AB57891F65164B00DB0DA1 /* custom-draggable-div.html */,
                                F4512E121F60C43400BB369E /* DataTransferItem-getAsEntry.html */,
                                0799C34A1EBA32F4003B7532 /* disableGetUserMedia.html */,
                                F41AB99E1EF4692C0083FA08 /* div-and-large-image.html */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/custom-draggable-div.html b/Tools/TestWebKitAPI/Tests/WebKitCocoa/custom-draggable-div.html
new file mode 100644 (file)
index 0000000..0886226
--- /dev/null
@@ -0,0 +1,55 @@
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+    body, html {
+        margin: 0;
+        width: 100%;
+        height: 100%;
+        font-family: -apple-system;
+    }
+
+    body {
+        margin: 0;
+    }
+
+    #source, #destination {
+        width: 200px;
+        height: 200px;
+        box-sizing: border-box;
+        border: 1px gray solid;
+    }
+
+    #item {
+        width: 100%;
+        height: 100%;
+        background-color: red;
+    }
+</style>
+
+<body>
+<div id="source">
+<div draggable="true" id="item"></div>
+</div>
+<div id="destination"></div>
+<div id="description">
+    <div>To manually test, drag and drop the red square in the top container into the bottom container.</div>
+    <div>Upon drop, the square should turn green and show "PASS" as text.</div>
+</div>
+</body>
+
+<script>
+item.addEventListener("dragstart", event => event.dataTransfer.setData("text/plain", item.id));
+destination.addEventListener("dragenter", event => event.preventDefault());
+destination.addEventListener("dragover", event => event.preventDefault());
+destination.addEventListener("drop", event => {
+    let identifier = event.dataTransfer.getData("text/plain");
+    let sourceItem = document.getElementById(identifier);
+    if (!sourceItem)
+        return;
+
+    sourceItem.style.backgroundColor = "green";
+    sourceItem.style.color = "white";
+    sourceItem.innerHTML = "<code>PASS</code>";
+    destination.appendChild(sourceItem);
+    event.preventDefault();
+});
+</script>
index 244a2852dd56288e145e3890f9ed1684493a0668..634126c88204f82d7d554274464d379b0a3cbcd4 100644 (file)
@@ -30,6 +30,7 @@
 #import "DataInteractionSimulator.h"
 #import "PlatformUtilities.h"
 #import "TestWKWebView.h"
+#import "UIKitSPI.h"
 #import "WKWebViewConfigurationExtras.h"
 #import <MobileCoreServices/MobileCoreServices.h>
 #import <UIKit/NSItemProvider+UIKitAdditions.h>
@@ -525,6 +526,17 @@ TEST(DataInteractionTests, EnterAndLeaveEvents)
     checkSelectionRectsWithLogging(@[ ], [dataInteractionSimulator finalSelectionRects]);
 }
 
+TEST(DataInteractionTests, CanStartDragOnDivWithDraggableAttribute)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    [webView synchronouslyLoadTestPageNamed:@"custom-draggable-div"];
+
+    auto dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
+    [dataInteractionSimulator runFrom:CGPointMake(100, 100) to:CGPointMake(250, 100)];
+
+    EXPECT_GT([dataInteractionSimulator sourceItemProviders].count, 0UL);
+}
+
 TEST(DataInteractionTests, ExternalSourcePlainTextToIFrame)
 {
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
@@ -1306,7 +1318,8 @@ TEST(DataInteractionTests, UnresponsivePageDoesNotHangUI)
     [webView evaluateJavaScript:@"while(1);" completionHandler:nil];
 
     // The test passes if we can prepare for data interaction without timing out.
-    [webView _simulatePrepareForDataInteractionSession:nil completion:^() { }];
+    auto dragSession = adoptNS([[MockDragSession alloc] init]);
+    [(id <UIDragInteractionDelegate_ForWebKitOnly>)[webView dragInteractionDelegate] _dragInteraction:[webView dragInteraction] prepareForSession:dragSession.get() completion:^() { }];
 }
 
 TEST(DataInteractionTests, WebItemProviderPasteboardLoading)
index a1332def8488c9c8b9f64424b72a8443548817da..55f67855b1c37df43b52cec06b97b1c7b798386f 100644 (file)
 #import <WebKit/_WKInputDelegate.h>
 #import <wtf/BlockPtr.h>
 
-@class MockDataOperationSession;
-@class MockDataInteractionSession;
+@class MockDropSession;
+@class MockDragSession;
+
+@interface MockDragDropSession : NSObject <UIDragDropSession> {
+@private
+    RetainPtr<NSArray> _mockItems;
+    RetainPtr<UIWindow> _window;
+}
+@property (nonatomic) CGPoint mockLocationInWindow;
+@property (nonatomic) BOOL allowMove;
+@end
+
+@interface MockDropSession : MockDragDropSession <UIDropSession>
+@property (nonatomic, strong) id localContext;
+@end
+
+@interface MockDragSession : MockDragDropSession <UIDragSession>
+@property (nonatomic, strong) id localContext;
+@property (nonatomic, strong) id context;
+@end
 
 extern NSString * const DataInteractionEnterEventName;
 extern NSString * const DataInteractionOverEventName;
@@ -96,11 +114,18 @@ typedef NS_ENUM(NSInteger, DataInteractionPhase) {
     DataInteractionPerforming = 4
 };
 
+@interface WKWebView (DragAndDropTesting)
+- (id <UIDropInteractionDelegate>)dropInteractionDelegate;
+- (id <UIDragInteractionDelegate>)dragInteractionDelegate;
+- (UIDropInteraction *)dropInteraction;
+- (UIDragInteraction *)dragInteraction;
+@end
+
 @interface DataInteractionSimulator : NSObject<WKUIDelegatePrivate, _WKInputDelegate> {
 @private
     RetainPtr<TestWKWebView> _webView;
-    RetainPtr<MockDataInteractionSession> _dataInteractionSession;
-    RetainPtr<MockDataOperationSession> _dataOperationSession;
+    RetainPtr<MockDragSession> _dragSession;
+    RetainPtr<MockDropSession> _dropSession;
     RetainPtr<NSMutableArray> _observedEventNames;
     RetainPtr<NSArray> _externalItemProviders;
     RetainPtr<NSArray *> _sourceItemProviders;
index a4eefd171e481228bc09fd27435c4ea79bcd1568..51eeddae9b5dcfea95f278ada6bf765ea3c0af79 100644 (file)
 
 #import "InstanceMethodSwizzler.h"
 #import "PlatformUtilities.h"
+#import "UIKitSPI.h"
 
 #import <UIKit/UIDragInteraction.h>
 #import <UIKit/UIDragItem.h>
+#import <UIKit/UIInteraction.h>
 
 #if USE(APPLE_INTERNAL_SDK)
 #import <UIKit/UIDragSession.h>
@@ -58,13 +60,43 @@ SOFT_LINK(UIKit, UIApplicationInstantiateSingleton, void, (Class singletonClass)
 
 using namespace TestWebKitAPI;
 
-@interface MockDragDropSession : NSObject <UIDragDropSession> {
-@private
-    RetainPtr<NSArray> _mockItems;
-    RetainPtr<UIWindow> _window;
+@implementation WKWebView (DragAndDropTesting)
+
+- (UIView *)_dragDropInteractionView
+{
+    return [self valueForKey:@"_currentContentView"];
+}
+
+- (id <UIDropInteractionDelegate>)dropInteractionDelegate
+{
+    return (id <UIDropInteractionDelegate>)self._dragDropInteractionView;
+}
+
+- (id <UIDragInteractionDelegate>)dragInteractionDelegate
+{
+    return (id <UIDragInteractionDelegate>)self._dragDropInteractionView;
+}
+
+- (UIDropInteraction *)dropInteraction
+{
+    UIView *interactionView = self._dragDropInteractionView;
+    for (id <UIInteraction> interaction in interactionView.interactions) {
+        if ([interaction isKindOfClass:[UIDropInteraction class]])
+            return (UIDropInteraction *)interaction;
+    }
+    return nil;
+}
+
+- (UIDragInteraction *)dragInteraction
+{
+    UIView *interactionView = self._dragDropInteractionView;
+    for (id <UIInteraction> interaction in interactionView.interactions) {
+        if ([interaction isKindOfClass:[UIDragInteraction class]])
+            return (UIDragInteraction *)interaction;
+    }
+    return nil;
 }
-@property (nonatomic) CGPoint mockLocationInWindow;
-@property (nonatomic) BOOL allowMove;
+
 @end
 
 @implementation MockDragDropSession
@@ -157,11 +189,7 @@ NSString * const DataInteractionPerformOperationEventName = @"drop";
 NSString * const DataInteractionLeaveEventName = @"dragleave";
 NSString * const DataInteractionStartEventName = @"dragstart";
 
-@interface MockDataOperationSession : MockDragDropSession <UIDropSession>
-@property (nonatomic, strong) id localContext;
-@end
-
-@implementation MockDataOperationSession
+@implementation MockDropSession
 
 - (instancetype)initWithProviders:(NSArray<UIItemProvider *> *)providers location:(CGPoint)locationInWindow window:(UIWindow *)window allowMove:(BOOL)allowMove
 {
@@ -226,12 +254,7 @@ NSString * const DataInteractionStartEventName = @"dragstart";
 
 @end
 
-@interface MockDataInteractionSession : MockDragDropSession <UIDragSession>
-@property (nonatomic, strong) id localContext;
-@property (nonatomic, strong) id context;
-@end
-
-@implementation MockDataInteractionSession
+@implementation MockDragSession
 
 - (instancetype)initWithWindow:(UIWindow *)window allowMove:(BOOL)allowMove
 {
@@ -314,8 +337,8 @@ static NSArray *dataInteractionEventNames()
     _isDoneWithCurrentRun = false;
     _observedEventNames = adoptNS([[NSMutableArray alloc] init]);
     _finalSelectionRects = @[ ];
-    _dataInteractionSession = nil;
-    _dataOperationSession = nil;
+    _dragSession = nil;
+    _dropSession = nil;
     _shouldPerformOperation = NO;
     _lastKnownDragCaretRect = CGRectZero;
     _remainingAdditionalItemRequestLocationsByProgress = nil;
@@ -333,8 +356,8 @@ static NSArray *dataInteractionEventNames()
     _phase = DataInteractionCancelled;
     _currentProgress = 1;
     _isDoneWithCurrentRun = true;
-    if (_dataInteractionSession)
-        [_webView _simulateDataInteractionSessionDidEnd:_dataInteractionSession.get()];
+    if (_dragSession)
+        [[_webView dragInteractionDelegate] dragInteraction:[_webView dragInteraction] session:_dragSession.get() didEndWithOperation:UIDropOperationCopy];
 }
 
 - (void)runFrom:(CGPoint)startLocation to:(CGPoint)endLocation
@@ -367,13 +390,13 @@ static NSArray *dataInteractionEventNames()
     _endLocation = endLocation;
 
     if (self.externalItemProviders.count) {
-        _dataOperationSession = adoptNS([[MockDataOperationSession alloc] initWithProviders:self.externalItemProviders location:_startLocation window:[_webView window] allowMove:self.shouldAllowMoveOperation]);
+        _dropSession = adoptNS([[MockDropSession alloc] initWithProviders:self.externalItemProviders location:_startLocation window:[_webView window] allowMove:self.shouldAllowMoveOperation]);
         _phase = DataInteractionBegan;
         [self _advanceProgress];
     } else {
-        _dataInteractionSession = adoptNS([[MockDataInteractionSession alloc] initWithWindow:[_webView window] allowMove:self.shouldAllowMoveOperation]);
-        [_dataInteractionSession setMockLocationInWindow:_startLocation];
-        [_webView _simulatePrepareForDataInteractionSession:_dataInteractionSession.get() completion:^() {
+        _dragSession = adoptNS([[MockDragSession alloc] initWithWindow:[_webView window] allowMove:self.shouldAllowMoveOperation]);
+        [_dragSession setMockLocationInWindow:_startLocation];
+        [(id <UIDragInteractionDelegate_ForWebKitOnly>)[_webView dragInteractionDelegate] _dragInteraction:[_webView dragInteraction] prepareForSession:_dragSession.get() completion:^() {
             DataInteractionSimulator *weakSelf = strongSelf.get();
             if (weakSelf->_phase == DataInteractionCancelled)
                 return;
@@ -399,17 +422,17 @@ static NSArray *dataInteractionEventNames()
 {
     _lastKnownDragCaretRect = [_webView _dragCaretRect];
     if (_shouldPerformOperation) {
-        [_webView _simulateDataInteractionPerformOperation:_dataOperationSession.get()];
+        [[_webView dropInteractionDelegate] dropInteraction:[_webView dropInteraction] performDrop:_dropSession.get()];
         _phase = DataInteractionPerforming;
     } else {
         _isDoneWithCurrentRun = YES;
         _phase = DataInteractionCancelled;
     }
 
-    [_webView _simulateDataInteractionEnded:_dataOperationSession.get()];
+    [[_webView dropInteractionDelegate] dropInteraction:[_webView dropInteraction] sessionDidEnd:_dropSession.get()];
 
-    if (_dataInteractionSession)
-        [_webView _simulateDataInteractionSessionDidEnd:_dataInteractionSession.get()];
+    if (_dragSession)
+        [[_webView dragInteractionDelegate] dragInteraction:[_webView dragInteraction] session:_dragSession.get() didEndWithOperation:UIDropOperationCopy];
 }
 
 - (void)_enqueuePendingAdditionalItemRequestLocations
@@ -436,7 +459,7 @@ static NSArray *dataInteractionEventNames()
     [_queuedAdditionalItemRequestLocations removeObjectAtIndex:0];
 
     auto requestLocation = [[_webView window] convertPoint:[requestLocationValue CGPointValue] toView:_webView.get()];
-    [_webView _simulateItemsForAddingToSession:_dataInteractionSession.get() atLocation:requestLocation completion:[dragSession = _dataInteractionSession, dropSession = _dataOperationSession] (NSArray *items) {
+    [(id <UIDragInteractionDelegate_Proposed_SPI_33146803>)[_webView dragInteractionDelegate] _dragInteraction:[_webView dragInteraction] itemsForAddingToSession:_dragSession.get() withTouchAtPoint:requestLocation completion:[dragSession = _dragSession, dropSession = _dropSession] (NSArray *items) {
         [dragSession addItems:items];
         [dropSession addItems:items];
     }];
@@ -454,8 +477,8 @@ static NSArray *dataInteractionEventNames()
     _lastKnownDragCaretRect = [_webView _dragCaretRect];
     _currentProgress += progressIncrementStep;
     CGPoint locationInWindow = self._currentLocation;
-    [_dataInteractionSession setMockLocationInWindow:locationInWindow];
-    [_dataOperationSession setMockLocationInWindow:locationInWindow];
+    [_dragSession setMockLocationInWindow:locationInWindow];
+    [_dropSession setMockLocationInWindow:locationInWindow];
 
     if (_currentProgress >= 1) {
         _currentProgress = 1;
@@ -466,7 +489,7 @@ static NSArray *dataInteractionEventNames()
     switch (_phase) {
     case DataInteractionBeginning: {
         NSMutableArray<UIItemProvider *> *itemProviders = [NSMutableArray array];
-        NSArray *items = [_webView _simulatedItemsForSession:_dataInteractionSession.get()];
+        NSArray *items = [[_webView dragInteractionDelegate] dragInteraction:[_webView dragInteraction] itemsForBeginningSession:_dragSession.get()];
         if (!items.count) {
             _phase = DataInteractionCancelled;
             _currentProgress = 1;
@@ -474,11 +497,14 @@ static NSArray *dataInteractionEventNames()
             return;
         }
 
-        for (UIDragItem *item in items)
+        for (UIDragItem *item in items) {
             [itemProviders addObject:item.itemProvider];
+            UITargetedDragPreview *liftPreview = [[_webView dragInteractionDelegate] dragInteraction:[_webView dragInteraction] previewForLiftingItem:item session:_dragSession.get()];
+            EXPECT_TRUE(!!liftPreview);
+        }
 
-        _dataOperationSession = adoptNS([[MockDataOperationSession alloc] initWithProviders:itemProviders location:self._currentLocation window:[_webView window] allowMove:self.shouldAllowMoveOperation]);
-        [_dataInteractionSession setItems:items];
+        _dropSession = adoptNS([[MockDropSession alloc] initWithProviders:itemProviders location:self._currentLocation window:[_webView window] allowMove:self.shouldAllowMoveOperation]);
+        [_dragSession setItems:items];
         _sourceItemProviders = itemProviders;
         if (self.showCustomActionSheetBlock) {
             // Defer progress until the custom action sheet is dismissed.
@@ -487,7 +513,7 @@ static NSArray *dataInteractionEventNames()
             return;
         }
 
-        [_webView _simulateWillBeginDataInteractionWithSession:_dataInteractionSession.get()];
+        [[_webView dragInteractionDelegate] dragInteraction:[_webView dragInteraction] sessionWillBegin:_dragSession.get()];
 
         RetainPtr<WKWebView> retainedWebView = _webView;
         dispatch_async(dispatch_get_main_queue(), ^() {
@@ -498,12 +524,12 @@ static NSArray *dataInteractionEventNames()
         break;
     }
     case DataInteractionBegan:
-        [_webView _simulateDataInteractionEntered:_dataOperationSession.get()];
+        [[_webView dropInteractionDelegate] dropInteraction:[_webView dropInteraction] sessionDidEnter:_dropSession.get()];
         _phase = DataInteractionEntered;
         break;
     case DataInteractionEntered: {
-        auto operation = static_cast<UIDropOperation>([_webView _simulateDataInteractionUpdated:_dataOperationSession.get()]);
-        _shouldPerformOperation = operation == UIDropOperationCopy || ([_dataOperationSession allowsMoveOperation] && operation != UIDropOperationCancel);
+        auto operation = static_cast<UIDropOperation>([[_webView dropInteractionDelegate] dropInteraction:[_webView dropInteraction] sessionDidUpdate:_dropSession.get()].operation);
+        _shouldPerformOperation = operation == UIDropOperationCopy || ([_dropSession allowsMoveOperation] && operation != UIDropOperationCancel);
         break;
     }
     default:
@@ -589,7 +615,7 @@ static NSArray *dataInteractionEventNames()
     RetainPtr<DataInteractionSimulator> strongSelf = self;
     dispatch_async(dispatch_get_main_queue(), ^() {
         DataInteractionSimulator *weakSelf = strongSelf.get();
-        [weakSelf->_webView _simulateWillBeginDataInteractionWithSession:weakSelf->_dataInteractionSession.get()];
+        [[weakSelf->_webView dragInteractionDelegate] dragInteraction:[weakSelf->_webView dragInteraction] sessionWillBegin:weakSelf->_dragSession.get()];
         weakSelf->_phase = DataInteractionBegan;
         [weakSelf _scheduleAdvanceProgress];
     });
index 9dcb22311bc31de15d555c6d11b2ef46eecf1c90..e02f5367f176989e2b8e7176baadf317b922fab5 100644 (file)
 
 #if PLATFORM(IOS)
 
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
+@protocol UIDragSession;
+@class UIDragInteraction;
+@class UIDragItem;
+#endif
+
 #if USE(APPLE_INTERNAL_SDK) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
 
 #import <UIKit/UIApplication_Private.h>
+#import <UIKit/UIDragInteraction_Private.h>
 
 #else
 
@@ -37,6 +44,19 @@ void UIApplicationInitialize(void);
 
 WTF_EXTERN_C_END
 
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
+@protocol UIDragInteractionDelegate_ForWebKitOnly <UIDragInteractionDelegate>
+@optional
+- (void)_dragInteraction:(UIDragInteraction *)interaction prepareForSession:(id<UIDragSession>)session completion:(void(^)(void))completion;
+@end
+#endif // __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
+
 #endif
 
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
+@protocol UIDragInteractionDelegate_Proposed_SPI_33146803 <UIDragInteractionDelegate>
+- (void)_dragInteraction:(UIDragInteraction *)interaction itemsForAddingToSession:(id <UIDragSession>)session withTouchAtPoint:(CGPoint)point completion:(void(^)(NSArray<UIDragItem *> *))completion;
+@end
+#endif // __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
+
 #endif // PLATFORM(IOS)