WebKit2: add support for drag and drop
authorenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jan 2011 01:56:45 +0000 (01:56 +0000)
committerenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jan 2011 01:56:45 +0000 (01:56 +0000)
commitf5e4e86211e0961ee7fee6c3a028d2cce80e60c0
tree9e1b5fea860ab02fc95ca2b7eb35880bd48838e8
parent892829395eaca5d6e7d7e8a85d608154774d87c3
WebKit2: add support for drag and drop
https://bugs.webkit.org/show_bug.cgi?id=52343
<rdar://problem/7660558>

Reviewed by Darin Adler.

This patch contains the remaining work to support drag and drop on Mac.
I've added a PasteboardTypes class to encapsulate all the pasteboard formats
supported for drag and drop.
In this implementation we don't support the promised types, since I could not
find an efficient way to do this across processes.
The bulk of the patch consists in creating a shareable bitmap for the drag image,
pass its handle to the UI process and create a new NSImage from it to be given to
AppKit for dragging.
I've added the missing implementation of the methods in the drag client to hook
up the placement of the data in the pasteboard.

* Shared/mac/PasteboardTypes.h: Added.
* Shared/mac/PasteboardTypes.mm: Added.
(WebKit::PasteboardTypes::forEditing):
(WebKit::PasteboardTypes::forURL):
(WebKit::PasteboardTypes::forImages):
(WebKit::PasteboardTypes::forImagesWithArchive):
* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::setDragImage): Added.
* UIProcess/API/mac/WKView.mm:
(-[WKView _registerDraggedTypes]): Refactored to use the new PasteboardTypes class.
(-[WKView initWithFrame:contextRef:pageGroupRef:]):
(-[WKView _setMouseDownEvent:]):
(-[WKView _mouseHandler:]):
(-[WKView mouseDown:]):
(-[WKView mouseUp:]):
(-[WKView mouseDragged:]):
(-[WKView draggedImage:endedAt:operation:]):
(-[WKView draggingEntered:]):
(-[WKView _setDragImage:at:linkDrag:]):
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setDragImage):
(WebKit::WebPageProxy::dragEnded):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebDragClient.cpp:
* WebProcess/WebCoreSupport/WebDragClient.h:
* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: Added.
(WebKit::fontFromNSFont):
(WebKit::WebDragClient::startDrag): Added implementation.
(WebKit::WebDragClient::createDragImageForLink): Ditto.
(WebKit::writeURL): Helper function.
(WebKit::writeImage): Helper function.
(WebKit::WebDragClient::declareAndWriteDragImage): Added implementation.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::dragEnded):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@76186 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/PasteboardTypes.h [new file with mode: 0644]
Source/WebKit2/Shared/mac/PasteboardTypes.mm [new file with mode: 0644]
Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in