Commit 9d9813d0 authored by enrica@apple.com's avatar enrica@apple.com

Source/WebCore: 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 changes required to support dropping content
in WebKit on the Mac. The DragData class has been extended to provide
additional context from the application (keyboard state, modal windows, etc.)
as well as information of the drag pasteboard being used.
The support for WebKit as drag source will be added with a separate patch.

* WebCore.exp.in:
* page/DragController.cpp:
(WebCore::DragController::dragIsMove): Added DragData parameter.
(WebCore::DragController::tryDocumentDrag): Modified call to dragIsMove.
(WebCore::DragController::concludeEditDrag): Same as above.
* page/DragController.h: Added parameter to isCopyKeyDown.
* page/mac/DragControllerMac.mm:
The following methods have been modified to use the information stored
in the DragData class.
(WebCore::DragController::isCopyKeyDown):
(WebCore::DragController::dragOperation):
* platform/DragData.h:
(WebCore::DragData::flags):
* platform/DragData.cpp: Added default flags parameter to the constructor.
* platform/mac/DragDataMac.mm:
(WebCore::DragData::DragData): Added constructor that receives the name of the pasteboard to use.
(WebCore::DragData::canSmartReplace):
(WebCore::DragData::containsColor):
(WebCore::DragData::containsFiles):
(WebCore::DragData::asFilenames):
(WebCore::DragData::containsPlainText):
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
All the following files have been modified to add the DragData
parameter to isCopyKeyDown. I plan to improve this in the future
and make isCopyKeyDown not platform specific.
* page/android/DragControllerAndroid.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/brew/DragControllerBrew.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/chromium/DragControllerChromium.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/efl/DragControllerEfl.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/gtk/DragControllerGtk.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/haiku/DragControllerHaiku.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/mac/DragControllerMac.mm:
(WebCore::DragController::isCopyKeyDown):
(WebCore::DragController::dragOperation):
* page/qt/DragControllerQt.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/win/DragControllerWin.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/wx/DragControllerWx.cpp:
(WebCore::DragController::isCopyKeyDown):

WebKit/mac: WebKit2: Add support for drag and drop
https://bugs.webkit.org/show_bug.cgi?id=52343
<rdar://problem/7660558>
        
Reviewed by Darin Adler.

The DragData class has been extended to provide
additional context from the application (keyboard state, modal windows, etc.)
as well as information of the drag pasteboard being used.
These are the changes to align the behavior for WebKit.

* WebView/WebView.mm:
(-[WebView applicationFlags:]): Added.
(-[WebView draggingEntered:]): Added parameter to the DragData constructor.
(-[WebView draggingUpdated:]): Added parameter to the DragData constructor.
(-[WebView draggingExited:]): Added parameter to the DragData constructor.
(-[WebView performDragOperation:]): Added parameter to the DragData constructor.

WebKit2: 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 changes required to support dropping content
in WebKit on the Mac. The DragData class has been extended to provide
additional context from the application (keyboard state, modal windows, etc.)
as well as information of the drag pasteboard being used.
The support for WebKit as drag source will be added with a separate patch.

