Title: [234816] trunk
Revision
234816
Author
[email protected]
Date
2018-08-13 14:07:55 -0700 (Mon, 13 Aug 2018)

Log Message

[WK2] [macOS] Implement a mechanism to test drag and drop
https://bugs.webkit.org/show_bug.cgi?id=181898
<rdar://problem/39181698>

Reviewed by Simon Fraser.

Source/WebKit:

Adds a new SPI method, `-_doAfterProcessingAllPendingMouseEvents:`, to WKWebView. This invokes the given
callback after all queued mouse events have been handled by the web process. See Tools/ChangeLog for more
detail.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _doAfterProcessingAllPendingMouseEvents:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/gtk/PageClientImpl.h:
* UIProcess/API/wpe/PageClientImpl.h:
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::processDidExit):

Invoke any outstanding callbacks for processing pending mouse events when the web process is terminated.

(WebKit::WebViewImpl::doAfterProcessingAllPendingMouseEvents):

Either invoke the callback immediately if there are no mouse events to be processed, or insert the callback in
a queue that will be flushed once all mouse events have been handled.

(WebKit::WebViewImpl::didFinishProcessingAllPendingMouseEvents):
(WebKit::WebViewImpl::flushPendingMouseEventCallbacks):
* UIProcess/PageClient.h:
(WebKit::PageClient::pinnedStateWillChange):
(WebKit::PageClient::pinnedStateDidChange):
(WebKit::PageClient::videoControlsManagerDidChange):

Drive-by tweaks: remove unnecessary semicolons after empty implementation stubs.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didReceiveEvent):

Notify the page client when there are no remaining mouse events left in the queue.

* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/mac/PageClientImplMac.h:
* UIProcess/mac/PageClientImplMac.mm:
(WebKit::PageClientImpl::didFinishProcessingAllPendingMouseEvents):

Add some plumbing through PageClient, so that WebPageProxy can tell WebViewImpl when it is finished processing
all mouse events.

* UIProcess/win/PageClientImpl.h:

Tools:

Implements the currently stubbed DragAndDropSimulator on macOS, and introduces a new API test for r227266. See
comments below for more detail.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/DragAndDropTests.mm: Copied from Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm.

Introduce a file for cross-platform drag and drop tests, currently for iOS and macOS. Additionally add a test
for r227266, which was fixed earlier this year but could not be tested due to a lack of testing mechanism on
macOS in WebKit2.

(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/full-page-dropzone.html: Added.

Minor tweaks to this test page to add "dragover" and "drop" event handlers.

* TestWebKitAPI/Tests/WebKitCocoa/image-in-link-and-input.html:
* TestWebKitAPI/Tests/WebKitCocoa/link-in-iframe-and-input.html: Added.

Add a new test page that includes a link embedded within an iframe below a plain text input.

* TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm: Added.
(TEST):
* TestWebKitAPI/Tests/mac/LegacyDragAndDropTests.mm: Renamed from Tools/TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm.

Move only existing WebKit2 macOS drag and drop test (DragAndDropPasteboardTests.NumberOfValidItemsForDrop) out
of DragAndDropPasteboardTests.mm and into a new file, DragAndDropTestsMac.mm. Additionally, rename
DragAndDropPasteboardTests to LegacyDragAndDropTests, since it now only contains two legacy WebView tests for
drag and drop.

(+[FrameLoadCompletionListener listenerWithCompletionBlock:]):
(-[FrameLoadCompletionListener initWithCompletionBlock:]):
(-[FrameLoadCompletionListener webView:didFinishLoadForFrame:]):
(-[DragSource draggingSourceOperationMaskForLocal:]):
(-[DragInfo initWithImage:offset:pasteboard:source:destinationWindow:]):
(-[DragInfo lastMousePosition]):
(-[DragInfo setLastMousePosition:]):
(-[DragInfo draggingDestinationWindow]):
(-[DragInfo draggingSourceOperationMask]):
(-[DragInfo draggingLocation]):
(-[DragInfo draggedImageLocation]):
(-[DragInfo draggedImage]):
(-[DragInfo draggingPasteboard]):
(-[DragInfo draggingSource]):
(-[DragInfo draggingSequenceNumber]):
(-[DragInfo slideDraggedImageTo:]):
(-[DragInfo namesOfPromisedFilesDroppedAtDestination:]):
(-[DragInfo draggingFormation]):
(-[DragInfo setDraggingFormation:]):
(-[DragInfo animatesToDestination]):
(-[DragInfo setAnimatesToDestination:]):
(-[DragInfo numberOfValidItemsForDrop]):
(-[DragInfo setNumberOfValidItemsForDrop:]):
(-[DragInfo enumerateDraggingItemsWithOptions:forView:classes:searchOptions:usingBlock:]):
(-[DragInfo springLoadingHighlight]):
(-[DragInfo resetSpringLoading]):
(TestWebKitAPI::getTestImage):
(TestWebKitAPI::webViewAfterPerformingDragOperation):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/mac/full-page-dropzone.html: Removed.
* TestWebKitAPI/cocoa/DragAndDropSimulator.h:

Flesh out some of the DragAndDropSimulator API for macOS, exposing (among other things) the drag pasteboard,
the current NSDraggingInfo, the initial location of the drag image, and the drag image itself.

* TestWebKitAPI/cocoa/TestWKWebView.h:
* TestWebKitAPI/cocoa/TestWKWebView.mm:
(-[TestWKWebView mouseDownAtPoint:simulatePressure:]):
(-[TestWKWebView mouseUpAtPoint:]):
(-[TestWKWebView mouseMoveToPoint:withFlags:]):
(-[TestWKWebView sendClicksAtPoint:numberOfClicks:]):
(-[TestWKWebView mouseEnterAtPoint:]):
(-[TestWKWebView mouseExitAtPoint:]):
(-[TestWKWebView mouseDragToPoint:]):
(-[TestWKWebView _mouseEventWithType:atLocation:]):
(-[TestWKWebView _mouseEventWithType:atLocation:flags:timestamp:clickCount:]):

Add TestWKWebView helpers to send MouseMove, MouseEnter and MouseDrag NSEvents to the web view. Additionally,
rename parameter names to these helpers to make it more obvious that these locations are all in NSWindow
coordinates.

(-[TestWKWebView typeCharacter:]):

Drive-by style fix: put this opening brace on the beginning of the next line.

* TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm:
(-[DragAndDropSimulator initWithWebViewFrame:]):
(-[DragAndDropSimulator initWithWebViewFrame:configuration:]):
(-[DragAndDropSimulator webView]):

Small iOS DragAndDropSimulator adjustments for new DragAndDropSimulator interfaces.

* TestWebKitAPI/mac/DragAndDropSimulatorMac.mm:
(-[DragAndDropTestWKWebView initWithFrame:configuration:simulator:]):

Introduce a WKWebView subclass for testing drag and drop that overrides `-dragImage:at:offset:…`, and instead
allows DragAndDropSimulator to take over the drag.

(-[DragAndDropTestWKWebView dragImage:at:offset:event:pasteboard:source:slideBack:]):

Override this entry point into drag and drop code, and instead call out to the DragAndDropSimulator to
coordinate the drag.

(-[DragAndDropTestWKWebView waitForPendingMouseEvents]):

Helper method to wait for the web process to finish handling all in-flight mouse events.

(defaultExternalDragImage):

Set this image as the default drag image when simulating an incoming drag session from outside of the web view.

(-[DragAndDropSimulator initWithWebViewFrame:]):
(-[DragAndDropSimulator initWithWebViewFrame:configuration:]):
(-[DragAndDropSimulator flipAboutXAxisInHostWindow:]):

Helper method to flip a given point about the X axis of the window.

(-[DragAndDropSimulator locationInViewForCurrentProgress]):

Map a progress value (between 0 and 1) to a drag location.

(-[DragAndDropSimulator initialProgressForMouseDrag]):

Determines the initial progress value when initiation a drag in web content. This is the initial progress
required to ensure that the first mouse drag event exceeds the drag distance hysteresis and causes any drag
(if applicable) to begin.

(-[DragAndDropSimulator runFrom:to:]):
(-[DragAndDropSimulator performDragInWebView:atLocation:withImage:pasteboard:source:]):

Helper to coordinate drag updates in both the cases where we're simulating a drag session entering from outside
of the web view, and in the case where we've initiated a drag from the web view itself.

(-[DragAndDropSimulator webView]):
(-[DragAndDropSimulator setExternalDragPasteboard:]):
(-[DragAndDropSimulator externalDragPasteboard]):

Just like its iOS counterpart (setExternalItemProviders:), setting an external drag pasteboard on macOS puts the
DragAndDropSimulator in a mode that simulates a drag coming in from outside the web view, using the given
pasteboard.

(-[DragAndDropSimulator setExternalDragImage:]):
(-[DragAndDropSimulator externalDragImage]):

May be optionally set when specifying an external drag pasteboard to specify the drag image used. If no external
drag image is specified, falls back to the default image returned by `defaultExternalDragImage()`.

(-[DragAndDropSimulator draggingInfo]):
(-[DragAndDropSimulator willEndDraggingHandler]):
(-[DragAndDropSimulator setWillEndDraggingHandler:]):

Hook to allow tests to run logic right before performing the drop (if the current drag operation is not none) or
ending the drag session without performing a drag operation.

(-[DragAndDropSimulator initWithWebView:]): Deleted.
(-[DragAndDropSimulator dealloc]): Deleted.
(-[DragAndDropSimulator phase]): Deleted.
* TestWebKitAPI/mac/TestDraggingInfo.h: Copied from Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm.
* TestWebKitAPI/mac/TestDraggingInfo.mm: Added.

Mock object conforming to NSDraggingInfo that is passed to WKWebView when invoking -draggingUpdated:,
-draggingEntered: and -draggingExited:.

(-[TestDraggingInfo draggingPasteboard]):
(-[TestDraggingInfo setDraggingPasteboard:]):
(-[TestDraggingInfo draggingSource]):
(-[TestDraggingInfo setDraggingSource:]):
(-[TestDraggingInfo enumerateDraggingItemsWithOptions:forView:classes:searchOptions:usingBlock:]):
(-[TestDraggingInfo draggingDestinationWindow]):
(-[TestDraggingInfo draggedImage]):
(-[TestDraggingInfo setDraggedImage:]):
(-[TestDraggingInfo slideDraggedImageTo:]):
(-[TestDraggingInfo namesOfPromisedFilesDroppedAtDestination:]):
(-[TestDraggingInfo resetSpringLoading]):

Empty method stubs, to be implemented in the future as needed.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (234815 => 234816)


--- trunk/Source/WebKit/ChangeLog	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Source/WebKit/ChangeLog	2018-08-13 21:07:55 UTC (rev 234816)
@@ -1,3 +1,55 @@
+2018-08-13  Wenson Hsieh  <[email protected]>
+
+        [WK2] [macOS] Implement a mechanism to test drag and drop
+        https://bugs.webkit.org/show_bug.cgi?id=181898
+        <rdar://problem/39181698>
+
+        Reviewed by Simon Fraser.
+
+        Adds a new SPI method, `-_doAfterProcessingAllPendingMouseEvents:`, to WKWebView. This invokes the given
+        callback after all queued mouse events have been handled by the web process. See Tools/ChangeLog for more
+        detail.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _doAfterProcessingAllPendingMouseEvents:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/API/gtk/PageClientImpl.h:
+        * UIProcess/API/wpe/PageClientImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::processDidExit):
+
+        Invoke any outstanding callbacks for processing pending mouse events when the web process is terminated.
+
+        (WebKit::WebViewImpl::doAfterProcessingAllPendingMouseEvents):
+
+        Either invoke the callback immediately if there are no mouse events to be processed, or insert the callback in
+        a queue that will be flushed once all mouse events have been handled.
+
+        (WebKit::WebViewImpl::didFinishProcessingAllPendingMouseEvents):
+        (WebKit::WebViewImpl::flushPendingMouseEventCallbacks):
+        * UIProcess/PageClient.h:
+        (WebKit::PageClient::pinnedStateWillChange):
+        (WebKit::PageClient::pinnedStateDidChange):
+        (WebKit::PageClient::videoControlsManagerDidChange):
+
+        Drive-by tweaks: remove unnecessary semicolons after empty implementation stubs.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didReceiveEvent):
+
+        Notify the page client when there are no remaining mouse events left in the queue.
+
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/mac/PageClientImplMac.h:
+        * UIProcess/mac/PageClientImplMac.mm:
+        (WebKit::PageClientImpl::didFinishProcessingAllPendingMouseEvents):
+
+        Add some plumbing through PageClient, so that WebPageProxy can tell WebViewImpl when it is finished processing
+        all mouse events.
+
+        * UIProcess/win/PageClientImpl.h:
+
 2018-08-13  Alex Christensen  <[email protected]>
 
         Fix linux build after r234811

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (234815 => 234816)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-08-13 21:07:55 UTC (rev 234816)
@@ -6337,6 +6337,11 @@
     _page->setFooterBannerHeightForTesting(height);
 }
 
