Diff
Modified: trunk/Source/WebKit/ChangeLog (221869 => 221870)
--- trunk/Source/WebKit/ChangeLog 2017-09-11 18:46:43 UTC (rev 221869)
+++ trunk/Source/WebKit/ChangeLog 2017-09-11 19:06:00 UTC (rev 221870)
@@ -1,3 +1,54 @@
+2017-09-11 Wenson Hsieh <[email protected]>
+
+ [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 <[email protected]>
Modernize BoxExtent into RectEdges
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (221869 => 221870)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2017-09-11 18:46:43 UTC (rev 221869)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2017-09-11 19:06:00 UTC (rev 221870)
@@ -5793,73 +5793,6 @@
#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)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (221869 => 221870)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2017-09-11 18:46:43 UTC (rev 221869)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2017-09-11 19:06:00 UTC (rev 221870)
@@ -378,16 +378,6 @@
@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));
Modified: trunk/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm (221869 => 221870)
--- trunk/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm 2017-09-11 18:46:43 UTC (rev 221869)
+++ trunk/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm 2017-09-11 19:06:00 UTC (rev 221870)
@@ -94,13 +94,24 @@
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 @@
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)]);
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (221869 => 221870)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2017-09-11 18:46:43 UTC (rev 221869)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2017-09-11 19:06:00 UTC (rev 221870)
@@ -325,24 +325,13 @@
- (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;
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (221869 => 221870)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2017-09-11 18:46:43 UTC (rev 221869)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2017-09-11 19:06:00 UTC (rev 221870)
@@ -4823,55 +4823,12 @@
_page->dragEnded(roundedIntPoint(client), roundedIntPoint(global), DragOperationNone);
}
-#pragma mark - Unit testing support
+#endif
-- (void)_simulateDataInteractionEntered:(id)session
-{
- [self dropInteraction:_dropInteraction.get() sessionDidEnter:session];
-}
+@end
-- (NSUInteger)_simulateDataInteractionUpdated:(id)session
-{
- return [self dropInteraction:_dropInteraction.get() sessionDidUpdate:session].operation;
-}
+@implementation WKContentView (WKTesting)
-- (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];
-}
-
-- (void)_simulateItemsForAddingToSession:(id)session atLocation:(CGPoint)location completion:(void(^)(NSArray *))completion
-{
- [self _dragInteraction:_dragInteraction.get() itemsForAddingToSession:session withTouchAtPoint:location completion:completion];
-}
-
-#endif
-
- (void)_simulateLongPressActionAtLocation:(CGPoint)location
{
RetainPtr<WKContentView> protectedSelf = self;
@@ -4881,10 +4838,6 @@
} forRequest:InteractionInformationRequest(roundedIntPoint(location))];
}
-@end
-
-@implementation WKContentView (WKTesting)
-
- (void)selectFormAccessoryPickerRow:(NSInteger)rowIndex
{
if ([_inputPeripheral isKindOfClass:[WKFormSelectControl self]])
Modified: trunk/Tools/ChangeLog (221869 => 221870)
--- trunk/Tools/ChangeLog 2017-09-11 18:46:43 UTC (rev 221869)
+++ trunk/Tools/ChangeLog 2017-09-11 19:06:00 UTC (rev 221870)
@@ -1,3 +1,72 @@
+2017-09-11 Wenson Hsieh <[email protected]>
+
+ [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 <[email protected]>
Make the WPT entry point for LayoutTests/http/wpt more discoverable
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (221869 => 221870)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-09-11 18:46:43 UTC (rev 221869)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-09-11 19:06:00 UTC (rev 221870)
@@ -691,6 +691,7 @@
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 */; };
@@ -817,6 +818,7 @@
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 */,
@@ -1726,6 +1728,7 @@
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>"; };
@@ -2161,6 +2164,7 @@
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 */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/custom-draggable-div.html (0 => 221870)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/custom-draggable-div.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/custom-draggable-div.html 2017-09-11 19:06:00 UTC (rev 221870)
@@ -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>
Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm (221869 => 221870)
--- trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm 2017-09-11 18:46:43 UTC (rev 221869)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm 2017-09-11 19:06:00 UTC (rev 221870)
@@ -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 @@
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 @@
[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)
Modified: trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h (221869 => 221870)
--- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h 2017-09-11 18:46:43 UTC (rev 221869)
+++ trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h 2017-09-11 19:06:00 UTC (rev 221870)
@@ -77,9 +77,27 @@
#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;
extern NSString * const DataInteractionPerformOperationEventName;
@@ -96,11 +114,18 @@
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;
Modified: trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm (221869 => 221870)
--- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm 2017-09-11 18:46:43 UTC (rev 221869)
+++ trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm 2017-09-11 19:06:00 UTC (rev 221870)
@@ -30,9 +30,11 @@
#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 @@
using namespace TestWebKitAPI;
-@interface MockDragDropSession : NSObject <UIDragDropSession> {
-@private
- RetainPtr<NSArray> _mockItems;
- RetainPtr<UIWindow> _window;
+@implementation WKWebView (DragAndDropTesting)
+
+- (UIView *)_dragDropInteractionView
+{
+ return [self valueForKey:@"_currentContentView"];
}
-@property (nonatomic) CGPoint mockLocationInWindow;
-@property (nonatomic) BOOL allowMove;
+
+- (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;
+}
+
@end
@implementation MockDragDropSession
@@ -157,12 +189,8 @@
NSString * const DataInteractionLeaveEventName = @"dragleave";
NSString * const DataInteractionStartEventName = @"dragstart";
-@interface MockDataOperationSession : MockDragDropSession <UIDropSession>
-@property (nonatomic, strong) id localContext;
-@end
+@implementation MockDropSession
-@implementation MockDataOperationSession
-
- (instancetype)initWithProviders:(NSArray<UIItemProvider *> *)providers location:(CGPoint)locationInWindow window:(UIWindow *)window allowMove:(BOOL)allowMove
{
auto items = adoptNS([[NSMutableArray alloc] init]);
@@ -226,13 +254,8 @@
@end
-@interface MockDataInteractionSession : MockDragDropSession <UIDragSession>
-@property (nonatomic, strong) id localContext;
-@property (nonatomic, strong) id context;
-@end
+@implementation MockDragSession
-@implementation MockDataInteractionSession
-
- (instancetype)initWithWindow:(UIWindow *)window allowMove:(BOOL)allowMove
{
return [super initWithItems:@[ ] location:CGPointZero window:window allowMove:allowMove];
@@ -314,8 +337,8 @@
_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 @@
_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 @@
_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,7 +422,7 @@
{
_lastKnownDragCaretRect = [_webView _dragCaretRect];
if (_shouldPerformOperation) {
- [_webView _simulateDataInteractionPerformOperation:_dataOperationSession.get()];
+ [[_webView dropInteractionDelegate] dropInteraction:[_webView dropInteraction] performDrop:_dropSession.get()];
_phase = DataInteractionPerforming;
} else {
_isDoneWithCurrentRun = YES;
@@ -406,10 +429,10 @@
_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 @@
[_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 @@
_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 @@
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 @@
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 @@
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 @@
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 @@
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];
});
Modified: trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h (221869 => 221870)
--- trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h 2017-09-11 18:46:43 UTC (rev 221869)
+++ trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h 2017-09-11 19:06:00 UTC (rev 221870)
@@ -25,9 +25,16 @@
#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 @@
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)