* Shared/DragControllerAction.h: Added.
* UIProcess/API/mac/WKView.mm:
Added implemention of the methods required to add suport for a drop target.
To maintain asynchronous communication with the WebProcess, we always return
the previous calculated value for the drag operation.
(-[WKView _registerDraggedTypes]):
(-[WKView initWithFrame:contextRef:pageGroupRef:]):
(-[WKView applicationFlags:]):
(-[WKView draggingEntered:]):
(-[WKView draggingUpdated:]):
(-[WKView draggingExited:]):
(-[WKView prepareForDragOperation:]):
(-[WKView performDragOperation:]):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::performDragControllerAction):
(WebKit::WebPageProxy::didPerformDragControllerAction):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::dragOperation):
(WebKit::WebPageProxy::resetDragOperation):
* UIProcess/WebPageProxy.messages.in:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebDragClient.cpp:
(WebKit::WebDragClient::willPerformDragDestinationAction):
(WebKit::WebDragClient::willPerformDragSourceAction):
(WebKit::WebDragClient::actionMaskForDrag):
(WebKit::WebDragClient::dragSourceActionMaskForPoint):
(WebKit::WebDragClient::startDrag):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::performDragControllerAction):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75743 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent de794561
2011-01-12 Enrica Casucci <enrica@apple.com>
Reviewed by Darin Adler.
WebKit2: Add support for drag and drop
https://bugs.webkit.org/show_bug.cgi?id=52343
<rdar://problem/7660558>
This patch contains the changes required to support dropping content
in WebKit on the Mac. The DragData class has been extended to provide
additional context from the application (keyboard state, modal windows, etc.)
as well as information of the drag pasteboard being used.
The support for WebKit as drag source will be added with a separate patch.
* WebCore.exp.in:
* page/DragController.cpp:
(WebCore::DragController::dragIsMove): Added DragData parameter.
(WebCore::DragController::tryDocumentDrag): Modified call to dragIsMove.
(WebCore::DragController::concludeEditDrag): Same as above.
* page/DragController.h: Added parameter to isCopyKeyDown.
* page/mac/DragControllerMac.mm:
The following methods have been modified to use the information stored
in the DragData class.
(WebCore::DragController::isCopyKeyDown):
(WebCore::DragController::dragOperation):
* platform/DragData.h:
(WebCore::DragData::flags):
* platform/DragData.cpp: Added default flags parameter to the constructor.
* platform/mac/DragDataMac.mm:
(WebCore::DragData::DragData): Added constructor that receives the name of the pasteboard to use.
(WebCore::DragData::canSmartReplace):
(WebCore::DragData::containsColor):
(WebCore::DragData::containsFiles):
(WebCore::DragData::asFilenames):
(WebCore::DragData::containsPlainText):
(WebCore::DragData::asPlainText):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
All the following files have been modified to add the DragData
parameter to isCopyKeyDown. I plan to improve this in the future
and make isCopyKeyDown not platform specific.
* page/android/DragControllerAndroid.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/brew/DragControllerBrew.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/chromium/DragControllerChromium.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/efl/DragControllerEfl.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/gtk/DragControllerGtk.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/haiku/DragControllerHaiku.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/mac/DragControllerMac.mm:
(WebCore::DragController::isCopyKeyDown):
(WebCore::DragController::dragOperation):
* page/qt/DragControllerQt.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/win/DragControllerWin.cpp:
(WebCore::DragController::isCopyKeyDown):
* page/wx/DragControllerWx.cpp:
(WebCore::DragController::isCopyKeyDown):
2011-01-13 David Kilzer <ddkilzer@apple.com>
Add missing MathMLElementFactory.h and MathMLNames.h to Xcode project
......@@ -299,6 +363,7 @@
* html/canvas/WebGLRenderingContext.cpp:
>>>>>>> .r75740
2011-01-13 Adrienne Walker <enne@google.com>
Reviewed by Kenneth Russell.
......@@ -758,6 +823,7 @@
(WebCore::firstPositionInOrBeforeNode): Added.
(WebCore::lastPositionInOrAfterNode): Added.
>>>>>>> .r75734
2011-01-12 Sam Weinig <sam@webkit.org>
Another build fix.
......
......@@ -1328,7 +1328,8 @@ __ZN7WebCore14DragController11dragUpdatedEPNS_8DragDataE
__ZN7WebCore14DragController11performDragEPNS_8DragDataE
__ZN7WebCore14DragController14placeDragCaretERKNS_8IntPointE
__ZN7WebCore14DragController9dragEndedEv
__ZN7WebCore8DragDataC1EP11objc_objectRKNS_8IntPointES5_NS_13DragOperationE
__ZN7WebCore8DragDataC1EP11objc_objectRKNS_8IntPointES5_NS_13DragOperationENS_20DragApplicationFlagsE
__ZN7WebCore8DragDataC1ERKN3WTF6StringERKNS_8IntPointES7_NS_13DragOperationENS_20DragApplicationFlagsE
#endif
#if ENABLE(GEOLOCATION)
......
......@@ -22381,6 +22381,7 @@
isa = PBXProject;
buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
compatibilityVersion = "Xcode 2.4";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
......@@ -141,9 +141,9 @@ static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD
return 0;
}
bool DragController::dragIsMove(SelectionController* selection)
bool DragController::dragIsMove(SelectionController* selection, DragData* dragData)
{
return m_documentUnderMouse == m_dragInitiator && selection->isContentEditable() && !isCopyKeyDown();
return m_documentUnderMouse == m_dragInitiator && selection->isContentEditable() && !isCopyKeyDown(dragData);
}
// FIXME: This method is poorly named. We're just clearing the selection from the document this drag is exiting.
......@@ -335,7 +335,7 @@ bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction a
}
Frame* innerFrame = element->document()->frame();
operation = dragIsMove(innerFrame->selection()) ? DragOperationMove : DragOperationCopy;
operation = dragIsMove(innerFrame->selection(), dragData) ? DragOperationMove : DragOperationCopy;
return true;
}
// If we're not over an editable region, make sure we're clearing any prior drag cursor.
......@@ -449,7 +449,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
return false;
CachedResourceLoader* cachedResourceLoader = range->ownerDocument()->cachedResourceLoader();
cachedResourceLoader->setAllowStaleResources(true);
if (dragIsMove(innerFrame->selection()) || dragCaret.isContentRichlyEditable()) {
if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRichlyEditable()) {
bool chosePlainText = false;
RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, innerFrame, range, true, chosePlainText);
if (!fragment || !innerFrame->editor()->shouldInsertFragment(fragment, range, EditorInsertActionDropped)) {
......@@ -458,7 +458,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
}
m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
if (dragIsMove(innerFrame->selection())) {
if (dragIsMove(innerFrame->selection(), dragData)) {
// NSTextView behavior is to always smart delete on moving a selection,
// but only to smart insert if the selection granularity is word granularity.
bool smartDelete = innerFrame->editor()->smartInsertDeleteEnabled();
......
......@@ -99,8 +99,8 @@ namespace WebCore {
bool tryDHTMLDrag(DragData*, DragOperation&);
DragOperation dragOperation(DragData*);
void cancelDrag();
bool dragIsMove(SelectionController*);
bool isCopyKeyDown();
bool dragIsMove(SelectionController*, DragData*);
bool isCopyKeyDown(DragData*);
void mouseMovedIntoDocument(Document*);
......
......@@ -32,7 +32,7 @@
namespace WebCore {
bool DragController::isCopyKeyDown()
bool DragController::isCopyKeyDown(DragData*)
{
return false;
}
......
......@@ -41,7 +41,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f;
bool DragController::isCopyKeyDown()
bool DragController::isCopyKeyDown(DragData*)
{
return false;
}
......
......@@ -54,7 +54,7 @@ DragOperation DragController::dragOperation(DragData* dragData)
return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
}
bool DragController::isCopyKeyDown()
bool DragController::isCopyKeyDown(DragData*)
{
// FIXME: This should not be OS specific. Delegate to the embedder instead.
#if OS(WINDOWS)
......
......@@ -43,7 +43,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f;
bool DragController::isCopyKeyDown()
bool DragController::isCopyKeyDown(DragData*)
{
return false;
}
......
......@@ -42,7 +42,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f;
bool DragController::isCopyKeyDown()
bool DragController::isCopyKeyDown(DragData*)
{
return false;
}
......
......@@ -44,7 +44,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f;
bool DragController::isCopyKeyDown()
bool DragController::isCopyKeyDown(DragData*)
{
if (modifiers() & B_COMMAND_KEY)
return true;
......
......@@ -42,19 +42,19 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f;
bool DragController::isCopyKeyDown()
bool DragController::isCopyKeyDown(DragData* dragData)
{
return [[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask;
return dragData->flags() & DragApplicationIsCopyKeyDown;
}
DragOperation DragController::dragOperation(DragData* dragData)
{
ASSERT(dragData);
if ([NSApp modalWindow] || !dragData->containsURL(m_page->mainFrame()))
if ((dragData->flags() & DragApplicationIsModal) || !dragData->containsURL(m_page->mainFrame()))
return DragOperationNone;
if (!m_documentUnderMouse || (![[m_page->mainFrame()->view()->getOuterView() window] attachedSheet]
&& [dragData->platformData() draggingSource] != m_page->mainFrame()->view()->getOuterView()))
if (!m_documentUnderMouse || (!(dragData->flags() & (DragApplicationHasAttachedSheet | DragApplicationIsSource))))
return DragOperationCopy;
return DragOperationNone;
......
......@@ -43,7 +43,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f;
bool DragController::isCopyKeyDown()
bool DragController::isCopyKeyDown(DragData*)
{
return false;
}
......
......@@ -50,7 +50,7 @@ DragOperation DragController::dragOperation(DragData* dragData)
return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
}
bool DragController::isCopyKeyDown()
bool DragController::isCopyKeyDown(DragData*)
{
return ::GetAsyncKeyState(VK_CONTROL);
}
......
......@@ -43,7 +43,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f;
bool DragController::isCopyKeyDown()
bool DragController::isCopyKeyDown(DragData*)
{
notImplemented();
return false;
......
......@@ -31,11 +31,22 @@ namespace WebCore {
#if !PLATFORM(MAC)
DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition,
DragOperation sourceOperationMask)
DragOperation sourceOperationMask, DragApplicationFlags flags)
: m_clientPosition(clientPosition)
, m_globalPosition(globalPosition)
, m_platformDragData(data)
, m_draggingSourceOperationMask(sourceOperationMask)
, m_applicationFlags(flags)
{
}
DragData::DragData(const String&, const IntPoint& clientPosition, const IntPoint& globalPosition,
DragOperation sourceOperationMask, DragApplicationFlags flags)
: m_clientPosition(clientPosition)
, m_globalPosition(globalPosition)
, m_platformDragData(0)
, m_draggingSourceOperationMask(sourceOperationMask)
, m_applicationFlags(flags)
{
}
#endif
......
......@@ -34,12 +34,15 @@
#include <wtf/Vector.h>
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <AppKit/NSDragging.h>
typedef id <NSDraggingInfo> DragDataRef;
@class NSPasteboard;
#else
typedef void* DragDataRef;
class NSPasteboard;
#endif
#elif PLATFORM(QT)
QT_BEGIN_NAMESPACE
......@@ -72,14 +75,25 @@ class DocumentFragment;
class KURL;
class Range;
enum DragApplicationFlags {
DragApplicationNone = 0,
DragApplicationIsModal = 1,
DragApplicationIsSource = 2,
DragApplicationHasAttachedSheet = 4,
DragApplicationIsCopyKeyDown = 8
};
class DragData {
public:
enum FilenameConversionPolicy { DoNotConvertFilenames, ConvertFilenames };
// clientPosition is taken to be the position of the drag event within the target window, with (0,0) at the top left
DragData(DragDataRef, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation operation);
DragData(DragDataRef, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation, DragApplicationFlags = DragApplicationNone);
DragData(const String& dragStorageName, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation, DragApplicationFlags = DragApplicationNone);
const IntPoint& clientPosition() const { return m_clientPosition; }
const IntPoint& globalPosition() const { return m_globalPosition; }
DragApplicationFlags flags() { return m_applicationFlags; }
DragDataRef platformData() const { return m_platformDragData; }
DragOperation draggingSourceOperationMask() const { return m_draggingSourceOperationMask; }
bool containsURL(Frame*, FilenameConversionPolicy filenamePolicy = ConvertFilenames) const;
......@@ -99,6 +113,10 @@ private:
IntPoint m_globalPosition;
DragDataRef m_platformDragData;
DragOperation m_draggingSourceOperationMask;
DragApplicationFlags m_applicationFlags;
#if PLATFORM(MAC)
RetainPtr<NSPasteboard> m_pasteboard;
#endif
};
}
......
......@@ -38,11 +38,24 @@
namespace WebCore {
DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition,
DragOperation sourceOperationMask)
DragOperation sourceOperationMask, DragApplicationFlags flags)
: m_clientPosition(clientPosition)
, m_globalPosition(globalPosition)
, m_platformDragData(data)
, m_draggingSourceOperationMask(sourceOperationMask)
, m_applicationFlags(flags)
, m_pasteboard([m_platformDragData draggingPasteboard])
{
}
DragData::DragData(const String& dragStorageName, const IntPoint& clientPosition, const IntPoint& globalPosition,
DragOperation sourceOperationMask, DragApplicationFlags flags)
: m_clientPosition(clientPosition)
, m_globalPosition(globalPosition)
, m_platformDragData(0)
, m_draggingSourceOperationMask(sourceOperationMask)
, m_applicationFlags(flags)
, m_pasteboard([NSPasteboard pasteboardWithName:dragStorageName])
{
}
......@@ -50,22 +63,22 @@ bool DragData::canSmartReplace() const
{
//Need to call this so that the various Pasteboard type strings are intialised
Pasteboard::generalPasteboard();
return [[[m_platformDragData draggingPasteboard] types] containsObject:WebSmartPastePboardType];
return [[m_pasteboard.get() types] containsObject:WebSmartPastePboardType];
}
bool DragData::containsColor() const
{
return [[[m_platformDragData draggingPasteboard] types] containsObject:NSColorPboardType];
return [[m_pasteboard.get() types] containsObject:NSColorPboardType];
}
bool DragData::containsFiles() const
{
return [[[m_platformDragData draggingPasteboard] types] containsObject:NSFilenamesPboardType];
return [[m_pasteboard.get() types] containsObject:NSFilenamesPboardType];
}
void DragData::asFilenames(Vector<String>& result) const
{
NSArray *filenames = [[m_platformDragData draggingPasteboard] propertyListForType:NSFilenamesPboardType];
NSArray *filenames = [m_pasteboard.get() propertyListForType:NSFilenamesPboardType];
NSEnumerator *fileEnumerator = [filenames objectEnumerator];
while (NSString *filename = [fileEnumerator nextObject])
......@@ -74,19 +87,18 @@ void DragData::asFilenames(Vector<String>& result) const
bool DragData::containsPlainText() const
{
NSPasteboard *pasteboard = [m_platformDragData draggingPasteboard];
NSArray *types = [pasteboard types];
NSArray *types = [m_pasteboard.get() types];
return [types containsObject:NSStringPboardType]
|| [types containsObject:NSRTFDPboardType]
|| [types containsObject:NSRTFPboardType]
|| [types containsObject:NSFilenamesPboardType]
|| [NSURL URLFromPasteboard:pasteboard];
|| [NSURL URLFromPasteboard:m_pasteboard.get()];
}
String DragData::asPlainText(Frame *frame) const
{
Pasteboard pasteboard([m_platformDragData draggingPasteboard]);
Pasteboard pasteboard(m_pasteboard.get());
return pasteboard.plainText(frame);
}
......@@ -113,8 +125,7 @@ static NSArray *insertablePasteboardTypes()
bool DragData::containsCompatibleContent() const
{
NSPasteboard *pasteboard = [m_platformDragData draggingPasteboard];
NSMutableSet *types = [NSMutableSet setWithArray:[pasteboard types]];
NSMutableSet *types = [NSMutableSet setWithArray:[m_pasteboard.get() types]];
[types intersectSet:[NSSet setWithArray:insertablePasteboardTypes()]];
return [types count] != 0;
}
......@@ -133,13 +144,13 @@ String DragData::asURL(Frame* frame, FilenameConversionPolicy filenamePolicy, St
if (NSString *URLTitleString = [[m_platformDragData draggingPasteboard] stringForType:WebURLNamePboardType])
*title = URLTitleString;
}
Pasteboard pasteboard([m_platformDragData draggingPasteboard]);
Pasteboard pasteboard(m_pasteboard.get());
return pasteboard.asURL(frame);
}
PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range> range, bool allowPlainText, bool& chosePlainText) const
{
Pasteboard pasteboard([m_platformDragData draggingPasteboard]);
Pasteboard pasteboard(m_pasteboard.get());
return pasteboard.documentFragment(frame, range, allowPlainText, chosePlainText);
}
......
2011-01-12 Enrica Casucci <enrica@apple.com>
Reviewed by Darin Adler.
WebKit2: Add support for drag and drop
https://bugs.webkit.org/show_bug.cgi?id=52343
<rdar://problem/7660558>
The DragData class has been extended to provide
additional context from the application (keyboard state, modal windows, etc.)
as well as information of the drag pasteboard being used.
These are the changes to align the behavior for WebKit.
* WebView/WebView.mm:
(-[WebView applicationFlags:]): Added.
(-[WebView draggingEntered:]): Added parameter to the DragData constructor.
(-[WebView draggingUpdated:]): Added parameter to the DragData constructor.
(-[WebView draggingExited:]): Added parameter to the DragData constructor.
(-[WebView performDragOperation:]): Added parameter to the DragData constructor.
2011-01-12 Beth Dakin <bdakin@apple.com>
Reviewed by Anders Carlsson.
......
......@@ -3765,11 +3765,25 @@ static bool needsWebViewInitThreadWorkaround()
return [documentView _shouldAutoscrollForDraggingInfo:draggingInfo];
}
- (DragApplicationFlags)applicationFlags:(id <NSDraggingInfo>)draggingInfo
{
uint32_t flags = 0;
if ([NSApp modalWindow])
flags = DragApplicationIsModal;
if ([[self window] attachedSheet])
flags |= DragApplicationHasAttachedSheet;
if ([draggingInfo draggingSource] == self)
flags |= DragApplicationIsSource;
if ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask)
flags |= DragApplicationIsCopyKeyDown;
return static_cast<DragApplicationFlags>(flags);
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)draggingInfo
{
IntPoint client([draggingInfo draggingLocation]);
IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask]);
DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
return core(self)->dragController()->dragEntered(&dragData);
}
......@@ -3781,7 +3795,7 @@ static bool needsWebViewInitThreadWorkaround()
IntPoint client([draggingInfo draggingLocation]);
IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask]);
DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
return page->dragController()->dragUpdated(&dragData);
}
......@@ -3793,7 +3807,7 @@ static bool needsWebViewInitThreadWorkaround()
IntPoint client([draggingInfo draggingLocation]);
IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask]);
DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
page->dragController()->dragExited(&dragData);
}
......@@ -3806,7 +3820,7 @@ static bool needsWebViewInitThreadWorkaround()
{
IntPoint client([draggingInfo draggingLocation]);
IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
DragData dragData(draggingInfo, client, global, (DragOperation)[draggingInfo draggingSourceOperationMask]);
DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
return core(self)->dragController()->performDrag(&dragData);
}
......
2011-01-13 Enrica Casucci <enrica@apple.com>
Reviewed by Darin Adler.
WebKit2: Add support for drag and drop
https://bugs.webkit.org/show_bug.cgi?id=52343
<rdar://problem/7660558>
This patch contains the changes required to support dropping content
in WebKit on the Mac. The DragData class has been extended to provide
additional context from the application (keyboard state, modal windows, etc.)
as well as information of the drag pasteboard being used.
The support for WebKit as drag source will be added with a separate patch.
* Shared/DragControllerAction.h: Added.
* UIProcess/API/mac/WKView.mm:
Added implemention of the methods required to add suport for a drop target.
To maintain asynchronous communication with the WebProcess, we always return
the previous calculated value for the drag operation.
(-[WKView _registerDraggedTypes]):
(-[WKView initWithFrame:contextRef:pageGroupRef:]):
(-[WKView applicationFlags:]):
(-[WKView draggingEntered:]):
(-[WKView draggingUpdated:]):
(-[WKView draggingExited:]):
(-[WKView prepareForDragOperation:]):
(-[WKView performDragOperation:]):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::performDragControllerAction):
(WebKit::WebPageProxy::didPerformDragControllerAction):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::dragOperation):
(WebKit::WebPageProxy::resetDragOperation):
* UIProcess/WebPageProxy.messages.in:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebDragClient.cpp:
(WebKit::WebDragClient::willPerformDragDestinationAction):
(WebKit::WebDragClient::willPerformDragSourceAction):
(WebKit::WebDragClient::actionMaskForDrag):
(WebKit::WebDragClient::dragSourceActionMaskForPoint):
(WebKit::WebDragClient::startDrag):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::performDragControllerAction):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
2011-01-13 Dan Bernstein <mitz@apple.com>
Reviewed by John Sullivan.
/*
* Copyright (C) 2011 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.
*/
#ifndef DragControllerAction_h
#define DragControllerAction_h
namespace WebKit {
enum DragControllerAction {
DragControllerActionEntered,
DragControllerActionUpdated,
DragControllerActionExited,
DragControllerActionPerformDrag
};
} // namespace WebKit
#endif // DragControllerAction_h
......@@ -50,9 +50,12 @@
#import "WebSystemInterface.h"
#import <QuartzCore/QuartzCore.h>
#import <WebCore/ColorMac.h>
#import <WebCore/DragController.h>
#import <WebCore/DragData.h>
#import <WebCore/FloatRect.h>
#import <WebCore/IntRect.h>
#import <WebCore/KeyboardEvent.h>
#import <WebCore/PlatformMouseEvent.h>
#import <WebCore/PlatformScreen.h>
#import <WebKitSystemInterface.h>