+- (void)_doAfterProcessingAllPendingMouseEvents:(dispatch_block_t)action
+{
+    _impl->doAfterProcessingAllPendingMouseEvents(action);
+}
+
 #endif // PLATFORM(MAC)
 
 - (void)_requestActiveNowPlayingSessionInfo:(void(^)(BOOL, BOOL, NSString*, double, double, NSInteger))callback

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (234815 => 234816)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2018-08-13 21:07:55 UTC (rev 234816)
@@ -445,6 +445,7 @@
 
 - (void)_setHeaderBannerHeight:(int)height WK_API_AVAILABLE(macosx(10.12.3));
 - (void)_setFooterBannerHeight:(int)height WK_API_AVAILABLE(macosx(10.12.3));
+- (void)_doAfterProcessingAllPendingMouseEvents:(dispatch_block_t)action WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 #endif
 
 - (void)_requestActiveNowPlayingSessionInfo:(void(^)(BOOL, BOOL, NSString*, double, double, NSInteger))callback WK_API_AVAILABLE(macosx(10.13.4), ios(11.3));

Modified: trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h (234815 => 234816)


--- trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h	2018-08-13 21:07:55 UTC (rev 234816)
@@ -145,6 +145,8 @@
     void isPlayingAudioWillChange() final { }
     void isPlayingAudioDidChange() final { }
 
+    void didFinishProcessingAllPendingMouseEvents() final { }
+
 #if ENABLE(VIDEO) && USE(GSTREAMER)
     bool decidePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&) override;
 #endif

Modified: trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h (234815 => 234816)


--- trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h	2018-08-13 21:07:55 UTC (rev 234816)
@@ -139,6 +139,8 @@
     void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
 #endif
 
+    void didFinishProcessingAllPendingMouseEvents() final { }
+
     WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
 
     WKWPE::View& m_view;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (234815 => 234816)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2018-08-13 21:07:55 UTC (rev 234816)
@@ -526,6 +526,9 @@
 
     void handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate);
 
+    void doAfterProcessingAllPendingMouseEvents(dispatch_block_t action);
+    void didFinishProcessingAllPendingMouseEvents();
+
 #if HAVE(TOUCH_BAR)
     NSTouchBar *makeTouchBar();
     void updateTouchBar();
@@ -622,6 +625,7 @@
     bool mightBeginScrollWhileInactive();
 
     void handleRequestedCandidates(NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates);
+    void flushPendingMouseEventCallbacks();
 
     WeakObjCPtr<NSView<WebViewImplDelegate>> m_view;
     std::unique_ptr<PageClient> m_pageClient;
@@ -732,6 +736,7 @@
     // that has been already sent to WebCore.
     RetainPtr<NSEvent> m_keyDownEventBeingResent;
     Vector<WebCore::KeypressCommand>* m_collectedKeypressCommands { nullptr };
+    Vector<BlockPtr<void()>> m_callbackHandlersAfterProcessingPendingMouseEvents;
 
     String m_lastStringForCandidateRequest;
     NSInteger m_lastCandidateRequestSequenceNumber;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (234815 => 234816)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2018-08-13 21:07:55 UTC (rev 234816)
@@ -1378,6 +1378,7 @@
         setAcceleratedCompositingRootLayer(nil);
 
     updateRemoteAccessibilityRegistration(false);
+    flushPendingMouseEventCallbacks();
 
     m_gestureController = nullptr;
 }
@@ -3144,6 +3145,29 @@
     m_page->handleAcceptedCandidate(textCheckingResultFromNSTextCheckingResult(acceptedCandidate));
 }
 
+void WebViewImpl::doAfterProcessingAllPendingMouseEvents(dispatch_block_t action)
+{
+    if (!m_page->isProcessingMouseEvents()) {
+        action();
+        return;
+    }
+
+    m_callbackHandlersAfterProcessingPendingMouseEvents.append(makeBlockPtr(action));
+}
+
+void WebViewImpl::didFinishProcessingAllPendingMouseEvents()
+{
+    flushPendingMouseEventCallbacks();
+}
+
+void WebViewImpl::flushPendingMouseEventCallbacks()
+{
+    for (auto& callback : m_callbackHandlersAfterProcessingPendingMouseEvents)
+        callback();
+
+    m_callbackHandlersAfterProcessingPendingMouseEvents.clear();
+}
+
 void WebViewImpl::preferencesDidChange()
 {
     BOOL needsViewFrameInWindowCoordinates = m_page->preferences().pluginsEnabled();

Modified: trunk/Source/WebKit/UIProcess/PageClient.h (234815 => 234816)


--- trunk/Source/WebKit/UIProcess/PageClient.h	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Source/WebKit/UIProcess/PageClient.h	2018-08-13 21:07:55 UTC (rev 234816)
@@ -393,8 +393,8 @@
     virtual void didChangeBackgroundColor() = 0;
     virtual void isPlayingAudioWillChange() = 0;
     virtual void isPlayingAudioDidChange() = 0;
-    virtual void pinnedStateWillChange() { };
-    virtual void pinnedStateDidChange() { };
+    virtual void pinnedStateWillChange() { }
+    virtual void pinnedStateDidChange() { }
 
 #if PLATFORM(MAC)
     virtual void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object*) = 0;
@@ -403,8 +403,9 @@
 
     virtual void didHandleAcceptedCandidate() = 0;
 #endif
+    virtual void didFinishProcessingAllPendingMouseEvents() = 0;
 
-    virtual void videoControlsManagerDidChange() { };
+    virtual void videoControlsManagerDidChange() { }
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
     virtual WebCore::WebMediaSessionManager& mediaSessionManager() = 0;

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (234815 => 234816)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-08-13 21:07:55 UTC (rev 234816)
@@ -5538,8 +5538,11 @@
         if (!m_mouseEventQueue.isEmpty()) {
             LOG(MouseHandling, " UIProcess: handling a queued mouse event from didReceiveEvent");
             processNextQueuedMouseEvent();
-        } else if (auto* automationSession = process().processPool().automationSession())
-            automationSession->mouseEventsFlushedForPage(*this);
+        } else {
+            if (auto* automationSession = process().processPool().automationSession())
+                automationSession->mouseEventsFlushedForPage(*this);
+            m_pageClient.didFinishProcessingAllPendingMouseEvents();
+        }
 
         break;
     }

Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (234815 => 234816)


--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2018-08-13 21:07:55 UTC (rev 234816)
@@ -218,6 +218,8 @@
     void didChangeDataInteractionCaretRect(const WebCore::IntRect& previousCaretRect, const WebCore::IntRect& caretRect) override;
 #endif
 
+    void didFinishProcessingAllPendingMouseEvents() final { }
+
     WKContentView *m_contentView;
     RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;
 };

Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (234815 => 234816)


--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h	2018-08-13 21:07:55 UTC (rev 234816)
@@ -238,6 +238,8 @@
     _WKRemoteObjectRegistry *remoteObjectRegistry() override;
 #endif
 
+    void didFinishProcessingAllPendingMouseEvents() final;
+
     NSView *m_view;
     WebViewImpl* m_impl { nullptr };
 #if USE(AUTOCORRECTION_PANEL)

Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (234815 => 234816)


--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm	2018-08-13 21:07:55 UTC (rev 234816)
@@ -888,6 +888,11 @@
 }
 #endif
 
+void PageClientImpl::didFinishProcessingAllPendingMouseEvents()
+{
+    m_impl->didFinishProcessingAllPendingMouseEvents();
+}
+
 void PageClientImpl::didRestoreScrollPosition()
 {
     m_impl->didRestoreScrollPosition();

Modified: trunk/Source/WebKit/UIProcess/win/PageClientImpl.h (234815 => 234816)


--- trunk/Source/WebKit/UIProcess/win/PageClientImpl.h	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Source/WebKit/UIProcess/win/PageClientImpl.h	2018-08-13 21:07:55 UTC (rev 234816)
@@ -140,6 +140,8 @@
 
     WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override { return WebCore::UserInterfaceLayoutDirection::LTR; }
 
+    void didFinishProcessingAllPendingMouseEvents() final { }
+
     // Members of PageClientImpl class
     DefaultUndoController m_undoController;
 

Modified: trunk/Tools/ChangeLog (234815 => 234816)


--- trunk/Tools/ChangeLog	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Tools/ChangeLog	2018-08-13 21:07:55 UTC (rev 234816)
@@ -1,3 +1,187 @@
+2018-08-13  Wenson Hsieh  <[email protected]>
+
+        [WK2] [macOS] Implement a mechanism to test drag and drop
+        https://bugs.webkit.org/show_bug.cgi?id=181898
+        <rdar://problem/39181698>
+
+        Reviewed by Simon Fraser.
+
+        Implements the currently stubbed DragAndDropSimulator on macOS, and introduces a new API test for r227266. See
+        comments below for more detail.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/DragAndDropTests.mm: Copied from Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm.
+
+        Introduce a file for cross-platform drag and drop tests, currently for iOS and macOS. Additionally add a test
+        for r227266, which was fixed earlier this year but could not be tested due to a lack of testing mechanism on
+        macOS in WebKit2.
+
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/full-page-dropzone.html: Added.
+
+        Minor tweaks to this test page to add "dragover" and "drop" event handlers.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/image-in-link-and-input.html:
+        * TestWebKitAPI/Tests/WebKitCocoa/link-in-iframe-and-input.html: Added.
+
+        Add a new test page that includes a link embedded within an iframe below a plain text input.
+
+        * TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm: Added.
+        (TEST):
+        * TestWebKitAPI/Tests/mac/LegacyDragAndDropTests.mm: Renamed from Tools/TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm.
+
+        Move only existing WebKit2 macOS drag and drop test (DragAndDropPasteboardTests.NumberOfValidItemsForDrop) out
+        of DragAndDropPasteboardTests.mm and into a new file, DragAndDropTestsMac.mm. Additionally, rename
+        DragAndDropPasteboardTests to LegacyDragAndDropTests, since it now only contains two legacy WebView tests for
+        drag and drop.
+
+        (+[FrameLoadCompletionListener listenerWithCompletionBlock:]):
+        (-[FrameLoadCompletionListener initWithCompletionBlock:]):
+        (-[FrameLoadCompletionListener webView:didFinishLoadForFrame:]):
+        (-[DragSource draggingSourceOperationMaskForLocal:]):
+        (-[DragInfo initWithImage:offset:pasteboard:source:destinationWindow:]):
+        (-[DragInfo lastMousePosition]):
+        (-[DragInfo setLastMousePosition:]):
+        (-[DragInfo draggingDestinationWindow]):
+        (-[DragInfo draggingSourceOperationMask]):
+        (-[DragInfo draggingLocation]):
+        (-[DragInfo draggedImageLocation]):
+        (-[DragInfo draggedImage]):
+        (-[DragInfo draggingPasteboard]):
+        (-[DragInfo draggingSource]):
+        (-[DragInfo draggingSequenceNumber]):
+        (-[DragInfo slideDraggedImageTo:]):
+        (-[DragInfo namesOfPromisedFilesDroppedAtDestination:]):
+        (-[DragInfo draggingFormation]):
+        (-[DragInfo setDraggingFormation:]):
+        (-[DragInfo animatesToDestination]):
+        (-[DragInfo setAnimatesToDestination:]):
+        (-[DragInfo numberOfValidItemsForDrop]):
+        (-[DragInfo setNumberOfValidItemsForDrop:]):
+        (-[DragInfo enumerateDraggingItemsWithOptions:forView:classes:searchOptions:usingBlock:]):
+        (-[DragInfo springLoadingHighlight]):
+        (-[DragInfo resetSpringLoading]):
+        (TestWebKitAPI::getTestImage):
+        (TestWebKitAPI::webViewAfterPerformingDragOperation):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/mac/full-page-dropzone.html: Removed.
+        * TestWebKitAPI/cocoa/DragAndDropSimulator.h:
+
+        Flesh out some of the DragAndDropSimulator API for macOS, exposing (among other things) the drag pasteboard,
+        the current NSDraggingInfo, the initial location of the drag image, and the drag image itself.
+
+        * TestWebKitAPI/cocoa/TestWKWebView.h:
+        * TestWebKitAPI/cocoa/TestWKWebView.mm:
+        (-[TestWKWebView mouseDownAtPoint:simulatePressure:]):
+        (-[TestWKWebView mouseUpAtPoint:]):
+        (-[TestWKWebView mouseMoveToPoint:withFlags:]):
+        (-[TestWKWebView sendClicksAtPoint:numberOfClicks:]):
+        (-[TestWKWebView mouseEnterAtPoint:]):
+        (-[TestWKWebView mouseExitAtPoint:]):
+        (-[TestWKWebView mouseDragToPoint:]):
+        (-[TestWKWebView _mouseEventWithType:atLocation:]):
+        (-[TestWKWebView _mouseEventWithType:atLocation:flags:timestamp:clickCount:]):
+
+        Add TestWKWebView helpers to send MouseMove, MouseEnter and MouseDrag NSEvents to the web view. Additionally,
+        rename parameter names to these helpers to make it more obvious that these locations are all in NSWindow
+        coordinates.
+
+        (-[TestWKWebView typeCharacter:]):
+
+        Drive-by style fix: put this opening brace on the beginning of the next line.
+
+        * TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm:
+        (-[DragAndDropSimulator initWithWebViewFrame:]):
+        (-[DragAndDropSimulator initWithWebViewFrame:configuration:]):
+        (-[DragAndDropSimulator webView]):
+
+        Small iOS DragAndDropSimulator adjustments for new DragAndDropSimulator interfaces.
+
+        * TestWebKitAPI/mac/DragAndDropSimulatorMac.mm:
+        (-[DragAndDropTestWKWebView initWithFrame:configuration:simulator:]):
+
+        Introduce a WKWebView subclass for testing drag and drop that overrides `-dragImage:at:offset:…`, and instead
+        allows DragAndDropSimulator to take over the drag.
+
+        (-[DragAndDropTestWKWebView dragImage:at:offset:event:pasteboard:source:slideBack:]):
+
+        Override this entry point into drag and drop code, and instead call out to the DragAndDropSimulator to
+        coordinate the drag.
+
+        (-[DragAndDropTestWKWebView waitForPendingMouseEvents]):
+
+        Helper method to wait for the web process to finish handling all in-flight mouse events.
+
+        (defaultExternalDragImage):
+
+        Set this image as the default drag image when simulating an incoming drag session from outside of the web view.
+
+        (-[DragAndDropSimulator initWithWebViewFrame:]):
+        (-[DragAndDropSimulator initWithWebViewFrame:configuration:]):
+        (-[DragAndDropSimulator flipAboutXAxisInHostWindow:]):
+
+        Helper method to flip a given point about the X axis of the window.
+
+        (-[DragAndDropSimulator locationInViewForCurrentProgress]):
+
+        Map a progress value (between 0 and 1) to a drag location.
+
+        (-[DragAndDropSimulator initialProgressForMouseDrag]):
+
+        Determines the initial progress value when initiation a drag in web content. This is the initial progress
+        required to ensure that the first mouse drag event exceeds the drag distance hysteresis and causes any drag
+        (if applicable) to begin.
+
+        (-[DragAndDropSimulator runFrom:to:]):
+        (-[DragAndDropSimulator performDragInWebView:atLocation:withImage:pasteboard:source:]):
+
+        Helper to coordinate drag updates in both the cases where we're simulating a drag session entering from outside
+        of the web view, and in the case where we've initiated a drag from the web view itself.
+
+        (-[DragAndDropSimulator webView]):
+        (-[DragAndDropSimulator setExternalDragPasteboard:]):
+        (-[DragAndDropSimulator externalDragPasteboard]):
+
+        Just like its iOS counterpart (setExternalItemProviders:), setting an external drag pasteboard on macOS puts the
+        DragAndDropSimulator in a mode that simulates a drag coming in from outside the web view, using the given
+        pasteboard.
+
+        (-[DragAndDropSimulator setExternalDragImage:]):
+        (-[DragAndDropSimulator externalDragImage]):
+
+        May be optionally set when specifying an external drag pasteboard to specify the drag image used. If no external
+        drag image is specified, falls back to the default image returned by `defaultExternalDragImage()`.
+
+        (-[DragAndDropSimulator draggingInfo]):
+        (-[DragAndDropSimulator willEndDraggingHandler]):
+        (-[DragAndDropSimulator setWillEndDraggingHandler:]):
+
+        Hook to allow tests to run logic right before performing the drop (if the current drag operation is not none) or
+        ending the drag session without performing a drag operation.
+
+        (-[DragAndDropSimulator initWithWebView:]): Deleted.
+        (-[DragAndDropSimulator dealloc]): Deleted.
+        (-[DragAndDropSimulator phase]): Deleted.
+        * TestWebKitAPI/mac/TestDraggingInfo.h: Copied from Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm.
+        * TestWebKitAPI/mac/TestDraggingInfo.mm: Added.
+
+        Mock object conforming to NSDraggingInfo that is passed to WKWebView when invoking -draggingUpdated:,
+        -draggingEntered: and -draggingExited:.
+
+        (-[TestDraggingInfo draggingPasteboard]):
+        (-[TestDraggingInfo setDraggingPasteboard:]):
+        (-[TestDraggingInfo draggingSource]):
+        (-[TestDraggingInfo setDraggingSource:]):
+        (-[TestDraggingInfo enumerateDraggingItemsWithOptions:forView:classes:searchOptions:usingBlock:]):
+        (-[TestDraggingInfo draggingDestinationWindow]):
+        (-[TestDraggingInfo draggedImage]):
+        (-[TestDraggingInfo setDraggedImage:]):
+        (-[TestDraggingInfo slideDraggedImageTo:]):
+        (-[TestDraggingInfo namesOfPromisedFilesDroppedAtDestination:]):
+        (-[TestDraggingInfo resetSpringLoading]):
+
+        Empty method stubs, to be implemented in the future as needed.
+
 2018-08-13  Thomas Denney  <[email protected]>
 
         Added Thomas Denney to contributors.json.

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (234815 => 234816)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-08-13 21:07:55 UTC (rev 234816)
@@ -303,7 +303,6 @@
 		6BFD294C1D5E6C1D008EC968 /* HashCountedSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */; };
 		751B05D61F8EAC410028A09E /* DatabaseTrackerTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 751B05D51F8EAC1A0028A09E /* DatabaseTrackerTest.mm */; };
 		754CEC811F6722F200D0039A /* AutoFillAvailable.mm in Sources */ = {isa = PBXBuildFile; fileRef = 754CEC801F6722DC00D0039A /* AutoFillAvailable.mm */; };
-		764322D71B61CCC30024F801 /* WordBoundaryTypingAttributes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 764322D51B61CCA40024F801 /* WordBoundaryTypingAttributes.mm */; };
 		7673499D1930C5BB00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7673499A1930182E00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp */; };
 		76E182DD1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76E182DC1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp */; };
 		76E182DF154767E600F1FADD /* auto-submitting-form.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 76E182DE15475A8300F1FADD /* auto-submitting-form.html */; };
@@ -660,7 +659,6 @@
 		A179918B1E1CA24100A505ED /* SharedBufferTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A17991891E1CA24100A505ED /* SharedBufferTest.cpp */; };
 		A17EAC55208305A00084B41B /* find.pdf in Copy Resources */ = {isa = PBXBuildFile; fileRef = A17EAC542083056E0084B41B /* find.pdf */; };
 		A180C0FA1EE67DF000468F47 /* RunOpenPanel.mm in Sources */ = {isa = PBXBuildFile; fileRef = A180C0F91EE67DF000468F47 /* RunOpenPanel.mm */; };
-		A1819B13208975D300C09B83 /* full-page-dropzone.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A1819B1220894D0400C09B83 /* full-page-dropzone.html */; };
 		A1C4FB731BACD1CA003742D0 /* pages.pages in Copy Resources */ = {isa = PBXBuildFile; fileRef = A1C4FB721BACD1B7003742D0 /* pages.pages */; };
 		A1DF74321C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1DF74301C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm */; };
 		A1EC11881F42541200D0146E /* PreviewLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1EC11871F42541200D0146E /* PreviewLoader.cpp */; };
@@ -813,6 +811,9 @@
 		F45E15732112CE2900307E82 /* KeyboardInputTestsIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = F45E15722112CE2900307E82 /* KeyboardInputTestsIOS.mm */; };
 		F45E15762112CE6200307E82 /* TestInputDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = F45E15752112CE6200307E82 /* TestInputDelegate.mm */; };
 		F46128B7211C8ED500D9FADB /* DragAndDropSimulatorMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = F46128B6211C8ED500D9FADB /* DragAndDropSimulatorMac.mm */; };
+		F46128CB211D475100D9FADB /* TestDraggingInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = F46128CA211D475100D9FADB /* TestDraggingInfo.mm */; };
+		F46128D4211E40FD00D9FADB /* link-in-iframe-and-input.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F46128D1211E2D2500D9FADB /* link-in-iframe-and-input.html */; };
+		F46128D7211E489C00D9FADB /* DragAndDropTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F46128D6211E489C00D9FADB /* DragAndDropTests.mm */; };
 		F464AF9220BB66EA007F9B18 /* RenderingProgressTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F464AF9120BB66EA007F9B18 /* RenderingProgressTests.mm */; };
 		F46849BE1EEF58E400B937FE /* UIPasteboardTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F46849BD1EEF58E400B937FE /* UIPasteboardTests.mm */; };
 		F46849C01EEF5EF300B937FE /* rich-and-plain-text.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F46849BF1EEF5EDC00B937FE /* rich-and-plain-text.html */; };
@@ -828,7 +829,7 @@
 		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 */; };
 		F4B86D4F20BCD5B20099A7E6 /* paint-significant-area-milestone.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4B86D4E20BCD5970099A7E6 /* paint-significant-area-milestone.html */; };
-		F4BFA68E1E4AD08000154298 /* DragAndDropPasteboardTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */; };
+		F4BFA68E1E4AD08000154298 /* LegacyDragAndDropTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4BFA68C1E4AD08000154298 /* LegacyDragAndDropTests.mm */; };
 		F4C2AB221DD6D95E00E06D5B /* enormous-video-with-sound.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */; };
 		F4C8797F2059D8D3009CD00B /* ScrollViewInsetTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4C8797E2059D8D3009CD00B /* ScrollViewInsetTests.mm */; };
 		F4CD74C620FDACFA00DE3794 /* text-with-async-script.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4CD74C520FDACF500DE3794 /* text-with-async-script.html */; };
@@ -840,6 +841,8 @@
 		F4D65DA81F5E4704009D8C27 /* selected-text-image-link-and-editable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4D65DA71F5E46C0009D8C27 /* selected-text-image-link-and-editable.html */; };
 		F4DEF6ED1E9B4DB60048EF61 /* image-in-link-and-input.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4DEF6EC1E9B4D950048EF61 /* image-in-link-and-input.html */; };
 		F4E0A296211FC5FB00AF7C7F /* selected-text-and-textarea.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4E0A295211FC5A300AF7C7F /* selected-text-and-textarea.html */; };
+		F4E0A28B211E4A2B00AF7C7F /* full-page-dropzone.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F46128D8211E496300D9FADB /* full-page-dropzone.html */; };
+		F4E0A28F211E5D5B00AF7C7F /* DragAndDropTestsMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4E0A28E211E5D5B00AF7C7F /* DragAndDropTestsMac.mm */; };
 		F4E3D80820F70BB9007B58C5 /* significant-text-milestone-article.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4E3D80720F708E4007B58C5 /* significant-text-milestone-article.html */; };
 		F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */; };
 		F4F405BC1D4C0D1C007A9707 /* full-size-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */; };
@@ -1013,7 +1016,7 @@
 				932AE53D1D371047005DFFAF /* focus-inputs.html in Copy Resources */,
 				1A7E8B3618120B2F00AEB74A /* FragmentNavigation.html in Copy Resources */,
 				F47728991E4AE3C1007ABF6A /* full-page-contenteditable.html in Copy Resources */,
-				A1819B13208975D300C09B83 /* full-page-dropzone.html in Copy Resources */,
+				F4E0A28B211E4A2B00AF7C7F /* full-page-dropzone.html in Copy Resources */,
 				F4F405BC1D4C0D1C007A9707 /* full-size-autoplaying-video-with-audio.html in Copy Resources */,
 				CD78E11E1DB7EE2A0014A2DE /* FullscreenDelegate.html in Copy Resources */,
 				3FBD1B4A1D3D66AB00E6D6FA /* FullscreenLayoutConstraints.html in Copy Resources */,
@@ -1085,6 +1088,7 @@
 				C25CCA0B1E5140C10026CB8A /* LineBreaking.html in Copy Resources */,
 				F41AB9A61EF4696B0083FA08 /* link-and-input.html in Copy Resources */,
 				F41AB9A71EF4696B0083FA08 /* link-and-target-div.html in Copy Resources */,
+				F46128D4211E40FD00D9FADB /* link-in-iframe-and-input.html in Copy Resources */,
 				8361F1781E610B4E00759B25 /* link-with-download-attribute-with-slashes.html in Copy Resources */,
 				8349D3C41DB9728E004A9F65 /* link-with-download-attribute.html in Copy Resources */,
 				378E64791632707400B6C676 /* link-with-title.html in Copy Resources */,
@@ -1585,7 +1589,6 @@
 		754CEC801F6722DC00D0039A /* AutoFillAvailable.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AutoFillAvailable.mm; sourceTree = "<group>"; };
 		7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCacheAddImageToCacheIOS.mm; sourceTree = "<group>"; };
 		75F3133F18C171B70041CAEC /* EphemeralSessionPushStateNoHistoryCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EphemeralSessionPushStateNoHistoryCallback.cpp; sourceTree = "<group>"; };
-		764322D51B61CCA40024F801 /* WordBoundaryTypingAttributes.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WordBoundaryTypingAttributes.mm; sourceTree = "<group>"; };
 		76734997193016DC00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StopLoadingDuringDidFailProvisionalLoad.cpp; sourceTree = "<group>"; };
 		7673499A1930182E00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StopLoadingDuringDidFailProvisionalLoad_bundle.cpp; sourceTree = "<group>"; };
 		76E182D91547550100F1FADD /* WillSendSubmitEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillSendSubmitEvent.cpp; sourceTree = "<group>"; };
@@ -1791,7 +1794,6 @@
 		A179918A1E1CA24100A505ED /* SharedBufferTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedBufferTest.h; sourceTree = "<group>"; };
 		A17EAC542083056E0084B41B /* find.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = find.pdf; path = Tests/WebKit/find.pdf; sourceTree = SOURCE_ROOT; };
 		A180C0F91EE67DF000468F47 /* RunOpenPanel.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RunOpenPanel.mm; sourceTree = "<group>"; };
-		A1819B1220894D0400C09B83 /* full-page-dropzone.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "full-page-dropzone.html"; sourceTree = "<group>"; };
 		A18AA8CC1C3FA218009B2B97 /* ContentFiltering.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentFiltering.h; sourceTree = "<group>"; };
 		A1A4FE5D18DD3DB700B5EA8A /* Download.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Download.mm; sourceTree = "<group>"; };
 		A1C4FB6C1BACCE50003742D0 /* QuickLook.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QuickLook.mm; sourceTree = "<group>"; };
@@ -2048,6 +2050,11 @@
 		F45E15752112CE6200307E82 /* TestInputDelegate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TestInputDelegate.mm; sourceTree = "<group>"; };
 		F46128B4211C861A00D9FADB /* DragAndDropSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DragAndDropSimulator.h; path = cocoa/DragAndDropSimulator.h; sourceTree = "<group>"; };
 		F46128B6211C8ED500D9FADB /* DragAndDropSimulatorMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropSimulatorMac.mm; sourceTree = "<group>"; };
+		F46128C9211D475100D9FADB /* TestDraggingInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TestDraggingInfo.h; sourceTree = "<group>"; };
+		F46128CA211D475100D9FADB /* TestDraggingInfo.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TestDraggingInfo.mm; sourceTree = "<group>"; };
+		F46128D1211E2D2500D9FADB /* link-in-iframe-and-input.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "link-in-iframe-and-input.html"; sourceTree = "<group>"; };
+		F46128D6211E489C00D9FADB /* DragAndDropTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropTests.mm; sourceTree = "<group>"; };
+		F46128D8211E496300D9FADB /* full-page-dropzone.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "full-page-dropzone.html"; sourceTree = "<group>"; };
 		F464AF9120BB66EA007F9B18 /* RenderingProgressTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderingProgressTests.mm; sourceTree = "<group>"; };
 		F46849BD1EEF58E400B937FE /* UIPasteboardTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = UIPasteboardTests.mm; sourceTree = "<group>"; };
 		F46849BF1EEF5EDC00B937FE /* rich-and-plain-text.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "rich-and-plain-text.html"; sourceTree = "<group>"; };
@@ -2064,7 +2071,7 @@
 		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>"; };
 		F4B86D4E20BCD5970099A7E6 /* paint-significant-area-milestone.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "paint-significant-area-milestone.html"; sourceTree = "<group>"; };
-		F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropPasteboardTests.mm; sourceTree = "<group>"; };
+		F4BFA68C1E4AD08000154298 /* LegacyDragAndDropTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyDragAndDropTests.mm; sourceTree = "<group>"; };
 		F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "enormous-video-with-sound.html"; sourceTree = "<group>"; };
 		F4C8797E2059D8D3009CD00B /* ScrollViewInsetTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollViewInsetTests.mm; sourceTree = "<group>"; };
 		F4CD74C520FDACF500DE3794 /* text-with-async-script.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "text-with-async-script.html"; sourceTree = "<group>"; };
@@ -2077,6 +2084,7 @@
 		F4D65DA71F5E46C0009D8C27 /* selected-text-image-link-and-editable.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "selected-text-image-link-and-editable.html"; sourceTree = "<group>"; };
 		F4DEF6EC1E9B4D950048EF61 /* image-in-link-and-input.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "image-in-link-and-input.html"; sourceTree = "<group>"; };
 		F4E0A295211FC5A300AF7C7F /* selected-text-and-textarea.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "selected-text-and-textarea.html"; sourceTree = "<group>"; };
+		F4E0A28E211E5D5B00AF7C7F /* DragAndDropTestsMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropTestsMac.mm; sourceTree = "<group>"; };
 		F4E3D80720F708E4007B58C5 /* significant-text-milestone-article.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "significant-text-milestone-article.html"; sourceTree = "<group>"; };
 		F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-test-now-playing.html"; sourceTree = "<group>"; };
 		F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "full-size-autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
@@ -2299,6 +2307,7 @@
 				518EE51620A78CDF00E024F3 /* DoubleDefersLoading.mm */,
 				518EE51720A78CDF00E024F3 /* DoubleDefersLoadingPlugin.mm */,
 				A1A4FE5D18DD3DB700B5EA8A /* Download.mm */,
+				F46128D6211E489C00D9FADB /* DragAndDropTests.mm */,
 				A15502281E05020B00A24C57 /* DuplicateCompletionHandlerCalls.mm */,
 				F44D06461F395C4D001A0E29 /* EditorStateTests.mm */,
 				CDA29B2820FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm */,
@@ -2632,6 +2641,7 @@
 				A17EAC542083056E0084B41B /* find.pdf */,
 				F43E3BC020DADB8000A4E7ED /* fixed-nav-bar.html */,
 				93575C551D30366E000D604D /* focus-inputs.html */,
+				F46128D8211E496300D9FADB /* full-page-dropzone.html */,
 				F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */,
 				CD78E11B1DB7EA360014A2DE /* FullscreenDelegate.html */,
 				3FBD1B491D39D1DB00E6D6FA /* FullscreenLayoutConstraints.html */,
@@ -2686,6 +2696,7 @@
 				C25CCA0A1E513F490026CB8A /* LineBreaking.html */,
 				F41AB9961EF4692C0083FA08 /* link-and-input.html */,
 				F41AB99D1EF4692C0083FA08 /* link-and-target-div.html */,
+				F46128D1211E2D2500D9FADB /* link-in-iframe-and-input.html */,
 				8C10AF97206467830018FD90 /* localstorage-empty-string-value.html */,
 				51E6A8951D2F1C7700C004B6 /* LocalStorageClear.html */,
 				46C519E21D35629600DAA51A /* LocalStorageNullEntries.html */,
@@ -3127,6 +3138,8 @@
 				C081224413FC19EC00DC39AE /* SyntheticBackingScaleFactorWindow.m */,
 				29AB8AA3164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.h */,
 				29AB8AA2164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.mm */,
+				F46128C9211D475100D9FADB /* TestDraggingInfo.h */,
+				F46128CA211D475100D9FADB /* TestDraggingInfo.mm */,
 				C08587BE13FE956C001EF4E5 /* WebKitAgnosticTest.h */,
 				C08587BD13FE956C001EF4E5 /* WebKitAgnosticTest.mm */,
 			);
@@ -3171,7 +3184,7 @@
 				46397B941DC2C850009A78AE /* DOMNode.mm */,
 				3751AF7A169518F800764319 /* DOMNodeFromJSObject.mm */,
 				37DC678B140D7C5000ABCCDB /* DOMRangeOfString.mm */,
-				F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */,
+				F4E0A28E211E5D5B00AF7C7F /* DragAndDropTestsMac.mm */,
 				C07E6CAE13FD67650038B22B /* DynamicDeviceScaleFactor.mm */,
 				1A9FB6CC1CA34BE500966124 /* EarlyKVOCrash.mm */,
 				4BB4160316815F9100824238 /* ElementAtPointInWebFrame.mm */,
@@ -3184,6 +3197,7 @@
 				C507E8A614C6545B005D6B3B /* InspectorBar.mm */,
 				57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */,
 				4BB4160116815B2600824238 /* JSWrapperForNodeInWebFrame.mm */,
+				F4BFA68C1E4AD08000154298 /* LegacyDragAndDropTests.mm */,
 				7A7B0E7E1EAFE454006AB8AE /* LimitTitleSize.mm */,
 				57901FAE1CAF137100ED64F9 /* LoadInvalidURLRequest.mm */,
 				CDA315961ED53651009F60D3 /* MediaPlaybackSleepAssertion.mm */,
@@ -3220,7 +3234,6 @@
 				1A7BFC0A171A0BDB00BC5F64 /* WillSendSubmitEvent.mm */,
 				A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */,
 				F4FA917F1E61849B007B8C1D /* WKWebViewMacEditingTests.mm */,
-				764322D51B61CCA40024F801 /* WordBoundaryTypingAttributes.mm */,
 			);
 			path = mac;
 			sourceTree = "<group>";
@@ -3240,7 +3253,6 @@
 				F4FA91821E618566007B8C1D /* double-click-does-not-select-trailing-space.html */,
 				1A7E8B351812093600AEB74A /* FragmentNavigation.html */,
 				F47728981E4AE3AD007ABF6A /* full-page-contenteditable.html */,
-				A1819B1220894D0400C09B83 /* full-page-dropzone.html */,
 				CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */,
 				9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */,
 				9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */,
@@ -3713,10 +3725,11 @@
 				518EE51820A78CE200E024F3 /* DoubleDefersLoading.mm in Sources */,
 				7CCE7F231A411AF600447C4C /* Download.mm in Sources */,
 				7CCE7EEE1A411AE600447C4C /* DownloadDecideDestinationCrash.cpp in Sources */,
-				F4BFA68E1E4AD08000154298 /* DragAndDropPasteboardTests.mm in Sources */,
 				F4D4F3B61E4E2BCB00BB2767 /* DragAndDropSimulatorIOS.mm in Sources */,
 				F46128B7211C8ED500D9FADB /* DragAndDropSimulatorMac.mm in Sources */,
+				F46128D7211E489C00D9FADB /* DragAndDropTests.mm in Sources */,
 				F4D4F3B91E4E36E400BB2767 /* DragAndDropTestsIOS.mm in Sources */,
+				F4E0A28F211E5D5B00AF7C7F /* DragAndDropTestsMac.mm in Sources */,
 				A155022A1E05020B00A24C57 /* DuplicateCompletionHandlerCalls.mm in Sources */,
 				7CCE7EBE1A411A7E00447C4C /* DynamicDeviceScaleFactor.mm in Sources */,
 				5C0BF8921DD599B600B00328 /* EarlyKVOCrash.mm in Sources */,
@@ -3802,6 +3815,7 @@
 				F45E15732112CE2900307E82 /* KeyboardInputTestsIOS.mm in Sources */,
 				7CCE7F061A411AE600447C4C /* LayoutMilestonesWithAllContentInFrame.cpp in Sources */,
 				7CCE7EDF1A411A9200447C4C /* LayoutUnit.cpp in Sources */,
+				F4BFA68E1E4AD08000154298 /* LegacyDragAndDropTests.mm in Sources */,
 				7A66BDB61EAF14EF00CCC924 /* LimitTitleSize.cpp in Sources */,
 				7A7B0E7F1EAFE4C3006AB8AE /* LimitTitleSize.mm in Sources */,
 				C25CCA061E51380B0026CB8A /* LineBreaking.mm in Sources */,
@@ -3940,6 +3954,7 @@
 				1C734B5320788C4800F430EA /* SystemColors.mm in Sources */,
 				7CCE7F161A411AE600447C4C /* TerminateTwice.cpp in Sources */,
 				7CCE7EA91A411A1D00447C4C /* TestBrowsingContextLoadDelegate.mm in Sources */,
+				F46128CB211D475100D9FADB /* TestDraggingInfo.mm in Sources */,
 				F45E15762112CE6200307E82 /* TestInputDelegate.mm in Sources */,
 				2D1C04A71D76298B000A6816 /* TestNavigationDelegate.mm in Sources */,
 				A14FC5901B8AE36F00D107EB /* TestProtocol.mm in Sources */,
@@ -4036,7 +4051,6 @@
 				F4FA91811E61849B007B8C1D /* WKWebViewMacEditingTests.mm in Sources */,
 				93F56DA91E5F919D003EDE84 /* WKWebViewSnapshot.mm in Sources */,
 				9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */,
-				764322D71B61CCC30024F801 /* WordBoundaryTypingAttributes.mm in Sources */,
 				9C64DC321D76198A004B598E /* YouTubePluginReplacement.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;

Copied: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DragAndDropTests.mm (from rev 234815, trunk/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm) (0 => 234816)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DragAndDropTests.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DragAndDropTests.mm	2018-08-13 21:07:55 UTC (rev 234816)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "DragAndDropSimulator.h"
+#import "PlatformUtilities.h"
+
+#if WK_API_ENABLED && ENABLE(DRAG_SUPPORT)
+
+TEST(DragAndDropTests, DragImageLocationForLinkInSubframe)
+{
+    auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:CGRectMake(0, 0, 400, 400)]);
+    [[simulator webView] synchronouslyLoadTestPageNamed:@"link-in-iframe-and-input"];
+    [simulator runFrom:NSMakePoint(200, 375) to:NSMakePoint(200, 125)];
+
+    EXPECT_WK_STREQ("https://www.apple.com/", [[simulator webView] stringByEvaluatingJavaScript:@"document.querySelector('input').value"]);
+
+#if PLATFORM(MAC)
+    EXPECT_TRUE(NSPointInRect([simulator initialDragImageLocationInView], NSMakeRect(0, 250, 400, 250)));
+#endif
+}
+
+#endif // WK_API_ENABLED && ENABLE(DRAG_SUPPORT)

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/full-page-dropzone.html (0 => 234816)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/full-page-dropzone.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/full-page-dropzone.html	2018-08-13 21:07:55 UTC (rev 234816)
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<meta name="viewport" content="width=device-width">
+<body style="width: 100vw; height: 100vh; margin: 0;"
+    _ondragenter_="window.observedDragEnter = true; return false;"
+    _ondragover_="window.observedDragOver = true; return false;"
+    _ondrop_="window.observedDrop = true; return false;">

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/image-in-link-and-input.html (234815 => 234816)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/image-in-link-and-input.html	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/image-in-link-and-input.html	2018-08-13 21:07:55 UTC (rev 234816)
@@ -25,6 +25,6 @@
 </head>
 
 <body>
-    <div><a id="link" href="" src=""
-    <div><input id="editor"></input></div>
+    <div id="top"><a id="link" href="" src=""
+    <div id="bottom"><input id="editor"></input></div>
 </body>

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/link-in-iframe-and-input.html (0 => 234816)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/link-in-iframe-and-input.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/link-in-iframe-and-input.html	2018-08-13 21:07:55 UTC (rev 234816)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+body, html {
+    width: 100%;
+    height: 100%;
+    margin: 0;
+}
+
+iframe, input {
+    width: 100%;
+    height: 250px;
+    display: block;
+    font-size: 100px;
+}
+</style>
+</head>
+<body>
+<input></input>
+<iframe srcdoc="<a href='' style='font-size: 100px;'>Link to apple.com</a>">
+</body>

Deleted: trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm (234815 => 234816)


--- trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm	2018-08-13 21:07:55 UTC (rev 234816)
@@ -1,288 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if PLATFORM(MAC)
-
-#import "PlatformUtilities.h"
-#import "TestWKWebView.h"
-#import <AppKit/NSDragging.h>
-#import <WebKit/WebView.h>
-#import <wtf/BlockPtr.h>
-#import <wtf/RetainPtr.h>
-
-@interface FrameLoadCompletionListener : NSObject<WebFrameLoadDelegate> {
-    BlockPtr<void (void)> _completionBlock;
-}
-+ (instancetype)listenerWithCompletionBlock:(dispatch_block_t)completionBlock;
-@end
-
-@implementation FrameLoadCompletionListener
-
-+ (instancetype)listenerWithCompletionBlock:(dispatch_block_t)completionBlock
-{
-    return [[[FrameLoadCompletionListener alloc] initWithCompletionBlock:completionBlock] autorelease];
-}
-
-- (instancetype)initWithCompletionBlock:(dispatch_block_t)completionBlock
-{
-    if (self = [super init])
-        _completionBlock = completionBlock;
-
-    return self;
-}
-
-- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
-{
-    if (_completionBlock)
-        _completionBlock();
-}
-@end
-
-@interface DragSource : NSObject
-- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag;
-@end
-
-@implementation DragSource
-
-- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag
-{
-    return NSDragOperationCopy;
-}
-
-@end
-
-@interface DragInfo : NSObject<NSDraggingInfo> {
-    NSPoint _lastMousePosition;
-    RetainPtr<NSImage> _image;
-    RetainPtr<NSPasteboard> _pasteboard;
-    RetainPtr<DragSource> _source;
-    RetainPtr<NSWindow> _window;
-    NSSize _offset;
-    NSInteger _numberOfValidItemsForDrop;
-}
-@property (nonatomic) NSPoint lastMousePosition;
-@end
-
-@implementation DragInfo
-
-- (id)initWithImage:(NSImage *)image offset:(NSSize)offset pasteboard:(NSPasteboard *)pasteboard source:(DragSource *)source destinationWindow:(NSWindow *)destinationWindow
-{
-    if (self = [super init]) {
-        _image = image;
-        _pasteboard = pasteboard;
-        _source = source;
-        _window = destinationWindow;
-        _offset = offset;
-    }
-    return self;
-}
-
-- (NSPoint)lastMousePosition
-{
-    return _lastMousePosition;
-}
-
-- (void)setLastMousePosition:(NSPoint)lastMousePosition
-{
-    _lastMousePosition = lastMousePosition;
-}
-
-- (NSWindow *)draggingDestinationWindow
-{
-    return _window.get();
-}
-
-- (NSDragOperation)draggingSourceOperationMask
-{
-    return NSDragOperationCopy;
-}
-
-- (NSPoint)draggingLocation
-{
-    return _lastMousePosition;
-}
-
-- (NSPoint)draggedImageLocation
-{
-    return NSMakePoint(_lastMousePosition.x + _offset.width, _lastMousePosition.y + _offset.height);
-}
-
-- (NSImage *)draggedImage
-{
-    return _image.get();
-}
-
-- (NSPasteboard *)draggingPasteboard
-{
-    return _pasteboard.get();
-}
-
-- (id)draggingSource
-{
-    return _source.get();
-}
-
-- (NSInteger)draggingSequenceNumber
-{
-    return 0;
-}
-
-- (void)slideDraggedImageTo:(NSPoint)screenPoint
-{
-}
-
-- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
-{
-    return nil;
-}
-
-- (NSDraggingFormation)draggingFormation
-{
-    return NSDraggingFormationDefault;
-}
-
-- (void)setDraggingFormation:(NSDraggingFormation)formation
-{
-}
-
-- (BOOL)animatesToDestination
-{
-    return NO;
-}
-
-- (void)setAnimatesToDestination:(BOOL)flag
-{
-}
-
-- (NSInteger)numberOfValidItemsForDrop
-{
-    return _numberOfValidItemsForDrop;
-}
-
-- (void)setNumberOfValidItemsForDrop:(NSInteger)number
-{
-    _numberOfValidItemsForDrop = number;
-}
-
-- (void)enumerateDraggingItemsWithOptions:(NSEnumerationOptions)enumOpts forView:(NSView *)view classes:(NSArray *)classArray searchOptions:(NSDictionary *)searchOptions usingBlock:(void (^)(NSDraggingItem *draggingItem, NSInteger idx, BOOL *stop))block
-{
-}
-
-- (NSSpringLoadingHighlight)springLoadingHighlight
-{
-    return NSSpringLoadingHighlightNone;
-}
-
-- (void)resetSpringLoading
-{
-}
-
-@end
-
-namespace TestWebKitAPI {
-
-static NSImage *getTestImage()
-{
-    return [[[NSImage alloc] initWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"icon" withExtension:@"png" subdirectory:@"TestWebKitAPI.resources"]] autorelease];
-}
-
-static WebView *webViewAfterPerformingDragOperation(NSPasteboard *pasteboard)
-{
-    RetainPtr<WebView> destination = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
-    RetainPtr<NSWindow> hostWindow = adoptNS([[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 400, 400) styleMask:0 backing:NSBackingStoreBuffered defer:NO]);
-    [hostWindow setFrameOrigin:NSMakePoint(0, 0)];
-    [[hostWindow contentView] addSubview:destination.get()];
-    __block bool isDone = false;
-    [destination setFrameLoadDelegate:[FrameLoadCompletionListener listenerWithCompletionBlock:^() {
-        RetainPtr<DragSource> source = adoptNS([[DragSource alloc] init]);
-        RetainPtr<DragInfo> info = adoptNS([[DragInfo alloc] initWithImage:getTestImage() offset:NSMakeSize(0, 0) pasteboard:pasteboard source:source.get() destinationWindow:hostWindow.get()]);
-        [info setLastMousePosition:NSMakePoint(0, 200)];
-        [destination draggingEntered:info.get()];
-        [info setLastMousePosition:NSMakePoint(200, 200)];
-        [destination draggingUpdated:info.get()];
-
-        EXPECT_TRUE([destination performDragOperation:info.get()]);
-        isDone = true;
-    }]];
-    [[destination mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"full-page-contenteditable" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
-
-    TestWebKitAPI::Util::run(&isDone);
-    return destination.get();
-}
-
-TEST(DragAndDropPasteboardTests, DropUTF8PlainText)
-{
-    NSPasteboard *pasteboard = [NSPasteboard pasteboardWithUniqueName];
-    [pasteboard setData:[@"I am a WebKit." dataUsingEncoding:NSUTF8StringEncoding] forType:(__bridge NSString *)kUTTypeUTF8PlainText];
-
-    RetainPtr<WebView> resultingWebView = webViewAfterPerformingDragOperation(pasteboard);
-    EXPECT_TRUE([[resultingWebView stringByEvaluatingJavaScriptFromString:@"document.body.textContent"] containsString:@"I am a WebKit."]);
-}
-
-TEST(DragAndDropPasteboardTests, DropJPEG)
-{
-    NSPasteboard *pasteboard = [NSPasteboard pasteboardWithUniqueName];
-    NSImage *icon = getTestImage();
-    NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:icon.TIFFRepresentation];
-    [pasteboard setData:[imageRep representationUsingType:NSJPEGFileType properties:@{ NSImageCompressionFactor: @(0.9) }] forType:(__bridge NSString *)kUTTypeJPEG];
-
-    RetainPtr<WebView> resultingWebView = webViewAfterPerformingDragOperation(pasteboard);
-    EXPECT_TRUE([[resultingWebView stringByEvaluatingJavaScriptFromString:@"document.querySelector('img').tagName === 'IMG'"] isEqualToString:@"true"]);
-}
-    
-#if WK_API_ENABLED
-
-TEST(DragAndDropPasteboardTests, NumberOfValidItemsForDrop)
-{
-    NSPasteboard *pasteboard = [NSPasteboard pasteboardWithUniqueName];
-    [pasteboard declareTypes:@[NSFilenamesPboardType] owner:nil];
-    [pasteboard setPropertyList:@[@"file-name"] forType:NSFilenamesPboardType];
-
-    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
-    auto hostWindow = adoptNS([[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 400, 400) styleMask:0 backing:NSBackingStoreBuffered defer:NO]);
-    [hostWindow setFrameOrigin:NSMakePoint(0, 0)];
-    [[hostWindow contentView] addSubview:webView.get()];
-
-    [webView synchronouslyLoadTestPageNamed:@"full-page-dropzone"];
-
-    auto dragSource = adoptNS([[DragSource alloc] init]);
-    auto dragInfo = adoptNS([[DragInfo alloc] initWithImage:getTestImage() offset:NSMakeSize(0, 0) pasteboard:pasteboard source:dragSource.get() destinationWindow:hostWindow.get()]);
-
-    [dragInfo setLastMousePosition:NSMakePoint(0, 200)];
-    [webView draggingEntered:dragInfo.get()];
-    EXPECT_WK_STREQ(@"1", [webView stringByEvaluatingJavaScript:@"window.dragEnteredForTesting"]);
-
-    [dragInfo setLastMousePosition:NSMakePoint(200, 200)];
-    [webView draggingUpdated:dragInfo.get()];
-    EXPECT_EQ(1U, [dragInfo numberOfValidItemsForDrop]);
-}
-
-#endif // WK_API_ENABLED
-
-} // namespace TestWebKitAPI
-
-#endif

Added: trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm (0 => 234816)


--- trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm	2018-08-13 21:07:55 UTC (rev 234816)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "DragAndDropSimulator.h"
+#import "PlatformUtilities.h"
+
+#if WK_API_ENABLED && ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
+
+TEST(DragAndDropTests, NumberOfValidItemsForDrop)
+{
+    NSPasteboard *pasteboard = [NSPasteboard pasteboardWithUniqueName];
+    [pasteboard declareTypes:@[NSFilenamesPboardType] owner:nil];
+    [pasteboard setPropertyList:@[@"file-name"] forType:NSFilenamesPboardType];
+
+    auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:NSMakeRect(0, 0, 400, 400)]);
+    TestWKWebView *webView = [simulator webView];
+    [simulator setExternalDragPasteboard:pasteboard];
+
+    auto hostWindow = adoptNS([[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 400, 400) styleMask:0 backing:NSBackingStoreBuffered defer:NO]);
+    [hostWindow setFrameOrigin:NSMakePoint(0, 0)];
+    [[hostWindow contentView] addSubview:webView];
+    [webView synchronouslyLoadTestPageNamed:@"full-page-dropzone"];
+
+    NSInteger numberOfValidItemsForDrop = 0;
+    [simulator setWillEndDraggingHandler:[&numberOfValidItemsForDrop, simulator] {
+        numberOfValidItemsForDrop = [simulator draggingInfo].numberOfValidItemsForDrop;
+    }];
+
+    [simulator runFrom:NSMakePoint(0, 0) to:NSMakePoint(200, 200)];
+
+    EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"observedDragEnter"].boolValue);
+    EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"observedDragOver"].boolValue);
+    EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"observedDrop"].boolValue);
+    EXPECT_EQ(1U, numberOfValidItemsForDrop);
+}
+
+#endif // WK_API_ENABLED && ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)

Copied: trunk/Tools/TestWebKitAPI/Tests/mac/LegacyDragAndDropTests.mm (from rev 234815, trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm) (0 => 234816)


--- trunk/Tools/TestWebKitAPI/Tests/mac/LegacyDragAndDropTests.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/LegacyDragAndDropTests.mm	2018-08-13 21:07:55 UTC (rev 234816)
@@ -0,0 +1,259 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if PLATFORM(MAC)
+
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+#import <AppKit/NSDragging.h>
+#import <WebKit/WebView.h>
+#import <wtf/BlockPtr.h>
+#import <wtf/RetainPtr.h>
+
+@interface FrameLoadCompletionListener : NSObject<WebFrameLoadDelegate> {
+    BlockPtr<void()> _completionBlock;
+}
++ (instancetype)listenerWithCompletionBlock:(dispatch_block_t)completionBlock;
+@end
+
+@implementation FrameLoadCompletionListener
+
++ (instancetype)listenerWithCompletionBlock:(dispatch_block_t)completionBlock
+{
+    return [[[FrameLoadCompletionListener alloc] initWithCompletionBlock:completionBlock] autorelease];
+}
+
+- (instancetype)initWithCompletionBlock:(dispatch_block_t)completionBlock
+{
+    if (self = [super init])
+        _completionBlock = completionBlock;
+
+    return self;
+}
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+    if (_completionBlock)
+        _completionBlock();
+}
+@end
+
+@interface DragSource : NSObject
+- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag;
+@end
+
+@implementation DragSource
+
+- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag
+{
+    return NSDragOperationCopy;
+}
+
+@end
+
+@interface DragInfo : NSObject<NSDraggingInfo> {
+    NSPoint _lastMousePosition;
+    RetainPtr<NSImage> _image;
+    RetainPtr<NSPasteboard> _pasteboard;
+    RetainPtr<DragSource> _source;
+    RetainPtr<NSWindow> _window;
+    NSSize _offset;
+    NSInteger _numberOfValidItemsForDrop;
+}
+@property (nonatomic) NSPoint lastMousePosition;
+@end
+
+@implementation DragInfo
+
+- (id)initWithImage:(NSImage *)image offset:(NSSize)offset pasteboard:(NSPasteboard *)pasteboard source:(DragSource *)source destinationWindow:(NSWindow *)destinationWindow
+{
+    if (self = [super init]) {
+        _image = image;
+        _pasteboard = pasteboard;
+        _source = source;
+        _window = destinationWindow;
+        _offset = offset;
+    }
+    return self;
+}
+
+- (NSPoint)lastMousePosition
+{
+    return _lastMousePosition;
+}
+
+- (void)setLastMousePosition:(NSPoint)lastMousePosition
+{
+    _lastMousePosition = lastMousePosition;
+}
+
+- (NSWindow *)draggingDestinationWindow
+{
+    return _window.get();
+}
+
+- (NSDragOperation)draggingSourceOperationMask
+{
+    return NSDragOperationCopy;
+}
+
+- (NSPoint)draggingLocation
+{
+    return _lastMousePosition;
+}
+
+- (NSPoint)draggedImageLocation
+{
+    return NSMakePoint(_lastMousePosition.x + _offset.width, _lastMousePosition.y + _offset.height);
+}
+
+- (NSImage *)draggedImage
+{
+    return _image.get();
+}
+
+- (NSPasteboard *)draggingPasteboard
+{
+    return _pasteboard.get();
+}
+
+- (id)draggingSource
+{
+    return _source.get();
+}
+
+- (NSInteger)draggingSequenceNumber
+{
+    return 0;
+}
+
+- (void)slideDraggedImageTo:(NSPoint)screenPoint
+{
+}
+
+- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
+{
+    return nil;
+}
+
+- (NSDraggingFormation)draggingFormation
+{
+    return NSDraggingFormationDefault;
+}
+
+- (void)setDraggingFormation:(NSDraggingFormation)formation
+{
+}
+
+- (BOOL)animatesToDestination
+{
+    return NO;
+}
+
+- (void)setAnimatesToDestination:(BOOL)flag
+{
+}
+
+- (NSInteger)numberOfValidItemsForDrop
+{
+    return _numberOfValidItemsForDrop;
+}
+
+- (void)setNumberOfValidItemsForDrop:(NSInteger)number
+{
+    _numberOfValidItemsForDrop = number;
+}
+
+- (void)enumerateDraggingItemsWithOptions:(NSEnumerationOptions)enumOpts forView:(NSView *)view classes:(NSArray *)classArray searchOptions:(NSDictionary *)searchOptions usingBlock:(void (^)(NSDraggingItem *draggingItem, NSInteger idx, BOOL *stop))block
+{
+}
+
+- (NSSpringLoadingHighlight)springLoadingHighlight
+{
+    return NSSpringLoadingHighlightNone;
+}
+
+- (void)resetSpringLoading
+{
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+static NSImage *getTestImage()
+{
+    return [[[NSImage alloc] initWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"icon" withExtension:@"png" subdirectory:@"TestWebKitAPI.resources"]] autorelease];
+}
+
+static WebView *webViewAfterPerformingDragOperation(NSPasteboard *pasteboard)
+{
+    RetainPtr<WebView> destination = adoptNS([[WebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
+    RetainPtr<NSWindow> hostWindow = adoptNS([[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 400, 400) styleMask:0 backing:NSBackingStoreBuffered defer:NO]);
+    [hostWindow setFrameOrigin:NSMakePoint(0, 0)];
+    [[hostWindow contentView] addSubview:destination.get()];
+    __block bool isDone = false;
+    [destination setFrameLoadDelegate:[FrameLoadCompletionListener listenerWithCompletionBlock:^() {
+        RetainPtr<DragSource> source = adoptNS([[DragSource alloc] init]);
+        RetainPtr<DragInfo> info = adoptNS([[DragInfo alloc] initWithImage:getTestImage() offset:NSMakeSize(0, 0) pasteboard:pasteboard source:source.get() destinationWindow:hostWindow.get()]);
+        [info setLastMousePosition:NSMakePoint(0, 200)];
+        [destination draggingEntered:info.get()];
+        [info setLastMousePosition:NSMakePoint(200, 200)];
+        [destination draggingUpdated:info.get()];
+
+        EXPECT_TRUE([destination performDragOperation:info.get()]);
+        isDone = true;
+    }]];
+    [[destination mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"full-page-contenteditable" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+
+    TestWebKitAPI::Util::run(&isDone);
+    return destination.get();
+}
+
+TEST(LegacyDragAndDropTests, DropUTF8PlainText)
+{
+    NSPasteboard *pasteboard = [NSPasteboard pasteboardWithUniqueName];
+    [pasteboard setData:[@"I am a WebKit." dataUsingEncoding:NSUTF8StringEncoding] forType:(__bridge NSString *)kUTTypeUTF8PlainText];
+
+    RetainPtr<WebView> resultingWebView = webViewAfterPerformingDragOperation(pasteboard);
+    EXPECT_TRUE([[resultingWebView stringByEvaluatingJavaScriptFromString:@"document.body.textContent"] containsString:@"I am a WebKit."]);
+}
+
+TEST(LegacyDragAndDropTests, DropJPEG)
+{
+    NSPasteboard *pasteboard = [NSPasteboard pasteboardWithUniqueName];
+    NSImage *icon = getTestImage();
+    NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:icon.TIFFRepresentation];
+    [pasteboard setData:[imageRep representationUsingType:NSJPEGFileType properties:@{ NSImageCompressionFactor: @(0.9) }] forType:(__bridge NSString *)kUTTypeJPEG];
+
+    RetainPtr<WebView> resultingWebView = webViewAfterPerformingDragOperation(pasteboard);
+    EXPECT_TRUE([[resultingWebView stringByEvaluatingJavaScriptFromString:@"document.querySelector('img').tagName === 'IMG'"] isEqualToString:@"true"]);
+}
+
+} // namespace TestWebKitAPI
+
+#endif

Deleted: trunk/Tools/TestWebKitAPI/Tests/mac/full-page-dropzone.html (234815 => 234816)


--- trunk/Tools/TestWebKitAPI/Tests/mac/full-page-dropzone.html	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/full-page-dropzone.html	2018-08-13 21:07:55 UTC (rev 234816)
@@ -1,2 +0,0 @@
-<!DOCTYPE html>
-<body style="width: 100vw; height: 100vh; margin: 0;" _ondragenter_="window.dragEnteredForTesting = true; return false;">

Modified: trunk/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h (234815 => 234816)


--- trunk/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h	2018-08-13 21:07:55 UTC (rev 234816)
@@ -37,6 +37,8 @@
 #import <UIKit/NSItemProvider+UIKitAdditions.h>
 #endif
 
+#if PLATFORM(IOS)
+
 typedef NS_ENUM(NSInteger, DragAndDropPhase) {
     DragAndDropPhaseCancelled = 0,
     DragAndDropPhaseBeginning = 1,
@@ -45,8 +47,6 @@
     DragAndDropPhasePerformingDrop = 4
 };
 
-#if PLATFORM(IOS)
-
 typedef NSDictionary<NSNumber *, NSValue *> *ProgressToCGPointValueMap;
 
 @interface MockDragDropSession : NSObject <UIDragDropSession> {
@@ -75,19 +75,22 @@
 
 @interface DragAndDropSimulator : NSObject<WKUIDelegatePrivate, _WKInputDelegate>
 
-- (instancetype)initWithWebView:(TestWKWebView *)webView;
+- (instancetype)initWithWebViewFrame:(CGRect)frame;
+- (instancetype)initWithWebViewFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration;
 // The start location, end location, and locations of additional item requests are all in window coordinates.
 - (void)runFrom:(CGPoint)startLocation to:(CGPoint)endLocation;
 @property (nonatomic, readonly) NSArray<_WKAttachment *> *insertedAttachments;
 @property (nonatomic, readonly) NSArray<_WKAttachment *> *removedAttachments;
-@property (nonatomic, readonly) DragAndDropPhase phase;
+@property (nonatomic, readonly) TestWKWebView *webView;
 
 #if PLATFORM(IOS)
 
+- (instancetype)initWithWebView:(TestWKWebView *)webView;
 - (void)runFrom:(CGPoint)startLocation to:(CGPoint)endLocation additionalItemRequestLocations:(ProgressToCGPointValueMap)additionalItemRequestLocations;
 - (void)waitForInputSession;
 - (void)endDataTransfer;
 
+@property (nonatomic, readonly) DragAndDropPhase phase;
 @property (nonatomic) BOOL allowsFocusToStartInputSession;
 @property (nonatomic) BOOL shouldEnsureUIApplication;
 @property (nonatomic) BOOL shouldAllowMoveOperation;
@@ -106,6 +109,17 @@
 
 #endif // PLATFORM(IOS)
 
+#if PLATFORM(MAC)
+
+@property (nonatomic, readonly) id <NSDraggingInfo> draggingInfo;
+@property (nonatomic, readonly) NSPoint initialDragImageLocationInView;
+@property (nonatomic, readonly) NSDragOperation currentDragOperation;
+@property (nonatomic, strong) NSPasteboard *externalDragPasteboard;
+@property (nonatomic, strong) NSImage *externalDragImage;
+@property (nonatomic, copy) dispatch_block_t willEndDraggingHandler;
+
+#endif // PLATFORM(MAC)
+
 @end
 
 #endif // ENABLE(DRAG_SUPPORT) && WK_API_ENABLED

Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h (234815 => 234816)


--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h	2018-08-13 21:07:55 UTC (rev 234816)
@@ -72,10 +72,12 @@
 #if PLATFORM(MAC)
 @interface TestWKWebView (MacOnly)
 // Simulates clicking with a pressure-sensitive device, if possible.
-- (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure;
-- (void)mouseUpAtPoint:(NSPoint)point;
-- (void)mouseMoveToPoint:(NSPoint)point withFlags:(NSEventModifierFlags)flags;
-- (void)sendClicksAtPoint:(NSPoint)point numberOfClicks:(NSUInteger)numberOfClicks;
+- (void)mouseDownAtPoint:(NSPoint)pointInWindow simulatePressure:(BOOL)simulatePressure;
+- (void)mouseDragToPoint:(NSPoint)pointInWindow;
+- (void)mouseEnterAtPoint:(NSPoint)pointInWindow;
+- (void)mouseUpAtPoint:(NSPoint)pointInWindow;
+- (void)mouseMoveToPoint:(NSPoint)pointInWindow withFlags:(NSEventModifierFlags)flags;
+- (void)sendClicksAtPoint:(NSPoint)pointInWindow numberOfClicks:(NSUInteger)numberOfClicks;
 - (NSWindow *)hostWindow;
 - (void)typeCharacter:(char)character;
 @end

Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm (234815 => 234816)


--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm	2018-08-13 21:07:55 UTC (rev 234816)
@@ -372,35 +372,62 @@
 
 #if PLATFORM(MAC)
 @implementation TestWKWebView (MacOnly)
-- (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure
+- (void)mouseDownAtPoint:(NSPoint)pointInWindow simulatePressure:(BOOL)simulatePressure
 {
-    [_hostWindow _mouseDownAtPoint:point simulatePressure:simulatePressure clickCount:1];
+    [_hostWindow _mouseDownAtPoint:pointInWindow simulatePressure:simulatePressure clickCount:1];
 }
 
-- (void)mouseUpAtPoint:(NSPoint)point
+- (void)mouseUpAtPoint:(NSPoint)pointInWindow
 {
-    [_hostWindow _mouseUpAtPoint:point clickCount:1];
+    [_hostWindow _mouseUpAtPoint:pointInWindow clickCount:1];
 }
 
-- (void)mouseMoveToPoint:(NSPoint)point withFlags:(NSEventModifierFlags)flags
+- (void)mouseMoveToPoint:(NSPoint)pointInWindow withFlags:(NSEventModifierFlags)flags
 {
-    [self mouseMoved:[NSEvent mouseEventWithType:NSEventTypeMouseMoved location:point modifierFlags:flags timestamp:GetCurrentEventTime() windowNumber:[_hostWindow windowNumber] context:[NSGraphicsContext currentContext] eventNumber:++gEventNumber clickCount:0 pressure:0]];
+    [self mouseMoved:[self _mouseEventWithType:NSEventTypeMouseMoved atLocation:pointInWindow flags:flags timestamp:GetCurrentEventTime() clickCount:0]];
 }
 
-- (void)sendClicksAtPoint:(NSPoint)point numberOfClicks:(NSUInteger)numberOfClicks
+- (void)sendClicksAtPoint:(NSPoint)pointInWindow numberOfClicks:(NSUInteger)numberOfClicks
 {
     for (NSUInteger clickCount = 1; clickCount <= numberOfClicks; ++clickCount) {
-        [_hostWindow _mouseDownAtPoint:point simulatePressure:NO clickCount:clickCount];
-        [_hostWindow _mouseUpAtPoint:point clickCount:clickCount];
+        [_hostWindow _mouseDownAtPoint:pointInWindow simulatePressure:NO clickCount:clickCount];
+        [_hostWindow _mouseUpAtPoint:pointInWindow clickCount:clickCount];
     }
 }
 
+- (void)mouseEnterAtPoint:(NSPoint)pointInWindow
+{
+    [self mouseEntered:[self _mouseEventWithType:NSEventTypeMouseEntered atLocation:pointInWindow]];
+}
+
+- (void)mouseDragToPoint:(NSPoint)pointInWindow
+{
+    [self mouseDragged:[self _mouseEventWithType:NSEventTypeLeftMouseDragged atLocation:pointInWindow]];
+}
+
+- (NSEvent *)_mouseEventWithType:(NSEventType)type atLocation:(NSPoint)pointInWindow
+{
+    return [self _mouseEventWithType:type atLocation:pointInWindow flags:0 timestamp:GetCurrentEventTime() clickCount:0];
+}
+
+- (NSEvent *)_mouseEventWithType:(NSEventType)type atLocation:(NSPoint)locationInWindow flags:(NSEventModifierFlags)flags timestamp:(NSTimeInterval)timestamp clickCount:(NSUInteger)clickCount
+{
+    switch (type) {
+    case NSEventTypeMouseEntered:
+    case NSEventTypeMouseExited:
+        return [NSEvent enterExitEventWithType:type location:locationInWindow modifierFlags:flags timestamp:timestamp windowNumber:[_hostWindow windowNumber] context:[NSGraphicsContext currentContext] eventNumber:++gEventNumber trackingNumber:1 userData:nil];
+    default:
+        return [NSEvent mouseEventWithType:type location:locationInWindow modifierFlags:flags timestamp:timestamp windowNumber:[_hostWindow windowNumber] context:[NSGraphicsContext currentContext] eventNumber:++gEventNumber clickCount:clickCount pressure:0];
+    }
+}
+
 - (NSWindow *)hostWindow
 {
     return _hostWindow.get();
 }
 
-- (void)typeCharacter:(char)character {
+- (void)typeCharacter:(char)character
+{
     NSString *characterAsString = [NSString stringWithFormat:@"%c" , character];
     NSEventType keyDownEventType = NSEventTypeKeyDown;
     NSEventType keyUpEventType = NSEventTypeKeyUp;

Modified: trunk/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm (234815 => 234816)


--- trunk/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm	2018-08-13 21:07:55 UTC (rev 234816)
@@ -318,6 +318,19 @@
     RetainPtr<UIDropProposal> _currentDropProposal;
 }
 
+- (instancetype)initWithWebViewFrame:(CGRect)frame
+{
+    return [self initWithWebViewFrame:frame configuration:nil];
+}
+
+- (instancetype)initWithWebViewFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration
+{
+    if (configuration)
+        return [self initWithWebView:[[[TestWKWebView alloc] initWithFrame:frame configuration:configuration] autorelease]];
+
+    return [self initWithWebView:[[[TestWKWebView alloc] initWithFrame:frame] autorelease]];
+}
+
 - (instancetype)initWithWebView:(TestWKWebView *)webView
 {
     if (self = [super init]) {
@@ -623,6 +636,11 @@
     [[_webView dragInteractionDelegate] dragInteraction:[_webView dragInteraction] sessionDidTransferItems:_dragSession.get()];
 }
 
+- (TestWKWebView *)webView
+{
+    return _webView.get();
+}
+
 #pragma mark - WKUIDelegatePrivate
 
 - (void)_webView:(WKWebView *)webView dataInteractionOperationWasHandled:(BOOL)handled forSession:(id)session itemProviders:(NSArray<UIItemProvider *> *)itemProviders

Modified: trunk/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm (234815 => 234816)


--- trunk/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm	2018-08-13 20:18:05 UTC (rev 234815)
+++ trunk/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm	2018-08-13 21:07:55 UTC (rev 234816)
@@ -28,40 +28,173 @@
 
 #if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) && WK_API_ENABLED
 
+#import "PlatformUtilities.h"
+#import "TestDraggingInfo.h"
 #import "TestWKWebView.h"
+#import <cmath>
+#import <wtf/WeakObjCPtr.h>
 
+@class DragAndDropTestWKWebView;
+
+@interface DragAndDropSimulator ()
+- (void)performDragInWebView:(DragAndDropTestWKWebView *)webView atLocation:(NSPoint)viewLocation withImage:(NSImage *)image pasteboard:(NSPasteboard *)pasteboard source:(id)source;
+@end
+
+@interface DragAndDropTestWKWebView : TestWKWebView
+@end
+
+@implementation DragAndDropTestWKWebView {
+    WeakObjCPtr<DragAndDropSimulator> _dragAndDropSimulator;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration simulator:(DragAndDropSimulator *)simulator
+{
+    if (self = [super initWithFrame:frame configuration:configuration])
+        _dragAndDropSimulator = simulator;
+    return self;
+}
+
+- (void)dragImage:(NSImage *)image at:(NSPoint)viewLocation offset:(NSSize)initialOffset event:(NSEvent *)event pasteboard:(NSPasteboard *)pboard source:(id)sourceObj slideBack:(BOOL)slideFlag
+{
+    [_dragAndDropSimulator performDragInWebView:self atLocation:viewLocation withImage:image pasteboard:pboard source:sourceObj];
+}
+
+- (void)waitForPendingMouseEvents
+{
+    __block bool doneProcessMouseEvents = false;
+    [self _doAfterProcessingAllPendingMouseEvents:^{
+        doneProcessMouseEvents = true;
+    }];
+    TestWebKitAPI::Util::run(&doneProcessMouseEvents);
+}
+
+@end
+
+// This exceeds the default drag hysteresis of all potential drag types.
+const double initialMouseDragDistance = 45;
+const double dragUpdateProgressIncrement = 0.05;
+
+static NSImage *defaultExternalDragImage()
+{
+    return [[[NSImage alloc] initWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"icon" withExtension:@"png" subdirectory:@"TestWebKitAPI.resources"]] autorelease];
+}
+
 @implementation DragAndDropSimulator {
-    RetainPtr<TestWKWebView> _webView;
+    RetainPtr<DragAndDropTestWKWebView> _webView;
+    RetainPtr<TestDraggingInfo> _draggingInfo;
+    RetainPtr<NSPasteboard> _externalDragPasteboard;
+    RetainPtr<NSImage> _externalDragImage;
+    BlockPtr<void()> _willEndDraggingHandler;
+    NSPoint _startLocationInWindow;
+    NSPoint _endLocationInWindow;
+    double _progress;
 }
 
-- (instancetype)initWithWebView:(TestWKWebView *)webView
+@synthesize currentDragOperation=_currentDragOperation;
+@synthesize initialDragImageLocationInView=_initialDragImageLocationInView;
+
+- (instancetype)initWithWebViewFrame:(CGRect)frame
 {
+    return [self initWithWebViewFrame:frame configuration:nil];
+}
+
+- (instancetype)initWithWebViewFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration
+{
     if (self = [super init]) {
-        _webView = webView;
+        _webView = adoptNS([[DragAndDropTestWKWebView alloc] initWithFrame:frame configuration:configuration ?: [[[WKWebViewConfiguration alloc] init] autorelease] simulator:self]);
         [_webView setUIDelegate:self];
-        [_webView _setInputDelegate:self];
     }
     return self;
 }
 
-- (void)dealloc
+- (NSPoint)flipAboutXAxisInHostWindow:(NSPoint)point
 {
-    if ([_webView UIDelegate] == self)
-        [_webView setUIDelegate:nil];
+    return { point.x, NSHeight([[_webView hostWindow] frame]) - point.y };
+}
 
-    if ([_webView _inputDelegate] == self)
-        [_webView _setInputDelegate:nil];
+- (NSPoint)locationInViewForCurrentProgress
+{
+    return {
+        _startLocationInWindow.x + (_endLocationInWindow.x - _startLocationInWindow.x) * _progress,
+        _startLocationInWindow.y + (_endLocationInWindow.y - _startLocationInWindow.y) * _progress
+    };
+}
 
-    [super dealloc];
+- (double)initialProgressForMouseDrag
+{
+    double totalDistance = std::sqrt(std::pow(_startLocationInWindow.x - _endLocationInWindow.x, 2) + std::pow(_startLocationInWindow.y - _endLocationInWindow.y, 2));
+    return !totalDistance ? 1 : std::min<double>(1, initialMouseDragDistance / totalDistance);
 }
 
-- (void)runFrom:(CGPoint)startLocation to:(CGPoint)endLocation
+- (void)runFrom:(CGPoint)flippedStartLocation to:(CGPoint)flippedEndLocation
 {
-    // FIXME: Add a mechanism to simulate dragging on macOS.
-    UNUSED_PARAM(startLocation);
-    UNUSED_PARAM(endLocation);
+    _startLocationInWindow = [self flipAboutXAxisInHostWindow:flippedStartLocation];
+    _endLocationInWindow = [self flipAboutXAxisInHostWindow:flippedEndLocation];
+    _currentDragOperation = NSDragOperationNone;
+    _draggingInfo = nil;
+    _progress = 0;
+
+    if (NSPasteboard *pasteboard = self.externalDragPasteboard) {
+        NSPoint startLocationInView = [_webView convertPoint:_startLocationInWindow fromView:nil];
+        NSImage *dragImage = self.externalDragImage ?: defaultExternalDragImage();
+        [self performDragInWebView:_webView.get() atLocation:startLocationInView withImage:dragImage pasteboard:pasteboard source:nil];
+        return;
+    }
+
+    _progress = [self initialProgressForMouseDrag];
+    if (_progress == 1) {
+        [NSException raise:@"DragAndDropSimulator" format:@"Drag start (%@) and drag end (%@) locations are too close!", NSStringFromPoint(flippedStartLocation), NSStringFromPoint(flippedEndLocation)];
+        return;
+    }
+
+    [_webView mouseEnterAtPoint:_startLocationInWindow];
+    [_webView mouseMoveToPoint:_startLocationInWindow withFlags:0];
+    [_webView mouseDownAtPoint:_startLocationInWindow simulatePressure:NO];
+    [_webView mouseDragToPoint:[self locationInViewForCurrentProgress]];
+    [_webView waitForPendingMouseEvents];
+
+    [_webView mouseUpAtPoint:_endLocationInWindow];
+    [_webView waitForPendingMouseEvents];
 }
 
+- (void)performDragInWebView:(DragAndDropTestWKWebView *)webView atLocation:(NSPoint)viewLocation withImage:(NSImage *)image pasteboard:(NSPasteboard *)pasteboard source:(id)source
+{
+    _initialDragImageLocationInView = viewLocation;
+    _draggingInfo = adoptNS([[TestDraggingInfo alloc] init]);
+    [_draggingInfo setDraggedImage:image];
+    [_draggingInfo setDraggingPasteboard:pasteboard];
+    [_draggingInfo setDraggingSource:source];
+    [_draggingInfo setDraggingLocation:[self locationInViewForCurrentProgress]];
+    [_draggingInfo setDraggingSourceOperationMask:NSDragOperationEvery];
+    [_draggingInfo setNumberOfValidItemsForDrop:pasteboard.pasteboardItems.count];
+
+    _currentDragOperation = [_webView draggingEntered:_draggingInfo.get()];
+    [_webView waitForNextPresentationUpdate];
+
+    while (_progress != 1) {
+        _progress = std::min<double>(1, _progress + dragUpdateProgressIncrement);
+        [_draggingInfo setDraggingLocation:[self locationInViewForCurrentProgress]];
+        _currentDragOperation = [_webView draggingUpdated:_draggingInfo.get()];
+        [_webView waitForNextPresentationUpdate];
+    }
+
+    [_draggingInfo setDraggingLocation:_endLocationInWindow];
+
+    if (_willEndDraggingHandler)
+        _willEndDraggingHandler();
+
+    if (_currentDragOperation != NSDragOperationNone && [_webView prepareForDragOperation:_draggingInfo.get()])
+        [_webView performDragOperation:_draggingInfo.get()];
+    else if (_currentDragOperation == NSDragOperationNone)
+        [_webView draggingExited:_draggingInfo.get()];
+    [_webView waitForNextPresentationUpdate];
+
+    if (!self.externalDragPasteboard) {
+        [_webView draggedImage:[_draggingInfo draggedImage] endedAt:_endLocationInWindow operation:_currentDragOperation];
+        [_webView waitForNextPresentationUpdate];
+    }
+}
+
 - (NSArray<_WKAttachment *> *)insertedAttachments
 {
     return @[ ];
@@ -72,11 +205,46 @@
     return @[ ];
 }
 
-- (DragAndDropPhase)phase
+- (TestWKWebView *)webView
 {
-    return DragAndDropPhaseCancelled;
+    return _webView.get();
 }
 
+- (void)setExternalDragPasteboard:(NSPasteboard *)externalDragPasteboard
+{
+    _externalDragPasteboard = externalDragPasteboard;
+}
+
+- (NSPasteboard *)externalDragPasteboard
+{
+    return _externalDragPasteboard.get();
+}
+
+- (void)setExternalDragImage:(NSImage *)externalDragImage
+{
+    _externalDragImage = externalDragImage;
+}
+
+- (NSImage *)externalDragImage
+{
+    return _externalDragImage.get();
+}
+
+- (id <NSDraggingInfo>)draggingInfo
+{
+    return _draggingInfo.get();
+}
+
+- (dispatch_block_t)willEndDraggingHandler
+{
+    return _willEndDraggingHandler.get();
+}
+
+- (void)setWillEndDraggingHandler:(dispatch_block_t)willEndDraggingHandler
+{
+    _willEndDraggingHandler = makeBlockPtr(willEndDraggingHandler);
+}
+
 @end
 
 #endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) && WK_API_ENABLED

Copied: trunk/Tools/TestWebKitAPI/mac/TestDraggingInfo.h (from rev 234815, trunk/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm) (0 => 234816)


--- trunk/Tools/TestWebKitAPI/mac/TestDraggingInfo.h	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/mac/TestDraggingInfo.h	2018-08-13 21:07:55 UTC (rev 234816)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) && WK_API_ENABLED
+
+#import <AppKit/NSDragging.h>
+
+@interface TestDraggingInfo : NSObject <NSDraggingInfo>
+
+@property (nonatomic) NSPoint draggingLocation;
+@property (nonatomic) NSPoint draggedImageLocation;
+@property (nonatomic) NSInteger draggingSequenceNumber;
+@property (nonatomic) NSDragOperation draggingSourceOperationMask;
+@property (nonatomic, strong) NSPasteboard *draggingPasteboard;
+@property (nonatomic, strong) NSImage *draggedImage;
+@property (nonatomic, weak) id draggingSource;
+
+@end
+
+#endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) && WK_API_ENABLED

Added: trunk/Tools/TestWebKitAPI/mac/TestDraggingInfo.mm (0 => 234816)


--- trunk/Tools/TestWebKitAPI/mac/TestDraggingInfo.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/mac/TestDraggingInfo.mm	2018-08-13 21:07:55 UTC (rev 234816)
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "TestDraggingInfo.h"
+
+#if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) && WK_API_ENABLED
+
+#import <wtf/WeakObjCPtr.h>
+
+@implementation TestDraggingInfo {
+    WeakObjCPtr<id> _source;
+    RetainPtr<NSPasteboard> _pasteboard;
+    RetainPtr<NSImage> _draggedImage;
+}
+
+@synthesize draggingSourceOperationMask=_draggingSourceOperationMask;
+@synthesize draggingLocation=_draggingLocation;
+@synthesize draggingFormation=_draggingFormation;
+@synthesize numberOfValidItemsForDrop=_numberOfValidItemsForDrop;
+
+- (NSPasteboard *)draggingPasteboard
+{
+    return _pasteboard.get();
+}
+
+- (void)setDraggingPasteboard:(NSPasteboard *)draggingPasteboard
+{
+    _pasteboard = draggingPasteboard;
+}
+
+- (id)draggingSource
+{
+    return _source.get().get();
+}
+
+- (void)setDraggingSource:(id)draggingSource
+{
+    _source = draggingSource;
+}
+
+- (void)enumerateDraggingItemsWithOptions:(NSDraggingItemEnumerationOptions)enumOpts forView:(NSView *)view classes:(NSArray<Class> *)classArray searchOptions:(NSDictionary<NSString *, id> *)searchOptions usingBlock:(void (^)(NSDraggingItem *, NSInteger, BOOL *))block
+{
+    // FIXME: Implement this to test file promise drop handling.
+}
+
+// The following methods are not currently used by WebKit.
+
+@synthesize draggedImageLocation=_draggedImageLocation;
+@synthesize draggingSequenceNumber=_draggingSequenceNumber;
+@synthesize animatesToDestination=_animatesToDestination;
+@synthesize springLoadingHighlight=_springLoadingHighlight;
+
+- (NSWindow *)draggingDestinationWindow
+{
+    return nil;
+}
+
+- (NSImage *)draggedImage
+{
+    return _draggedImage.get();
+}
+
+- (void)setDraggedImage:(NSImage *)draggedImage
+{
+    _draggedImage = draggedImage;
+}
+
+- (void)slideDraggedImageTo:(NSPoint)screenPoint
+{
+}
+
+- (NSArray<NSString *> *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
+{
+    return @[ ];
+}
+
+- (void)resetSpringLoading
+{
+}
+
+@end
+
+#endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) && WK_API_ENABLED
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to